linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: Laurent Riffard <laurent.riffard@free.fr>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	axboe@suse.de
Subject: Re: 2.6.17-rc6-mm1/pktcdvd - BUG: possible circular locking
Date: 14 Jul 2006 23:06:51 +0200	[thread overview]
Message-ID: <m3odvrc2vo.fsf@telia.com> (raw)
In-Reply-To: <1152884770.3159.37.camel@laptopd505.fenrus.org>

Arjan van de Ven <arjan@linux.intel.com> writes:

> On Fri, 2006-07-14 at 13:22 +0200, Peter Osterlund wrote:
> > > and what locking prevents this? And via multiple opens?
> > 
> > You are right that my reasoning was incorrect. If someone is doing
> > "pktsetup ; pktsetup -d" quickly in a loop while someone else is
> > trying to open the device, one thread could be at the start of
> > pkt_open() at the same time as another thread is in pkt_new_dev().
> > 
> > However, I added a 5s delay in pkt_open() to enlarge the race window.
> > I still couldn't make the driver lock up though. The explanation is
> > that pkt_new_dev() calls blkdev_get() with the CD device (eg /dev/hdc)
> > as bdev parameter, while do_open() locks the bd_mutex for the pktcdvd
> > device (eg /dev/pktcdvd/0).
> > 
> > Do you still think this could deadlock? If not, how should the code be
> > annotated to make this warning go away?
> 
> unless we KNOW it won't deadlock (eg we have a "this cannot deadlock
> BECAUSE of X, Y and Z") I don't think annotations are the right idea. In
> addition, the "how to annotate" really depends on what X, Y and Z
> are....

In the first call chain, do_open -> pkt_open, the bd_mutex object that
is being locked corresponds to a pktcdvd block device, because those
are the only devices that have their open method set to pkt_open.

In the second call chain, pkt_ctl_ioctl -> pkt_new_dev -> do_open, the
bd_mutex object that is being locked *does not* correspond to a
pktcdvd block device, because pkt_new_dev will bail out with a "Can't
chain pktcdvd devices" error if you call it with "dev" set to a
pktcdvd device.

Therefore, there is no AB-BA deadlock possibility. The locking
dependencies are A -> B and B -> A', where it is known that A, B and
A' are all different.

So the claim from the lockdep code, "BUG: possible circular locking
deadlock detected!", is a false alarm.

-- 
Peter Osterlund - petero2@telia.com
http://web.telia.com/~u89404340

  reply	other threads:[~2006-07-14 21:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-08 19:09 2.6.17-rc6-mm1/pktcdvd - BUG: possible circular locking Laurent Riffard
2006-06-12 15:14 ` Arjan van de Ven
2006-06-12 16:41   ` Jens Axboe
2006-06-21 10:21     ` Arjan van de Ven
2006-06-22 14:50   ` Peter Osterlund
2006-06-22 18:20     ` Arjan van de Ven
2006-07-14 11:22       ` Peter Osterlund
2006-07-14 13:46         ` Arjan van de Ven
2006-07-14 21:06           ` Peter Osterlund [this message]
2006-07-14 22:29             ` Arjan van de Ven
2006-07-15  7:04             ` [patch] lockdep: annotate pktcdvd natural device hierarchy Arjan van de Ven
2006-07-15 10:35               ` Laurent Riffard
2006-07-15 10:57                 ` Peter Osterlund
2006-07-16 10:33                   ` Laurent Riffard
2006-07-25  2:27                     ` Andrew Morton
2006-07-25  5:34                       ` Arjan van de Ven
2006-07-25  6:31                         ` Andrew Morton

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=m3odvrc2vo.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=arjan@linux.intel.com \
    --cc=axboe@suse.de \
    --cc=laurent.riffard@free.fr \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).