From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Gregory Price <gourry@gourry.net>, linux-mm@kvack.org
Cc: linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev,
linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
kernel-team@meta.com, dan.j.williams@intel.com,
vishal.l.verma@intel.com, dave.jiang@intel.com, mst@redhat.com,
jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
eperezma@redhat.com, osalvador@suse.de,
akpm@linux-foundation.org, Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCH 8/8] dax/kmem: add memory notifier to block external state changes
Date: Wed, 14 Jan 2026 10:44:08 +0100 [thread overview]
Message-ID: <d1938a63-839b-44a5-a68f-34ad290fef21@kernel.org> (raw)
In-Reply-To: <20260114085201.3222597-9-gourry@gourry.net>
On 1/14/26 09:52, Gregory Price wrote:
> Add a memory notifier to prevent external operations from changing the
> online/offline state of memory blocks managed by dax_kmem. This ensures
> state changes only occur through the driver's hotplug sysfs interface,
> providing consistent state tracking and preventing races with auto-online
> policies or direct memory block sysfs manipulation.
>
> The notifier uses a transition protocol with memory barriers:
> - Before initiating a state change, set target_state then in_transition
> - Use a barrier to ensure target_state is visible before in_transition
> - The notifier checks in_transition, then uses barrier before reading
> target_state to ensure proper ordering on weakly-ordered architectures
>
> The notifier callback:
> - Returns NOTIFY_DONE for non-overlapping memory (not our concern)
> - Returns NOTIFY_BAD if in_transition is false (block external ops)
> - Validates the memory event matches target_state (MEM_GOING_ONLINE
> for online operations, MEM_GOING_OFFLINE for offline/unplug)
> - Returns NOTIFY_OK only for driver-initiated operations with matching
> target_state
>
> This prevents scenarios where:
> - Auto-online policies re-online memory the driver is trying to offline
Is this still a problem when using offline_and_remove_memory() ?
> - Users manually change memory state via /sys/devices/system/memory/
I don't see why we would want to care about that :)
> - Other kernel subsystems interfere with driver-managed memory state
What do you have in mind?
Not sure if this functionality here is really needed when the driver
does add+online and offline+remove in a single operation. So please
elaborate :)
--
Cheers
David
prev parent reply other threads:[~2026-01-14 9:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 8:51 Subject: [PATCH 0/8] dax/kmem: add runtime hotplug state control Gregory Price
2026-01-14 8:51 ` [PATCH 1/8] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-01-14 9:46 ` David Hildenbrand (Red Hat)
2026-01-14 8:51 ` [PATCH 2/8] mm/memory_hotplug: extract __add_memory_resource() and __offline_memory() Gregory Price
2026-01-14 10:14 ` David Hildenbrand (Red Hat)
2026-01-14 8:51 ` [PATCH 3/8] mm/memory_hotplug: add APIs for explicit online type control Gregory Price
2026-01-14 10:21 ` David Hildenbrand (Red Hat)
2026-01-14 8:51 ` [PATCH 4/8] mm/memory_hotplug: return online type from add_memory_driver_managed() Gregory Price
2026-01-14 10:49 ` David Hildenbrand (Red Hat)
2026-01-14 8:51 ` [PATCH 5/8] dax/kmem: extract hotplug/hotremove helper functions Gregory Price
2026-01-14 8:51 ` [PATCH 6/8] dax/kmem: add online/offline " Gregory Price
2026-01-14 8:51 ` [PATCH 7/8] dax/kmem: add sysfs interface for runtime hotplug state control Gregory Price
2026-01-14 10:55 ` David Hildenbrand (Red Hat)
2026-01-14 8:52 ` [PATCH 8/8] dax/kmem: add memory notifier to block external state changes Gregory Price
2026-01-14 9:44 ` David Hildenbrand (Red Hat) [this message]
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=d1938a63-839b-44a5-a68f-34ad290fef21@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=eperezma@redhat.com \
--cc=gourry@gourry.net \
--cc=hare@suse.de \
--cc=jasowang@redhat.com \
--cc=kernel-team@meta.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mst@redhat.com \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=virtualization@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
--cc=xuanzhuo@linux.alibaba.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