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:	Tue, 5 Apr 2011 16:48:36 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	john stultz <johnstul@...ibm.com>
Cc:	Eric Dumazet <eric.dumazet@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Avi Kivity <avi@...hat.com>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	Richard Cochran <richard.cochran@...cron.at>, ben@...u.net
Subject: Re: [PATCH] posix-timers: RCU conversion

On 04/04, john stultz wrote:
>
> On Sun, 2011-04-03 at 18:54 +0200, Eric Dumazet wrote:
> > --- a/include/linux/posix-timers.h
> > +++ b/include/linux/posix-timers.h
> > @@ -81,6 +81,7 @@ struct k_itimer {
> >  			unsigned long expires;
> >  		} mmtimer;
> >  	} it;
> > +	struct rcu_head rcu;
> >  };

Can't we move this rcu_head into the union above?

> >  struct k_clock {
> > diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
> > index 4c01249..acb9be9 100644
> > --- a/kernel/posix-timers.c
> > +++ b/kernel/posix-timers.c
> > @@ -491,6 +491,13 @@ static struct k_itimer * alloc_posix_timer(void)
> >  	return tmr;
> >  }
> >
> > +static void k_itimer_rcu_free(struct rcu_head *head)
> > +{
> > +	struct k_itimer *tmr = container_of(head, struct k_itimer, rcu);
> > +
> > +	kmem_cache_free(posix_timers_cache, tmr);
> > +}

Not that I really think it makes sense to change the patch... but we
could even use SLAB_DESTROY_BY_RCU, this is more effective. All we
need is ctor which sets ->it_signal = NULL and initializes ->it_lock
for lock_timer().

> >  static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags)
> >  {
> >  	struct k_itimer *timr;
> > -	/*
> > -	 * Watch out here.  We do a irqsave on the idr_lock and pass the
> > -	 * flags part over to the timer lock.  Must not let interrupts in
> > -	 * while we are moving the lock.
> > -	 */
> > -	spin_lock_irqsave(&idr_lock, *flags);
> > +
> > +	rcu_read_lock();
> >  	timr = idr_find(&posix_timers_id, (int)timer_id);
> >  	if (timr) {
> > -		spin_lock(&timr->it_lock);
> > +		spin_lock_irqsave(&timr->it_lock, *flags);
> >  		if (timr->it_signal == current->signal) {
> > -			spin_unlock(&idr_lock);
> > +			rcu_read_unlock();
> >  			return timr;
> >  		}
> > -		spin_unlock(&timr->it_lock);
> > +		spin_unlock_irqrestore(&timr->it_lock, *flags);
> >  	}
> > -	spin_unlock_irqrestore(&idr_lock, *flags);
> > +	rcu_read_unlock();

I think this is correct.

The question is, why do we use the global database for the timer ids.
All timers live in signal_struct->posix_timers anyway, perhaps we could
use a per-process array instead.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ