mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andrea Righi <arighi@nvidia.com>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	John Stultz <jstultz@google.com>, Ingo Molnar <mingo@redhat.com>,
	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>,
	Christian Loehle <christian.loehle@arm.com>,
	David Dai <david.dai@linux.dev>, Koba Ko <kobak@nvidia.com>,
	Aiqun Yu <aiqun.yu@oss.qualcomm.com>,
	Shuah Khan <shuah@kernel.org>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCHSET v14 sched_ext/for-7.4] sched: Make proxy execution compatible with sched_ext
Date: Thu, 24 Sep 2026 09:59:25 +0200	[thread overview]
Message-ID: <20260924075925.GE4121620@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260924075237.GH2009045@noisy.programming.kicks-ass.net>

On Thu, Sep 24, 2026 at 09:52:38AM +0200, Peter Zijlstra wrote:
> On Tue, Sep 22, 2026 at 06:51:39PM +0200, Andrea Righi wrote:
> 
> > Andrea Righi (16):
> >       sched/core: Drop mutex locks before proxy rescheduling
> >       sched/core: Dequeue waking proxy donors before reset
> >       sched/core: Mark wakeups completed through ttwu_runnable()
> >       sched: Add helper to block retained proxy donors
> >       sched: Add sched_ext hooks for proxy execution
> 
> Right, so these add:
> 
> WF_TTWU_RQ:
> 
>   Used like ENQUEUE_DELAYED; could be fixed by generalizing that to cover all
>   of p->is_blocked.
> 
> scx_allow_proxy_exec():
> 
>   Hook to kill proxy exec for scx
> 
> scx_proxy_reenqueue_retry():
> 
>   Like put_prev_task(), but for current. Ensures current gets put back on a DSQ
>   once its done running.
> 
> scx_proxy_donor_start():
> 
>   Delayed set_next_task(), confirms donor will be used.
> 
> sched_proxy_block_task():
> 
>   Almost like switching_to_scx(), except it needs to change ctx->queued in case
>   of p->is_blocked. Hence a new callback ran before sched_change_begin().

And I wonder, would something like so work?

---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index adcc9264c0c6..3e7691d24930 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -11215,8 +11215,13 @@ void sched_change_end(struct sched_change_ctx *ctx)
 	 */
 	WARN_ON_ONCE(p->sched_class != ctx->class && !(ctx->flags & ENQUEUE_CLASS));
 
-	if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to)
-		p->sched_class->switching_to(rq, p);
+	if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to) {
+		bool block = p->sched_class->switching_to(rq, p);
+		if (block && p->is_blocked) {
+			block_task(rq, p, READ_ONCE(p->__state));
+			ctx->queued = false;
+		}
+	}
 
 	if (ctx->queued)
 		enqueue_task(rq, p, ctx->flags);
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 9c1f10cf3c24..e706fb899834 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -4288,12 +4288,12 @@ static void prio_changed_scx(struct rq *rq, struct task_struct *p, u64 oldprio)
 {
 }
 
-static void switching_to_scx(struct rq *rq, struct task_struct *p)
+static bool switching_to_scx(struct rq *rq, struct task_struct *p)
 {
 	struct scx_sched *sch = scx_task_sched(p);
 
 	if (task_dead_and_done(p))
-		return;
+		return false;
 
 	scx_enable_task(sch, p);
 
@@ -4303,6 +4303,8 @@ static void switching_to_scx(struct rq *rq, struct task_struct *p)
 	 */
 	if (SCX_HAS_OP(sch, set_cpumask))
 		scx_call_op_set_cpumask(sch, rq, p, (struct cpumask *)p->cpus_ptr);
+
+	return !scx_allow_proxy_exec(p);
 }
 
 static void switched_from_scx(struct rq *rq, struct task_struct *p)
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 76f3c84ca684..23217b91db03 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -543,7 +543,7 @@ static void task_tick_idle(struct rq *rq, struct task_struct *curr, int queued)
 	update_curr_idle(rq);
 }
 
-static void switching_to_idle(struct rq *rq, struct task_struct *p)
+static bool switching_to_idle(struct rq *rq, struct task_struct *p)
 {
 	BUG();
 }
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index e06b34984e48..ba4c55d0a601 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2759,7 +2759,7 @@ struct sched_class {
 	 */
 	void (*switching_from)(struct rq *this_rq, struct task_struct *task);
 	void (*switched_from) (struct rq *this_rq, struct task_struct *task);
-	void (*switching_to)  (struct rq *this_rq, struct task_struct *task);
+	bool (*switching_to)  (struct rq *this_rq, struct task_struct *task);
 	void (*switched_to)   (struct rq *this_rq, struct task_struct *task);
 	u64  (*get_prio)     (struct rq *this_rq, struct task_struct *task);
 	void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 1e0109ec36b3..b7541bb7b593 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -78,7 +78,7 @@ static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued)
 {
 }
 
-static void switching_to_stop(struct rq *rq, struct task_struct *p)
+static bool switching_to_stop(struct rq *rq, struct task_struct *p)
 {
 	BUG(); /* its impossible to change to this class */
 }

  reply	other threads:[~2026-09-24  7:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 16:51 Andrea Righi
2026-09-22 16:51 ` [PATCH 01/16] sched/core: Drop mutex locks before proxy rescheduling Andrea Righi
2026-09-22 16:51 ` [PATCH 02/16] sched/core: Dequeue waking proxy donors before reset Andrea Righi
2026-09-22 16:51 ` [PATCH 03/16] sched/core: Mark wakeups completed through ttwu_runnable() Andrea Righi
2026-09-22 16:51 ` [PATCH 04/16] sched: Add helper to block retained proxy donors Andrea Righi
2026-09-22 16:51 ` [PATCH 05/16] sched: Add sched_ext hooks for proxy execution Andrea Righi
2026-09-24  7:51   ` Peter Zijlstra
2026-09-22 16:51 ` [PATCH 06/16] sched_ext: Block proxy donors before taking control Andrea Righi
2026-09-22 16:51 ` [PATCH 07/16] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Andrea Righi
2026-09-22 16:51 ` [PATCH 08/16] sched_ext: Move reject DSQ draining into core Andrea Righi
2026-09-22 16:51 ` [PATCH 09/16] sched_ext: Generalize the reject DSQ reenqueue path Andrea Righi
2026-09-22 16:51 ` [PATCH 10/16] sched_ext: Handle proxy-exec races in remote DSQ transfers Andrea Righi
2026-09-22 16:51 ` [PATCH 11/16] sched_ext: Split curr|donor references properly Andrea Righi
2026-09-22 16:51 ` [PATCH 12/16] sched_ext: Track proxy execution for NOHZ_FULL Andrea Righi
2026-09-22 16:51 ` [PATCH 13/16] sched_ext: Delegate proxy donor admission to BPF schedulers Andrea Righi
2026-09-22 16:51 ` [PATCH 14/16] sched_ext: Add selftest for blocked donor admission Andrea Righi
2026-09-22 16:51 ` [PATCH 15/16] sched_ext: scx_qmap: Add proxy execution support Andrea Righi
2026-09-22 16:51 ` [PATCH 16/16] sched: Allow enabling proxy exec with sched_ext Andrea Righi
2026-09-24  7:52 ` [PATCHSET v14 sched_ext/for-7.4] sched: Make proxy execution compatible " Peter Zijlstra
2026-09-24  7:59   ` Peter Zijlstra [this message]
2026-09-24  8:10     ` K Prateek Nayak
2026-09-24  9:09       ` Peter Zijlstra

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=20260924075925.GE4121620@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=aiqun.yu@oss.qualcomm.com \
    --cc=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=changwoo@igalia.com \
    --cc=christian.loehle@arm.com \
    --cc=david.dai@linux.dev \
    --cc=dietmar.eggemann@arm.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kobak@nvidia.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=shuah@kernel.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.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®