From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Israel Batista <linux@israelbatista.dev.br>
Cc: david@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org,
osandov@osandov.com, linux-debuggers@vger.kernel.org
Subject: Re: [PATCH v2 1/3] mm: convert memory block states (MEM_*) macros to enum
Date: Thu, 30 Oct 2025 10:52:46 +0000 [thread overview]
Message-ID: <c26bc5eb-ef7f-4858-8ee0-2de013b53bf9@lucifer.local> (raw)
In-Reply-To: <20251029195617.2210700-2-linux@israelbatista.dev.br>
On Wed, Oct 29, 2025 at 07:56:28PM +0000, Israel Batista wrote:
> Converting the MEM_* constants from macros to an enum ensures that their
> values will be correctly emitted in the debug symbols, making it easier
> to trace the meaning of each value when debugging with tools such as
> drgn, without the need to hard-code the values.
>
> Since the values are mutually exclusive and they are not exposed directly to
> userspace, I also dropped the misleading pattern (1<<X) that made it look like
> they were combinable flags.
>
> Signed-off-by: Israel Batista <linux@israelbatista.dev.br>
LGTM, so:
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> include/linux/memory.h | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index 0c214256216f..f4e358477c6a 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -64,6 +64,18 @@ struct memory_group {
> };
> };
>
> +enum memory_block_state {
> + /* These states are exposed to userspace as text strings in sysfs */
> + MEM_ONLINE, /* exposed to userspace */
> + MEM_GOING_OFFLINE, /* exposed to userspace */
> + MEM_OFFLINE, /* exposed to userspace */
> + MEM_GOING_ONLINE,
> + MEM_CANCEL_ONLINE,
> + MEM_CANCEL_OFFLINE,
> + MEM_PREPARE_ONLINE,
> + MEM_FINISH_OFFLINE,
> +};
> +
> struct memory_block {
> unsigned long start_section_nr;
> unsigned long state; /* serialized by the dev->lock */
> @@ -89,16 +101,6 @@ 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)
> -#define MEM_PREPARE_ONLINE (1<<6)
> -#define MEM_FINISH_OFFLINE (1<<7)
> -
> struct memory_notify {
> /*
> * The altmap_start_pfn and altmap_nr_pages fields are designated for
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-10-30 10:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 19:56 [PATCH v2 0/3] mm: Convert memory block states (MEM_*) macros to Israel Batista
2025-10-29 19:56 ` [PATCH v2 1/3] mm: convert memory block states (MEM_*) macros to enum Israel Batista
2025-10-30 10:52 ` Lorenzo Stoakes [this message]
2025-10-30 11:31 ` David Hildenbrand
2025-10-29 19:56 ` [PATCH v2 2/3] mm: change type of state in struct memory_block Israel Batista
2025-10-29 20:59 ` Randy Dunlap
2025-10-30 11:00 ` Lorenzo Stoakes
2025-10-30 11:32 ` David Hildenbrand
2025-10-29 19:56 ` [PATCH v2 3/3] mm: change type of parameter for memory_notify Israel Batista
2025-10-30 10:56 ` Lorenzo Stoakes
2025-10-30 11:16 ` Israel Batista
2025-10-30 11:34 ` David Hildenbrand
2025-10-30 12:00 ` Israel Batista
2025-10-30 14:57 ` [PATCH v2 0/3] mm: Convert memory block states (MEM_*) macros to Mike Rapoport
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=c26bc5eb-ef7f-4858-8ee0-2de013b53bf9@lucifer.local \
--to=lorenzo.stoakes@oracle.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 \
--cc=osandov@osandov.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