linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Oscar Salvador <osalvador@suse.de>,
	Tejun Heo <tj@kernel.org>, Waiman Long <longman@redhat.com>
Subject: [PATCH v3] include/linux/nodemask.h: Use nr_node_ids (not MAX_NUMNODES) in __nodemask_pr_numnodes()
Date: Wed, 19 Dec 2018 16:04:52 -0500	[thread overview]
Message-ID: <1545253492-32070-1-git-send-email-longman@redhat.com> (raw)

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.

 v3: Fix build problem with MAX_NUMNODES=1.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 include/linux/nodemask.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 5a30ad5..9e3a30d 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -98,6 +98,13 @@
 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
 extern nodemask_t _unused_nodemask_arg_;
 
+#if MAX_NUMNODES > 1
+extern int nr_node_ids;
+extern int nr_online_nodes;
+#else
+#define nr_node_ids	MAX_NUMNODES
+#endif
+
 /**
  * nodemask_pr_args - printf args to output a nodemask
  * @maskp: nodemask to be printed
@@ -108,7 +115,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 +451,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);
-- 
1.8.3.1


             reply	other threads:[~2018-12-19 21:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 21:04 Waiman Long [this message]
2018-12-21  0:39 ` [PATCH v3] include/linux/nodemask.h: Use nr_node_ids (not MAX_NUMNODES) in __nodemask_pr_numnodes() kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1545253492-32070-1-git-send-email-longman@redhat.com \
    --to=longman@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=osalvador@suse.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).