On 3/21/26 16:04, Gregory Price wrote:
> There is no way for drivers leveraging dax_kmem to plumb through a
> preferred auto-online policy - the system default policy is forced.
> 
> Add 'enum mmop' field to DAX device creation path to allow drivers
> to specify an auto-online policy when using the kmem driver.
> 
> Current callers initialize online_type to mhp_get_default_online_type()
> to retain backward compatibility and to make explicit to the drivers
> what is actually happening underneath.
> 
> No functional changes to existing callers.
> 
> Cc:David Hildenbrand <[email protected]>
> Signed-off-by: Gregory Price <[email protected]>
> ---

[...]

>  
>       return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index 798f389df992..d4c34b2e3766 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
> @@ -16,6 +16,11 @@
>  #include "dax-private.h"
>  #include "bus.h"
>  
> +/* Internal function exported only to kmem module */
> +extern int __add_memory_driver_managed(int nid, u64 start, u64 size,
> +                                    const char *resource_name,
> +                                    mhp_t mhp_flags, enum mmop online_type);

This should just go to the memory_hotplug.h header.

The EXPORT will make sure that only supported modules can use this.

> +
>  /* Memory resource name used for add_memory_driver_managed(). */
>  static const char *kmem_name;
>  /* Set if any memory will remain added when the driver will be unloaded. */
> @@ -49,6 +54,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
>       struct dax_kmem_data *data;
>       struct memory_dev_type *mtype;
>       int i, rc, mapped = 0;
> +     enum mmop online_type;
>       mhp_t mhp_flags;
>       int numa_node;
>       int adist = MEMTIER_DEFAULT_LOWTIER_ADISTANCE;
> @@ -111,6 +117,8 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
>               goto err_reg_mgid;
>       data->mgid = rc;
>  
> +     online_type = dev_dax->online_type;

Do you need the temporary variable?



-- 
Cheers,

David

Reply via email to