From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B05CF2BE630 for ; Sat, 4 Apr 2026 05:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775281003; cv=none; b=c9Rk+B3YOMgOVsoBpS4o+yeD2cJdrweJhV6FBtsq/0MYNFwSbtdFkBw8ySP/AJeWrtWuiy5eD2pcqa8D5VtwnW/k+IL8LB0yAko6AS39HstUQR/0LrSbjFyVF+Qne1+fAcC5bj7+vxYyiM47qzl7Z1qT56QyQTMnnHQP4CdtVVY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775281003; c=relaxed/simple; bh=SJIIhU9Kx6xTIzgJ7CLr7PqEHn4VKt806qhFmD3is9o=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=DXPi0daKbTcDiul9btgnqiha8+Wicr36iJ+Dj7huXtxIiWC+AITWgmDUG+gwqMjdBOb2HZSaRqUJQxJeSB0Csr8kYXX40tlxpjbBYi6rfFKuI7e0NRZMnTLA55mvkuBOLFRf/2x+/yx8De/mec5BeNA92Cdsu+p2yQgD9uamzeo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qmghSfwk; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qmghSfwk" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3568090851aso6653100a91.1 for ; Fri, 03 Apr 2026 22:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775281001; x=1775885801; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=X1idYPxJuJRExE8HlRBz5zahjeYCzGkVnJP3nPLWgzw=; b=qmghSfwkHaijXgBfUbY7HuDs0aNp3ZOzeVRoN62Eh+p3c4tBTNarFSK8ccOFedACOf kUgOy5mUon+Fs8oncdfOsBU2+26R6ryUFsj9rXv/rw7EDM6Bpn/PZ1QJVkYREy/ka9R3 DIBTEbTAq+bxISLtI6bmv+Wtt0Lze/GOFV5TNqG9KyT+FWw1T+lClhWZPLhQlCWuIHdu ODDdQnLuKdCdeAF2wRNihHa2zJvX2Bi/FMG78Tc5XgtMwFxaVAxKml3thYiqL44p3/BV ejE+twFyBlMcAohjFF0j1oxHLFwI7fvUUC72Yr8CBfHGKvwb4BHmVBtFF3eht7o4Rxdy 51hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775281001; x=1775885801; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X1idYPxJuJRExE8HlRBz5zahjeYCzGkVnJP3nPLWgzw=; b=nubsJeM4a4DeH4lVM2xFuPLMzisQtXvJoi+po/4gJqFEyH5gmyWzjlsJrZsZkB8aYo ZUlP7tWh6mZ2HZCcU8Xof2XwYHKTOCpj3ISydCYat+fGJXBjYp1RXi2SEtvqM1QC29jf 8SIcPNxYY7+zEOA62dLVU12MA5cEOHkArNZnRAVCB5vRPH3eJHJAZp0HtL9vsXtF5aAc XOGs3XxFLIi3IeRKLWXO3gHoAaO+/bHh2VuyaHCCSJSAS8jVqBh+3gtM4NPA5qBEOQQ1 LdeiCO3rLe8811NfDaiG7gnhASKJ1U6XtT5RVVa/B/wFGtDYfbW9VghJ2/ND34YzOm5p 6bjw== X-Gm-Message-State: AOJu0YzuDAEnN8PVnFQkOKR0ZUMWbJ7bwal3W/L73sBBzurKAZS+ZngR gkzjCDd9M7n/2/NqzQhocDYcyAsgaEq8yuTj7pn1yKJjBg1IG/kVUiqGgsbyBn/rNvAbO3cliM7 0DUpnP3Y83H27Y38bdEtumHE98xctuAtK2VmmfKeOYD+MEBhKaKlunn73UajipYXKwMPp5DtBOg XmBkHy7ZQIcp2XY7y6+2aifciAf1YXlDz0VfRJnYQKCfnzy0HO X-Received: from pgac12.prod.google.com ([2002:a05:6a02:294c:b0:c76:6b47:41fe]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:3d26:b0:398:f1ed:7fa3 with SMTP id adf61e73a8af0-39f2f16d600mr5180750637.57.1775281000668; Fri, 03 Apr 2026 22:36:40 -0700 (PDT) Date: Sat, 4 Apr 2026 05:36:17 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260404053632.1729280-1-jstultz@google.com> Subject: [PATCH v27 00/10] Optimized Donor Migration for Proxy Execution From: John Stultz To: LKML Cc: John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey All, Since Peter queued my last chunk of the Proxy Execution series (simple donor migration) I wanted to send out the next chunk of the series for discussion: Optimized Donor Migration. This is just the next step for Proxy Execution, allowing proxy-return-migration to occur from the try_to_wake_up() callpath. This however introduces some complexity as it means the rq->donor can change from a try_to_wake_up() call, and thus there are further changes needed to make this safe. As always, I=E2=80=99m trying to submit this larger work in smallish digestible pieces, so in this portion of the series, I=E2=80=99m only submitting for review and consideration these patches which minimize the use of passing =E2=80=9Cprev=E2=80=9D (ie: the rq->donor) down through the class schedulers since this cached value can become invalid across runqueue lock drops. From there there are some fixups to yield and the deadline class scheduler to avoid issues when the donor changes, then the actual patch to do return migration from ttwu() followed by some optimization patches so we migrate the entire task chain in proxy_migrate_task(). I really want to share my appreciation for recent feedback and changes provided by Peter, Steven, and K Prateek!=20 New in this iteration: * Major late rework, getting rid of proxy_force_return() and handling all of the return migrations from try_to_wake_up suggested by Peter along with help from K Prateek. This is a pretty significant change, but it=E2=80=99s survived some initial testing but I still need to run more thorough testing to make sure we haven=E2=80=99t introduced any troubles. * Integrate simplifications to proxy_needs_return() suggested by K Prateek * Rework ttwu_runnable to align with ACQUIRE(__task_rq_lock, guard)(p) usage as suggested by Peter I=E2=80=99d love to get further feedback on any place where these patches are confusing, or could use additional clarifications. Additionally I=E2=80=99d appreciate any testing or comments that folks have with the full Proxy Execution series! You can find the full Proxy Exec series here (based on current tip/sched/core): https://github.com/johnstultz-work/linux-dev/commits/proxy-exec-v27-7.0-r= c6-tip-sched-core/ https://github.com/johnstultz-work/linux-dev.git proxy-exec-v27-7.0-rc6-t= ip-sched-core Issues still to address with the full series: * Continue testing with the recent ttwu rework to ensure the whole stack is working as intended. * Continue working to get sched_ext to be ok with Proxy Execution enabled. * Reevaluate performance regression K Prateek Nayak found with the full series. * The chain migration functionality needs further iterations and better validation to ensure it truly maintains the RT/DL load balancing invariants (despite this being broken in vanilla upstream with RT_PUSH_IPI currently) Future work: * Expand to more locking primitives: Figuring out pi-futexes would be good, using proxy for Binder PI is something else we=E2=80=99re exploring. * Eventually: Work to replace rt_mutexes and get things happy with PREEMPT_RT Credit/Disclaimer: =E2=80=94-------------------- As always, this Proxy Execution series has a long history with lots of developers that deserve credit:=20 First described in a paper[1] by Watkins, Straub, Niehaus, then from patches from Peter Zijlstra, extended with lots of work by Juri Lelli, Valentin Schneider, and Connor O'Brien. (and thank you to Steven Rostedt for providing additional details here!). Thanks also to Joel Fernandes, Dietmar Eggemann, Metin Kaya, K Prateek Nayak and Suleiman Souhlal for their substantial review, suggestion, and patch contributions. So again, many thanks to those above, as all the credit for this series really is due to them - while the mistakes are surely mine. Thanks so much! -john [1] https://static.lwn.net/images/conf/rtlws11/papers/proc/p38.pdf Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Mel Gorman Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Metin Kaya Cc: Xuewen Yan Cc: K Prateek Nayak Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Suleiman Souhlal Cc: kuyo chang Cc: hupu Cc: kernel-team@android.com John Stultz (8): sched: Rework pick_next_task() and prev_balance() to avoid stale prev references sched: Avoid donor->sched_class->yield_task() null traversal sched: deadline: Add some helper variables to cleanup deadline logic sched: deadline: Add dl_rq->curr pointer to address issues with Proxy Exec sched: Rework block_task so it can be directly called sched: Have try_to_wake_up() handle return-migration for PROXY_WAKING case sched: Break out core of attach_tasks() helper into sched.h sched: Migrate whole chain in proxy_migrate_task() K Prateek Nayak (1): sched/core: Reset the donor to current task when donor is woken Peter Zijlstra (1): sched: Add blocked_donor link to task for smarter mutex handoffs include/linux/sched.h | 3 +- init/init_task.c | 1 + kernel/fork.c | 1 + kernel/locking/mutex.c | 44 +++++- kernel/sched/core.c | 315 +++++++++++++++++++++------------------ kernel/sched/deadline.c | 44 ++++-- kernel/sched/fair.c | 25 +--- kernel/sched/idle.c | 2 +- kernel/sched/rt.c | 8 +- kernel/sched/sched.h | 30 +++- kernel/sched/stop_task.c | 2 +- kernel/sched/syscalls.c | 3 +- 12 files changed, 291 insertions(+), 187 deletions(-) --=20 2.53.0.1213.gd9a14994de-goog