[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1380065419.3467.59.camel@schen9-DESK>
Date: Tue, 24 Sep 2013 16:30:19 -0700
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Jason Low <jason.low2@...com>
Cc: Ingo Molnar <mingo@...e.hu>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrea Arcangeli <aarcange@...hat.com>,
Alex Shi <alex.shi@...aro.org>,
Andi Kleen <andi@...stfloor.org>,
Michel Lespinasse <walken@...gle.com>,
Davidlohr Bueso <davidlohr.bueso@...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 v5 1/6] rwsem: check the lock before cpmxchg in
down_write_trylock
On Tue, 2013-09-24 at 16:22 -0700, Jason Low wrote:
> Should we do something similar with __down_read_trylock, such as
> the following?
>
>
> Signed-off-by: Jason Low <jason.low2@...com>
> ---
> include/asm-generic/rwsem.h | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/include/asm-generic/rwsem.h b/include/asm-generic/rwsem.h
> index bb1e2cd..47990dc 100644
> --- a/include/asm-generic/rwsem.h
> +++ b/include/asm-generic/rwsem.h
> @@ -42,6 +42,9 @@ static inline int __down_read_trylock(struct
> rw_semaphore *sem)
> long tmp;
>
> while ((tmp = sem->count) >= 0) {
> + if (sem->count != tmp)
> + continue;
> +
Considering that tmp has just been assigned the value of sem->count, the
added if check failure is unlikely and probably not needed. We should
proceed to cmpxchg below.
> if (tmp == cmpxchg(&sem->count, tmp,
> tmp + RWSEM_ACTIVE_READ_BIAS)) {
> return 1;
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