All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gregory Price <gourry@gourry.net>
To: "Dan Williams (nvidia)" <djbw@kernel.org>
Cc: linux-mm@kvack.org, 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,
	vishal.l.verma@intel.com, dave.jiang@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: Sun, 12 Jul 2026 09:19:18 -0400	[thread overview]
Message-ID: <alOUVvJCSQDO6yNn@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <6a51920acece6_35cf3310061@djbw-dev.notmuch>

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

On Fri, Jul 10, 2026 at 05:44:58PM -0700, Dan Williams (nvidia) wrote:
> Gregory Price wrote:
> > On Thu, Jul 09, 2026 at 06:08:45PM -0400, Gregory Price wrote:
> > > On Thu, Jul 09, 2026 at 02:46:39PM -0700, Dan Williams (nvidia) wrote:
> > > 
> > > This was more a matter of having the DEFAULT set consistently across
> > > the dax driver variant probe() functions to make the behavior explicit.
> > > I didn't want an un-set value bug to creep in here somehow.
> > > 
> > > Happy to drop them if you think that's unneeded.
> > > 
> > 
> > Ah
> > 
> > Not setting the value in each of those places is equivalent to setting
> > MMOP_OFFLINE (0), so better to just set DEFAULT regardless.
> > 
> > So unless you have strong feelings i will keep them as-is.
> 
> Right, the mild feelings are only coming from the changelog mismatch
> which says "Oh no, device-dax drivers can not specify their online type
> besides the default" and all this series does is keep the status quo.
> 
> That can be had by just having unconditional:
> 
>      online_type = mhp_get_default_online_type();
> 
> ...in dev_dax_kmem_probe() and get rid of dev_dax->online_type until the
> first user arrives. If you are respinning the series and that patch
> drops, yay. If not, oh well.

if you prefer, i can add the CXL build option to this series instead of
the follow up (attached).  The code is fully contained in DAX anyway,
and I have it sitting off in another branch anyway.

I suppose with this, we can terminate the entire series and the first
user that grows an opinion can add the following:

cxl/cxl.h:
    struct cxl_dax_region *cxlr_dax {
    +   int online_type
    };

dax/cxl.c:
   data.online_type = (cxlr_dax.online_type == DAX_ONLINE_DEFAULT) ?
                      cxl_dax_online_type() : cxlr_dax.online_type;

~Gregory

[-- Attachment #2: 0001-dax-cxl-add-build-time-CXL-RAM-region-auto-online-po.patch --]
[-- Type: text/plain, Size: 3587 bytes --]

From b2cb5c4f5f03dd698df97ae3db2c0207db4acd83 Mon Sep 17 00:00:00 2001
From: Gregory Price <gourry@gourry.net>
Date: Thu, 9 Jul 2026 19:31:28 -0700
Subject: [PATCH] dax/cxl: add build-time CXL RAM region auto-online policy

CXL devices using kmem follow the single global auto-online policy.

On systems with multiple drivers using memory hotplug, this makes
management more complex - a single special kmem device forces all
kmem devices to be managed manually in userland.

Add a build-time option to select CXL device online policy.

  - System default   -> DAX_ONLINE_DEFAULT (default)
  - Online           -> MMOP_ONLINE
  - Online (movable) -> MMOP_ONLINE_MOVABLE
  - Online (kernel)  -> MMOP_ONLINE_KERNEL
  - Unplugged        -> DAX_KMEM_UNPLUGGED

Default to system default to retain userland backward compatibility.

Signed-off-by: Gregory Price <gourry@gourry.net>
---
 drivers/cxl/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++++
 drivers/dax/cxl.c   | 15 ++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig
index 80aeb0d556bd7..52450225dbb11 100644
--- a/drivers/cxl/Kconfig
+++ b/drivers/cxl/Kconfig
@@ -212,6 +212,47 @@ config CXL_REGION
 
 	  If unsure say 'y'
 
+choice
+	prompt "CXL Memory Hotplug Policy"
+	depends on CXL_REGION
+	default CXL_MEMHP_POLICY_SYSTEM_DEFAULT
+	help
+	  Select the online policy the CXL driver requests when a region is
+	  hotplugged as System RAM.
+
+	  If unsure, select "System default".
+
+config CXL_MEMHP_POLICY_SYSTEM_DEFAULT
+	bool "System default"
+	help
+	  Follow the system-wide memory hotplug policy.
+
+config CXL_MEMHP_POLICY_ONLINE
+	bool "Online"
+	help
+	  Automatically online memory and let the kernel choose the zone.
+
+config CXL_MEMHP_POLICY_ONLINE_MOVABLE
+	bool "Online (movable)"
+	help
+	  Automatically online the memory into ZONE_MOVABLE. Choose this for
+	  memory that may need to be hotremoved later, or if you do not want
+	  unmovable, kernel allocations to land on this memory.
+
+config CXL_MEMHP_POLICY_ONLINE_KERNEL
+	bool "Online (kernel)"
+	help
+	  Automatically online the memory into ZONE_NORMAL. The kernel may
+	  place unmovable allocations on this memory.
+
+config CXL_MEMHP_POLICY_UNPLUGGED
+	bool "Unplugged"
+	help
+	  Create the dax/kmem device but add no memory at bind time.
+	  Choose this if a userland orchestrator will manage the device.
+
+endchoice
+
 config CXL_REGION_INVALIDATION_TEST
 	bool "CXL: Region Cache Management Bypass (TEST)"
 	depends on CXL_REGION
diff --git a/drivers/dax/cxl.c b/drivers/dax/cxl.c
index 1a7ec62122134..15f70d578c22b 100644
--- a/drivers/dax/cxl.c
+++ b/drivers/dax/cxl.c
@@ -6,6 +6,19 @@
 #include "../cxl/cxl.h"
 #include "bus.h"
 
+static int cxl_dax_online_type(void)
+{
+	if (IS_ENABLED(CONFIG_CXL_MEMHP_POLICY_UNPLUGGED))
+		return DAX_KMEM_UNPLUGGED;
+	if (IS_ENABLED(CONFIG_CXL_MEMHP_POLICY_ONLINE))
+		return MMOP_ONLINE;
+	if (IS_ENABLED(CONFIG_CXL_MEMHP_POLICY_ONLINE_MOVABLE))
+		return MMOP_ONLINE_MOVABLE;
+	if (IS_ENABLED(CONFIG_CXL_MEMHP_POLICY_ONLINE_KERNEL))
+		return MMOP_ONLINE_KERNEL;
+	return DAX_ONLINE_DEFAULT;
+}
+
 static int cxl_dax_region_probe(struct device *dev)
 {
 	struct cxl_dax_region *cxlr_dax = to_cxl_dax_region(dev);
@@ -27,7 +40,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,
+		.online_type = cxl_dax_online_type(),
 	};
 
 	return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
-- 
2.53.0-Meta


  reply	other threads:[~2026-07-12 13:19 UTC|newest]

Thread overview: 48+ 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
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-07-12 13:19           ` Gregory Price [this message]
2026-07-12 13:27           ` Gregory Price
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 21:32   ` sashiko-bot
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=alOUVvJCSQDO6yNn@gourry-fedora-PF4VCD3F \
    --to=gourry@gourry.net \
    --cc=Smita.KoralahalliChannabasappa@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=apopple@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dave.jiang@intel.com \
    --cc=david@kernel.org \
    --cc=djbw@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.