Skip to content

Commit e77a4a6

Browse files
committed
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. Signed-off-by: Dom Cobley <[email protected]>
1 parent 8d53a07 commit e77a4a6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mm/mempolicy.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static struct mempolicy default_policy = {
138138
.refcnt = ATOMIC_INIT(1), /* never free it */
139139
.mode = MPOL_LOCAL,
140140
};
141+
static bool mempolicy_cmdline_set;
141142

142143
static struct mempolicy preferred_node_policy[MAX_NUMNODES];
143144

@@ -1629,6 +1630,13 @@ static long kernel_set_mempolicy(int mode, const unsigned long __user *nmask,
16291630
int err;
16301631

16311632
err = sanitize_mpol_flags(&lmode, &mode_flags);
1633+
1634+
if (mempolicy_cmdline_set) {
1635+
pr_info("Request to set policy ignored (mode:%x lmode:%x flags:%x err:%d)\n",
1636+
mode, lmode, mode_flags, err);
1637+
return 0;
1638+
}
1639+
16321640
if (err)
16331641
return err;
16341642

@@ -3402,6 +3410,7 @@ static int __init setup_numapolicy(char *str)
34023410
default_policy = pol;
34033411
mpol_to_str(buf, sizeof(buf), &pol);
34043412
pr_info("NUMA default policy overridden to '%s'\n", buf);
3413+
mempolicy_cmdline_set = pol.mode != MPOL_DEFAULT;
34053414
} else {
34063415
pr_warn("Unable to parse numa_policy=\n");
34073416
}

0 commit comments

Comments
 (0)