From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796183574; b=jkV32sOEaMoP1u3/RERcby0Cvo/cNrup1P4y2+l8lE+j1yxqBzfAQGI9DG6SHQZmW/Un 6tnj7M4kv4KJBuP4L6Wv+lpTYl3bosirExYoEaIKqeuhorLm8IkLfB2UFMwaQhblCUBbM 2c59tGYjK0BoLQW3au3l8fQ32b100zsKFMyPk37FkKtqB5V0ILhYEdKSd88QF/8KiD7n8 AzPqXxCp0a2hWZSFmO4FaGe5n7UbxTknTdQB7nzbh0RMN3hUy+inTlkjgTLlNSiOYW1il JJKTE9s3UkV8Pxzkiqxt/hpReo5ehO+YROn9D3jGYjxT9HoBoc87ggEV/SuSS0p5UhQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183574; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=WBO0ov82ojkWb4SWWOdeY6ygPLBOWI+DI2WH6UilQE8=; b=dSy9vNb/dVBuK/xU8x0iyTdJ2dO8cj75Rtok4fmZ1PAvI74NWo05yfQwWv+ydP+X5deU 9rgNIB21UEwEAWydiX8ibA0+u+CdxUGtRRgHbgO671ZOWnGIZTq9OWZIHCC6CQd9NHVN9 f6+UTKC6SJ1b8ksxdOIKEMVcNqXKdBYNav+4t+ZtYa9amoq9vN1b9NCgqg0lHY/rGmpv4 DJhc6sr1EFwEv7HoFKSV1UmfkH/2qA5vyPYG05Eh0oYpD8ovSOGlLzzcUmZHIUz09QOpd dvFCLbNyIsDvNbhjB4tysLXQkk4Osf5kegfVKgeNAQRcvyXccqKXhBWbeCb6nigeeFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="fR/WMonH"; arc=none smtp.remote-ip=209.85.215.200 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1B27606A681 for ; Wed, 2 Dec 2026 03:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B1B27606A681 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.a=rsa-sha256 header.s=20260707 header.b=fR/WMonH Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cdb8c46e240so7519451a12.1 for ; Tue, 01 Dec 2026 19:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796183573; x=1796788373; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WBO0ov82ojkWb4SWWOdeY6ygPLBOWI+DI2WH6UilQE8=; b=fR/WMonHi+9RcV0cEezZZUY+UKYdz5wohuXDuAAdrn5HAr7lIHMv+T0qI8ZUbNiy0S 4fIxuz/w2/FNqhyHpaQwKmefRBlIHpFoh2zamvwZj5xxyF2bOFGR7BaEgImuonYR7cgM AhMa/vxfLO1jSJQkRSm0xdproTNXyGm993sjojznTTM5feig+Ltf8hdsED1KOwOAenD1 hz7CAnOiIKgUFxyM+7oDKMMrrsFqwKL2JOmpEv5YWrGT4rc/249hJc/96cvv4Xwj4oNn JLK3johbbW3qj7XNRsRMMQd9aPv/hWp7WmykaLbsBzVao4QzxFEmxaUJ8C5Rjcqpn/Hp o9ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796183573; x=1796788373; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WBO0ov82ojkWb4SWWOdeY6ygPLBOWI+DI2WH6UilQE8=; b=zMWrBQlH6YgnfrvSmendAMiWYyGkNHucSFhxv1injOZSlsOoG6q3WGg6sf1bID4Ikd 9RDkQidFT7eNDXWbi6jh1Aqde8psG6p/blanQT2eE17M59MRZzXuXfRCPIho0PjymAKm TQP+LyP7eT+1G7Uzu06KzMLPMMDGy9w92p3SGAxjU74qME3vCaDFpa91QC/myW4Z7yiy ro5J736HASOBrLAW1HANbhbM/P8WhukfI8c0nTPHsyqX0DD6AEIFdksMBsM5VJmMbJhw FNtDMR1l7gMU3R7gb20C+trGQGm8rpbgktoO2QpZoxe82CleeL94enhb8wFWPN1NXMXw sDfA== X-Gm-Message-State: APuU4Z/SjC+vS40I7aRMXyXxHwBiaFbaMZZ6nfCC8az+CDMFw/vk4VMt dzZiXW4UsOa/BjaEaD57UiNuGOo5LnsBR66uOKDmE5JfnJlibTNPAj47kkSw0DxSwlR2oxGdMXV ifS/v1vmlMj+iwR5KS49qZIk41MIV80bgnsKTYlrqrdHY386yAXgDTUEycHOims9V26vCW6Tz98 QIZzxacpaj/Yo12lt7zvG8G3yjvcmQL08SCwWf4BQXrGm0NSPL X-Received: from pjyj24.prod.google.com ([2002:a17:90a:e618:b0:3b4:1cd2:f6a]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2ecb:b0:3b3:c45e:c715 with SMTP id 98e67ed59e1d1-3b41c95e7bcmr35780959a91.50.1796183572259; Tue, 01 Dec 2026 19:52:52 -0800 (PST) Date: Wed, 2 Dec 2026 03:52:31 +0000 In-Reply-To: <20261202035248.1210026-1-jstultz@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202035248.1210026-1-jstultz@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202035248.1210026-4-jstultz@google.com> Subject: [PATCH v34 03/14] sched/proxy: Reschedule when a blocked task is woken under a proxy From: John Stultz To: LKML Cc: Mathieu Desnoyers , John Stultz , Peter Zijlstra , Ingo Molnar , K Prateek Nayak , Thomas Gleixner , Juri Lelli , Vincent Guittot , Valentin Schneider , Suleiman Souhlal , Andrea Righi , Johannes Weiner , Metin Kaya , Dietmar Eggemann , Steven Rostedt , Zimuzo Ezeozue , Waiman Long , Boqun Feng , "Paul E. McKenney" , Joel Fernandes , Qais Yousef , Xuewen Yan , kuyo chang , hupu , Zhan Xusheng , "zhidao su (Xiaomi)" , Hui Su , "Shubhang Kaushik (Ampere)" , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" From: Mathieu Desnoyers With proxy execution, a task blocked on a mutex stays on its runqueue. The scheduler can pick it as the donor and run the mutex owner in its place. When the donor is woken, the CPU must stop running the owner on the donor's context. Commit 7918cf369361 ("sched/proxy: Only return migrate when needed") wakes a blocked task in place when it is still on its original CPU. ttwu_runnable() then relies on wakeup_preempt() to preempt the running task. But every class compares the woken task with rq->donor. When the woken task is the donor, it compares the task with itself, and no reschedule is requested. Only sched_ext handles this, with WF_TTWU_RQ. So the old owner keeps the donor's context after the mutex hand-off or after a signal. With a SCHED_FIFO donor nothing bounds this: the owner runs at the donor's priority until it blocks. With a SCHED_DEADLINE donor the owner consumes the donor's runtime. In a test on one CPU, a SCHED_OTHER owner kept spinning in user space after it released the mutex. A SCHED_FIFO waiter then ran 800ms late. A SCHED_DEADLINE waiter ran one period late. The same would happen when a task in the middle of a chain is woken. proxy_needs_return() resets the donor only when the woken task is the donor. Fix this in ttwu_runnable(). When a blocked task is woken on a runqueue that runs a proxy, reschedule. The next pick walks the chain again. A blocked task outside the donor's chain causes a harmless reschedule too. Fixes: 7918cf369361 ("sched/proxy: Only return migrate when needed") Signed-off-by: Mathieu Desnoyers [jstultz: Slightly simplified Mathieu's patch] Signed-off-by: John Stultz --- Cc: Peter Zijlstra Cc: Ingo Molnar Cc: K Prateek Nayak Cc: Thomas Gleixner Cc: Juri Lelli Cc: Vincent Guittot Cc: Valentin Schneider Cc: Suleiman Souhlal Cc: Andrea Righi Cc: Johannes Weiner Cc: Metin Kaya Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Zimuzo Ezeozue Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Joel Fernandes Cc: Qais Yousef Cc: Xuewen Yan Cc: kuyo chang Cc: hupu Cc: Zhan Xusheng Cc: zhidao su (Xiaomi) Cc: Hui Su Cc: Shubhang Kaushik (Ampere) Cc: kernel-team@android.com --- kernel/sched/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 181d0e70c88d4..9ba25925c928a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3981,6 +3981,14 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags) if (p->is_blocked) { if (p->se.sched_delayed) enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED); + /* + * If we're waking a blocked task and we are + * currently proxying, force a resched in case + * the woken task p is in the current donor chain + */ + if (rq->donor != rq->curr) + resched_curr(rq); + if (proxy_needs_return(rq, p)) return 0; } -- 2.56.1.911.g883d8bcb20-goog