From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C5731B837 for ; Thu, 26 Mar 2026 22:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774565532; cv=none; b=Rna4qZJaI+bysZ6fSemCBvOgjrrA4IDO/GtN9BpwVhH2fOw+N/LPGP/cN4MAhtywynY6e/P2f8upMtwqMvTz8R3pcN1qOYpWzzDlwsSEfNpo2ymmb6Cad5vikeFKfMjT5POh78Grk1tp+oYS1LFSmrIq1smW1Sl0GfooStV6cCk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774565532; c=relaxed/simple; bh=5Aw/Ty7sOlAbPDcmjULXCTLn54JkuH08B/q5/xoVTdg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VbYmtaMh/wNk5mG75ZWvJ2bo2mwMcyi5oCHXVAVZHCIX0sQ6IcS1LL30coDc8mAFzLK0LkbqP+s26kCaOMeoqOjAxKJGatIVH62VMbN64hp6oWRnj+bsc0uadUqW8UeAsFnNoHBu/p0jjvfYRobLUTfWW2Hffec2eDteKp9O/0A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1B1D51B95FA; Thu, 26 Mar 2026 22:52:02 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf04.hostedemail.com (Postfix) with ESMTPA id 3357020023; Thu, 26 Mar 2026 22:51:57 +0000 (UTC) Date: Thu, 26 Mar 2026 18:52:44 -0400 From: Steven Rostedt To: John Stultz Cc: LKML , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , kuyo chang , hupu , kernel-team@android.com Subject: Re: [PATCH v26 10/10] sched: Handle blocked-waiter migration (and return migration) Message-ID: <20260326185244.31635eb2@gandalf.local.home> In-Reply-To: <20260324191337.1841376-11-jstultz@google.com> References: <20260324191337.1841376-1-jstultz@google.com> <20260324191337.1841376-11-jstultz@google.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: msyrxt48p6suziyuo4kyfspqtrozx5bq X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: 3357020023 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX19itbsaPjVenou7zYJgMyc5Dpy8v6tV4AE= X-HE-Tag: 1774565517-406297 X-HE-Meta: U2FsdGVkX1/Zo/Zl8RkT8n0TXWv33IrfDATyC13YMPRFspgrMpUN4LNNx/MAEyofRqdiJ8wZ2ogfjHTwLXcoF+ms0CoSAkgMK8bqw4mva8lh2R5CbhKtrJtpPQnxtA0GDX5xQngikG7sKXytM2YrBCCzAuIfT4VnM3PbrBw/uOYfW/7S+pZ9Dk3YWN7lE9jbyG/FsCH6vTtR3e8tVvJlRcNgY8Aw+kizKFQYayrgF/2cdrMO5QteoQF22pyoxS77A7NOmGOF0uq6JSgbN5/oPgw0a4nVy0pg09CKnvuhZlfft8xEI91niJqMIyadtnr9SsbQaSR6DSNtzwe7+L13/z6K9ZveGbZq On Tue, 24 Mar 2026 19:13:25 +0000 John Stultz wrote: > kernel/sched/core.c | 225 ++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 197 insertions(+), 28 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 4ed24ef590f73..49e4528450083 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3643,6 +3643,23 @@ void update_rq_avg_idle(struct rq *rq) > rq->idle_stamp = 0; > } > > +#ifdef CONFIG_SCHED_PROXY_EXEC > +static inline void proxy_set_task_cpu(struct task_struct *p, int cpu) > +{ > + unsigned int wake_cpu; > + > + /* > + * Since we are enqueuing a blocked task on a cpu it may > + * not be able to run on, preserve wake_cpu when we > + * __set_task_cpu so we can return the task to where it > + * was previously runnable. > + */ > + wake_cpu = p->wake_cpu; > + __set_task_cpu(p, cpu); > + p->wake_cpu = wake_cpu; > +} > +#endif /* CONFIG_SCHED_PROXY_EXEC */ Hmm, this is only used in proxy_migrate_task() which is also within a #ifdef CONFIG_SCHED_PROXY_EXEC block. Why did you put this function here and create yet another #ifdef block with the same conditional? Couldn't you just add it just before where it is used? [..] > +/* > + * If the blocked-on relationship crosses CPUs, migrate @p to the > + * owner's CPU. > + * > + * This is because we must respect the CPU affinity of execution > + * contexts (owner) but we can ignore affinity for scheduling > + * contexts (@p). So we have to move scheduling contexts towards > + * potential execution contexts. > + * > + * Note: The owner can disappear, but simply migrate to @target_cpu > + * and leave that CPU to sort things out. > + */ > +static void proxy_migrate_task(struct rq *rq, struct rq_flags *rf, > + struct task_struct *p, int target_cpu) > + __must_hold(__rq_lockp(rq)) > +{ > + struct rq *target_rq = cpu_rq(target_cpu); > + > + lockdep_assert_rq_held(rq); > + WARN_ON(p == rq->curr); > + /* > + * Since we are migrating a blocked donor, it could be rq->donor, > + * and we want to make sure there aren't any references from this > + * rq to it before we drop the lock. This avoids another cpu > + * jumping in and grabbing the rq lock and referencing rq->donor > + * or cfs_rq->curr, etc after we have migrated it to another cpu, > + * and before we pick_again in __schedule. > + * > + * So call proxy_resched_idle() to drop the rq->donor references > + * before we release the lock. > + */ > + proxy_resched_idle(rq); > + > + deactivate_task(rq, p, DEQUEUE_NOCLOCK); > + proxy_set_task_cpu(p, target_cpu); > + > + proxy_release_rq_lock(rq, rf); > + > + attach_one_task(target_rq, p); > + > + proxy_reacquire_rq_lock(rq, rf); > +} -- Steve