Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1325645
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree |
| Date | 2016-02-03 17:50 +0100 |
| Message-ID | <qY8MW-4sb-9@gated-at.bofh.it> (permalink) |
| References | <qY0mm-7ok-27@gated-at.bofh.it> <qY0mm-7ok-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Ingo Molnar <mingo@kernel.org> - 2016-02-03 08:50 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-02-03 10:50 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Ingo Molnar <mingo@kernel.org> - 2016-02-03 10:50 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Andrew Morton <akpm@linux-foundation.org> - 2016-02-03 17:50 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Andrew Morton <akpm@linux-foundation.org> - 2016-02-03 21:50 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Andrew Morton <akpm@linux-foundation.org> - 2016-02-03 22:50 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-02-04 14:20 +0100
Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree Michael Ellerman <mpe@ellerman.id.au> - 2016-02-08 10:40 +0100
csiph-web