Skip to content

Commit db6cc3f

Browse files
yu-chen-surfakpm00
authored andcommitted
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/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: ad6b26b ("sched/numa: add statistics of numa balance task") Signed-off-by: Chen Yu <[email protected]> Reported-by: Jirka Hladky <[email protected]> Closes: https://lore.kernel.org/all/CAE4VaGBLJxpd=NeRJXpSCuw=REhC5LWJpC29kDy-Zh2ZDyzQZA@mail.gmail.com/ Reported-by: Srikanth Aithal <[email protected]> Reported-by: Suneeth D <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Hladky <[email protected]> Cc: Libo Chen <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 82241a8 commit db6cc3f

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
@@ -1732,12 +1732,6 @@ The following nested keys are defined.
17321732
numa_hint_faults (npn)
17331733
Number of NUMA hinting faults.
17341734

1735-
numa_task_migrated (npn)
1736-
Number of task migration by NUMA balancing.
1737-
1738-
numa_task_swapped (npn)
1739-
Number of task swap by NUMA balancing.
1740-
17411735
pgdemote_kswapd
17421736
Number of pages demoted by kswapd.
17431737

include/linux/sched.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,6 @@ struct sched_statistics {
548548
u64 nr_failed_migrations_running;
549549
u64 nr_failed_migrations_hot;
550550
u64 nr_forced_migrations;
551-
#ifdef CONFIG_NUMA_BALANCING
552-
u64 numa_task_migrated;
553-
u64 numa_task_swapped;
554-
#endif
555551

556552
u64 nr_wakeups;
557553
u64 nr_wakeups_sync;

include/linux/vm_event_item.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
6666
NUMA_HINT_FAULTS,
6767
NUMA_HINT_FAULTS_LOCAL,
6868
NUMA_PAGE_MIGRATE,
69-
NUMA_TASK_MIGRATE,
70-
NUMA_TASK_SWAP,
7169
#endif
7270
#ifdef CONFIG_MIGRATION
7371
PGMIGRATE_SUCCESS, PGMIGRATE_FAIL,

kernel/sched/core.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,10 +3362,6 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
33623362
#ifdef CONFIG_NUMA_BALANCING
33633363
static void __migrate_swap_task(struct task_struct *p, int cpu)
33643364
{
3365-
__schedstat_inc(p->stats.numa_task_swapped);
3366-
count_vm_numa_event(NUMA_TASK_SWAP);
3367-
count_memcg_event_mm(p->mm, NUMA_TASK_SWAP);
3368-
33693365
if (task_on_rq_queued(p)) {
33703366
struct rq *src_rq, *dst_rq;
33713367
struct rq_flags srf, drf;
@@ -7939,9 +7935,8 @@ int migrate_task_to(struct task_struct *p, int target_cpu)
79397935
if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))
79407936
return -EINVAL;
79417937

7942-
__schedstat_inc(p->stats.numa_task_migrated);
7943-
count_vm_numa_event(NUMA_TASK_MIGRATE);
7944-
count_memcg_event_mm(p->mm, NUMA_TASK_MIGRATE);
7938+
/* TODO: This is not properly updating schedstats */
7939+
79457940
trace_sched_move_numa(p, curr_cpu, target_cpu);
79467941
return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg);
79477942
}

kernel/sched/debug.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,10 +1210,6 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
12101210
P_SCHEDSTAT(nr_failed_migrations_running);
12111211
P_SCHEDSTAT(nr_failed_migrations_hot);
12121212
P_SCHEDSTAT(nr_forced_migrations);
1213-
#ifdef CONFIG_NUMA_BALANCING
1214-
P_SCHEDSTAT(numa_task_migrated);
1215-
P_SCHEDSTAT(numa_task_swapped);
1216-
#endif
12171213
P_SCHEDSTAT(nr_wakeups);
12181214
P_SCHEDSTAT(nr_wakeups_sync);
12191215
P_SCHEDSTAT(nr_wakeups_migrate);

mm/memcontrol.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,6 @@ static const unsigned int memcg_vm_event_stat[] = {
474474
NUMA_PAGE_MIGRATE,
475475
NUMA_PTE_UPDATES,
476476
NUMA_HINT_FAULTS,
477-
NUMA_TASK_MIGRATE,
478-
NUMA_TASK_SWAP,
479477
#endif
480478
};
481479

mm/vmstat.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,6 @@ const char * const vmstat_text[] = {
13461346
"numa_hint_faults",
13471347
"numa_hint_faults_local",
13481348
"numa_pages_migrated",
1349-
"numa_task_migrated",
1350-
"numa_task_swapped",
13511349
#endif
13521350
#ifdef CONFIG_MIGRATION
13531351
"pgmigrate_success",

0 commit comments

Comments
 (0)