linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chunsheng Luo <luochunsheng@ustc.edu>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Chunsheng Luo <luochunsheng@ustc.edu>
Subject: [PATCH] mempolicy: add home_node info to mpol_to_str()
Date: Tue, 30 Jan 2024 05:48:39 -0500	[thread overview]
Message-ID: <20240130104839.10270-1-luochunsheng@ustc.edu> (raw)

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


                 reply	other threads:[~2024-01-30 10:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240130104839.10270-1-luochunsheng@ustc.edu \
    --to=luochunsheng@ustc.edu \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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).