All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ming Lei <tom.leiming@gmail.com>
Cc: mingo@elte.hu, akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] kernel/lockdep: use BFS(breadth-first search) algorithm to search target
Date: Tue, 26 May 2009 15:59:34 +0200	[thread overview]
Message-ID: <1243346374.23657.9.camel@twins> (raw)
In-Reply-To: <20090526215442.2dbd888b@linux-lm>

On Tue, 2009-05-26 at 21:54 +0800, Ming Lei wrote:
> Hi,All
> 
> Currently lockdep uses recursion DFS(depth-first search) algorithm to
> search target in checking lock circle(check_noncircular()),irq-safe
> -> irq-unsafe(check_irq_usage()) and irq inversion when adding a new
> lock dependency. I plan to replace the current DFS with BFS, based on
> the following consideration:
> 
> 	1,no loss of efficiency, no matter DFS or BFS, the running time
> 	are O(V+E) (V is vertex count, and E is edge count of one
> 	graph);
> 
> 	2,BFS may be easily implemented by circular queue and consumes
> 	much less kernel stack space than DFS for DFS is implemented by
> 	recursion, we know kernel stack is very limited, eg. 4KB.
> 
> 	3, The shortest path can be obtained by BFS if the target is
> 	found, but can't be got by DFS. By the shortest path, we can
> 	shorten the lock dependency chain and help to troubleshoot lock
> 	problem easier than before.
> 
> Any suggestions, objections or viewpoint?

Ah, replace the full cycle detection might be worth it, esp with that
pre-allocated stack you used. Its all serialized on the graph lock
anyway.

I'm not sure about 3, though, since we search on adding a each new
dependency we'll only ever have a choice between cycles when one new
dependency generates two cycles at the same time. Something I think is
rare.

But yes, it wuold be nice to get rid of the current recursive algorithm
there.


  reply	other threads:[~2009-05-26 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 13:54 [RFC] kernel/lockdep: use BFS(breadth-first search) algorithm to search target Ming Lei
2009-05-26 13:59 ` Peter Zijlstra [this message]
2009-05-26 14:36   ` Ming Lei
2009-05-27  0:30   ` Ming Lei

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=1243346374.23657.9.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tom.leiming@gmail.com \
    /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.