Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1740785 > unrolled thread

Re: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer handling

Started byAnna-Maria Gleixner <anna-maria@linutronix.de>
First post2017-09-27 16:30 +0200
Last post2017-09-27 18:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer  handling Anna-Maria Gleixner <anna-maria@linutronix.de> - 2017-09-27 16:30 +0200
    Re: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer handling Peter Zijlstra <peterz@infradead.org> - 2017-09-27 18:50 +0200

#1740785 — Re: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer handling

FromAnna-Maria Gleixner <anna-maria@linutronix.de>
Date2017-09-27 16:30 +0200
SubjectRe: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer handling
Message-ID<uulvA-4kL-21@gated-at.bofh.it>
On Tue, 26 Sep 2017, Peter Zijlstra wrote:

> On Thu, Aug 31, 2017 at 12:23:42PM -0000, Anna-Maria Gleixner wrote:
> >  static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
> >  			  struct hrtimer_clock_base *base,
> > -			  struct hrtimer *timer, ktime_t *now)
> > +			  struct hrtimer *timer, ktime_t *now,
> > +			  bool hardirq)
> >  {
> >  	enum hrtimer_restart (*fn)(struct hrtimer *);
> >  	int restart;
> > @@ -1241,11 +1298,19 @@ static void __run_hrtimer(struct hrtimer
> >  	 * protected against migration to a different CPU even if the lock
> >  	 * is dropped.
> >  	 */
> > -	raw_spin_unlock(&cpu_base->lock);
> > +	if (hardirq)
> > +		raw_spin_unlock(&cpu_base->lock);
> > +	else
> > +		raw_spin_unlock_irq(&cpu_base->lock);
> > +
> >  	trace_hrtimer_expire_entry(timer, now);
> >  	restart = fn(timer);
> >  	trace_hrtimer_expire_exit(timer);
> > -	raw_spin_lock(&cpu_base->lock);
> > +
> > +	if (hardirq)
> > +		raw_spin_lock(&cpu_base->lock);
> > +	else
> > +		raw_spin_lock_irq(&cpu_base->lock);
> >  
> 
> That's just nasty...
> 

I know and Thomas was unhappy about that as well, but we did not come
up with a better solution.

The nasty alternative is:

static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
			  struct hrtimer_clock_base *base,
-			  struct hrtimer *timer, ktime_t *now)
+			  struct hrtimer *timer, ktime_t *now,
+                   	  unsigned long flags)
...
-	raw_spin_unlock(&cpu_base->lock);
+	raw_spin_unlock_irqrestore(&cpu_base->lock, flags);

...
-	raw_spin_lock(&cpu_base->lock);
+	raw_spin_lock_irq(&cpu_base->lock, flags);

and hand in flags from the callsites via local_save_flags().

We wanted to avoid the pointless lock_irq for the interrupt context,
but yes the conditional is equally bad.


Anna-Maria

[toc] | [next] | [standalone]


#1740886 — Re: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer handling

FromPeter Zijlstra <peterz@infradead.org>
Date2017-09-27 18:50 +0200
SubjectRe: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer handling
Message-ID<uunH5-5Cm-19@gated-at.bofh.it>
In reply to#1740785
On Wed, Sep 27, 2017 at 04:22:39PM +0200, Anna-Maria Gleixner wrote:
> I know and Thomas was unhappy about that as well, but we did not come
> up with a better solution.
> 
> The nasty alternative is:
> 
> static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
> 			  struct hrtimer_clock_base *base,
> -			  struct hrtimer *timer, ktime_t *now)
> +			  struct hrtimer *timer, ktime_t *now,
> +                   	  unsigned long flags)
> ...
> -	raw_spin_unlock(&cpu_base->lock);
> +	raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
> 
> ...
> -	raw_spin_lock(&cpu_base->lock);
> +	raw_spin_lock_irq(&cpu_base->lock, flags);
> 
> and hand in flags from the callsites via local_save_flags().

Just push it up one more level and use raw_spin_lock_irqsave() in the
(soft)irq handlers and then pass the flags around.

Thta's what I did in that patch I just send.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web