Re: lockdep warning while booting POWER9 PowerNV

From: Qian Cai
Date: Thu Sep 05 2019 - 10:30:09 EST


On Thu, 2019-09-05 at 13:55 +1000, Michael Ellerman wrote:
> Bart Van Assche <bvanassche@xxxxxxx> writes:
> > On 8/30/19 2:13 PM, Qian Cai wrote:
> > > https://raw.githubusercontent.com/cailca/linux-mm/master/powerpc.config
> > >
> > > Once in a while, booting an IBM POWER9 PowerNV system (8335-GTH) would
> > > generate
> > > a warning in lockdep_register_key() at,
> > >
> > > if (WARN_ON_ONCE(static_obj(key)))
> > >
> > > because
> > >
> > > key = 0xc0000000019ad118
> > > &_stext = 0xc000000000000000
> > > &_end = 0xc0000000049d0000
> > >
> > > i.e., it will cause static_obj() returns 1.
> >
> > (back from a trip)
> >
> > Hi Qian,
> >
> > Does this mean that on POWER9 it can happen that a dynamically allocatedÂ
> > object has an address that falls between &_stext and &_end?
>
> I thought that was true on all arches due to initmem, but seems not.
>
> I guess we have the same problem as s390 and we need to define
> arch_is_kernel_initmem_freed().

Actually, it is in the .bss section. The commit 2d4f567103ff ("KVM: PPC:
Introduce kvm_tmp framework") adds kvm_tmp[] into the .bss section and then free
the rest of unused spaces back to the page allocator.

kernel_init
 kvm_guest_init
ÂÂÂÂkvm_free_tmp
ÂÂÂÂÂÂfree_reserved_area
ÂÂÂÂÂÂÂÂfree_unref_page
ÂÂÂÂÂÂÂÂÂÂfree_unref_page_prepare

Later, alloc_workqueue() happens to allocate some pages from there, and triggers
the warning. Not sure what the best way to solve this.