From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "jimmy bahuleyan" <knight.camelot@gmail.com>
Cc: "Jonathan Corbet" <corbet@lwn.net>,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
"Jesper Juhl" <jesper.juhl@gmail.com>,
"Randy Dunlap" <randy.dunlap@oracle.com>,
"Heikki Orsila" <shdl@zakalwe.fi>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] "volatile considered harmful", take 2
Date: Fri, 11 May 2007 03:14:50 +0530 [thread overview]
Message-ID: <a781481a0705101444o4d04bb99xac7cbb587355e56f@mail.gmail.com> (raw)
In-Reply-To: <464382DE.5020206@gmail.com>
On 5/11/07, jimmy bahuleyan <knight.camelot@gmail.com> wrote:
> Jonathan Corbet wrote:
> [snip..]
> > +
> > + - The jiffies variable is special in that it can have a different value
> > + every time it is referenced, but it can be read without any special
> > + locking. So jiffies can be volatile, but the addition of other
> > + variables of this type is strongly frowned upon. Jiffies is considered
> > + to be a "stupid legacy" issue in this regard.
>
> Why is it that you consider jiffies to be a "stupid legacy"?
You could find better explanations in previous threads, but to
summarize my understanding of the matter:
Because it is not humanly possible to audit the entire kernel tree to
find all usages of jiffies and fix them appropriately (i.e. "stupid
legacy reasons"). Hence, we just define jiffies as volatile.
> Isn't it natural to have a externally modified variable which is only /read/ to
> be volatile?
No, even in such a case, it would have been saner to simply define the
jiffies _without_ volatile, and only cast _accesses_ to it with the
volatile type qualifier.
Unfortunately, even this is not possible to do in all existing users
in the kernel (i.e. "stupid legacy reasons").
> (or is jiffies supposed to be replaced with something smarter/better :)
Not _replace_ jiffies. But if it were _really_ possible to do so (i.e.
assuming for a moment that we could change all kernel code in one
magic sweep), then again we wouldn't need to use volatile for jiffies
(or even use a volatile cast, IMO).
Just ensure all accesses to jiffies are protected behind an
appropriate barrier() instead, the effects of which are more clearly
defined than the vague and insufficient "volatile", and which
*guarantees* that all memory would be re-read from that point (note
that "volatile" is merely a hint to a C compiler, it comes with no
guarantees at all, which is particularly worrisome these days when
compilers are not the only entities that can re-order code -- hardware
can do so too).
However, yet again, it is _not_ possible to fix the above for all the
existing kernel code that uses jiffies (i.e. "stupid legacy reasons"),
so we just define jiffies as volatile.
My understanding, at least.
next prev parent reply other threads:[~2007-05-10 21:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-10 20:20 Jonathan Corbet
2007-05-10 20:38 ` jimmy bahuleyan
2007-05-10 21:44 ` Satyam Sharma [this message]
2007-05-11 12:21 ` Johannes Stezenbach
2007-05-11 13:52 ` jimmy bahuleyan
2007-05-11 14:21 ` Satyam Sharma
2007-05-10 21:34 ` Jan Engelhardt
2007-05-10 21:45 ` H. Peter Anvin
2007-05-11 21:33 ` Jan Engelhardt
2007-05-11 21:47 ` H. Peter Anvin
[not found] ` <64026d4a0705112157p75d76956g40455c7402b096d6@mail.gmail.com>
2007-05-12 5:32 ` H. Peter Anvin
2007-05-11 7:41 ` Philipp Matthias Hahn
2007-05-11 8:41 ` Bernd Eckenfels
2007-05-11 11:17 ` Stefan Richter
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=a781481a0705101444o4d04bb99xac7cbb587355e56f@mail.gmail.com \
--to=satyam.sharma@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=hpa@zytor.com \
--cc=jesper.juhl@gmail.com \
--cc=knight.camelot@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@oracle.com \
--cc=shdl@zakalwe.fi \
/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
all inboxes | Powered by JetHome®