lkml.org 
[lkml]   [2011]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: block: ioc->refcount accessed twice in put_io_context()?
On 2011-04-11 10:45, Paul Bolle wrote:
> 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?

It's not possible, if it was then that would be the bug - someone
releasing a reference to the ioc that they do not hold. And that is what
the BUG_ON() is there to catch, not a race between two threads.

--
Jens Axboe



\
 
 \ /
  Last update: 2011-04-11 10:55    [W:0.028 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site