From: Paul Mackerras <paulus@samba.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Oleg Nesterov <oleg@tv-sign.ru>,
Andrew Morton <akpm@linux-foundation.org>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
Eric Dumazet <dada1@cosmosbay.com>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ulrich Drepper <drepper@redhat.com>,
linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@mandriva.com>
Subject: Re: [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock
Date: Sun, 22 Jul 2007 10:31:16 +1000 [thread overview]
Message-ID: <18082.42324.417377.935153@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <20070721150547.GA23560@elte.hu>
Ingo Molnar writes:
>
> * Oleg Nesterov <oleg@tv-sign.ru> wrote:
>
> > static inline void ccids_read_lock(void)
> > {
> > atomic_inc(&ccids_lockct);
> > spin_unlock_wait(&ccids_lock);
> > }
> >
> > This looks racy, in theory atomic_inc() and spin_unlock_wait() could
> > be re-ordered. However, in this particular case we have an "optimized"
> > smp_mb_after_atomic_inc(), perhaps it is good that the caller can
> > choose the "right" barrier by hand.
>
> _all_ default locking and atomic APIs should be barrier-safe i believe.
> (and that includes atomic_inc() too) Most people dont have barriers on
> their mind when their code. _If_ someone is barrier-conscious then we
> should have barrier-less APIs too for that purpose of squeezing the last
> half cycle out of the code, but it should be a non-default choice. The
> reason: nobody notices an unnecessary barrier, but a missing barrier can
> be nasty.
The approach we have taken on powerpc is that the atomic_*_test and
atomic_*_return functions have a barrier, but the straight atomic_inc
etc. don't.
As for putting barriers in, it's not a half cycle, it's more like 50
to 100 on some processors. Added to that, what I think you are
actually advocating is *two* full barriers - one before the increment
and one after. That seems like an enormous penalty to pay just
because some people want to roll their own lock primitives instead of
using the standard ones.
Why is ccids_read_lock trying to implement a rwlock without using an
rwlock? Could it be converted to an ordinary rwlock? Or an rwsem?
Paul.
prev parent reply other threads:[~2007-07-22 0:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-21 11:57 [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock Oleg Nesterov
2007-07-21 12:31 ` Ingo Molnar
2007-07-21 14:18 ` Oleg Nesterov
2007-07-21 15:02 ` [PATCH] fix theoretical ccids_{read,write}_lock() race Oleg Nesterov
2007-07-21 19:02 ` Andrew Morton
2007-07-21 19:11 ` Oleg Nesterov
2007-07-21 19:21 ` Andrew Morton
2007-07-21 20:06 ` Oleg Nesterov
2007-07-21 15:05 ` [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock Ingo Molnar
2007-07-21 16:39 ` Oleg Nesterov
2007-08-06 7:30 ` Ingo Molnar
2007-07-22 0:31 ` Paul Mackerras [this message]
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=18082.42324.417377.935153@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=acme@mandriva.com \
--cc=akpm@linux-foundation.org \
--cc=dada1@cosmosbay.com \
--cc=drepper@redhat.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=rostedt@goodmis.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox