From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (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 4F7583C9ED9 for ; Fri, 24 Jul 2026 18:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784916769; cv=none; b=p9nHglCcHCJu9P02X5JShVZ9bVLWGzHbeJoqRlaKlSNG0NmRFCln3YHjpekOV9/DjxB6B3/h6E0pZeoEPPmVBJq9PZERVUMH3JV898kgb+uyA+iC/pbq1zWXTvswCezkSBSfhYdTJXT3j2+Q2Z+0g3auvxpXNSIwyxKcuK3aElE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784916769; c=relaxed/simple; bh=hfCyaujzoD2BnYDdd5euZDzhLPjmpwude885TQnSLDk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SLiturD9dxjmv7BAdQdSC3xWEmoWY3OOGaCddo70j7RkO7GwxnRpF3Wd1ANnZaBcDE1Cqm1+p0rX46wyAwK/sbVrYXW9BNgh0PihGNVp0bDdYhMPbR+EVwB+9ytBWN/S0v/eOtzNIpYTCrSXggmTzjGclNDoybibu0JEIfuGhfg= 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=BC+3czXZ; arc=none smtp.client-ip=209.85.214.200 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="BC+3czXZ" Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2cc88e22f92so14971155ad.1 for ; Fri, 24 Jul 2026 11:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784916766; x=1785521566; 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=qBHfJAWhzNVyF+D9jhMXkxmBaLOzY2vh4135EZHyFR4=; b=BC+3czXZbW0xTfB3+FaljnWESLnhpITR9asWlN/TeN4y/TAZo1nbuEFjCKL9R8p12W w1ziHXNRM1PbJdzG4Pk6Tm+Qe2rpGY0ZteOXWR5mF7obQjN0nAXNxQUTeo5+0fgvEOD6 ZVehmezfcS/Ic3K+Hwdnv5eQlHyVyWV3MAD8q+OKidMsWkbAdaQPq6dTMu0TKFo9pNKP TA70lVCfwbl9HG63uSWG1GX5MATpcIzniZdXZt4k3Wqqq0SnWanfJEHmAalcGNiQaebt ZMOqT1aWZUaysIxQFs2y45E/wA2Uz8fUooMEDpWZ3Yffwi5s2T/mbdKJ77h8dyLD+YiF Hfbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784916766; x=1785521566; 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=qBHfJAWhzNVyF+D9jhMXkxmBaLOzY2vh4135EZHyFR4=; b=XBamhde0r1fuBP7z0zI+U2Eccm9BsfLSzd4ZG93D/iFjDmt6r+HuZSoqSgekYiz4Wp Uwa/aEJLJrPfpwbI+lNtHnDX5DsW/wk3MSED/zNTnKwDKCGTZcoyoFG+GhNrGjigkSrK jWnkLeNbGmtO70TFe6YkhTt3CjGU8rGllmetAnjsJ9/ouOCMJajEqwlvV5ziwYUaXLx4 fuwkpxrcsnMM0t+OBJ3dlq08vx+/q7x+RAg8XxMF6e46CHs7iAH4XA7AsenEm7/RFV1m atF4VvkCSUdwhTu5Gwf+iHgulqvzU5VtgGNfGfmPM/WOCqFvCldvsY7sO2QvVCv0zpmW jtOg== X-Gm-Message-State: AOJu0Yx0U5zfBSsDxCyiMWMGXZQyStlHjCDjD8dttA1dZ9etMsBvvGGj Onp5ibOTG7oDHfn/P+Q1kZVR0b9qA9x/2CgrJ2RidM2GHTcptcwuTdj3hsAbGTKj7I/W0oW3B+f xIjtM/yH1wUQykzmQxhARPf6rl9+Oo4XkQrw0MHNxEnuY3TzU6UGp7M9bRjpBHy/eyVFWh0RNGh pZZ90tXQm9LaLd0E+Wef/q1Jc1RHFLtdhfHEXWRRkbi6cd4Jnq X-Received: from plblo15.prod.google.com ([2002:a17:903:434f:b0:2ca:d0f4:2f91]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2385:b0:2ce:ed59:7044 with SMTP id d9443c01a7336-2cfa748ce5fmr93276075ad.30.1784916765351; Fri, 24 Jul 2026 11:12:45 -0700 (PDT) Date: Fri, 24 Jul 2026 18:12:18 +0000 In-Reply-To: <20260724181238.3445275-1-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260724181238.3445275-1-jstultz@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260724181238.3445275-5-jstultz@google.com> Subject: [PATCH v31 4/9] sched/core: Don't proxy-exec unmatched cookie lock owners From: John Stultz To: LKML Cc: Vasily Gorbik , K Prateek Nayak , 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 , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , Andrea Righi , kuyo chang , hupu , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" From: Vasily Gorbik Core scheduling chooses a core-wide cookie before __schedule() installs the next task. With proxy-exec enabled, that task becomes the donor/scheduling context, and find_proxy_task() may then replace the execution context with the runnable mutex owner. If its cookie differs from the selected core cookie, running it would bypass core scheduling's cookie selection. When the final mutex owner found by find_proxy_task() does not match the selected core cookie, stop proxying the donor. If the current execution context is already in the blocked chain, fall back to idle like the existing proxy-exec retry paths do. Otherwise deactivate the donor and let __schedule() pick again. The mutex owner can be picked later under its own cookie. Fixes: 7de9d4f94638 ("sched: Start blocked_on chain processing in find_proxy_task()") Reported-by: K Prateek Nayak Link: https://lore.kernel.org/lkml/10282ce9-f4ae-498f-9b57-f4e1e61fffbc@amd.com/ Signed-off-by: Vasily Gorbik [jstultz: Added tweak to ensure we deactivate donor, not runnable owner] Signed-off-by: John Stultz --- 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: Andrea Righi Cc: kuyo chang Cc: hupu 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 8e661b5f133d7..36e1db67a8374 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7004,6 +7004,14 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf) owner->blocked_donor = p; } WARN_ON_ONCE(owner && !owner->on_rq); + + if (owner && !sched_cpu_cookie_match(rq, owner)) { + if (curr_in_chain) + return proxy_resched_idle(rq); + p = donor; /* Deactivate the donor, not the runnable owner */ + clear_task_blocked_on(p, NULL); + goto deactivate; + } return owner; deactivate: -- 2.55.0.229.g6434b31f56-goog