mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anna-Maria Behnsen <anna-maria@linutronix.de>
To: "Beckius, Mikael" <mikael.beckius@windriver.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Sv: [PATCH] hrtimer: Interrupt storm on clock_settime
Date: Tue, 23 Feb 2021 16:53:06 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.21.2102231638540.1861@somnus> (raw)
In-Reply-To: <PH0PR11MB4904A4830FED08F91CA97C04928B9@PH0PR11MB4904.namprd11.prod.outlook.com>

Hi Micke,

On Fri, 12 Feb 2021, Beckius, Mikael wrote:

> Thanks for the update and sorry for the late reply. After long-term
> testing of the patch, storm detection improved, it turns out that a
> similar problem can occur if hrtimer_interrupt runs during
> clock_settime. In this case it seems the offset can get updated and later
> read using hrtimer_update_base in hrtimer_interrupt before
> softirq_expires_next gets updated. As soon as softirq_expires_next gets
> updated by hrtimer_force_reprogram the storm ends. To fix this I made the
> below changes.
> 
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -529,8 +529,10 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
>  			if (exclude)
>  				continue;
>  
> -			if (timer->is_soft)
> +			if (timer->is_soft) {
>  				cpu_base->softirq_next_timer = timer;
> +				cpu_base->softirq_expires_next = expires;
> +			}
>  			else
>  				cpu_base->next_timer = timer;
>  		}
> @@ -633,19 +635,6 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
>  	 */
>  	expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL);
>  
> -	if (cpu_base->next_timer && cpu_base->next_timer->is_soft) {
> -		/*
> -		 * When the softirq is activated, hrtimer has to be
> -		 * programmed with the first hard hrtimer because soft
> -		 * timer interrupt could occur too late.
> -		 */
> -		if (cpu_base->softirq_activated)
> -			expires_next = __hrtimer_get_next_event(cpu_base,
> -								HRTIMER_ACTIVE_HARD);
> -		else
> -			cpu_base->softirq_expires_next = expires_next;
> -	}
> -
>  	if (skip_equal && expires_next == cpu_base->expires_next)
>  		return;
>  
> --
> 

The proposed change breaks the reprogramming logic. To keep it working
cpu_base::*expires_next is only updated by hrtimer_reprogram() and
hrtimer_interrupt(). I will send you a patch for testing in reply to this
thread. The patch is compile tested only.

Thanks,

	Anna-Maria


  reply	other threads:[~2021-02-23 15:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28 14:02 Mikael Beckius
2021-02-05 15:45 ` Thomas Gleixner
2021-02-12 13:38   ` Sv: " Beckius, Mikael
2021-02-23 15:53     ` Anna-Maria Behnsen [this message]
2021-02-25 11:18       ` Sv: " Mikael Beckius
2021-03-01  9:13         ` Thomas Gleixner
2021-02-23 16:02     ` [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event() Anna-Maria Behnsen
2021-02-25 11:18       ` Sv: " Mikael Beckius
2021-03-01  9:23       ` [tip: timers/urgent] " tip-bot2 for Anna-Maria Behnsen
2021-03-06 12:00       ` tip-bot2 for Anna-Maria Behnsen
2021-03-08  8:41       ` tip-bot2 for Anna-Maria Behnsen
2021-02-09 15:22 ` [tip: timers/urgent] hrtimer: Update softirq_expires_next correctly in hrtimer_force_reprogram() tip-bot2 for Mikael Beckius

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=alpine.DEB.2.21.2102231638540.1861@somnus \
    --to=anna-maria@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikael.beckius@windriver.com \
    --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®