linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mm: Convert memory block states (MEM_*) macros to
@ 2025-10-29 19:56 Israel Batista
  2025-10-29 19:56 ` [PATCH v2 1/3] mm: convert memory block states (MEM_*) macros to enum Israel Batista
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Israel Batista @ 2025-10-29 19:56 UTC (permalink / raw)
  To: david, lorenzo.stoakes, akpm, linux-mm; +Cc: osandov, linux-debuggers

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/20251026162156.12141-1-linux@israelbatista.dev.br/ [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(-)

-- 
2.51.0



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-10-30 14:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).