diff options
| author | Hui Su <sh_def@163.com> | 2026-09-16 00:59:53 +0900 |
|---|---|---|
| committer | Thomas Gleixner <tglx@kernel.org> | 2026-10-20 15:31:33 +0200 |
| commit | 7dbc307b6c72a5412e3f4e9fa2e0e926925fc5d6 (patch) | |
| tree | 92d28edbd92308681c9a63d511daa2136b64e3f7 /scripts/basic/split-include.c | |
| parent | c03c1a14507dfaf8b856c2608f9ac216021fc222 (diff) | |
| download | linux-7dbc307b6c72a5412e3f4e9fa2e0e926925fc5d6.tar.gz linux-7dbc307b6c72a5412e3f4e9fa2e0e926925fc5d6.zip | |
sched/mmcid: Fix affinity-triggered switch back to per-task mode
MM CID switches to per-CPU ownership when the number of users of an mm
exceeds the maximum number of CIDs. When the affinity union grows, the
per-CPU threshold is recalculated and the MM can switch back to per-task
ownership through deferred work.
mm_cid_calc_pcpu_thrs() incorrectly uses min(nr_cpus_allowed, users) to
calculate that switch-back threshold. This makes pcpu_thrs no larger than
users, so the users < pcpu_thrs check in mm_update_cpus_allowed() can never
succeed.
For example, with three users restricted to two CPUs, the MM enters per-CPU
mode. On an eight-CPU system, widening the affinity union to all eight CPUs
should produce a threshold of four, but the old calculation produces three
and returns early. The MM therefore remains in per-CPU mode even though the
widened CPU set makes per-task ownership preferable.
Calculate pcpu_thrs from nr_cpus_allowed directly. The users bound in
__mm_update_max_cids() still controls when per-CPU mode is entered, so this
does not change the threshold calculated when switching from per-task to
per-CPU ownership.
Tested with an x86_64 QEMU reproducer using three users, an initial two-CPU
affinity, and an eight-CPU affinity expansion. The baseline does not invoke
mm_cid_work_fn() after the affinity expansion. The fixed kernel invokes the
deferred work once and completes the switch back to per-task mode.
Fixes: fbd0e71dc370 ("sched/mmcid: Provide CID ownership mode fixup functions")
Signed-off-by: Hui Su <sh_def@163.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260915155953.2856524-1-sh_def@163.com
Diffstat (limited to 'scripts/basic/split-include.c')
0 files changed, 0 insertions, 0 deletions
