From: Omar Sandoval <osandov@osandov.com>
To: Israel Batista <linux@israelbatista.dev.br>
Cc: akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org,
linux-debuggers@vger.kernel.org
Subject: Re: [PATCH] mm: Convert memory block states (MEM_*) macros to enum
Date: Mon, 27 Oct 2025 11:18:29 -0700 [thread overview]
Message-ID: <aP-3dauwpc-Kq5Kh@telecaster> (raw)
In-Reply-To: <20251026162156.12141-1-linux@israelbatista.dev.br>
On Sun, Oct 26, 2025 at 04:22:05PM +0000, Israel Batista wrote:
> The MEM_* constants indicating the state of the memory block are
> currently defined as macros, meaning their definitions will be omitted
> from the debuginfo on most kernel builds. This makes it harder for
> debuggers to correctly map the block state at runtime, which can be
> quite useful when analysing errors related to memory hot plugging and
> unplugging with tools such as drgn and eBPF.
>
> Converting the constants to an enum will ensure the correct information
> is emitted by the compiler and available for the debugger, without needing
> to hard-code them into the debugger and track their changes.
>
> Signed-off-by: Israel Batista <linux@israelbatista.dev.br>
> ---
> include/linux/memory.h | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index ba1515160894..8feba3bfcd18 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -89,13 +89,15 @@ int arch_get_memory_phys_device(unsigned long start_pfn);
> unsigned long memory_block_size_bytes(void);
> int set_memory_block_size_order(unsigned int order);
>
> -/* These states are exposed to userspace as text strings in sysfs */
> -#define MEM_ONLINE (1<<0) /* exposed to userspace */
> -#define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */
> -#define MEM_OFFLINE (1<<2) /* exposed to userspace */
> -#define MEM_GOING_ONLINE (1<<3)
> -#define MEM_CANCEL_ONLINE (1<<4)
> -#define MEM_CANCEL_OFFLINE (1<<5)
What kernel version is this patch based on? It doesn't apply on mainline
because it is missing a couple of definitions added in 6.9 by commit
c5f1e2d18909 ("mm/memory_hotplug: introduce
MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers").
> +enum mem_states {
mem_state is very vague. enum memory_block_state might be a more
appropriate name.
Thanks for sending this!
Omar
> + /* These states are exposed to userspace as text strings in sysfs */
> + MEM_ONLINE = (1<<0), /* exposed to userspace */
> + MEM_GOING_OFFLINE = (1<<1), /* exposed to userspace */
> + MEM_OFFLINE = (1<<2), /* exposed to userspace */
> + MEM_GOING_ONLINE = (1<<3),
> + MEM_CANCEL_ONLINE = (1<<4),
> + MEM_CANCEL_OFFLINE = (1<<5),
> +};
>
> struct memory_notify {
> unsigned long start_pfn;
> --
> 2.51.0
>
>
next prev parent reply other threads:[~2025-10-27 18:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 16:22 [PATCH] mm: Convert memory block states (MEM_*) macros to enum Israel Batista
2025-10-27 9:29 ` David Hildenbrand
2025-10-27 18:15 ` Omar Sandoval
2025-10-27 19:16 ` David Hildenbrand
2025-10-27 19:46 ` Lorenzo Stoakes
2025-10-27 23:34 ` Omar Sandoval
2025-10-28 16:06 ` David Hildenbrand
2025-10-28 16:33 ` Lorenzo Stoakes
2025-10-28 17:40 ` Omar Sandoval
2025-10-27 23:53 ` Israel Batista
2025-10-28 16:34 ` Lorenzo Stoakes
2025-10-28 19:06 ` Israel Batista
2025-10-28 19:13 ` Lorenzo Stoakes
2025-10-27 18:18 ` Omar Sandoval [this message]
2025-10-27 19:17 ` David Hildenbrand
2025-10-27 23:41 ` Israel Batista
2025-10-28 6:51 ` Omar Sandoval
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=aP-3dauwpc-Kq5Kh@telecaster \
--to=osandov@osandov.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-debuggers@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@israelbatista.dev.br \
/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.