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

Showing the changes to kernel (2 of 7 files). Show all

Unified · Split

2 files
  1. kernel/sched/core.c +2 −7
  2. kernel/sched/debug.c +0 −4
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
3362#ifdef CONFIG_NUMA_BALANCING3362#ifdef CONFIG_NUMA_BALANCING
3363static void __migrate_swap_task(struct task_struct *p, int cpu)3363static void __migrate_swap_task(struct task_struct *p, int cpu)
3364{3364{
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
3369 if (task_on_rq_queued(p)) {3365 if (task_on_rq_queued(p)) {
3370 struct rq *src_rq, *dst_rq;3366 struct rq *src_rq, *dst_rq;
3371 struct rq_flags srf, drf;3367 struct rq_flags srf, drf;
@@ -7939,9 +7935,8 @@ int migrate_task_to(struct task_struct *p, int target_cpu) · 4567 unmodified lines
7939 if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))7935 if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))
7940 return -EINVAL;7936 return -EINVAL;
7941 7937
7942 __schedstat_inc(p->stats.numa_task_migrated);7938 /* TODO: This is not properly updating schedstats */
7943 count_vm_numa_event(NUMA_TASK_MIGRATE);7939
7944 count_memcg_event_mm(p->mm, NUMA_TASK_MIGRATE);
7945 trace_sched_move_numa(p, curr_cpu, target_cpu);7940 trace_sched_move_numa(p, curr_cpu, target_cpu);
7946 return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg);7941 return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg);
7947}7942}
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
1210 P_SCHEDSTAT(nr_failed_migrations_running);1210 P_SCHEDSTAT(nr_failed_migrations_running);
1211 P_SCHEDSTAT(nr_failed_migrations_hot);1211 P_SCHEDSTAT(nr_failed_migrations_hot);
1212 P_SCHEDSTAT(nr_forced_migrations);1212 P_SCHEDSTAT(nr_forced_migrations);
1213#ifdef CONFIG_NUMA_BALANCING
1214 P_SCHEDSTAT(numa_task_migrated);
1215 P_SCHEDSTAT(numa_task_swapped);
1216#endif
1217 P_SCHEDSTAT(nr_wakeups);1213 P_SCHEDSTAT(nr_wakeups);
1218 P_SCHEDSTAT(nr_wakeups_sync);1214 P_SCHEDSTAT(nr_wakeups_sync);
1219 P_SCHEDSTAT(nr_wakeups_migrate);1215 P_SCHEDSTAT(nr_wakeups_migrate);