Re: [PATCH v2 0/3] mm: Convert memory block states (MEM_*) macros to

Mike Rapoport <[email protected]> Thu, 30 Oct 2025 16:57:33 +0200
Newsgroups org.kernel.vger.linux-debuggers,org.kvack.linux-mm
Message-ID <[email protected]>
On Wed, Oct 29, 2025 at 07:56:26PM +0000, Israel Batista wrote:
> The MEM_* constants indicating the state of a 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.
> 
> Converting the constants to an enum would 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.
> 
> This patch series aims to replace the current macros with a newly
> created enum named memory_block_state, while also taking advantage of
> the compile time guarantees that we get when using enums.
> 
> The first patch does the conversion of the macros to an enum, while the
> 2nd and 3rd patches use this enum to clean up some type declarations and
> make sure that only valid values are used.
> 
> ---
> 
> Link: https://lore.kernel.org/linux-mm/[email protected]/ [v1]
> 
> v1 -> v2
> - Rename the enum to make it more descriptive.
> - Let the enum auto-generate the values, as the (1<<X) pattern could be
>   misleading and they're not exposed to userspace.
> - Change the type signature from unsigned long to enum memory_block_state
>   where suitable.
> 
> Thanks to everyone who took their time to review the first version.
> 
> This patch series applies to commit: f30d294530d9 (mm-new)
> 
> Israel Batista (3):
>   mm: convert memory block states (MEM_*) macros to enum
>   mm: change type of state in struct memory_block
>   mm: change type of parameter for memory_notify
> 
>  drivers/base/memory.c  |  6 +++---
>  include/linux/memory.h | 28 +++++++++++++++-------------
>  2 files changed, 18 insertions(+), 16 deletions(-)

I wonder if we need three patches for this, but regardless

Acked-by: Mike Rapoport (Microsoft) <[email protected]>
 
> -- 
> 2.51.0
> 

-- 
Sincerely yours,
Mike.