From: Andrew Morton <akpm@linux-foundation.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: aryabinin@virtuozzo.com, krinkin.m.u@gmail.com, mingo@elte.hu,
peterz@infradead.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree
Date: Wed, 3 Feb 2016 08:51:11 -0800 [thread overview]
Message-ID: <20160203085111.fc3f2631.akpm@linux-foundation.org> (raw)
In-Reply-To: <20160203074430.GA32652@gmail.com>
On Wed, 3 Feb 2016 08:44:30 +0100 Ingo Molnar <mingo@kernel.org> wrote:
> > Mike said:
> >
> > : CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled, i. e
> > : kernel with CONFIG_UBSAN_ALIGNMENT fails to load without even any error
> > : message.
> > :
> > : The problem is that ubsan callbacks use spinlocks and might be called
> > : before lockdep is initialized. Particularly this line in the
> > : reserve_ebda_region function causes problem:
> > :
> > : lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
> > :
> > : If i put lockdep_init() before reserve_ebda_region call in
> > : x86_64_start_reservations kernel loads well.
> >
> > Fix this ordering issue permanently: change lockdep so that it ensures
> > that the hash tables are initialized when they are about to be used.
> >
> > The overhead will be pretty small: a test-n-branch in places where lockdep
> > is about to do a lot of work anyway.
> >
> > Possibly lockdep_initialized should be made __read_mostly.
> >
> > A better fix would be to simply initialize these (32768 entry) arrays of
> > empty list_heads at compile time, but I don't think there's a way of
> > teaching gcc to do this.
> >
> > We could write a little script which, at compile time, emits a file
> > containing
> >
> > [0] = LIST_HEAD_INIT(__chainhash_table[0]),
> > [1] = LIST_HEAD_INIT(__chainhash_table[1]),
> > ...
> > [32767] = LIST_HEAD_INIT(__chainhash_table[32767]),
> >
> > and then #include this file into lockdep.c. Sounds like a lot of fuss.
> >
>
> ...
>
> Yuck, I don't really like this.
>
> Lockdep initialization must happen early on,
It should happen at compile time.
> and it should happen in a well
> defined place, not be opportunistic (and relatively random) like this, making it
> dependent on config options and calling contexts.
That's an unusable assertion, sorry.
Initializing lockdep in the above manner guarantees that it is initialized
before it is used. It is *much* more reliable than "try to initialize
it before some piece of code which hasn't even been written yet tries
to take a lock".
The conceptual problem is that if some piece of code does
spin_lock_init() or DEFINE_SPINLOCK(), that lock isn't necessarily
initialized yet.
next prev parent reply other threads:[~2016-02-03 16:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <56b11d2d.vVw1kB2la7Y+70xF%akpm@linux-foundation.org>
2016-02-03 7:44 ` + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Ingo Molnar
2016-02-03 9:42 ` Andrey Ryabinin
2016-02-03 9:49 ` Ingo Molnar
2016-02-03 16:51 ` Andrew Morton [this message]
2016-02-03 20:40 ` Andrew Morton
2016-02-03 21:44 ` Andrew Morton
2016-02-04 13:13 ` Andrey Ryabinin
2016-02-08 9:33 ` Michael Ellerman
2016-02-09 11:00 ` Ingo Molnar
2016-02-09 11:12 ` Ingo Molnar
2016-02-09 20:17 ` Andrew Morton
2016-02-29 9:11 ` Ingo Molnar
2016-02-29 9:25 ` Ingo Molnar
2016-02-29 9:30 ` Andrey Ryabinin
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=20160203085111.fc3f2631.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.p.zijlstra@chello.nl \
--cc=aryabinin@virtuozzo.com \
--cc=krinkin.m.u@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.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 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).