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

Eric Dumazet
2011-10-30T17:59:53Z

Le dimanche 30 octobre 2011 à 10:48 -0700, Linus Torvalds a écrit :
> On Sun, Oct 30, 2011 at 10:41 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> >
> > Changing atomic_read(const atomic_t *v) prototype to
> > atomic_read(atomic_t *v) is not an option.
>
> Why not?
>
> #define atomic_read(v) ACCESS_AT_MOST_ONCE((v)->counter)
>
> seems to be the cleanest thing.
>

As I said, because v can be a const pointer provided by the caller.

Try it yourself and you'll discover hundred of call sites doing

.... some_function(const struct *xxx, ...)
{
if (atomic_read(&xxx->refcnt) <= 0)
do_something();
else
do_otherthing();
}

> And if you don't think this is "an option", I really can't see why you
> care about the extra instructions in the code stream either.
>

Not an option if we have to change all callers that expected to be able
to use a const atomic_t pointer.

OK, I now have to leave the net.