[PATCH v5 1/2] sched/numa: use static_branch_inc/dec for sched_numa_balancing
From: Gang Li
Date: Wed Oct 26 2022 - 22:54:11 EST
per-process numa balancing use static_branch_inc/dec() to count
how many enables in sched_numa_balancing. So here must be converted
to inc/dec too.
Signed-off-by: Gang Li <ligang.bdlg@xxxxxxxxxxxxx>
---
kernel/sched/core.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index cb2aa2b54c7a..43716d107d72 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4372,21 +4372,15 @@ DEFINE_STATIC_KEY_FALSE(sched_numa_balancing);
int sysctl_numa_balancing_mode;
-static void __set_numabalancing_state(bool enabled)
-{
- if (enabled)
- static_branch_enable(&sched_numa_balancing);
- else
- static_branch_disable(&sched_numa_balancing);
-}
-
void set_numabalancing_state(bool enabled)
{
- if (enabled)
+ if (enabled) {
sysctl_numa_balancing_mode = NUMA_BALANCING_NORMAL;
- else
+ static_branch_enable(&sched_numa_balancing);
+ } else {
sysctl_numa_balancing_mode = NUMA_BALANCING_DISABLED;
- __set_numabalancing_state(enabled);
+ static_branch_disable(&sched_numa_balancing);
+ }
}
#ifdef CONFIG_PROC_SYSCTL
@@ -4420,8 +4414,14 @@ int sysctl_numa_balancing(struct ctl_table *table, int write,
if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) &&
(state & NUMA_BALANCING_MEMORY_TIERING))
reset_memory_tiering();
- sysctl_numa_balancing_mode = state;
- __set_numabalancing_state(state);
+ if (sysctl_numa_balancing_mode != state) {
+ if (state == NUMA_BALANCING_DISABLED)
+ static_branch_dec(&sched_numa_balancing);
+ else if (sysctl_numa_balancing_mode == NUMA_BALANCING_DISABLED)
+ static_branch_inc(&sched_numa_balancing);
+
+ sysctl_numa_balancing_mode = state;
+ }
}
return err;
}
--
2.20.1