public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@logfs.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: dwmw2@infradead.org, Ingo Molnar <mingo@elte.hu>,
	Erez Zadok <ezk@cs.sunysb.edu>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [BLOCK2MTD] WARNING: at kernel/lockdep.c:2331 lockdep_init_map()
Date: Sun, 21 Oct 2007 13:12:18 +0200	[thread overview]
Message-ID: <20071021111217.GC5052@lazybastard.org> (raw)
In-Reply-To: <1192818689.9471.14.camel@lappy>

On Fri, 19 October 2007 20:31:29 +0200, Peter Zijlstra wrote:
> > 
> > BUG: key f88e1340 not in .data!
> > WARNING: at kernel/lockdep.c:2331 lockdep_init_map()
> >  [<c0102bc2>] show_trace_log_lvl+0x1a/0x2f
> >  [<c0103692>] show_trace+0x12/0x14
> >  [<c01037b2>] dump_stack+0x15/0x17
> >  [<c0125432>] lockdep_init_map+0x94/0x3e4
> >  [<c0125001>] debug_mutex_init+0x2c/0x3c
> >  [<c01210d4>] __mutex_init+0x38/0x40
> >  [<f88e01d3>] 0xf88e01d3
> >  [<c011dda7>] parse_args+0x123/0x200
> >  [<c012b725>] sys_init_module+0xdd0/0x122c
> >  [<c0102586>] sysenter_past_esp+0x5f/0x91
> >  =======================
> > block2mtd: mtd0: [d: /dev/loop0] erase_size = 128KiB [131072]
> > block2mtd: version $Revision: 1.30 $
> 
> Someone stuck a key object in non static storage. That breaks lockdep,
> don't do that :-)
> 
> Is the mutex_init() done from a function tagged with __init?

Root cause is an ordering problem in module loading.  Code flow is
roughly this:
sys_init_module
`-> load_module
:   `->	parse_args
:	`-> block2mtd_setup
:	    `-> __mutex_init
:		`-> lockdep_init_map
:		    `-> static_obj
:			`-> is_module_address
`-> __link_module

is_module_address() would return something sane, if __link_module() had
already been called.  In fact, if the parameter is passed through
/sys/modules/block2mtd/parameters/block2mtd _after_ module load time,
the exact same code works fine.  Only when passing the parameter as a
module parameter do we see this problem.

So what should be done?  We could move parse_args() below
__link_module(), but I'd guess such a change would break some other
modules what depend on certain parameters or at least should fail to
load with illegal parameters.  Do such modules exist?

Or we could add some kind of parse_args_late() that is called after
__link_module(), if requested by a module, and annotate block2mtd to
prefer that version.

[ Adding Ingo on Cc:.  Since block2mtd predates lockdep I found a bug in
  his code and not the other way around. ;) ]

Jörn

-- 
Do not stop an army on its way home.
-- Sun Tzu

  reply	other threads:[~2007-10-21 11:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-19 17:53 [BLOCK2MTD] WARNING: at kernel/lockdep.c:2331 lockdep_init_map() Erez Zadok
2007-10-19 18:31 ` Peter Zijlstra
2007-10-21 11:12   ` Jörn Engel [this message]
2007-10-19 19:14 ` Jörn Engel
2007-10-19 20:04   ` Erez Zadok
2007-10-20  9:29     ` Jörn Engel
2007-10-19 20:37   ` Erez Zadok

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=20071021111217.GC5052@lazybastard.org \
    --to=joern@logfs.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dwmw2@infradead.org \
    --cc=ezk@cs.sunysb.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox