Skip to content

Commit 550a46e

Browse files
popcornmixpelwell
authored andcommitted
mm/mempolicy: Ignore runtime policy changes when set through cmdline
Some apps like linpack use numa_setpolicy to disable numa, but that tends to have a significant performance hit for us. If you have a cmdline.txt setting of numa_policy (to something other than default), then lets ignore runtime changes and stick with the cmdline.txt setting. Not specifying numa_setpolicy in cmdline, or setting numa_setpolicy=default(*) will allow runtime settings to work. (*) easier to do when numa_setpolicy=interleave is set in DT. Ignore logging for the first 40 seconds as there are some expected switches during boot. Signed-off-by: Dom Cobley <popcornmix@gmail.com>
1 parent bdf5a26 commit 550a46e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mm/mempolicy.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#include <linux/highmem.h>
8686
#include <linux/hugetlb.h>
8787
#include <linux/kernel.h>
88+
#include <linux/ktime.h>
8889
#include <linux/sched.h>
8990
#include <linux/sched/mm.h>
9091
#include <linux/sched/numa_balancing.h>
@@ -138,6 +139,7 @@ static struct mempolicy default_policy = {
138139
.refcnt = ATOMIC_INIT(1), /* never free it */
139140
.mode = MPOL_LOCAL,
140141
};
142+
static bool mempolicy_cmdline_set;
141143

142144
static struct mempolicy preferred_node_policy[MAX_NUMNODES];
143145

@@ -1629,6 +1631,14 @@ static long kernel_set_mempolicy(int mode, const unsigned long __user *nmask,
16291631
int err;
16301632

16311633
err = sanitize_mpol_flags(&lmode, &mode_flags);
1634+
1635+
if (mempolicy_cmdline_set) {
1636+
// ignore messages during boot which are expected
1637+
if (ktime_get_boottime_seconds() > 40)
1638+
pr_info("Request to set policy to %d ignored\n", mode);
1639+
return 0;
1640+
}
1641+
16321642
if (err)
16331643
return err;
16341644

@@ -3402,6 +3412,7 @@ static int __init setup_numapolicy(char *str)
34023412
default_policy = pol;
34033413
mpol_to_str(buf, sizeof(buf), &pol);
34043414
pr_info("NUMA default policy overridden to '%s'\n", buf);
3415+
mempolicy_cmdline_set = pol.mode != MPOL_DEFAULT;
34053416
} else {
34063417
pr_warn("Unable to parse numa_policy=\n");
34073418
}

0 commit comments

Comments
 (0)