lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 16 Sep 2013 11:47:27 +0300
From:	"Michael S. Tsirkin" <mst@...hat.com>
To:	Stephen Rothwell <sfr@...b.auug.org.au>
Cc:	Rusty Russell <rusty@...tcorp.com.au>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: Why does test_bit() take a volatile addr?

On Mon, Sep 16, 2013 at 06:02:31PM +1000, Stephen Rothwell wrote:
> Hi Michael,
> 
> On Mon, 16 Sep 2013 10:26:03 +0300 "Michael S. Tsirkin" <mst@...hat.com> wrote:
> >
> > On Mon, Sep 16, 2013 at 04:53:44PM +1000, Stephen Rothwell wrote:
> > > 
> > > On Mon, 16 Sep 2013 13:38:35 +0930 Rusty Russell <rusty@...tcorp.com.au> wrote:
> > > >
> > > > Predates git, does anyone remember the rationale?
> > > > 
> > > > ie:
> > > >         int test_bit(int nr, const volatile unsigned long *addr)
> > > 
> > > Because we sometimes pass volatile pointers to it and gcc will complain
> > > if you pass a volatile to a non volatile  (I think).
> > 
> > Where are these? I did git grep -W test_bit and looked for volatile,
> > couldn't find anything.
> 
> OK, so it was a bit of a guess.  Have you really checked the type of
> every address passed to every call of test_bit()?

Yea, I have this magic tool called gcc :)

Change
-static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)
+static __always_inline int constant_test_bit(long nr, const unsigned long *addr)

and watch for new warnings.

I didn't see any.

> Second guess:  we wanted to make the test_bit access volatile (as opposed
> to the datatypes of the objects being tested) so that things like
> 
> 	while (testbit(bit, addr)) {
> 		do_very_little();
> 	}
> 
> don't get over optimised (since we are operating in a very threaded
> environment that the compiler not might expect).
> 
> -- 
> Cheers,
> Stephen Rothwell                    sfr@...b.auug.org.au


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ