From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Gregory Price <gourry@gourry.net>
Cc: <linux-mm@kvack.org>, <linux-cxl@vger.kernel.org>,
<nvdimm@lists.linux.dev>, <linux-fsdevel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<kernel-team@meta.com>, <dave@stgolabs.net>,
<dave.jiang@intel.com>, <alison.schofield@intel.com>,
<vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
<dan.j.williams@intel.com>, <willy@infradead.org>, <jack@suse.cz>,
<terry.bowman@amd.com>, <john@jagalactic.com>
Subject: Re: [PATCH 8/9] cxl/core: Add dax_kmem_region and sysram_region drivers
Date: Mon, 2 Feb 2026 18:20:15 +0000 [thread overview]
Message-ID: <20260202182015.0000325b@huawei.com> (raw)
In-Reply-To: <20260129210442.3951412-9-gourry@gourry.net>
On Thu, 29 Jan 2026 16:04:41 -0500
Gregory Price <gourry@gourry.net> wrote:
> In the current kmem driver binding process, the only way for users
> to define hotplug policy is via a build-time option, or by not
> onlining memory by default and setting each individual memory block
> online after hotplug occurs. We can solve this with a configuration
> step between region-probe and dax-probe.
>
> Add the infrastructure for a two-stage driver binding for kmem-mode
> dax regions. The cxl_dax_kmem_region driver probes cxl_sysram_region
> devices and creates cxl_dax_region with dax_driver=kmem.
>
> This creates an interposition step where users can configure policy.
>
> Device hierarchy:
> region0 -> sysram_region0 -> dax_region0 -> dax0.0
>
> The sysram_region device exposes a sysfs 'online_type' attribute
> that allows users to configure the memory online type before the
> underlying dax_region is created and memory is hotplugged.
>
> sysram_region0/online_type:
> invalid: not configured, blocks probe
> offline: memory will not be onlined automatically
> online: memory will be onlined in ZONE_NORMAL
> online_movable: memory will be onlined in ZONE_MMOVABLE
ZONE_MOVABLE
>
> The device initializes with online_type=invalid which prevents the
> cxl_dax_kmem_region driver from binding until the user explicitly
> configures a valid online_type.
>
> This enables a two-step binding process:
> echo region0 > cxl_sysram_region/bind
> echo online_movable > sysram_region0/online_type
> echo sysram_region0 > cxl_dax_kmem_region/bind
>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Trivial stuff. Will mull over this series as a whole...
My first instinctive reaction is positive - I'm just wondering
where additional drivers fit into this and whether it has the
right degree of flexibility.
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 6200ca1cc2dd..8bef91dc726c 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -3734,8 +3734,20 @@ int cxl_region_init(void)
> if (rc)
> goto err_dax;
>
> + rc = cxl_driver_register(&cxl_sysram_region_driver);
This smells like a loop over an array of drivers is becoming sensible.
> + if (rc)
> + goto err_sysram;
> +
> + rc = cxl_driver_register(&cxl_dax_kmem_region_driver);
> + if (rc)
> + goto err_dax_kmem;
> +
> return 0;
>
> +err_dax_kmem:
> + cxl_driver_unregister(&cxl_sysram_region_driver);
> +err_sysram:
> + cxl_driver_unregister(&cxl_devdax_region_driver);
> err_dax:
> cxl_driver_unregister(&cxl_region_driver);
> return rc;
> @@ -3743,6 +3755,8 @@ int cxl_region_init(void)
>
> void cxl_region_exit(void)
> {
> + cxl_driver_unregister(&cxl_dax_kmem_region_driver);
> + cxl_driver_unregister(&cxl_sysram_region_driver);
> cxl_driver_unregister(&cxl_devdax_region_driver);
> cxl_driver_unregister(&cxl_region_driver);
> }
> diff --git a/drivers/cxl/core/sysram_region.c b/drivers/cxl/core/sysram_region.c
> new file mode 100644
> index 000000000000..5665db238d0f
> --- /dev/null
> +++ b/drivers/cxl/core/sysram_region.c
> @@ -0,0 +1,180 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright(c) 2026 Meta Platforms, Inc. All rights reserved. */
> +/*
> + * CXL Sysram Region - Intermediate device for kmem hotplug configuration
> + *
> + * This provides an intermediate device between cxl_region and cxl_dax_region
> + * that allows users to configure memory hotplug parameters (like online_type)
> + * before the underlying dax_region is created and memory is hotplugged.
> + */
> +
> +#include <linux/memory_hotplug.h>
> +#include <linux/device.h>
> +#include <linux/slab.h>
> +#include <cxlmem.h>
> +#include <cxl.h>
> +#include "core.h"
> +
> +static DEVICE_ATTR_RW(online_type);
> +
> +static struct attribute *cxl_sysram_region_attrs[] = {
> + &dev_attr_online_type.attr,
> + NULL,
As below.
> +};
> +
> +static const struct attribute_group cxl_sysram_region_attribute_group = {
> + .attrs = cxl_sysram_region_attrs,
> +};
> +
> +static const struct attribute_group *cxl_sysram_region_attribute_groups[] = {
> + &cxl_base_attribute_group,
> + &cxl_sysram_region_attribute_group,
> + NULL,
Trivial, but don't want a comma on that NULL.
> +};
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 674d5f870c70..1544c27e9c89 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -596,6 +596,25 @@ struct cxl_dax_region {
> enum dax_driver_type dax_driver;
> };
>
> +/**
> + * struct cxl_sysram_region - CXL RAM region for system memory hotplug
> + * @dev: device for this sysram_region
> + * @cxlr: parent cxl_region
> + * @hpa_range: Host physical address range for the region
> + * @online_type: Memory online type (MMOP_* 0-3, or -1 if not configured)
Ah. An there's our reason for an int. Can we just add a MMOP enum value
for not configured yet and so let us use it as an enum?
Or have a separate bool for that and ignore the online_type until it's set.
> + *
> + * Intermediate device that allows configuration of memory hotplug
> + * parameters before the underlying dax_region is created. The device
> + * starts with online_type=-1 which prevents the cxl_dax_kmem_region
> + * driver from binding until the user explicitly sets online_type.
> + */
> +struct cxl_sysram_region {
> + struct device dev;
> + struct cxl_region *cxlr;
> + struct range hpa_range;
> + int online_type;
> +};
next prev parent reply other threads:[~2026-02-02 18:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 21:04 [PATCH 0/9] cxl: explicit DAX driver selection and hotplug Gregory Price
2026-01-29 21:04 ` [PATCH 1/9] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-02-02 17:10 ` Jonathan Cameron
2026-02-02 17:46 ` Gregory Price
2026-01-29 21:04 ` [PATCH 2/9] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg Gregory Price
2026-02-02 17:25 ` Jonathan Cameron
2026-02-02 18:02 ` Gregory Price
2026-02-02 18:46 ` Jonathan Cameron
2026-02-02 21:37 ` Gregory Price
2026-02-04 21:08 ` David Hildenbrand (arm)
2026-02-05 4:23 ` Gregory Price
2026-01-29 21:04 ` [PATCH 3/9] dax: plumb online_type from dax_kmem creators to hotplug Gregory Price
2026-01-29 21:04 ` [PATCH 4/9] drivers/cxl,dax: add dax driver mode selection for dax regions Gregory Price
2026-02-02 17:54 ` Jonathan Cameron
2026-01-29 21:04 ` [PATCH 5/9] cxl/core/region: move pmem region driver logic into pmem_region Gregory Price
2026-02-02 17:56 ` Jonathan Cameron
2026-01-29 21:04 ` [PATCH 6/9] cxl/core/region: move dax region device logic into dax_region.c Gregory Price
2026-02-02 17:57 ` Jonathan Cameron
2026-01-29 21:04 ` [PATCH 7/9] cxl/core: add cxl_devdax_region driver for explicit userland region binding Gregory Price
2026-01-29 21:04 ` [PATCH 8/9] cxl/core: Add dax_kmem_region and sysram_region drivers Gregory Price
2026-01-30 21:27 ` Cheatham, Benjamin
2026-01-30 22:12 ` Gregory Price
2026-02-02 17:02 ` Cheatham, Benjamin
2026-02-02 17:41 ` Gregory Price
2026-02-02 19:19 ` Gregory Price
2026-02-02 18:20 ` Jonathan Cameron [this message]
2026-02-02 18:23 ` Gregory Price
2026-01-29 21:04 ` [PATCH 9/9] Documentation/driver-api/cxl: add dax and sysram driver documentation Gregory Price
2026-01-29 21:17 ` [PATCH 0/9] cxl: explicit DAX driver selection and hotplug Gregory Price
2026-01-30 17:34 ` 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=20260202182015.0000325b@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=gourry@gourry.net \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=john@jagalactic.com \
--cc=kernel-team@meta.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nvdimm@lists.linux.dev \
--cc=terry.bowman@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
/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