vmalloc: add for_each_vmap_node() helper

To simplify iteration over vmap-nodes, add the for_each_vmap_node() macro
that iterates over all nodes in a system.  It tends to simplify the code.

Link: https://lkml.kernel.org/r/20250408151549.77937-1-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Christop Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
pull/1253/head
Uladzislau Rezki (Sony) 2025-04-08 17:15:47 +02:00 committed by Andrew Morton
parent a40b3fa844
commit 4318255091
1 changed files with 5 additions and 0 deletions

View File

@ -900,6 +900,11 @@ static struct vmap_node *vmap_nodes = &single;
static __read_mostly unsigned int nr_vmap_nodes = 1;
static __read_mostly unsigned int vmap_zone_size = 1;
/* A simple iterator over all vmap-nodes. */
#define for_each_vmap_node(vn) \
for ((vn) = &vmap_nodes[0]; \
(vn) < &vmap_nodes[nr_vmap_nodes]; (vn)++)
static inline unsigned int
addr_to_node_id(unsigned long addr)
{