From: Bill Davidsen <davidsen@tmr.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>,
Robert Hancock <hancockr@shaw.ca>,
linux-kernel <linux-kernel@vger.kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH] "volatile considered harmful" document
Date: Mon, 14 May 2007 10:10:52 -0400 [thread overview]
Message-ID: <46486DEC.1080506@tmr.com> (raw)
In-Reply-To: <20070513235341.GA4270@havoc.gtf.org>
Jeff Garzik wrote:
> On Sun, May 13, 2007 at 07:26:13PM -0400, Bill Davidsen wrote:
>
>> Krzysztof Halasa wrote:
>>
>>> Robert Hancock <hancockr@shaw.ca> writes:
>>>
>>>> You don't need volatile in that case, rmb() can be used.
>>>>
>
>
>>> rmb() invalidates all compiler assumptions, it can be much slower.
>>>
>
> It does not invalidate /all/ assumptions.
>
>
>
>> Yes, why would you use rmb() when a read of a volatile generates optimal
>> code?
>>
>
> Read of a volatile is guaranteed to generate the least optimal code.
> That's what volatile does, guarantee no optimization of that particular
> access.
>
By optimal you seem to mean "generate fewer CPU cycles by risking use of
an obsolete value," while by the same term I mean read the correct and
current value from the memory location without the overhead of locks. If
your logic doesn't require the correct value, why read it at all? And if
it does, how fewer cycles and cache impact can anything have than a
single register load from memory?
Locks are useful when the value will be changed by a thread, or when the
value must not be changed briefly. That's not always the case.
--
bill davidsen <davidsen@tmr.com>
CTO TMR Associates, Inc
Doing interesting things with small computers since 1979
next prev parent reply other threads:[~2007-05-14 14:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fa.UIDGHS72acFv9jKylmdQQwWcXPA@ifi.uio.no>
[not found] ` <fa.fKNBJtZJWOQthlLjc1TDfY6jCLc@ifi.uio.no>
2007-05-12 18:32 ` [PATCH] "volatile considered harmful" document Robert Hancock
2007-05-13 16:30 ` Krzysztof Halasa
2007-05-13 23:26 ` Bill Davidsen
2007-05-13 23:53 ` Jeff Garzik
2007-05-14 14:10 ` Bill Davidsen [this message]
2007-05-14 14:21 ` [2.6.21] circular locking dependency found in QUOTA OFF Folkert van Heusden
2007-05-14 17:43 ` Michal Piotrowski
2007-05-14 17:44 ` Folkert van Heusden
2007-05-15 14:09 ` Jan Kara
2007-05-15 17:52 ` Folkert van Heusden
2007-05-15 18:14 ` Jan Kara
2007-05-15 19:18 ` Jan Kara
2007-05-09 21:05 [PATCH] "volatile considered harmful" document Jonathan Corbet
2007-05-09 21:45 ` Jesper Juhl
2007-05-09 22:31 ` Satyam Sharma
2007-05-09 22:47 ` Jesper Juhl
2007-05-09 23:20 ` Satyam Sharma
2007-05-09 22:05 ` Heikki Orsila
2007-05-09 22:19 ` Randy Dunlap
2007-05-09 22:35 ` Scott Preece
2007-05-10 16:14 ` Giacomo A. Catenazzi
2007-05-10 19:35 ` H. Peter Anvin
2007-05-10 22:00 ` Alan Cox
2007-05-10 21:54 ` Bill Davidsen
2007-05-16 9:30 ` Thomas De Schampheleire
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=46486DEC.1080506@tmr.com \
--to=davidsen@tmr.com \
--cc=corbet@lwn.net \
--cc=hancockr@shaw.ca \
--cc=jeff@garzik.org \
--cc=khc@pm.waw.pl \
--cc=linux-kernel@vger.kernel.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.