Re: block: ioc->refcount accessed twice in put_io_context()?

From: Paul Bolle
Date: Mon Apr 11 2011 - 04:45:59 EST


On Mon, 2011-04-11 at 09:42 +0200, Jens Axboe wrote:
> Indeed, there is nothing wrong with having the BUG_ON() there first and
> doing the decrement later.

But what makes sure then that refcount doesn't get decremented by
something else just before the atomic_long_dec_and_test() call. Eg:

Thread 1 Thread 2
======== ========
BUG_ON()
BUG_ON()
atomic_long_dec_and_test()
atomic_long_dec_and_test()
/* refcount drops to -1 here */

Or is this not possible?

> If the BUG_ON() is hit, then it's not a race
> conditon - it's a plain bug in the code.

I haven't hit that BUG_ON(), I'm just wondering why an atomic variable
is accessed twice in the same function.


Paul Bolle

--
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/