Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796183573; b=p9/VGpGcVA9AbMItOv4+FEpllNqRKGrNBScBnWP1D7HmhDJG6dyQOYTW+toYqO/qjkfb SmffmWsa1jc1hfPTpLws6CvJpuXFrIJaPQopNWIt8fJrN+gTzU6sHXiXCe0jEsfafu3m6 ZH62QfAU2museNvicDEB35ZQN/C0Yc+IbM4o9cglkwgzEgjfY8CuRxGCAJqEApSub6nhF 9pOUH8P+8m8b2P1Tr1D2RkYpCSSnMaNUQFJJ6J9+VElGL1t4/Eisy20iJClXFKm7tQ/K4 rgsDRmy1fTq8QAb7BI0QmYUfPH+TbE6lcjQcUMKJJKtvU57QgkUH+ZM9TwTrRCsugnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183573; 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=SwDprKDn6dUYh2E8qi347X+gUv+zdjAfOnjr34wETIk=; b=a61ptzhVy/U5VOQNeHzwLDD7r+TfiND/V6JnfDEGJ1u4IldjhwTMMgi+jH2BmiYkxGIr B/cmXE69eNwuRTHY+tOdCPy97LyegSf8/Kl/B6GgpM9LFR4OA2ygUUMuBbIAa976yst1+ Nx32t0yn4bLpqSIIZM8FvrnEql8xwIEo/o2g7uHJsO21yrr4kCA+VpshkqeeH+uUhrmF5 YLvlQ2tI3e7PB2AUVrPmDAYrtsWRF/dcpt4eTFhu7YNicyed6LEA1b+BKKTCJ1JndHzxF SKaETkQMkaKcdJKbg4gbUHirxZAeC0EPTv07mj92N6SpEpaBdA50H1Bm3XqrHhw+nXQ== 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=BDfFeqt8; arc=none smtp.remote-ip=209.85.214.198 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (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 B1CB5606A333 for ; Wed, 2 Dec 2026 03:52:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B1CB5606A333 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=BDfFeqt8 Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2f053f9631cso162467245ad.1 for ; Tue, 01 Dec 2026 19:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796183572; x=1796788372; 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=SwDprKDn6dUYh2E8qi347X+gUv+zdjAfOnjr34wETIk=; b=BDfFeqt8jgv/YNEcYgWrc+Xlurnhm861YxXrYCOgv+R+ZW73XSjwYaGK3MQksmy1nb Hy8AkRYkGHg3YL5iYICqMrX36cn1am2inf79kVwKMfcT/GMpaUTUKRy0gwv6Wn3N0PQm DNwdNhOrNFxl33iPDVPbPhj5MeCme2t9BtfiGMeD6TvF9pyHlLpSlvW9PhsBR8R/Kqjp 5WmbFwJbweyhqdr4lAo20dAQ5/otyRpw96ZVtgKHtAQe081WZ3pWt5rzML42XoBh7LSe 6tWlo6UjKm7hGaPVEquyLAESjIOBwy1zDWOzW6AcnIhS4fuieWCn2EzjAZtMbwNiZaD7 Z3og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796183572; x=1796788372; 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=SwDprKDn6dUYh2E8qi347X+gUv+zdjAfOnjr34wETIk=; b=mH6HMsDC2j0ABetRKBeMqMdlN3caLOfOeO7WNywXfb5BMo4fwZHzQRJbyGnU0kZShZ EkWl6e7sBZAkGgtViuOU+u6gIQkCMJQjfTJ5k2AFUThYBCTqVQwBlvpHsGH+XBNUjwx/ vH1jOsfnAomSGAjkNt4tvYOacvQDfmOaHdlyXwGg7Ac785FjjwC3nV0B4IsC3qNa89Hz 2U+nayceX8KksS2Nk86wZuyUMLWCdACb73Uve65kqEwC/7UvFYcIybO4XoAFF8A8S18d K7N9uNCjx/F8OagsJ2n3VoHOEzkO8aucHeyW6wKBOcHdngEM+2qUTOhjO2GL8FKctwrU rTGg== X-Gm-Message-State: APuU4Z+PmVNw+5nYdFJ70RsZss8liSMgyoPCsF6Y+tNMKaB7G4FGp8bd kNww0QcPySfEXuCrCyfGWkfEqtNANZtjAuH6gOYiiuWUXngse3o9w5OOiwXBb/1frHOtrcWKxUl kYd/sa1OjhkVzWtuuI+98RINRo9FPmd2edhjwYLTEZblfJYHC9eyJmsMjktJ7w73NZWjkhfNipK d7lO+2AcIwWpjeJTz2C8r6sT9QG/cWvD1h5qaZtStG1ILZNGtq X-Received: from plic4.prod.google.com ([2002:a17:903:3704:b0:2f1:7172:ee5c]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ea01:b0:2e5:98d7:8202 with SMTP id d9443c01a7336-2f03f1cf4f1mr416889805ad.13.1796183571527; Tue, 01 Dec 2026 19:52:51 -0800 (PST) Date: Wed, 2 Dec 2026 03:52:30 +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-3-jstultz@google.com> Subject: [PATCH v34 02/14] sched/core: Use the scheduling context for remote ticks From: John Stultz To: LKML Cc: "Shubhang Kaushik (Ampere)" , Kayra Cizmeci , 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 , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" From: "Shubhang Kaushik (Ampere)" sched_tick_remote() assumes that a CPU in full dynticks mode has only one running task. It therefore assumes that proxy execution cannot be active and that rq->curr == rq->donor. However, sched_can_stop_tick() can stop the tick with multiple tasks on the runqueue. With exactly one SCHED_RR task, the tick is not needed for round-robin timeslice rotation. When there are no SCHED_RR tasks, SCHED_FIFO tasks do not require the tick because they have no forced tick preemption. Lower scheduling-class tasks can still be queued in both cases. Consequently, a SCHED_FIFO task blocked on a SCHED_NORMAL mutex owner can remain rq->donor while find_proxy_task() selects the owner to execute as rq->curr. sched_tick_remote() can therefore run with rq->curr != rq->donor. The full-nohz state check in sched_tick_remote() is intentionally racy and can allow an extra or missed remote tick. This issue does not rely on that race: the tick can be legitimately stopped in the cases above. Use rq->donor for the remote class tick and its full-nohz tick-interval sanity check, matching sched_tick() and hrtick(). Fixes: 7de9d4f94638 ("sched: Start blocked_on chain processing in find_proxy_task()") Reviewed-by: Kayra Cizmeci Signed-off-by: Shubhang Kaushik (Ampere) 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 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8f5e15af3c4e1..181d0e70c88d4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5966,26 +5966,20 @@ static void sched_tick_remote(struct work_struct *work) */ if (tick_nohz_tick_stopped_cpu(cpu)) { guard(rq_lock_irq)(rq); - struct task_struct *curr = rq->curr; + struct task_struct *donor = rq->donor; if (cpu_online(cpu)) { - /* - * Since this is a remote tick for full dynticks mode, - * we are always sure that there is no proxy (only a - * single task is running). - */ - WARN_ON_ONCE(rq->curr != rq->donor); update_rq_clock(rq); - if (!is_idle_task(curr)) { + if (!is_idle_task(donor)) { /* * Make sure the next tick runs within a * reasonable amount of time. */ - u64 delta = rq_clock_task(rq) - curr->se.exec_start; + u64 delta = rq_clock_task(rq) - donor->se.exec_start; WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 30); } - curr->sched_class->task_tick(rq, curr, 0); + donor->sched_class->task_tick(rq, donor, 0); calc_load_nohz_remote(rq); } -- 2.56.1.911.g883d8bcb20-goog