From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 9657135E936 for ; Wed, 22 Apr 2026 23:07:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776899228; cv=none; b=dLTd7CuZrsKc5RS5VT2Qx3phI14yz0w2UVJQnEIl8jrbytvt/dz7AHFCW2MrK3ZgkUgDjvsKpgbYaB1zdhQOLCfCtZid2KI6Nhz3DTFVvGItHBOA3AoHUP2rrYSmFBbayhA/QU1P3MejHvZazDzixzCJz4YV0BRuo8nNqDNDcJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776899228; c=relaxed/simple; bh=eBm5xliCqccw6y7f4uOzeYOd0iO4+te4weiw1L/EuBo=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=gXyA6cy/KKKO8pF+ji4CyF3LWvkFz8RBZwwRHSJ42jzBXg4ohrXbqae26g0uRpfUOsoY1YTMZx5IEKGRi/7OmnrsCIfnBML+bUSm7g8/DUlsziTR+RNZmQzPL+ntivzGTBe6WpxvrwYuMn+WY9g7GWXxODhYo8WheC11aRxcg+c= 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=LDwA6wzd; arc=none smtp.client-ip=209.85.214.201 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="LDwA6wzd" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b45cd0bb96so60236885ad.3 for ; Wed, 22 Apr 2026 16:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776899226; x=1777504026; 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=+i0YTXa+BOETYFXg6NZYNla8I4RC4LKnaTFTPLRRc6w=; b=LDwA6wzdwDevzhwRj3VHkqdg5dfLDfvMKJHIASdCzNhb/lgKiIbsaKy23fGkL4TPZ7 if0+rYIVrjMPGTZnkgZQWyjtTcxwbtykl0dbaVjycaQ+HVXjieVOswGgtNemUnjTsq4k n2y0vMAjcnZHcxMNtLXKw+tNEXwTzCfnZz7arPH7UvpjNAwzFZ9OPVumWGsZ3nQ5RtVP oi2cEvPssF0UMC/8FFBb1QAWvduE4ecg8KyQ7CiPQFmQ/PE49AZ8XNexN1ck4bTqnCJB RPw43xlRrX9YfN+czMoj2G3vpXaEDhlZKkIJLc0G4mmG/D2/ZvJ2hOcIaIm8vVVC9g6C 1sJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776899226; x=1777504026; 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=+i0YTXa+BOETYFXg6NZYNla8I4RC4LKnaTFTPLRRc6w=; b=iDX1MBt+g3okE5cWMqgx/bpnoBWwWfRJU+l8eTvKq70CRNxyl8i56pdP6MHMvwQ6jI 19Eu3kidyVwYhm6EZVjX0MLCtmtIeYkHLrZrrpVl/6W3vM/ePCgCAwQU2FRIfVxjj0Ix G0L3XdHDSYDi81vjgkW0yN4kBM15SNA4nkBMaJlqQTRT0hzXsY98VG8NKyr0TU5oU21H qjSfU7MRZZw7jw4vHRkhuQPvx41W4XWlf+JEVnaSiUlxjwI9xwnIthn+Oubw7Kj51QaC Kh/f9z9UdKLmjqrSGfGFvoFafWHUYH64GXdtNiGTwlS6wmBPJMqpf8wPPniksdFwnmU0 7uig== X-Gm-Message-State: AOJu0YzhFj8acC0epFWfjseb+OqEFYlpHvMIH2EjWAY+HDKOCPVNaIUM N7qHiUYpuXbbmV60RpwFWg5Kp7NsvKjzuton8arSwh1bLuasTnwdTFwN55fCyCDz+E0xBtQzSq3 ZZQ5M72Ym9Ob9a2E3Q9nzZx5BIM2EBZCE+WjeggThGUjJWvPoURa6lIhobbW3UcYB5nliL61dcc z/qjeGuteSyZgGjkUFe3IdrfPX+A4wQv928nAHjtdSm36gJFP9 X-Received: from plsb5.prod.google.com ([2002:a17:902:b605:b0:2b0:bf00:28c0]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:120d:b0:2ae:8253:1452 with SMTP id d9443c01a7336-2b5f9e8195fmr262398755ad.11.1776899225558; Wed, 22 Apr 2026 16:07:05 -0700 (PDT) Date: Wed, 22 Apr 2026 23:06:41 +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.54.0.rc2.533.g4f5dca5207-goog Message-ID: <20260422230659.903191-1-jstultz@google.com> Subject: [PATCH v28 0/8] 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 , 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, 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 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(). =20 While there=E2=80=99s not a whole lot new in this revision, I still want to give a big thanks to K Prateek for his feedback and suggestions on the new changes. New in this iteration: * Dropped the patch adding a rq->donor->sched_class->yield_task check, as with changes from K Prateek we shouldn=E2=80=99t temporarily run with idle as donor anymore. * Folded in change suggested by K Prateek to introduce proxy_reset_donor() to reset the donor to current task when the donor is woken up. * Drop an unnecessary PROXY_WAKING assignment which was noted by K Prateek 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: https://github.com/johnstultz-work/linux-dev/tree/proxy-exec-v28-7.1-rc0 https://github.com/johnstultz-work/linux-dev.git proxy-exec-v28-7.1-rc0 New changes to the full patch series in this revision include: * I found in the sleeping owner handling patch, we end up calling put_task() from __proxy_remove_from_sleeping_owner(), which might free the owner while we are still holing the owners->blocked_lock. So be sure to get_task()/put_task() around the owner usage to ensure we don't prematurely free the task. * Similarly I also re-orderd the put_task/unlock lines in activate_blocked_waiters(), to avoid the same problem Issues still to address with the full series: * Continue stress testing with the recent ttwu rework to ensure the whole stack is working as intended (so far so good). * Testing to double check I sorted the rwsem collisions w/ 7.1-rc properly * 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: 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 (7): sched: Rework pick_next_task() and prev_balance() to avoid stale prev references 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() 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 | 43 +++++- kernel/sched/core.c | 307 +++++++++++++++++++++------------------ 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 +- 11 files changed, 280 insertions(+), 186 deletions(-) --=20 2.54.0.rc2.533.g4f5dca5207-goog