From: Andrea Arcangeli <andrea@suse.de>
To: Stephen Hemminger <shemminger@osdl.org>,
Andrew Morton <akpm@digeo.com>, Andi Kleen <ak@suse.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: frlock and barrier discussion
Date: Thu, 30 Jan 2003 02:52:19 +0100 [thread overview]
Message-ID: <20030130015219.GT1237@dualathlon.random> (raw)
In-Reply-To: <20030129174133.A19912@twiddle.net>
On Wed, Jan 29, 2003 at 05:41:33PM -0800, Richard Henderson wrote:
> //begin
> t1 = rw->pre_sequence
> t1 += 1
> rw->pre_sequence = t1
> wmb()
>
> //stuff
> xtimensec = xtime.tv_nsec
>
> //end
> wmb()
> t2 = rw->post_sequence
> t2 += 1
> rw->post_sequence = t2
>
> is
>
> t1 = rw->pre_sequence
> t2 = rw->post_sequence
> xtimensec = xtime.tv_nsec
> t1 += 1;
> t2 += 2;
> rw->pre_sequence = t1
> wmb()
> wmb()
> rw->post_sequence = t2
No it's:
t1 = rw->pre_sequence
t2 = rw->post_sequence
t1 += 1;
t2 += 2;
rw->pre_sequence = t1
wmb()
xtimensec = xtime.tv_nsec
wmb()
rw->post_sequence = t2
you're missing xtimensec is a write.
or this if you prefer:
spin_lock() / now xtime can't change under us
t1 = rw->pre_sequence
t2 = rw->post_sequence
t3 = xtime.tv_nsec
t1 += 1;
t2 += 2;
rw->pre_sequence = t1
wmb()
xtimensec = t3
wmb()
rw->post_sequence = t2
spin_unlock() / now xtime can change again
and the above is the optimal implementation of the write-side. We
definitely don't want to forbid those reoderings. if gcc or cpu thinks
it's worthwhile they must be allowed to optimize it since it's legal.
I believe wmb() is correct, and mb() is overkill.
Andrea
next prev parent reply other threads:[~2003-01-30 1:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-28 23:42 [PATCH] (1/4) 2.5.59 fast reader/writer lock for gettimeofday Stephen Hemminger
2003-01-29 7:06 ` Richard Henderson
2003-01-29 7:26 ` Anton Blanchard
2003-01-29 8:41 ` Andrew Morton
2003-01-30 1:15 ` frlock and barrier discussion Stephen Hemminger
2003-01-30 1:29 ` Andrea Arcangeli
2003-01-30 1:41 ` Richard Henderson
2003-01-30 1:52 ` Andrea Arcangeli [this message]
2003-01-31 0:41 ` Richard Henderson
2003-01-31 0:57 ` Andrea Arcangeli
-- strict thread matches above, loose matches on Subject: below --
2003-01-30 18:20 Manfred Spraul
2003-01-30 18:26 ` Andrea Arcangeli
2003-01-30 19:05 ` Manfred Spraul
2003-01-30 19:54 ` Davide Libenzi
2003-01-30 22:32 ` Alan Cox
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=20030130015219.GT1237@dualathlon.random \
--to=andrea@suse.de \
--cc=ak@suse.de \
--cc=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shemminger@osdl.org \
/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.