遍历各个pg_data_t节点。
1.定义在include/linux/nodemask.h中
/* * Bitmasks that are kept for all the nodes. */ enum node_states { N_POSSIBLE, /* The node could become online at some point */ N_ONLINE, /* The node is online */ N_NORMAL_MEMORY, /* The node has regular memory */ #ifdef CONFIG_HIGHMEM N_HIGH_MEMORY, /* The node has regular or high memory */ #else N_HIGH_MEMORY = N_NORMAL_MEMORY, #endif N_CPU, /* The node has one or more cpus */ NR_NODE_STATES };
#define for_each_node(node) for_each_node_state(node, N_POSSIBLE)
for_each_node_state根据宏开关有不同的定义
#if MAX_NUMNODES #define for_each_node_state(__node, __state) \ for_each_node_mask((__node), node_states[__state]) #else #define for_each_node_state(node, __state) \ for ( (node) = 0; (node) == 0; (node) = 1)
2.MAX_NUMNODES
定义在include/linux/numa.h中
#ifdef CONFIG_NODES_SHIFT #define NODES_SHIFT CONFIG_NODES_SHIFT #else #define NODES_SHIFT 0 #endif #define MAX_NUMNODES (1 << NODES_SHIFT)
而CONFIG_NODES_SHIFT定义在不同板子的arch/arm/configs/xxx_defconfig文件中。
3.for_each_node_mask(node, mask)
#if MAX_NUMNODES > 1 #define for_each_node_mask(node, mask) \ for ((node) = first_node(mask); \ (node) < MAX_NUMNODES; \ (node) = next_node((node), (mask))) #else /* MAX_NUMNODES == 1 */ #define for_each_node_mask(node, mask) \ if (!nodes_empty(mask)) \ for ((node) = 0; (node) < 1; (node)++) #endif /* MAX_NUMNODES */