These are not the usual pointers to arrays The array data are held in the node structure itself

The zones of the node are held in node_zones[MAX_NR_ZONES]. The array always has three entries, even if the node has fewer zones. If the latter is the case, the remaining entries are filled with null elements.

Node State Management

If more than one node can be present on the system, the kernel keeps a bitmap that provides state information for each node. The states are specified with a bitmask, and the following values are possible:


enum node_states {




/* The node could become online at some point */







The states n_possible, n_online, and n_cpu are required for CPU and memory hotplugging, but these features are not considered in this book. Essential for memory management are the flags n_high_memory and n_normal_memory. While the first one announces that the zone is equipped with memory that may be either regular or high memory, n_normal_memory is only set if non-highmem memory is present on a node.

/* The node has regular or high memory */ = N_NORMAL_MEMORY,

Two auxiliary functions are provided to set or clear, respectively, a bit in the bit-field or a specific node: <nodemask.h>

void node_set_state(int node, enum node_states state) void node_clear_state(int node, enum node_states state)

Additionally, the macro for_each_node_state(_node, _state) allows for iterating over all nodes that are in a specific state, and for_each_online_node(node) iterates over all active nodes.

If the kernel is compiled to support only a single node, that is, using the flat memory model, the node bitmap is not present, and the functions to manipulate it resolve to empty operations that simply do nothing.

Continue reading here: Memory Zones

Was this article helpful?

0 0