All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH 1/2] workqueue: debug flushing deadlocks with lockdep
Date: Thu, 5 Jul 2007 18:32:17 +0400	[thread overview]
Message-ID: <20070705143217.GA170@tv-sign.ru> (raw)
In-Reply-To: <20070705110820.304578000@sipsolutions.net>

On 07/05, Johannes Berg wrote:
>
> @@ -257,7 +261,9 @@ static void run_workqueue(struct cpu_wor
>  
>  		BUG_ON(get_wq_data(work) != cwq);
>  		work_clear_pending(work);
> +		lock_acquire(&cwq->wq->lockdep_map, 0, 0, 0, 2, _THIS_IP_);
>  		f(work);
> +		lock_release(&cwq->wq->lockdep_map, 1, _THIS_IP_);

Johannes, my apologies. You were worried about recursion, and you were right,
sorry!

Currently it is allowed that work->func() does flush_workqueue() on its own
workqueue. So we have

	run_workqueue()
		work->func()
			flush_workqueue()
				run_workqueue()

All but work->func() take wq->lockdep_map, I guess check_deadlock() won't be
happy.

In your initial patch, wq->lockdep_map was taken in flush_cpu_workqueue() when
cwq->thread != current, but this is still not enough. Because we take the same
lock when flush_workqueue() does flush_cpu_workqueue() on another CPU.

run_workqueue() is easy, it can check cwq->run_depth == 1 before lock/unlock.

Anybody sees a simple soultion? Perhaps, some clever trick with LOCKDEP ?


OTOH. Perhaps we can can forbid such a behaviour? Andrew, do you know any
good example of "keventd trying to flush its own queue" ?

In any case, I think both patches are great, thanks for doing this!

Oleg.


  reply	other threads:[~2007-07-05 14:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-05 11:07 [PATCH 0/2] workqueue lockup debugging Johannes Berg
2007-07-05 11:07 ` [PATCH 1/2] workqueue: debug flushing deadlocks with lockdep Johannes Berg
2007-07-05 14:32   ` Oleg Nesterov [this message]
2007-07-05 14:40     ` Ingo Molnar
2007-07-05 14:52       ` Oleg Nesterov
2007-07-06 10:42         ` Johannes Berg
2007-07-05 11:07 ` [PATCH 2/2] workqueue: debug work related " Johannes Berg
2007-07-05 15:36   ` Oleg Nesterov
2007-07-06 10:43     ` Johannes Berg
2007-07-06 12:53       ` Oleg Nesterov
2007-07-11 11:37         ` Johannes Berg

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=20070705143217.GA170@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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.