Skip to content

Commit 89d5a14

Browse files
committed
Revert "sched/numa: add statistics of numa balance task"
JIRA: https://issues.redhat.com/browse/RHEL-110301 commit db6cc3f Author: Chen Yu <yu.c.chen@intel.com> Date: Fri Jul 4 21:56:20 2025 +0800 Revert "sched/numa: add statistics of numa balance task" This reverts commit ad6b26b. This commit introduces per-memcg/task NUMA balance statistics, but unfortunately it introduced a NULL pointer exception due to the following race condition: After a swap task candidate was chosen, its mm_struct pointer was set to NULL due to task exit. Later, when performing the actual task swapping, the p->mm caused the problem. CPU0 CPU1 : ... task_numa_migrate task_numa_find_cpu task_numa_compare # a normal task p is chosen env->best_task = p # p exit: exit_signals(p); p->flags |= PF_EXITING exit_mm p->mm = NULL; migrate_swap_stop __migrate_swap_task((arg->src_task, arg->dst_cpu) count_memcg_event_mm(p->mm, NUMA_TASK_SWAP)# p->mm is NULL task_lock() should be held and the PF_EXITING flag needs to be checked to prevent this from happening. After discussion, the conclusion was that adding a lock is not worthwhile for some statistics calculations. Revert the change and rely on the tracepoint for this purpose. Link: https://lkml.kernel.org/r/20250704135620.685752-1-yu.c.chen@intel.com Link: https://lkml.kernel.org/r/20250708064917.BBD13C4CEED@smtp.kernel.org Fixes: ad6b26b ("sched/numa: add statistics of numa balance task") Signed-off-by: Chen Yu <yu.c.chen@intel.com> Reported-by: Jirka Hladky <jhladky@redhat.com> Closes: https://lore.kernel.org/all/CAE4VaGBLJxpd=NeRJXpSCuw=REhC5LWJpC29kDy-Zh2ZDyzQZA@mail.gmail.com/ Reported-by: Srikanth Aithal <Srikanth.Aithal@amd.com> Reported-by: Suneeth D <Suneeth.D@amd.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Hladky <jhladky@redhat.com> Cc: Libo Chen <libo.chen@oracle.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent 0618c46 commit 89d5a14

File tree

7 files changed

+2
-27
lines changed

7 files changed

+2
-27
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,12 +1647,6 @@ The following nested keys are defined.
16471647
numa_hint_faults (npn)
16481648
Number of NUMA hinting faults.
16491649

1650-
numa_task_migrated (npn)
1651-
Number of task migration by NUMA balancing.
1652-
1653-
numa_task_swapped (npn)
1654-
Number of task swap by NUMA balancing.
1655-
16561650
pgdemote_kswapd
16571651
Number of pages demoted by kswapd.
16581652

include/linux/sched.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,6 @@ struct sched_statistics {
544544
u64 nr_failed_migrations_running;
545545
u64 nr_failed_migrations_hot;
546546
u64 nr_forced_migrations;
547-
#ifdef CONFIG_NUMA_BALANCING
548-
u64 numa_task_migrated;
549-
u64 numa_task_swapped;
550-
#endif
551547

552548
u64 nr_wakeups;
553549
u64 nr_wakeups_sync;

include/linux/vm_event_item.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
6464
NUMA_HINT_FAULTS,
6565
NUMA_HINT_FAULTS_LOCAL,
6666
NUMA_PAGE_MIGRATE,
67-
NUMA_TASK_MIGRATE,
68-
NUMA_TASK_SWAP,
6967
#endif
7068
#ifdef CONFIG_MIGRATION
7169
PGMIGRATE_SUCCESS, PGMIGRATE_FAIL,

kernel/sched/core.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,10 +3333,6 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
33333333
#ifdef CONFIG_NUMA_BALANCING
33343334
static void __migrate_swap_task(struct task_struct *p, int cpu)
33353335
{
3336-
__schedstat_inc(p->stats.numa_task_swapped);
3337-
count_vm_numa_event(NUMA_TASK_SWAP);
3338-
count_memcg_event_mm(p->mm, NUMA_TASK_SWAP);
3339-
33403336
if (task_on_rq_queued(p)) {
33413337
struct rq *src_rq, *dst_rq;
33423338
struct rq_flags srf, drf;
@@ -7843,9 +7839,8 @@ int migrate_task_to(struct task_struct *p, int target_cpu)
78437839
if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))
78447840
return -EINVAL;
78457841

7846-
__schedstat_inc(p->stats.numa_task_migrated);
7847-
count_vm_numa_event(NUMA_TASK_MIGRATE);
7848-
count_memcg_event_mm(p->mm, NUMA_TASK_MIGRATE);
7842+
/* TODO: This is not properly updating schedstats */
7843+
78497844
trace_sched_move_numa(p, curr_cpu, target_cpu);
78507845
return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg);
78517846
}

kernel/sched/debug.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,10 +1189,6 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
11891189
P_SCHEDSTAT(nr_failed_migrations_running);
11901190
P_SCHEDSTAT(nr_failed_migrations_hot);
11911191
P_SCHEDSTAT(nr_forced_migrations);
1192-
#ifdef CONFIG_NUMA_BALANCING
1193-
P_SCHEDSTAT(numa_task_migrated);
1194-
P_SCHEDSTAT(numa_task_swapped);
1195-
#endif
11961192
P_SCHEDSTAT(nr_wakeups);
11971193
P_SCHEDSTAT(nr_wakeups_sync);
11981194
P_SCHEDSTAT(nr_wakeups_migrate);

mm/memcontrol.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ static const unsigned int memcg_vm_event_stat[] = {
468468
NUMA_PAGE_MIGRATE,
469469
NUMA_PTE_UPDATES,
470470
NUMA_HINT_FAULTS,
471-
NUMA_TASK_MIGRATE,
472-
NUMA_TASK_SWAP,
473471
#endif
474472
};
475473

mm/vmstat.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,8 +1340,6 @@ const char * const vmstat_text[] = {
13401340
"numa_hint_faults",
13411341
"numa_hint_faults_local",
13421342
"numa_pages_migrated",
1343-
"numa_task_migrated",
1344-
"numa_task_swapped",
13451343
#endif
13461344
#ifdef CONFIG_MIGRATION
13471345
"pgmigrate_success",

0 commit comments

Comments
 (0)