hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAHJKC CVE: NA
--------------------------------
Numa affinity reuse some AutoNuma code, which were designed based on page fault based memory access awareness, so some logic need adjust for sampling based awareness. Add a helper numa_affinity_sampling_enabled() to distinguish the scenarios. Use it in task_tick_numa() to simplify the code.
Fixes: bdc4701337d7 ("mm/mem_sampling.c: Drive NUMA balancing via mem_sampling access data") Signed-off-by: Nanyong Sun sunnanyong@huawei.com --- include/linux/mem_sampling.h | 13 +++++++++++++ kernel/sched/fair.c | 11 ++++------- 2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/include/linux/mem_sampling.h b/include/linux/mem_sampling.h index 5c168bc60862..6978c11d5499 100644 --- a/include/linux/mem_sampling.h +++ b/include/linux/mem_sampling.h @@ -105,4 +105,17 @@ static inline int arm_spe_enabled(void) return 0; } #endif /* CONFIG_ARM_SPE_MEM_SAMPLING */ + +#ifdef CONFIG_NUMABALANCING_MEM_SAMPLING +static inline bool numa_affinity_sampling_enabled(void) +{ + return static_branch_unlikely(&sched_numabalancing_mem_sampling); +} +#else +static inline bool numa_affinity_sampling_enabled(void) +{ + return false; +} +#endif + #endif /* __MEM_SAMPLING_H */ diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7f56800b17da..2139edac2cb1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2968,16 +2968,13 @@ static void task_tick_numa(struct rq *rq, struct task_struct *curr) struct callback_head *work = &curr->numa_work; u64 period, now;
-#ifdef CONFIG_NUMABALANCING_MEM_SAMPLING /* - * If we are using access hints from hardware (like using - * SPE), don't scan the address space. - * Note that currently PMD-level page migration is not - * supported. + * numa affinity use hardware sampling to get numa info(like using + * SPE for ARM64), no need to scan the address space anymore. */ - if (static_branch_unlikely(&sched_numabalancing_mem_sampling)) + if (numa_affinity_sampling_enabled()) return; -#endif + /* * We don't care about NUMA placement if we don't have memory. */