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 2187737F8B9 for ; Wed, 4 Mar 2026 06:38:23 +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=1772606305; cv=none; b=novuiPJH5DHsbjoKpwyfMkKZ5nSMFSiUfvMequ4pRCJdoJRLbIIKUXdRID4+tTjPKjiGuaA1VmBguHcOvfFLx51/c/W6qaYiUBpArM3v3fUoSiDuu81xVOEvjYvl96l7NDCYdLRVdp0WmsQs46R0FA4akDRYsWA/Q6s2r3FVsm0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772606305; c=relaxed/simple; bh=bYIAEqF2g6O3kDcqG1p8NVNTIe39CWR2+Vj8hllieno=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ZjV6s3fSkMZImFtWF2WgEoW7brMNHRJb6LUVavfpdM299osvGO60LGvUr1Q1E/F5KfY/BOpTzSca4gWnz+CW3Z02X4mJ9uS/JYVUbfcEEIQwdcZZIfER41LdGKgZN3Qabh3xkOSPodUwg+eu0BsviCrCHybrnO2xBTP9pfJSFfo= 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=Jk6tFxLo; 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="Jk6tFxLo" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-354bc535546so5302489a91.3 for ; Tue, 03 Mar 2026 22:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772606303; x=1773211103; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OwCWMctcGgFWSIo3DdBgbZDVBDvknqA8PH6EsyvVc3Q=; b=Jk6tFxLo+G9tFvpryCV4zbQnzYbSpTLkPEALlpahhIWIhQSV5C8uAFmWpGFw9nm2c2 pXTUIQ9M9p7KH8XcmaRLjvgkROramnLzOozymgOt5dSNtrIWARnOuznpUGBrHo/qTNgF +x3dA3F3LrLkw0K2pqE4s3JcKFFDJxtJJv6djUtnAj73nv46lfOTnJIEWxXdd5X7UKiw hZsttded/Dj7EaY1uH0hQAKraIOLHSLh/fJeqK+zHg8Tg9rCJQolcNplX7kIDaJpch6m t5B1V1mAumd2zMTOtc6YvDeAk4VSucBSPt6F81oL7wyGH9gknZQza5bmNsoIlFYkhOxG FQgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772606303; x=1773211103; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OwCWMctcGgFWSIo3DdBgbZDVBDvknqA8PH6EsyvVc3Q=; b=gwQz/AdtLS5wKi0X80QgNDrdNN6MdSPbUBdQiy+U7v2baF4pNenc1QtCa6Ah2+twIg RNOAD4su9XhS0ARZ5QQkVbskpxqoyMk5RgGnSHEQ4BJ9jGoghZv8D8jK2a1Iz220XWK5 ++Cs5rWJjwHdnSuwdlXDU8k95jZBbfGwzSPiqwuRh7YXI7UeNLJLR/P00MYFwzy7U7IZ YJWov++lqGTQQWEGmiXwpIvttZTsPgeUw+K2soLWGb7oo9AhMUoALfp/99DWKudQNj9s K1JmLOFKSRUlFZvzRIWCoZDfBrpIUEuNCnb2rC8igoHqYuFh9F514y3OpK+2uRl8IvP/ E+jg== X-Gm-Message-State: AOJu0YxfvS+kG+Gk73Y7JBiY/ecWHyEnEsuv3+TiAFZvoaWpmHDgN7MB cmkRV2FiAfXY9rSbApEO0QusOqjXIdNqF/YKthjlmg5jkHAqDG0mq+l00N81J8Zo1ZdYP5ksCEw kJUvPfOlUCbLrPkhjGALRZ47SWrnG6LGeEVHUoFnqwVbjfGfayu54qIBz+k1igqIzuMjmrjT393 STfSff5rvJxsIXOOzfL0aNBzTvALIkBu+ZykSa2SCDn+1jcP6g X-Received: from pjyr8.prod.google.com ([2002:a17:90a:e188:b0:34a:bf4e:cb5c]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4c8f:b0:359:9224:6c16 with SMTP id 98e67ed59e1d1-359a69bde9bmr1160218a91.14.1772606303093; Tue, 03 Mar 2026 22:38:23 -0800 (PST) Date: Wed, 4 Mar 2026 06:38:09 +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.473.g4a7958ca14-goog Message-ID: <20260304063817.796180-1-jstultz@google.com> Subject: [RFC][PATCH 1/2] sched: proxy-exec: Fix tasks being left unpushable from proxy_tag_curr() From: John Stultz To: LKML Cc: John Stultz , K Prateek Nayak , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Johannes Weiner , Steven Rostedt , Ben Segall , Mel Gorman , Joel Fernandes , Qais Yousef , Xuewen Yan , Suleiman Souhlal , kuyo chang , hupu , zhidao su , soolaugust@gmail.com, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" With proxy-execution, when we are running a lock owner on behalf of a waiting donor, we call proxy_tag_curr() to ensure that both the selected donor task *and* the owner we will run are taken off the pushable lists. This avoids crashes where the running task gets migrated away because only the donor was removed from the pushable list. However, K Prateek noticed that while we take the task off of the pushable list, we don't actually return it to the pushable list when we are done running it as a proxy on behalf of a donor task. Fix this in __schedule() by calling proxy_tag_curr() again on the previously run task once we have switched the rq->curr value. This will call dequeue/enqueue again which will allow the task to be re-evaluated for being added to the pushable list in the class scheduler. Further optimizations to get rid of the dequeue/enqueue calls for something more focused will follow. NOTE: K Prateek also suggested that we should re-evaluate if balance callbacks should be set when we allow prev to be re-added to the pushable list, as pick_next_task() might have seen no pushable tasks. I think this is a good idea, but I've not yet addressed this. Fixes: be39617e38e0 ("sched: Fix proxy/current (push,pull)ability") Reported-by: K Prateek Nayak Closes: https://lore.kernel.org/lkml/e735cae0-2cc9-4bae-b761-fcb082ed3e94@amd.com/ Signed-off-by: John Stultz --- Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Johannes Weiner Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Joel Fernandes Cc: Qais Yousef Cc: Xuewen Yan Cc: K Prateek Nayak Cc: Suleiman Souhlal Cc: kuyo chang Cc: hupu Cc: zhidao su Cc: soolaugust@gmail.com Cc: kernel-team@android.com --- kernel/sched/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b7f77c165a6e0..55bafb1585eca 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6760,7 +6760,7 @@ static inline void proxy_tag_curr(struct rq *rq, struct task_struct *owner) */ static void __sched notrace __schedule(int sched_mode) { - struct task_struct *prev, *next; + struct task_struct *prev, *next, *prev_donor; /* * On PREEMPT_RT kernel, SM_RTLOCK_WAIT is noted * as a preemption by schedule_debug() and RCU. @@ -6779,7 +6779,7 @@ static void __sched notrace __schedule(int sched_mode) cpu = smp_processor_id(); rq = cpu_rq(cpu); prev = rq->curr; - + prev_donor = rq->donor; schedule_debug(prev, preempt); if (sched_feat(HRTICK) || sched_feat(HRTICK_DL)) @@ -6873,6 +6873,8 @@ static void __sched notrace __schedule(int sched_mode) if (!task_current_donor(rq, next)) proxy_tag_curr(rq, next); + if (!(!preempt && prev_state) && prev != prev_donor) + proxy_tag_curr(rq, prev); /* * The membarrier system call requires each architecture -- 2.53.0.473.g4a7958ca14-goog