All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: David Howells <dhowells@redhat.com>, Takashi Iwai <tiwai@suse.de>,
	Ingo Molnar <mingo@elte.hu>,
	Linux filesystem caching discussion list 
	<linux-cachefs@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	Johannes Berg <johannes@sipsolutions.net>
Subject: Re: Incorrect circular locking dependency?
Date: Tue, 4 Aug 2009 17:59:52 +0200	[thread overview]
Message-ID: <20090804155952.GA5211@redhat.com> (raw)
In-Reply-To: <1249397486.7924.243.camel@twins>

On 08/04, Peter Zijlstra wrote:
>
> On Mon, 2009-07-27 at 15:37 +0100, David Howells wrote:
> > Takashi Iwai <tiwai@suse.de> wrote:
> >
> > > =======================================================
> > > [ INFO: possible circular locking dependency detected ]
> > > 2.6.30-test #7
> > > -------------------------------------------------------
> > > swapper/0 is trying to acquire lock:
> > >  (&cwq->lock){-.-...}, at: [<c01519f3>] __queue_work+0x1f/0x4e
> > >
> > > but task is already holding lock:
> > >  (&q->lock){-.-.-.}, at: [<c012cc9c>] __wake_up+0x26/0x5c
> > >
> > > which lock already depends on the new lock.
> >
> > Okay.  I think I understand this:
> >
> >  (1) cachefiles_read_waiter() intercepts wake up events, and, as such, is run
> >      inside the waitqueue spinlock for the page bit waitqueue.
> >
> >  (2) cachefiles_read_waiter() calls fscache_enqueue_retrieval() which calls
> >      fscache_enqueue_operation() which calls schedule_work() for fast
> >      operations, thus taking a per-CPU workqueue spinlock.
> >
> >  (3) queue_work(), which is called by many things, calls __queue_work(), which
> >      takes the per-CPU workqueue spinlock.
> >
> >  (4) __queue_work() then calls insert_work(), which calls wake_up(), which
> >      takes the waitqueue spinlock for the per-CPU workqueue waitqueue.
> >
> > Even though the two waitqueues are separate, I think lockdep sees them as
> > having the same lock.
>
> Yeah, it looks like cwq->lock is always in the same lock class.
>
> Creating a new class for your second workqueue might help, we'd have to
> pass a second key through __create_workqueue_key() and pass that into
> init_cpu_workqueue() and apply it to cwq->lock using lockdep_set_class()
> and co.

Agreed.


But otoh, it would be nice to kill cwq->more_work and speedup workqueues
a bit. We don't actually need wait_queue_head_t, we have a single thread
cwq->thread which should be woken.  However this change is not completely
trivial, we need cwq->please_wakeup_me to avoid unnecessary wakeups inside
run_workqueue(). Not sure this worth the trouble.

Oleg.


  parent reply	other threads:[~2009-08-04 16:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-22  2:37 CacheFiles: Readpage failed on backing file Christian Kujau
2009-06-22  8:58 ` [Linux-cachefs] " David Howells
2009-06-22 14:54   ` Takashi Iwai
2009-06-22 15:21     ` David Howells
2009-06-22 15:45       ` Takashi Iwai
2009-07-07  7:21     ` Takashi Iwai
2009-07-07 13:00       ` David Howells
2009-07-07 13:05         ` Takashi Iwai
2009-07-27 14:37     ` Incorrect circular locking dependency? David Howells
2009-08-04 14:51       ` Peter Zijlstra
2009-08-04 15:50         ` David Howells
2009-08-04 16:08           ` Peter Zijlstra
2009-08-04 15:59         ` Oleg Nesterov [this message]
2009-08-04 17:23     ` [Linux-cachefs] CacheFiles: Readpage failed on backing file David Howells
2009-08-05 10:00       ` Takashi Iwai
2009-08-07 12:07       ` Takashi Iwai
2009-08-07 14:26         ` David Howells
2009-06-23  0:36   ` Christian Kujau
2009-06-23  7:49     ` Christian Kujau

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=20090804155952.GA5211@redhat.com \
    --to=oleg@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tiwai@suse.de \
    /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.