History

Revert "sched/numa: add statistics of numa balance task"

This reverts commit ad6b26b6a0a79166b53209df2ca1cf8636296382. 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.

Chen Yu committed 1 year ago

Commit db6cc3f1 parent 82241a87 files · +2 −27Browse files

Unified · Split

7 files
  1. Documentation/admin-guide/cgroup-v2.rst +0 −6
  2. include/linux/sched.h +0 −4
  3. include/linux/vm_event_item.h +0 −2
  4. kernel/sched/core.c +2 −7
  5. kernel/sched/debug.c +0 −4
  6. mm/memcontrol.c +0 −2
  7. mm/vmstat.c +0 −2
Documentation/admin-guide/cgroup-v2.rst+0−6
@@ -1732,12 +1732,6 @@ The following nested keys are defined. · 1731 unmodified lines
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+0−4
@@ -548,10 +548,6 @@ struct sched_statistics { · 547 unmodified lines
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+0−2
@@ -66,8 +66,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, · 65 unmodified lines
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+2−7
@@ -3362,10 +3362,6 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) · 3361 unmodified lines
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) · 4567 unmodified lines
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+0−4
@@ -1210,10 +1210,6 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, · 1209 unmodified lines
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+0−2
@@ -474,8 +474,6 @@ static const unsigned int memcg_vm_event_stat[] = { · 473 unmodified lines
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+0−2
@@ -1346,8 +1346,6 @@ const char * const vmstat_text[] = { · 1345 unmodified lines
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",