Re: [PATCH] mm/numa_balancing: Teach mpol_to_str about the balancing mode

From: Tvrtko Ursulin
Date: Wed Jun 26 2024 - 07:51:33 EST



On 26/06/2024 09:48, Huang, Ying wrote:
Tvrtko Ursulin <tursulin@xxxxxxxxxx> writes:

From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxx>

If a task has had MPOL_F_NUMA_BALANCING set it is useful to show that in

IIUC, MPOL_F_NUMA_BALANCING works for VMA area via mbind() too.

Ah okay.. I think I forgot to actually check and went by what commit text of bda420b98505 said, which is probably outdated.

procfs. Teach the mpol_to_str helper about its existance and while at it
update the comment to account for "weighted interleave" when suggesting
a recommended buffer size.

Otherwise LGTM, Thanks!

Reviewed-by: "Huang, Ying" <ying.huang@xxxxxxxxx>

Thank you! Would you have an idea of which tree this should go to aka which maintainer to ask to merge it?

Second question - I also have a patch which enables choosing balancing for tmpfs (mpol_parse_str) but I am unsure of its value. It would make things symmetrical, but is there some other benefit I don't know. Any thoughts on this?

Regards,

Tvrtko

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxx>
References: bda420b98505 ("numa balancing: migrate on fault among multiple bound nodes")
Cc: Huang Ying <ying.huang@xxxxxxxxx>
Cc: Mel Gorman <mgorman@xxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxx>
Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: David Rientjes <rientjes@xxxxxxxxxx>
---
mm/mempolicy.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index aec756ae5637..d147287c4505 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -3293,8 +3293,9 @@ int mpol_parse_str(char *str, struct mempolicy **mpol)
* @pol: pointer to mempolicy to be formatted
*
* Convert @pol into a string. If @buffer is too short, truncate the string.
- * Recommend a @maxlen of at least 32 for the longest mode, "interleave", the
- * longest flag, "relative", and to display at least a few node ids.
+ * Recommend a @maxlen of at least 42 for the longest mode, "weighted
+ * interleave", the longest flag, "balancing", and to display at least a few
+ * node ids.
*/
void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
{
@@ -3331,12 +3332,15 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
p += snprintf(p, buffer + maxlen - p, "=");
/*
- * Currently, the only defined flags are mutually exclusive
+ * The below two flags are mutually exclusive:
*/
if (flags & MPOL_F_STATIC_NODES)
p += snprintf(p, buffer + maxlen - p, "static");
else if (flags & MPOL_F_RELATIVE_NODES)
p += snprintf(p, buffer + maxlen - p, "relative");
+
+ if (flags & MPOL_F_NUMA_BALANCING)
+ p += snprintf(p, buffer + maxlen - p, "balancing");
}
if (!nodes_empty(nodes))