mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hang Zhengyang <hang.zhengyang1010@gmail.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Cheng-Yang Chou <yphbchou0911@gmail.com>,
	Barret Rhoden <brho@google.com>, Josh Don <joshdon@google.com>,
	Hao Luo <haoluo@google.com>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two races between fork and scx_post_fork()
Date: Fri,  4 Dec 2026 01:27:42 +0000	[thread overview]
Message-ID: <20261204012744.195571-1-hang.zhengyang1010@gmail.com> (raw)

Before scx_post_fork() runs, a new task can be reached by
sched_setscheduler() (patch 1, since v6.12) and by a cgroup migration to
another sub-scheduler (patch 2). Either can make ops.enable() run twice
or trip the task state check.

Tested on for-7.4-fixes with KASAN and lockdep. With a debug-only delay
before scx_post_fork(), all seven class change and migration cases warn
or enable tasks twice before and are clean after. Without the delay, 700
seconds of migrations enable 38 of 46133 tasks twice before and 0 of
44149 after. The sched_ext selftests pass.

Andrea Righi's pending "sched: Let switching_to() decide whether to keep
a retained proxy donor" makes switching_to_scx() return bool, so patch 1
will need a return value there.

I used Claude Code to find the issues, write the patches and run the
tests. I reviewed the patches.

Hang Zhengyang (2):
  sched_ext: Don't enable or disable a task being forked on class
    changes
  sched_ext: Don't enable a task twice when it migrates during fork

 kernel/sched/ext/ext.c | 32 +++++++++++++++++++++-----------
 kernel/sched/ext/sub.c | 26 +++++++++++++++++++-------
 2 files changed, 40 insertions(+), 18 deletions(-)


base-commit: b2b011d3d9cd7e01308ba8fa5775dcd1f2f11f70
-- 
2.53.0


             reply	other threads:[~2026-12-04  1:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  1:27 Hang Zhengyang [this message]
2026-12-04  1:27 ` [PATCH sched_ext/for-7.4-fixes 1/2] sched_ext: Don't enable or disable a task being forked on class changes Hang Zhengyang
2026-12-04  1:27 ` [PATCH sched_ext/for-7.4-fixes 2/2] sched_ext: Don't enable a task twice when it migrates during fork Hang Zhengyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204012744.195571-1-hang.zhengyang1010@gmail.com \
    --to=hang.zhengyang1010@gmail.com \
    --cc=arighi@nvidia.com \
    --cc=brho@google.com \
    --cc=bsegall@google.com \
    --cc=changwoo@igalia.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=haoluo@google.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.com \
    --cc=yphbchou0911@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®