All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Paul Bolle <pebolle@tiscali.nl>
Cc: Shaohua Li <shli@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: block: ioc->refcount accessed twice in put_io_context()?
Date: Mon, 11 Apr 2011 10:53:43 +0200	[thread overview]
Message-ID: <4DA2C197.1060402@kernel.dk> (raw)
In-Reply-To: <1302511553.29915.12.camel@t41.thuisdomein>

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


      reply	other threads:[~2011-04-11  8:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10 13:41 block: ioc->refcount accessed twice in put_io_context()? Paul Bolle
2011-04-11  1:54 ` Shaohua Li
2011-04-11  7:42   ` Jens Axboe
2011-04-11  8:45     ` Paul Bolle
2011-04-11  8:53       ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DA2C197.1060402@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pebolle@tiscali.nl \
    --cc=shli@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.