Re: [patch V3 00/20] sched: Rewrite MM CID management

Gabriele Monaco
2025-11-10T17:09:10Z

2025-10-29T13:09:04Z Thomas Gleixner <tglx@linutronix.de>:

> This is a follow up on V2 series which can be found here:
>

I confirm this series passes the selftest in [1] consistently and the observed latency spikes caused by task_mm_cid_work are gone.

Tested-by: Gabriele Monaco <gmonaco@redhat.com>

Thanks,
Gabriele

[1] - https://lore.kernel.org/lkml/20250929114225.36172-5-gmonaco@redhat.com

>     https://lore.kernel.org/20251022104005.907410538@linutronix.de
>
> The V1 cover letter contains a detailed analyisis of the issues:
>
>     https://lore.kernel.org/20251015164952.694882104@linutronix.de
>
> TLDR: The CID management is way to complex and adds significant overhead
> into scheduler hotpaths.
>
> The series rewrites MM CID management in a more simplistic way which
> focusses on low overhead in the scheduler while maintaining per task CIDs
> as long as the number of threads is not exceeding the number of possible
> CPUs.
>
> The series is based on the V6 series of the rseq rewrite:
>
>     https://lore.kernel.org/20251027084220.785525188@linutronix.de
>
> which is also available from git:
>
>     git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/rseq
>
> The series on top of the tip core/rseq branch is available from git as
> well:
>
>     git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git rseq/cid
>
> Changes vs. V2:
>
>    - Rename to cpumask/bitmap_weighted_or() - Yury
>
>    - Zero the bitmap with length of bitmap_size(nr_possible_cpus()) -
>      Shrikanth
>
>    - Move cpu_relax() out of for() as that fails to build when cpu_relax()
>      is a macro. - Shrikanth
>
>    - Picked up Reviewed/Acked-by tags where appropriate
>
> Thanks,
>
>     tglx
> ---
> Thomas Gleixner (20):
>       sched/mmcid: Revert the complex CID management
>       sched/mmcid: Use proper data structures
>       sched/mmcid: Cacheline align MM CID storage
>       sched: Fixup whitespace damage
>       sched/mmcid: Move scheduler code out of global header
>       sched/mmcid: Prevent pointless work in mm_update_cpus_allowed()
>       cpumask: Introduce cpumask_weighted_or()
>       sched/mmcid: Use cpumask_weighted_or()
>       cpumask: Cache num_possible_cpus()
>       sched/mmcid: Convert mm CID mask to a bitmap
>       signal: Move MMCID exit out of sighand lock
>       sched/mmcid: Move initialization out of line
>       sched/mmcid: Provide precomputed maximal value
>       sched/mmcid: Serialize sched_mm_cid_fork()/exit() with a mutex
>       sched/mmcid: Introduce per task/CPU ownership infrastrcuture
>       sched/mmcid: Provide new scheduler CID mechanism
>       sched/mmcid: Provide CID ownership mode fixup functions
>       irqwork: Move data struct to a types header
>       sched/mmcid: Implement deferred mode change
>       sched/mmcid: Switch over to the new mechanism
>
> include/linux/bitmap.h         |   15
> include/linux/cpumask.h        |   26 +
> include/linux/irq_work.h       |    9
> include/linux/irq_work_types.h |   14
> include/linux/mm_types.h       |  125 ------
> include/linux/rseq.h           |   27 -
> include/linux/rseq_types.h     |   71 +++
> include/linux/sched.h          |   19
> init/init_task.c               |    3
> kernel/cpu.c                   |   15
> kernel/exit.c                  |    1
> kernel/fork.c                  |    7
> kernel/sched/core.c            |  815 +++++++++++++++++++----------------------
> kernel/sched/sched.h           |  395 ++++++++-----------
> kernel/signal.c                |    2
> lib/bitmap.c                   |    6
> 16 files changed, 727 insertions(+), 823 deletions(-)