From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 7FC833750CC for ; Tue, 12 May 2026 02:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554607; cv=none; b=ROn92wkUMk67CQgozKWVzIQzP+K/Y78iDV5NjC4ASNrEhmgfODqeQ4PXSfHCiALLF/dSqgx5e2uKgASjM5t+wEMXAE4QS6reV2sZ+3EGMiZ6+k8z2s8brwul97OjKUAmUJ9wp5HOrD4goU3MKbMd/lneYUaGvt94QxdBvcNb7ik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554607; c=relaxed/simple; bh=LewggOKlzmlDgFDGo5s/xlvC/OiG+DsSEaMAA1ir4jE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=QiYrxJBg5HFXEl1MzhMPdj+Nbv32CgeCLexRHCyZeKl26hh+mUew4BZ9vUbQOjdK5Py/Otv1R40kEt32SgNYKavmin+x+UoDjb51gddTNnKcj9nHCUVS+cJH713uMjioQSkzAdZrS9BWfjGaoEUYko4eBoZT4JYiLWN6Wj6Dx+4= 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=rJuomE81; arc=none smtp.client-ip=209.85.216.73 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="rJuomE81" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-365fd467cf6so4377211a91.0 for ; Mon, 11 May 2026 19:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778554605; x=1779159405; 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=2gyDA1ntquJoBSM4DhFGeZpxWEFGfgKyRs0E5LD8itQ=; b=rJuomE81cFu9cCROmGafmWKIG8jcDDfhdBKlqf/eogivDaTF/a48bPtL9ZBKKzUKdZ BoGiBmd/nyEFLIKDXXyxMJafrlC1lUvMvfeusD20CI955vps8EA1SRrw2tY5InflunVB 73VuuQGY+NzLon3nKaZnis7CfGvFPKmWZglKLqgi5V3Ee/MLLnL2PC29OQuRD9ggpuCy OYEB4+yesen4RPUudtRrjVs7t4lBw7MhWv8GAJT27P7EdbjngNLczuTV9Z3R7wKteLfI IM1r7ESM6izZc9Sk4M3VGnyc+B1mpAxs0+MZNecbiKxiAoZ4/7ErdiGqBgluLoRqFan+ XruQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778554605; x=1779159405; 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=2gyDA1ntquJoBSM4DhFGeZpxWEFGfgKyRs0E5LD8itQ=; b=XyKj7nq6zE0/8EDzEeK0tmEGKYD6VGsJZicdO4P+Te0HdXYbNsDTx3xNNPm9C0+0bl 4lF+uEwqzW/vMEr52cq8XA+0yVv8bzXJc+Ljxg/ZfRL29iLE97gyeFS47N5MW4DSwV4w vRqIy9iyNA3LXsGe6XsJLuwaglsNMgSijhyHDUEcyzDBBfhMfc7AZYHo6yhkn49IqPxx OrQnKlX2I1v/ojv5KjZ7Z9f2wzpv54vJJN3NBFN45r8eUBGEce6/2vDVj79TTXe0NmnH fz5wN3KlVDP+tD1MgKqdxTcrwSZVGeiHTv49Zq7G+aF4DoWvAZflbUoG/ODU8GuUJC7k afJQ== X-Gm-Message-State: AOJu0YxeSRivjCW5kiVUdMUwMP4Q3lNxWCzIXWa1UBrsrDAKnWMuLR9r zBv9TyarDrOoCGRn9gA4qtXmmF4SugLm8OyMjrmWk40xTZPpm7Sha9szN/zRB9kzvqyohi2m6sk wbzcmPdPHpUl1jO5kvxmmZr7hbf7fvh/mfXa+C5iRxaPo43h+i2l/yncrB/Xmt8D7+m7Sx7aV9i HkPgk3G3cQeNTekofoYPZ7YYD8XBzZ4YOuhDApVv/2FpUAUvGD X-Received: from pga10.prod.google.com ([2002:a05:6a02:4f8a:b0:c79:89d2:43e2]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:6d94:10b0:3a2:d53f:6915 with SMTP id adf61e73a8af0-3ad9560a288mr747332637.10.1778554603832; Mon, 11 May 2026 19:56:43 -0700 (PDT) Date: Tue, 12 May 2026 02:56:10 +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.563.g4f69b47b94-goog Message-ID: <20260512025635.2840817-1-jstultz@google.com> Subject: [PATCH v29 0/9] 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 to the deadline class scheduler to avoid issues when the donor changes, then the actual patch to do return migration from ttwu() followed by the added is_blocked state to avoid the workqueue stall issue, and some optimization patches so we migrate the entire task chain in proxy_migrate_task(). Apologies for being sort of slow on recent replies, I was hoping to get this out last week, but caught whatever is going around and was out for a bit (but the series did get a few extra days of test runtime, without issue, so that=E2=80=99s good). Big thanks to K Prateek and PeterZ for their feedback and suggestions on the new changes. New in this iteration: * Vineeth Pillai diagnosed and reported subtle workqueue stalls being caused by __schedule(SM_PREEMPT) calls racing with __schedule(SM_NONE) calls made after the task=E2=80=99s blocked_on is set, causing tasks to be deactivated without running task workqueue work. Peter suggested that we use an is_blocked flag to better track when a task should have been blocked (even if we don=E2=80=99t block and keep it on the rq for proxy-exec). This solution requires the ttwu() changes in this series, so it was included in this set. * Use scoped_guard() in proxy_needs_return() to avoid calling block_task() while holding blocked_lock (a Sashiko suggestion) * Minor cleanup in deadline changes 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/commits/proxy-exec-v29-7.1-r= c3/ https://github.com/johnstultz-work/linux-dev.git proxy-exec-v29-7.1-rc3 New changes to the full patch series in this revision include: * Pulled in Vineeth=E2=80=99s waitqueue stall reproducer Issues still to address with the full series: * Really excited to see Andrea=E2=80=99s series taking a stab at better getting sched_ext and Proxy Execution to play nice with each other. I hope to try to integrate his series into my full stack for testing: https://lore.kernel.org/lkml/20260506174639.535232-1-arighi@nvidia.com/ * 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 (8): 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: Add is_blocked task flag 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 | 10 +- init/init_task.c | 1 + kernel/fork.c | 1 + kernel/locking/mutex.c | 43 +++++- kernel/sched/core.c | 322 +++++++++++++++++++++------------------ kernel/sched/deadline.c | 46 ++++-- 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, 300 insertions(+), 190 deletions(-) --=20 2.54.0.563.g4f69b47b94-goog