Skip to content

sched/mmcid: Cure fork()/vfork() related problems

Thomas Gleixner lkml 1 version Applied

Status from this message: The following commit has been merged into the sched/urgent branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4sched/mmcid: Prevent CID stalls due to concurrent forksinclude/linux/sched.h kernel/fork.c kernel/sched/core.c+15 -112 replies
2/4sched/mmcid: Handle vfork()/CLONE_VM correctlykernel/sched/core.c+1 -40 replies
3/4sched/mmcid: Remove pointless preempt guardkernel/sched/core.c+7 -50 replies
4/4sched/mmcid: Avoid full tasklist walksinclude/linux/rseq_types.h kernel/fork.c kernel/sched/core.c+18 -430 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchMatthieu Baerts (NGI0)
SeriesT-b
1/4
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [patch 0/4] sched/mmcid: Cure fork()/vfork() related problems

Matthiue and Jiri reported CPU stalls where a CPU git stuck in mm_get_cid():

https://lore.kernel.org/[email protected]

After some tedious debugging it turned out to be another subtle (or not so subtle) ownership mode change issue.

The logic handling vfork()'ed tasks in sched_mmcid_fixup_tasks_to_cpus() is broken. It is invoked when the number of tasks associated to a process is smaller than the number of MMCID users. It then walks the task list to find the vfork()'ed task, but accounts all the already processed tasks as well.

If that double processing brings the number of to be handled tasks to 0, the walk stops and the vfork()'ed task's CID is not fixed up. As a consequence a subsequent schedule in fails to acquire a (transitional) CID and the machine stalls.

Peter and me discovered also that there is a yet unreported issue vs. concurrent forks. Jiri noticed it independently.

The following series fixes those issues. It applies on top of Linus tree.

Thanks a lot to Matthieu and Jiri for providing valuable debug information and running the debug patches!

Thanks,

tglx

---
 include/linux/rseq_types.h |    6 ++-
 include/linux/sched.h      |    2 -
 kernel/fork.c              |    3 -
 kernel/sched/core.c        |   79 +++++++++++++++------------------------------
 4 files changed, 34 insertions(+), 56 deletions(-)