linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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>,
	David Hildenbrand <david@kernel.org>,
	Oscar Salvador <osalvador@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/9] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg
Date: Mon, 2 Feb 2026 18:46:09 +0000	[thread overview]
Message-ID: <20260202184609.00004a02@huawei.com> (raw)
In-Reply-To: <aYDmor_ruasxaZ-7@gourry-fedora-PF4VCD3F>

On Mon, 2 Feb 2026 13:02:10 -0500
Gregory Price <gourry@gourry.net> wrote:

> On Mon, Feb 02, 2026 at 05:25:24PM +0000, Jonathan Cameron wrote:
> > On Thu, 29 Jan 2026 16:04:35 -0500
> > Gregory Price <gourry@gourry.net> wrote:
> >   
> > > Enable dax kmem driver to select how to online the memory rather than
> > > implicitly depending on the system default.  This will allow users of
> > > dax to plumb through a preferred auto-online policy for their region.
> > > 
> > > Refactor and new interface:
> > > Add __add_memory_driver_managed() which accepts an explicit online_type
> > > and export mhp_get_default_online_type() so callers can pass it when
> > > they want the default behavior.  
> > 
> > Hi Gregory,
> > 
> > I think maybe I'd have left the export for the first user outside of
> > memory_hotplug.c. Not particularly important however.
> > 
> > Maybe talk about why a caller of __add_memory_driver_managed() might want
> > the default?  Feels like that's for the people who don't...
> >  
> 
> Less about why they want the default, more about maintaining backward
> compatibility.
> 
> In the cxl driver, Ben pointed out something that made me realize we can
> change `region/bind()` to actually use the new `sysram/bind` path by
> just adding a one line `sysram_regionN->online_type = default()`
> 
> I can add this detail to the changelog.
> 
> > 
> > Other comments are mostly about using a named enum. I'm not sure
> > if there is some existing reason why that doesn't work?  -Errno pushed through
> > this variable or anything like that?
> >   
> 
> I can add a cleanup-patch prior to use the enum, but i don't think this
> actually enables the compiler to do anything new at the moment?

Good point. More coffee needed (or sleep)

It lets sparse do some checking, but sadly only for wrong enum assignment.
(Gcc has -Wenum-conversion as well which I think is effectively the same)
I.e. you can't assign a value from a different enum without casting.

It can't do anything if people just pass in an out of range int.

> 
> An enum just resolves to an int, and setting `enum thing val = -1` when
> the enum definition doesn't include -1 doesn't actually fire any errors
> (at least IIRC - maybe i'm just wrong). Same with
> 
>    function(enum) -> function(-1) wouldn't fire a compilation error
> 
> It might actually be worth adding `MMOP_NOT_CONFIGURED = -1` so that the
> cxl-sysram driver can set this explicitly rather than just setting -1
> as an implicit version of this - but then why would memory_hotplug.c
> ever want to expose a NOT_CONFIGURED option lol.
> 
> So, yeah, the enum looks nicer, but not sure how much it buys us beyond
> that.
> 
> > It's a little odd to add nice kernel-doc formatted documentation
> > when the non __ variant has free form docs.  Maybe tidy that up first
> > if we want to go kernel-doc in this file?  (I'm in favor, but no idea
> > on general feelings...)
> >  
> 
> ack.  Can add some more cleanups early in the series.
> 
> > > +	if (online_type < 0 || online_type > MMOP_ONLINE_MOVABLE)  
> > 
> > This is where using an enum would help compiler know what is going on
> > and maybe warn if anyone writes something that isn't defined.
> >  
> 
> I think you still have to sanity check this, but maybe the code looks
> cleaner, so will do. 

I'm in two minds about this. If it's an enum and someone writes an int
I take take the view it's not our problem that they shot themselves in
the foot.  Maybe we should be paranoid...

J


> 
> ~Gregory
> 



  reply	other threads:[~2026-02-02 18:46 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 [this message]
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
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=20260202184609.00004a02@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=david@kernel.org \
    --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=osalvador@suse.de \
    --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