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.
Unified · Split
| @@ -1732,12 +1732,6 @@ The following nested keys are defined. · 1731 unmodified lines | ||
| 1732 | 1732 | numa_hint_faults (npn) |
| 1733 | 1733 | Number of NUMA hinting faults. |
| 1734 | 1734 | |
| 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 | − | |
| 1741 | 1735 | pgdemote_kswapd |
| 1742 | 1736 | Number of pages demoted by kswapd. |
| 1743 | 1737 | |
| @@ -548,10 +548,6 @@ struct sched_statistics { · 547 unmodified lines | ||
| 548 | 548 | u64 nr_failed_migrations_running; |
| 549 | 549 | u64 nr_failed_migrations_hot; |
| 550 | 550 | u64 nr_forced_migrations; |
| 551 | −#ifdef CONFIG_NUMA_BALANCING | |
| 552 | − u64 numa_task_migrated; | |
| 553 | − u64 numa_task_swapped; | |
| 554 | −#endif | |
| 555 | 551 | |
| 556 | 552 | u64 nr_wakeups; |
| 557 | 553 | u64 nr_wakeups_sync; |
| @@ -66,8 +66,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, · 65 unmodified lines | ||
| 66 | 66 | NUMA_HINT_FAULTS, |
| 67 | 67 | NUMA_HINT_FAULTS_LOCAL, |
| 68 | 68 | NUMA_PAGE_MIGRATE, |
| 69 | − NUMA_TASK_MIGRATE, | |
| 70 | − NUMA_TASK_SWAP, | |
| 71 | 69 | #endif |
| 72 | 70 | #ifdef CONFIG_MIGRATION |
| 73 | 71 | PGMIGRATE_SUCCESS, PGMIGRATE_FAIL, |
| @@ -3362,10 +3362,6 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) · 3361 unmodified lines | ||
| 3362 | 3362 | #ifdef CONFIG_NUMA_BALANCING |
| 3363 | 3363 | static 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 | 3365 | if (task_on_rq_queued(p)) { |
| 3370 | 3366 | struct rq *src_rq, *dst_rq; |
| 3371 | 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 | 7935 | if (!cpumask_test_cpu(target_cpu, p->cpus_ptr)) |
| 7940 | 7936 | return -EINVAL; |
| 7941 | 7937 | |
| 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 | + | |
| 7945 | 7940 | trace_sched_move_numa(p, curr_cpu, target_cpu); |
| 7946 | 7941 | return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg); |
| 7947 | 7942 | } |
| @@ -1210,10 +1210,6 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, · 1209 unmodified lines | ||
| 1210 | 1210 | P_SCHEDSTAT(nr_failed_migrations_running); |
| 1211 | 1211 | P_SCHEDSTAT(nr_failed_migrations_hot); |
| 1212 | 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 | 1213 | P_SCHEDSTAT(nr_wakeups); |
| 1218 | 1214 | P_SCHEDSTAT(nr_wakeups_sync); |
| 1219 | 1215 | P_SCHEDSTAT(nr_wakeups_migrate); |
| @@ -474,8 +474,6 @@ static const unsigned int memcg_vm_event_stat[] = { · 473 unmodified lines | ||
| 474 | 474 | NUMA_PAGE_MIGRATE, |
| 475 | 475 | NUMA_PTE_UPDATES, |
| 476 | 476 | NUMA_HINT_FAULTS, |
| 477 | − NUMA_TASK_MIGRATE, | |
| 478 | − NUMA_TASK_SWAP, | |
| 479 | 477 | #endif |
| 480 | 478 | }; |
| 481 | 479 | |
| @@ -1346,8 +1346,6 @@ const char * const vmstat_text[] = { · 1345 unmodified lines | ||
| 1346 | 1346 | "numa_hint_faults", |
| 1347 | 1347 | "numa_hint_faults_local", |
| 1348 | 1348 | "numa_pages_migrated", |
| 1349 | − "numa_task_migrated", | |
| 1350 | − "numa_task_swapped", | |
| 1351 | 1349 | #endif |
| 1352 | 1350 | #ifdef CONFIG_MIGRATION |
| 1353 | 1351 | "pgmigrate_success", |