linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Victor Hassan <victor@allwinnertech.com>,
	fweisbec@gmail.com, mingo@kernel.org, jindong.yue@nxp.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tick/broadcast: Do not set oneshot_mask except was_periodic was true
Date: Mon, 24 Apr 2023 20:28:27 +0200	[thread overview]
Message-ID: <875y9l16es.ffs@tglx> (raw)
In-Reply-To: <e4d1f832-d95e-02c9-ae7d-2aca48a45fb1@allwinnertech.com>

On Sun, Apr 23 2023 at 22:16, Victor Hassan wrote:
> On 4/16/2023 5:01 AM, Thomas Gleixner wrote:
>> After more analysis of that code it turns out that this is even more
>> broken because of this:
>> 
>> CPU0                       CPU1
>> 
>>                             idle()
>>                               tick_broadcast_enter()
>>                                   test_and_set_cpu(cpu, oneshot_mask);
>>                                   shutdown_cpu_local_device();
>>                                   tick_broadcast_set_event();
>>                               sleep_deep();
>> 
>>                             // All good. Broadcast will wake the CPU up
>> 
>> install_new_broadcast_device(newdev)
>>    tick_broadcast_setup_oneshot(newdev)
>>      if (was_periodic)  <- Path not taken because device is in shutdown state
>
> Are you saying that the "tick_broadcast_enter->broadcast_shutdown_local" 
> path will turn off the cpu1 tick device(as the broadcast)?

No. On CPU1 the idle path does:

    - Mark the CPU in the broadcast oneshot mask
    - Conditionally shut down the CPU local clock event device
    - Set the broadcast event

> I think this only happens when CPU1's tick device is used as the 
> broadcast device. However, the "broadcast_needs_cpu" path prevents this 
> from happening, right?

No. broadcast_shutdown_local() checks first whether

    - the broadcast device is hrtimer based, i.e. a software emulation
    - the broadcast device is armed
    - the CPU handling the hrtimer is the current CPU

If all apply then the CPU local device cannot be shut down.

Then it checks whether:

    - the broadcast device is hrtimer based, i.e. a software emulation
    - the CPU local event is before the broadcast event, as it cannot
      reprogram the remote CPUs clockevent device

If all apply then the CPU local device cannot be shut down.

> Nevertheless, there is still an issue here. At this point, the broadcast 
> will be in oneshot state (was_periodic is still false). The reason why 
> this has not caused any serious problems may be because other CPUs will 
> quickly enter idle to help refresh the broadcast.

The installation of a new broadcast device is a rare event and yes, if
the CPU which installed it or come other CPU goes idle shortly after it
will arm the broadcast event and stuff keeps moving, but that's far from
correct.

Thanks,

        tglx

  reply	other threads:[~2023-04-24 18:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12  0:34 [PATCH v2] tick/broadcast: Do not set oneshot_mask except was_periodic was true Victor Hassan
2023-04-15 21:01 ` Thomas Gleixner
2023-04-17 13:28   ` Frederic Weisbecker
2023-04-17 15:02   ` Frederic Weisbecker
2023-04-18  8:50     ` Thomas Gleixner
2023-04-18  9:09       ` Thomas Gleixner
2023-04-19 13:36   ` Frederic Weisbecker
2023-04-21 21:32     ` Thomas Gleixner
2023-05-02 11:19       ` Frederic Weisbecker
2023-05-02 12:38         ` Thomas Gleixner
2023-05-03 22:27           ` Frederic Weisbecker
2023-05-03 22:53             ` Thomas Gleixner
2023-05-04  7:50               ` Frederic Weisbecker
2023-05-06 16:40                 ` [PATCH v3] tick/broadcast: Make broadcast device replacement work correctly Thomas Gleixner
2023-05-08 21:27                   ` [tip: timers/urgent] " tip-bot2 for Thomas Gleixner
2023-05-06 12:09           ` [PATCH v2] tick/broadcast: Do not set oneshot_mask except was_periodic was true Victor Hassan
2023-04-23 14:16   ` Victor Hassan
2023-04-24 18:28     ` Thomas Gleixner [this message]
2023-04-24 18:31       ` Thomas Gleixner
2023-04-26  2:50         ` Victor Hassan
2023-05-05  1:46           ` Victor Hassan

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=875y9l16es.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=fweisbec@gmail.com \
    --cc=jindong.yue@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=victor@allwinnertech.com \
    /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;
as well as URLs for NNTP newsgroup(s).