All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: john stultz <johnstul@us.ibm.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>, Avi Kivity <avi@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Richard Cochran <richard.cochran@omicron.at>,
	ben@iagu.net
Subject: Re: [PATCH] posix-timers: RCU conversion
Date: Tue, 5 Apr 2011 16:48:36 +0200	[thread overview]
Message-ID: <20110405144836.GA17490@redhat.com> (raw)
In-Reply-To: <1301940501.2319.25.camel@work-vm>

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.


  parent reply	other threads:[~2011-04-05 14:49 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 12:02 KVM lock contention on 48 core AMD machine Ben Nagy
2011-03-18 12:30 ` Joerg Roedel
2011-03-19  4:45   ` Ben Nagy
2011-03-21  9:50     ` Avi Kivity
2011-03-21 11:43       ` Ben Nagy
2011-03-21 13:41         ` Ben Nagy
2011-03-21 13:53           ` Avi Kivity
     [not found]             ` <AANLkTikWQS281kTtJ32-qo5U+w_BAak7qUwVhUQgOxxv@mail.gmail.com>
2011-03-21 15:50               ` Avi Kivity
2011-03-21 16:16                 ` Ben Nagy
2011-03-21 16:33                   ` Avi Kivity
2011-03-21 16:54                   ` Eric Dumazet
2011-03-21 17:02                     ` Avi Kivity
2011-03-21 17:12                       ` Eric Dumazet
2011-03-21 18:12                         ` Ben Nagy
2011-03-21 22:27                           ` [RFC] posix-timers: RCU conversion Eric Dumazet
2011-03-22  7:09                             ` [PATCH] " Eric Dumazet
2011-03-22  8:59                               ` Ben Nagy
2011-03-22 10:35                                 ` Avi Kivity
2011-03-22 10:35                                   ` Avi Kivity
2011-04-04  3:30                                   ` Ben Nagy
2011-04-04  7:18                                     ` Avi Kivity
2011-04-04  7:18                                       ` Avi Kivity
2011-04-05  7:49                                   ` Peter Zijlstra
2011-04-05  8:16                                     ` Avi Kivity
2011-04-05  8:16                                       ` Avi Kivity
2011-04-05  8:48                                   ` Peter Zijlstra
2011-04-05  8:56                                     ` Avi Kivity
2011-04-05  8:56                                       ` Avi Kivity
2011-04-05  9:03                                       ` Peter Zijlstra
2011-04-05  9:08                                         ` Avi Kivity
2011-04-05  9:08                                           ` Avi Kivity
2011-04-05  9:50                                         ` Ben Nagy
2011-04-05  8:56                                     ` Mike Galbraith
2011-04-03 16:54                               ` Eric Dumazet
2011-04-04 18:08                                 ` john stultz
2011-04-04 19:47                                   ` Eric Dumazet
2011-04-05 14:48                                   ` Oleg Nesterov [this message]
2011-04-05 15:18                                     ` [PATCH v2] " Eric Dumazet
2011-04-05 15:43                                       ` Oleg Nesterov
2011-05-16 15:10                                       ` Avi Kivity
2011-05-16 15:30                                         ` Eric Dumazet
2011-04-08 18:28                                 ` [PATCH] " Paul E. McKenney
2011-03-21 18:14                         ` KVM lock contention on 48 core AMD machine Avi Kivity
2011-03-21 18:48                         ` Michael Tokarev
2011-03-21 18:53                           ` Avi Kivity
2011-03-18 12:44 ` Stefan Hajnoczi

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=20110405144836.GA17490@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=ben@iagu.net \
    --cc=eric.dumazet@gmail.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.cochran@omicron.at \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.