mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anna-Maria Behnsen <anna-maria@linutronix.de>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	John Stultz <jstultz@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Eric Dumazet <edumazet@google.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Arjan van de Ven <arjan@infradead.org>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Rik van Riel <riel@surriel.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sebastian Siewior <bigeasy@linutronix.de>,
	Giovanni Gherdovich <ggherdovich@suse.cz>,
	Lukasz Luba <lukasz.luba@arm.com>,
	"Gautham R . Shenoy" <gautham.shenoy@amd.com>
Subject: Re: [PATCH v7 19/21] timer: Implement the hierarchical pull model
Date: Mon, 12 Jun 2023 17:57:00 +0200 (CEST)	[thread overview]
Message-ID: <12d6e6ef-2b8a-7ed2-e386-60c0f4d76683@linutronix.de> (raw)
In-Reply-To: <ZIc1LX4Dm2HJ70bZ@2a01cb0980221ec3a67fd23915238df5.ipv6.abo.wanadoo.fr>

[-- Attachment #1: Type: text/plain, Size: 3598 bytes --]

On Mon, 12 Jun 2023, Frederic Weisbecker wrote:

> Le Wed, May 24, 2023 at 09:06:27AM +0200, Anna-Maria Behnsen a écrit :
> > +void tmigr_handle_remote(void)
> > +{
> > +	struct tmigr_cpu *tmc = this_cpu_ptr(&tmigr_cpu);
> > +	struct tmigr_remote_data data;
> > +
> > +	if (!is_tmigr_enabled() || !tmc->tmgroup || !tmc->online)
> > +		return;
> > +
> > +	/*
> > +	 * NOTE: This is a doubled check because migrator test will be done
> > +	 * in tmigr_handle_remote_up() anyway. Keep this check to fasten
> > +	 * the return when nothing has to be done.
> > +	 */
> > +	if (!tmigr_check_migrator(tmc->tmgroup, tmc->childmask))
> > +		return;
> > +
> > +	data.now = get_jiffies_update(&data.basej);
> > +	data.childmask = tmc->childmask;
> > +	data.wakeup = KTIME_MAX;
> > +
> > +	__walk_groups(&tmigr_handle_remote_up, &data, tmc);
> > +
> > +	raw_spin_lock_irq(&tmc->lock);
> > +	if (tmc->idle)
> > +		tmc->wakeup = data.wakeup;
> 
> So this assumes there will be a timer re-eavluation right after
> in the idle path but this is not true in the case of nohz_full.
> 
> If the softirq happens at the tail of the timer interrupt, you're
> good because the dynticks is re-evaluated right after. But if the
> softirq happens in ksoftirqd, you'll have no timer re-evaluation.

Ok. This problem is around only for nohz_full and not for nohz idle?

> The crude trick used by nohz_full in order to re-evaluate the dynticks when
> a timer is queued from the timer softirq is to launch a self IPI (from
> trigger_dyntick_cpu()). Here you would need something like that but
> that's not something we wish either.
> 
> In fact we don't want any nohz_full CPU to perform an idle migrator job.
> And the problem here is that whenever a timer interrupt occurs while
> tmc->idle == 1 (and that _might_ happen in nohz_full), it will go up the
> hierarchy as long as there is no active migrator on a given level and
> check for remote expiry. And if something expired it will not only perform
> the remote callbacks handling but also reprogram the next tick to fire in
> the next expiry. That's a potential disturbance on a nohz_full CPU.
> 
> There is always an active CPU in nohz_full so there is always an active
> migrator at least at the top level. Therefore you can spare concurrent
> idle migrators if they are nohz_full.
>

As long as the top level group is not/never idle, the wakeup value will be
KTIME_MAX and so it is no problem for nohz_full cpus - or? The check for
handling remote expiry is still a problem but please read my proposal for
this below.

> My suggestion is to make tmigr_requires_handle_remote() return 0 if
> tick_nohz_full_cpu(smp_processor_id()), so that we don't even bother
> raising the softirq. But if the timer softirq happens nevertheless, due
> to some local timer to process, also make tmigr_handle_remote() to
> return early.

Regarding this problem and also the two things you mentioned in the two
earlier review remarks (timer IRQ which fires too early, IPI when CPU goes
offline), I would propose to use the tmc->wakeup value slightly different
as it is used right now:

 - Whenever a wakeup value is required, because top level group is
   completely idle, the value is set in per CPU tmc struct. It could be
   then reevaluated in idle code in irq exit path.

 - For checking whether remote expiry is required, the wakeup value could
   also be used.

 - For nohz_full CPUs wakeup will be always KTIME_MAX - under the
   assumption that there is alwasy an active CPU in top level group.

What do you think about this? Do I miss something else here?

Thanks,

	Anna-Maria

  reply	other threads:[~2023-06-12 15:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24  7:06 [PATCH v7 00/21] timer: Move from a push remote at enqueue to a pull at expiry model Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 01/21] tick-sched: Warn when next tick seems to be in the past Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 02/21] timer: Do not IPI for deferrable timers Anna-Maria Behnsen
2023-06-05 21:29   ` Frederic Weisbecker
2023-05-24  7:06 ` [PATCH v7 03/21] timer: Add comment to get_next_timer_interrupt() description Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 04/21] timer: Move store of next event into __next_timer_interrupt() Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 05/21] timer: Split next timer interrupt logic Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 06/21] timer: Rework idle logic Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 07/21] timers: Introduce add_timer() variants which modify timer flags Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 08/21] workqueue: Use global variant for add_timer() Anna-Maria Behnsen
2023-06-05 22:25   ` Frederic Weisbecker
2023-05-24  7:06 ` [PATCH v7 09/21] timer: add_timer_on(): Make sure TIMER_PINNED flag is set Anna-Maria Behnsen
2023-06-05 22:26   ` Frederic Weisbecker
2023-05-24  7:06 ` [PATCH v7 10/21] timers: Ease code in run_local_timers() Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 11/21] timers: Create helper function to forward timer base clk Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 12/21] timer: Keep the pinned timers separate from the others Anna-Maria Behnsen
2023-06-06 10:27   ` Frederic Weisbecker
2023-05-24  7:06 ` [PATCH v7 13/21] timer: Retrieve next expiry of pinned/non-pinned timers separately Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 14/21] timer: Split out "get next timer interrupt" functionality Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 15/21] timer: Add get next timer interrupt functionality for remote CPUs Anna-Maria Behnsen
2023-06-07 14:55   ` Frederic Weisbecker
2023-06-12 12:01     ` Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 16/21] timer: Restructure internal locking Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 17/21] timer: Check if timers base is handled already Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 18/21] tick/sched: Split out jiffies update helper function Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 19/21] timer: Implement the hierarchical pull model Anna-Maria Behnsen
2023-06-06 20:10   ` Frederic Weisbecker
2023-06-07 13:54   ` Frederic Weisbecker
2023-06-12 12:29     ` Anna-Maria Behnsen
2023-06-12 14:30       ` Frederic Weisbecker
2023-06-11 21:19   ` Frederic Weisbecker
2023-06-12 15:09   ` Frederic Weisbecker
2023-06-12 15:57     ` Anna-Maria Behnsen [this message]
2023-06-12 21:20       ` Frederic Weisbecker
2023-06-13 10:51   ` Frederic Weisbecker
2023-05-24  7:06 ` [PATCH v7 20/21] timer_migration: Add tracepoints Anna-Maria Behnsen
2023-05-24  7:06 ` [PATCH v7 21/21] timer: Always queue timers on the local CPU Anna-Maria Behnsen

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=12d6e6ef-2b8a-7ed2-e386-60c0f4d76683@linutronix.de \
    --to=anna-maria@linutronix.de \
    --cc=arjan@infradead.org \
    --cc=bigeasy@linutronix.de \
    --cc=edumazet@google.com \
    --cc=frederic@kernel.org \
    --cc=fweisbec@gmail.com \
    --cc=gautham.shenoy@amd.com \
    --cc=ggherdovich@suse.cz \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=riel@surriel.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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®