linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mempolicy: add home_node info to mpol_to_str()
@ 2024-01-30 10:48 Chunsheng Luo
  0 siblings, 0 replies; only message in thread
From: Chunsheng Luo @ 2024-01-30 10:48 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Chunsheng Luo

There is currently no userspace interface for obtaining home_node,
so we have added home_node to the mpol_to_str(). This allows us to
obtain the home_node from the /proc/pid/numa_map.

Shown below:
7fe356e00000 bind:0-1(1) file=/root/test

Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
---
 mm/mempolicy.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 9282be2ae18e..7a8800036f88 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -3033,6 +3033,7 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
 	nodemask_t nodes = NODE_MASK_NONE;
 	unsigned short mode = MPOL_DEFAULT;
 	unsigned short flags = 0;
+	int home_node = NUMA_NO_NODE;
 
 	if (pol && pol != &default_policy && !(pol->flags & MPOL_F_MORON)) {
 		mode = pol->mode;
@@ -3043,9 +3044,10 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
 	case MPOL_DEFAULT:
 	case MPOL_LOCAL:
 		break;
-	case MPOL_PREFERRED:
 	case MPOL_PREFERRED_MANY:
 	case MPOL_BIND:
+		home_node = pol->home_node;
+	case MPOL_PREFERRED:
 	case MPOL_INTERLEAVE:
 		nodes = pol->nodes;
 		break;
@@ -3069,7 +3071,11 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
 			p += snprintf(p, buffer + maxlen - p, "relative");
 	}
 
-	if (!nodes_empty(nodes))
+	if (!nodes_empty(nodes)) {
 		p += scnprintf(p, buffer + maxlen - p, ":%*pbl",
 			       nodemask_pr_args(&nodes));
+
+		if (home_node != NUMA_NO_NODE)
+			p += scnprintf(p, buffer + maxlen - p, "(%d)", home_node);
+	}
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-30 10:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 10:48 [PATCH] mempolicy: add home_node info to mpol_to_str() Chunsheng Luo

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).