mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valentin Schneider <vschneid@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Subject: [PATCH] sched/fair: Don't let task_tick_cache() IPI dyntick CPUs
Date: Thu, 19 Nov 2026 21:38:25 +0100	[thread overview]
Message-ID: <20261119203825.2732984-1-vschneid@redhat.com> (raw)

While testing some CPU isolation / NOHZ_FULL stuff I stumbled on something
like so:

  kworker/u289:5-241489 [001] d..3.  2963.728734: ipi_send_cpu:         cpu=6 callsite=task_work_add+0x84 callback=0x0
  kworker/u289:5-241489 [001] d..3.  2963.728735: kernel_stack:         <stack trace >
  => trace_event_raw_event_ipi_send_cpu (ffffffffa6d7ba45)
  => kick_process (ffffffffa6d827a2)
  => task_work_add (ffffffffa6d645c4)
  => task_tick_fair (ffffffffa6d9cfbe)
  => sched_tick_remote (ffffffffa6d84c69)
  => process_one_work (ffffffffa6d5d57b)
  => worker_thread (ffffffffa6d5e1af)
  => kthread (ffffffffa6d66e85)
  => ret_from_fork (ffffffffa6cb3f2b)
  => ret_from_fork_asm (ffffffffa6c7741a)

In this case CPU6 is isolated via isolcpus=, and is executing a single pure
userspace task, so should be fully leveraging dynticks.

However, because that task is SCHED_OTHER, housekeeping CPUs periodically
handle a sched_tick_remote() on its behalf, and end up kicking that task
out of userspace to run the task_cache_work().

Let task_tick_cache() recognize when it is invoked via a remote tick, and
bail out rather than disturb dyntick CPUs.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
 kernel/sched/fair.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d4cc0caee6265..42394745a124b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1925,6 +1925,13 @@ static void task_tick_cache(struct rq *rq, struct task_struct *p)
 	    !grp->pcpu_sched)
 		return;
 
+	/*
+	 * We got here from a sched_tick_remote(), meaning @p is making use of
+	 * NOHZ_FULL. Don't disturb it with a task_work() IPI.
+	 */
+	if (cpu_of(rq) != smp_processor_id())
+		return;
+
 	epoch = rq->cpu_epoch;
 	/* avoid moving backwards */
 	if (time_after_eq(grp->epoch, epoch))
-- 
2.56.1


                 reply	other threads:[~2026-11-19 20:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119203825.2732984-1-vschneid@redhat.com \
    --to=vschneid@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®