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

From: Eric Dumazet
Date: Sun Oct 30 2011 - 14:00:01 EST


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@xxxxxxxxx> 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.


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