From: Dave Jiang <dave.jiang@intel.com>
To: Gregory Price <gourry@gourry.net>, linux-mm@kvack.org
Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-cxl@vger.kernel.org, driver-core@lists.linux.dev,
linux-kselftest@vger.kernel.org, kernel-team@meta.com,
david@kernel.org, osalvador@suse.de, gregkh@linuxfoundation.org,
rafael@kernel.org, dakr@kernel.org, djbw@kernel.org,
vishal.l.verma@intel.com, alison.schofield@intel.com,
akpm@linux-foundation.org, ljs@kernel.org, liam@infradead.org,
vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
mhocko@suse.com, shuah@kernel.org, iweiny@kernel.org,
Smita.KoralahalliChannabasappa@amd.com, apopple@nvidia.com
Subject: Re: [PATCH v6 07/10] dax: plumb hotplug online_type through dax
Date: Thu, 9 Jul 2026 14:07:19 -0700 [thread overview]
Message-ID: <8ad8e025-ffea-4bc8-8797-6a280ecc229f@intel.com> (raw)
In-Reply-To: <20260630211842.2252800-8-gourry@gourry.net>
On 6/30/26 2:18 PM, 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.
>
> Capturing the system default would otherwise break the ABI, because
> the system default can change - but we would be statically assigning
> the value at device creation time.
>
> To resolve this we add DAX_ONLINE_DEFAULT, which defaults devices to
> the current behavior, while providing a clean way to override it.
>
> No behavioural change for existing callers (still the system default).
behavioral
>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/dax/bus.c | 3 +++
> drivers/dax/bus.h | 9 +++++++++
> drivers/dax/cxl.c | 1 +
> drivers/dax/dax-private.h | 4 ++++
> drivers/dax/hmem/hmem.c | 1 +
> drivers/dax/kmem.c | 11 +++++++++--
> drivers/dax/pmem.c | 1 +
> 7 files changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index 492573b47f66..4a03b323b003 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -1,6 +1,7 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Copyright(c) 2017-2018 Intel Corporation. All rights reserved. */
> #include <linux/memremap.h>
> +#include <linux/memory_hotplug.h>
> #include <linux/device.h>
> #include <linux/mutex.h>
> #include <linux/list.h>
> @@ -394,6 +395,7 @@ static ssize_t create_store(struct device *dev, struct device_attribute *attr,
> .size = 0,
> .id = -1,
> .memmap_on_memory = false,
> + .online_type = DAX_ONLINE_DEFAULT,
> };
> struct dev_dax *dev_dax = __devm_create_dev_dax(&data);
>
> @@ -1527,6 +1529,7 @@ static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data)
> ida_init(&dev_dax->ida);
>
> dev_dax->memmap_on_memory = data->memmap_on_memory;
> + dev_dax->online_type = data->online_type;
>
> inode = dax_inode(dax_dev);
> dev->devt = inode->i_rdev;
> diff --git a/drivers/dax/bus.h b/drivers/dax/bus.h
> index 5909171a4428..3bc76bc0a145 100644
> --- a/drivers/dax/bus.h
> +++ b/drivers/dax/bus.h
> @@ -3,6 +3,7 @@
> #ifndef __DAX_BUS_H__
> #define __DAX_BUS_H__
> #include <linux/device.h>
> +#include <linux/memory_hotplug.h>
> #include <linux/platform_device.h>
> #include <linux/range.h>
> #include <linux/workqueue.h>
> @@ -16,6 +17,13 @@ struct dax_region;
> #define IORESOURCE_DAX_STATIC BIT(0)
> #define IORESOURCE_DAX_KMEM BIT(1)
>
> +/*
> + * online_type sentinel: the device was created without an explicit online
> + * policy, so the system default is resolved when the kmem driver binds,
> + * (not at device-creation time, which would freeze a stale policy).
> + */
> +#define DAX_ONLINE_DEFAULT (-1)
> +
> struct dax_region *alloc_dax_region(struct device *parent, int region_id,
> struct range *range, int target_node, unsigned int align,
> unsigned long flags);
> @@ -26,6 +34,7 @@ struct dev_dax_data {
> resource_size_t size;
> int id;
> bool memmap_on_memory;
> + int online_type; /* enum mmop, or DAX_ONLINE_DEFAULT sentinel */
> };
>
> struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
> diff --git a/drivers/dax/cxl.c b/drivers/dax/cxl.c
> index 3ab39b77843d..1a7ec6212213 100644
> --- a/drivers/dax/cxl.c
> +++ b/drivers/dax/cxl.c
> @@ -27,6 +27,7 @@ static int cxl_dax_region_probe(struct device *dev)
> .id = -1,
> .size = range_len(&cxlr_dax->hpa_range),
> .memmap_on_memory = true,
> + .online_type = DAX_ONLINE_DEFAULT,
> };
>
> return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
> diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h
> index 81e4af49e39c..902e922dc4e4 100644
> --- a/drivers/dax/dax-private.h
> +++ b/drivers/dax/dax-private.h
> @@ -8,6 +8,7 @@
> #include <linux/device.h>
> #include <linux/cdev.h>
> #include <linux/idr.h>
> +#include <linux/memory_hotplug.h>
>
> /* private routines between core files */
> struct dax_device;
> @@ -79,6 +80,8 @@ struct dev_dax_range {
> * @dev: device core
> * @pgmap: pgmap for memmap setup / lifetime (driver owned)
> * @memmap_on_memory: allow kmem to put the memmap in the memory
> + * @online_type: MMOP_* online type for memory hotplug, or DAX_ONLINE_DEFAULT
> + * to resolve the system default policy when kmem binds
> * @nr_range: size of @ranges
> * @ranges: range tuples of memory used
> */
> @@ -95,6 +98,7 @@ struct dev_dax {
> struct device dev;
> struct dev_pagemap *pgmap;
> bool memmap_on_memory;
> + int online_type; /* enum mmop, or DAX_ONLINE_DEFAULT sentinel */
> int nr_range;
> struct dev_dax_range *ranges;
> };
> diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
> index af21f66bf872..2de3bc925172 100644
> --- a/drivers/dax/hmem/hmem.c
> +++ b/drivers/dax/hmem/hmem.c
> @@ -37,6 +37,7 @@ static int dax_hmem_probe(struct platform_device *pdev)
> .id = -1,
> .size = region_idle ? 0 : range_len(&mri->range),
> .memmap_on_memory = false,
> + .online_type = DAX_ONLINE_DEFAULT,
> };
>
> return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index 592171ec10f4..0a184c0878dd 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
> @@ -72,6 +72,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
> int i, rc, mapped = 0;
> mhp_t mhp_flags;
> int numa_node;
> + int online_type;
> int adist = MEMTIER_DEFAULT_DAX_ADISTANCE;
>
> /*
> @@ -132,6 +133,11 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
> goto err_reg_mgid;
> data->mgid = rc;
>
> + /* Resolve system default at bind time in case it changed */
> + online_type = dev_dax->online_type;
> + if (online_type == DAX_ONLINE_DEFAULT)
> + online_type = mhp_get_default_online_type();
> +
> for (i = 0; i < dev_dax->nr_range; i++) {
> struct resource *res;
> struct range range;
> @@ -172,8 +178,9 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
> * Ensure that future kexec'd kernels will not treat
> * this as RAM automatically.
> */
> - rc = add_memory_driver_managed(data->mgid, range.start,
> - range_len(&range), kmem_name, mhp_flags);
> + rc = __add_memory_driver_managed(data->mgid, range.start,
> + range_len(&range), kmem_name, mhp_flags,
> + online_type);
>
> if (rc) {
> dev_warn(dev, "mapping%d: %#llx-%#llx memory add failed\n",
> diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
> index bee93066a849..e7adace69195 100644
> --- a/drivers/dax/pmem.c
> +++ b/drivers/dax/pmem.c
> @@ -63,6 +63,7 @@ static struct dev_dax *__dax_pmem_probe(struct device *dev)
> .pgmap = &pgmap,
> .size = range_len(&range),
> .memmap_on_memory = false,
> + .online_type = DAX_ONLINE_DEFAULT,
> };
>
> return devm_create_dev_dax(&data);
next prev parent reply other threads:[~2026-07-09 21:07 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 21:18 [PATCH v6 00/10] dax/kmem: atomic whole-device hotplug via sysfs Gregory Price
2026-06-30 21:18 ` [PATCH v6 01/10] mm/memory: add memory_block_aligned_range() helper Gregory Price
2026-07-09 17:58 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 02/10] mm/memory_hotplug: add mhp_online_type_to_str() and export string helpers Gregory Price
2026-07-01 8:30 ` David Hildenbrand (Arm)
2026-07-09 17:59 ` Dave Jiang
2026-07-09 21:08 ` Dave Jiang
2026-07-09 21:57 ` Gregory Price
2026-07-10 12:44 ` David Hildenbrand (Arm)
2026-06-30 21:18 ` [PATCH v6 03/10] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-07-09 18:22 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 04/10] mm/memory_hotplug: export mhp_get_default_online_type Gregory Price
2026-07-09 18:30 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 05/10] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg Gregory Price
2026-07-09 18:48 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 06/10] mm/memory_hotplug: add offline_and_remove_memory_ranges() Gregory Price
2026-07-01 8:32 ` David Hildenbrand (Arm)
2026-07-09 8:45 ` Richard Cheng
2026-07-09 15:06 ` Gregory Price
2026-07-09 17:15 ` Gregory Price
2026-07-09 18:53 ` Dave Jiang
2026-06-30 21:18 ` [PATCH v6 07/10] dax: plumb hotplug online_type through dax Gregory Price
2026-07-09 21:07 ` Dave Jiang [this message]
2026-07-09 21:46 ` Dan Williams (nvidia)
2026-07-09 22:08 ` Gregory Price
2026-07-10 1:30 ` Gregory Price
2026-07-11 0:44 ` Dan Williams (nvidia)
2026-06-30 21:18 ` [PATCH v6 08/10] dax/kmem: extract hotplug/hotremove helper functions Gregory Price
2026-07-09 21:44 ` Dave Jiang
2026-07-09 21:57 ` Gregory Price
2026-06-30 21:18 ` [PATCH v6 09/10] dax/kmem: add sysfs interface for atomic whole-device hotplug Gregory Price
2026-06-30 22:14 ` Gregory Price
2026-07-01 6:13 ` Hannes Reinecke
2026-07-01 6:23 ` Gregory Price
2026-07-09 8:07 ` Richard Cheng
2026-07-09 14:57 ` Gregory Price
2026-07-09 22:14 ` Dave Jiang
2026-07-09 22:22 ` Gregory Price
2026-07-09 22:36 ` Dan Williams (nvidia)
2026-07-09 23:06 ` Gregory Price
2026-07-09 23:57 ` Dan Williams (nvidia)
2026-07-10 3:08 ` Gregory Price
2026-06-30 21:18 ` [PATCH v6 10/10] selftests/dax: add dax/kmem hotplug sysfs regression test Gregory Price
2026-07-09 8:20 ` Richard Cheng
2026-07-09 15:02 ` Gregory Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8ad8e025-ffea-4bc8-8797-6a280ecc229f@intel.com \
--to=dave.jiang@intel.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=david@kernel.org \
--cc=djbw@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=iweiny@kernel.org \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox