Skip to contentSkip to conversation

include/linux/nodemask.h: Use nr_node_ids (not MAX_NUMNODES) in __nodemask_pr_numnodes()

PATCH Superseded Waiman Long 3 participants 3 messages Dec 18, 2018 – Dec 19, 2018 Bitmap API

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 include/linux/nodemask.h: Use nr_node_ids (not MAX_NUMNODES) in __nodemask_pr_numnodes()

When viewing the /proc/<pid>/status file, one can see output lines like

Cpus_allowed: ffffffff,ffffffff,ffffffff
Cpus_allowed_list: 0-95
Mems_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f
Mems_allowed_list: 0-3

The "Mems_allowed" line uses the "%*pb" format string while the "Mems_allowed_list" line uses the "%*pbl" format string together with the nodemask_pr_args() macro.

The "Mems_allowed" looks insane compared with the others. It is because the nodemask_pr_args() macro uses MAX_NUMNODES as the number of nodes to iterate. The cpumask_pr_args() macro uses nr_cpu_ids instead of MAX_CPUS. For nodes, there is a corresponding nr_node_ids. So it makes sense to use nr_node_ids instead to be consistent with "Cpus_allowed:".

With that change, the "Mems_allowed" line becomes sane again.

Mems_allowed: f

There are currently 10 call sites of nodemask_pr_args() in the kernel. Of them, only cpuset_task_status_allowed() in kernel/cgroup/cpuset.c uses the "%*pb" format string that will be affected by this change. That cpuset function is called by proc_pid_status() only.

---
 include/linux/nodemask.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
include/linux/nodemask.h +3 -4
index 5a30ad5..ba07661 100644
@@ -97,6 +97,8 @@
 
 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
 extern nodemask_t _unused_nodemask_arg_;
+extern int nr_node_ids;
+extern int nr_online_nodes;
 
 /**
  * nodemask_pr_args - printf args to output a nodemask
@@ -108,7 +110,7 @@
 				__nodemask_pr_bits(maskp)
 static inline unsigned int __nodemask_pr_numnodes(const nodemask_t *m)
 {
-	return m ? MAX_NUMNODES : 0;
+	return m ? nr_node_ids : 0;
 }
 static inline const unsigned long *__nodemask_pr_bits(const nodemask_t *m)
 {
@@ -444,9 +446,6 @@ static inline int next_memory_node(int nid)
 	return next_node(nid, node_states[N_MEMORY]);
 }
 
-extern int nr_node_ids;
-extern int nr_online_nodes;
-
 static inline void node_set_online(int nid)
 {
 	node_set_state(nid, N_ONLINE);
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Waiman Long
Thank you for the patch! Yet something to improve:

Hi Waiman,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc7 next-20181218]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Waiman-Long/include-linux-nodemask-h-Use-nr_node_ids-not-MAX_NUMNODES-in-__nodemask_pr_numnodes/20181219-110121
config: arm-omap2plus_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=arm

All errors (new ones prefixed by >>):

kernel/cgroup/cpuset.o: In function `cpuset_common_seq_show':

>> cpuset.c:(.text+0xe2c): undefined reference to `nr_node_ids'

kernel/cgroup/cpuset.o: In function `cpuset_print_current_mems_allowed':
cpuset.c:(.text+0x4624): undefined reference to nr_node_ids' kernel/cgroup/cpuset.o: In function cpuset_task_status_allowed':
cpuset.c:(.text+0x4d5c): undefined reference to nr_node_ids' mm/oom_kill.o: In function dump_header':
oom_kill.c:(.text.unlikely+0x3c4): undefined reference to nr_node_ids' mm/page_alloc.o: In function warn_alloc':
page_alloc.c:(.text+0x4ae0): undefined reference to `nr_node_ids'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation