[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240130104839.10270-1-luochunsheng@ustc.edu>
Date: Tue, 30 Jan 2024 05:48:39 -0500
From: Chunsheng Luo <luochunsheng@...c.edu>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Chunsheng Luo <luochunsheng@...c.edu>
Subject: [PATCH] mempolicy: add home_node info to mpol_to_str()
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@...c.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
Powered by blists - more mailing lists