lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Sep 2017 16:22:39 +0200 (CEST)
From:   Anna-Maria Gleixner <anna-maria@...utronix.de>
To:     Peter Zijlstra <peterz@...radead.org>
cc:     LKML <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...hat.com>,
        Christoph Hellwig <hch@....org>, keescook@...omium.org,
        John Stultz <john.stultz@...aro.org>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 17/25] hrtimer: Implementation of softirq hrtimer
 handling

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ