Re: [RFC] should VM_BUG_ON(cond) really evaluate cond

Eric Dumazet
2011-10-28T02:53:11Z

Le vendredi 28 octobre 2011 à 02:44 +0100, Ben Hutchings a écrit :

> Whether or not it needs to provide any ordering guarantee, atomic_read()
> must never read more than once, and I think that requires the volatile
> qualification. It might be clearer to use the ACCESS_ONCE macro,
> however.
>

Where this requirement comes from ?

Maybe then introduce atomic_read_once() for users really needing it :)

ACCESS_ONCE will force the read/move instruction I try to avoid :(

By the way, removing volatile on my x86_64 defconfig saves a bit of
space :

# size vmlinux vmlinux.old
text data bss dec hex filename
10907585 2890992 1540096 15338673 ea0cb1 vmlinux
10912342 2891056 1540096 15343494 ea1f86 vmlinux.old

booted and everything seems fine, but obviously lightly tested...

Note : There is still one useless access to page-flags,
'fixing' atomic_read() is not enough.

0,04 : ffffffff815e4675: je ffffffff815e4870 <tcp_sendmsg+0xc80>
0,08 : ffffffff815e467b: mov (%r9),%rax // useless
2,08 : ffffffff815e467e: lock incl 0x1c(%r9)
3,58 : ffffffff815e4683: mov (%r9),%rax
0,04 : ffffffff815e4686: test $0x80,%ah
0,00 : ffffffff815e4689: jne ffffffff815e48ee <tcp_sendmsg+0xcfe>