[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1372287397.22432.146.camel@schen9-DESK>
Date: Wed, 26 Jun 2013 15:56:37 -0700
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Davidlohr Bueso <davidlohr.bueso@...com>
Cc: Ingo Molnar <mingo@...e.hu>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrea Arcangeli <aarcange@...hat.com>,
Alex Shi <alex.shi@...el.com>,
Andi Kleen <andi@...stfloor.org>,
Michel Lespinasse <walken@...gle.com>,
Matthew R Wilcox <matthew.r.wilcox@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Rik van Riel <riel@...hat.com>,
Peter Hurley <peter@...leysoftware.com>,
linux-kernel@...r.kernel.org, linux-mm <linux-mm@...ck.org>
Subject: Re: [PATCH v4 5/5] rwsem: do optimistic spinning for writer lock
acquisition
On Wed, 2013-06-26 at 15:40 -0700, Davidlohr Bueso wrote:
> On Wed, 2013-06-26 at 15:28 -0700, Tim Chen wrote:
> > We want to add optimistic spinning to rwsems because we've noticed that
> > the writer rwsem does not perform as well as mutexes. Tim noticed that
> > for exim (mail server) workloads, when reverting commit 4fc3f1d6 and Davidlohr
> > noticed it when converting the i_mmap_mutex to a rwsem in some aim7
> > workloads. We've noticed that the biggest difference, in a nutshell, is
> > when we fail to acquire a mutex in the fastpath, optimistic spinning
> > comes in to play and we can avoid a large amount of unnecessary sleeping
> > and wait queue overhead.
> >
> > For rwsems on the other hand, upon entering the writer slowpath in
> > rwsem_down_write_failed(), we just acquire the ->wait_lock, add
> > ourselves to the wait_queue and blocking until we get the lock.
> >
> > Reviewed-by: Peter Zijlstra <peterz@...radead.org>
> > Reviewed-by: Peter Hurley <peter@...leysoftware.com>
> > Signed-off-by: Tim Chen <tim.c.chen@...ux.intel.com>
> > Signed-off-by: Davidlohr Bueso <davidlohr.bueso@...com>
> > ---
> > include/linux/rwsem.h | 3 +
> > init/Kconfig | 9 +++
> > kernel/rwsem.c | 29 +++++++++-
> > lib/rwsem.c | 150 +++++++++++++++++++++++++++++++++++++++++++++----
> > 4 files changed, 179 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
> > index 0616ffe..0c5933b 100644
> > --- a/include/linux/rwsem.h
> > +++ b/include/linux/rwsem.h
> > @@ -29,6 +29,9 @@ struct rw_semaphore {
> > #ifdef CONFIG_DEBUG_LOCK_ALLOC
> > struct lockdep_map dep_map;
> > #endif
> > +#ifdef CONFIG_RWSEM_SPIN_ON_WRITE_OWNER
> > + struct task_struct *owner;
> > +#endif
> > };
> >
> > extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
> > diff --git a/init/Kconfig b/init/Kconfig
> > index 9d3a788..1c582d1 100644
> > --- a/init/Kconfig
> > +++ b/init/Kconfig
> > @@ -1595,6 +1595,15 @@ config TRACEPOINTS
> >
> > source "arch/Kconfig"
> >
> > +config RWSEM_SPIN_ON_WRITE_OWNER
> > + bool "Optimistic spin write acquisition for writer owned rw-sem"
> > + default n
> > + depends on SMP
> > + help
> > + Allows a writer to perform optimistic spinning if another writer own
> > + the read write semaphore. This gives a greater chance for writer to
> > + acquire a semaphore before blocking it and putting it to sleep.
> > +
>
> Quoting from kernel/mutex.c:
>
> "The rationale is that if the lock owner is running, it is likely to
> release the lock soon."
>
> It would be good to add that to the Kconfig.
Sounds good.
Tim
--
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