From: "Michael S. Tsirkin" <mst@redhat.com>
To: Oliver Neukum <oliver@neukum.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
torvalds@linux-foundation.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Why does test_bit() take a volatile addr?
Date: Mon, 16 Sep 2013 11:44:53 +0300 [thread overview]
Message-ID: <20130916084453.GA1222@redhat.com> (raw)
In-Reply-To: <1379320800.15916.15.camel@linux-fkkt.site>
On Mon, Sep 16, 2013 at 10:40:00AM +0200, Oliver Neukum wrote:
> On Mon, 2013-09-16 at 13:38 +0930, Rusty Russell wrote:
> > Predates git, does anyone remember the rationale?
> >
> > ie:
> > int test_bit(int nr, const volatile unsigned long *addr)
> >
> > I noticed because gcc failed to elimiate some code in a patch I was
> > playing with.
> >
> > I'm nervous about subtle bugs involved in ripping it out, even if noone
> > knows why. Should I add __test_bit()?
>
> It seems to me that if you do
>
> b = *ptr & 0xf;
> c = b << 2;
> if (test_bit(1, ptr))
>
> the compiler could optimize away the memory access on ptr without
> the volatile. We'd have to add a lot of mb().
>
> Regards
> Oliver
What is this code supposed to do?
Any specific examples?
--
MST
next prev parent reply other threads:[~2013-09-16 8:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-16 4:08 Why does test_bit() take a volatile addr? Rusty Russell
2013-09-16 6:53 ` Stephen Rothwell
2013-09-16 7:26 ` Michael S. Tsirkin
2013-09-16 8:02 ` Stephen Rothwell
2013-09-16 8:47 ` Michael S. Tsirkin
2013-09-16 8:20 ` Geert Uytterhoeven
2013-09-16 8:37 ` Michael S. Tsirkin
2013-09-16 8:40 ` Oliver Neukum
2013-09-16 8:44 ` Michael S. Tsirkin [this message]
2013-09-16 8:49 ` Oliver Neukum
2013-09-16 11:59 ` Linus Torvalds
2013-09-22 21:37 ` Rob Landley
2013-09-23 1:13 ` Rusty Russell
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=20130916084453.GA1222@redhat.com \
--to=mst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox