• Valentin Schneider's avatar
    sched/core: Take the hotplug lock in sched_init_smp() · ef8d2a5d
    Valentin Schneider authored
    [ Upstream commit 40fa3780 ]
    
    When running on linux-next (8c60c36d0b8c ("Add linux-next specific files
    for 20181019")) + CONFIG_PROVE_LOCKING=y on a big.LITTLE system (e.g.
    Juno or HiKey960), we get the following report:
    
     [    0.748225] Call trace:
     [    0.750685]  lockdep_assert_cpus_held+0x30/0x40
     [    0.755236]  static_key_enable_cpuslocked+0x20/0xc8
     [    0.760137]  build_sched_domains+0x1034/0x1108
     [    0.764601]  sched_init_domains+0x68/0x90
     [    0.768628]  sched_init_smp+0x30/0x80
     [    0.772309]  kernel_init_freeable+0x278/0x51c
     [    0.776685]  kernel_init+0x10/0x108
     [    0.780190]  ret_from_fork+0x10/0x18
    
    The static_key in question is 'sched_asym_cpucapacity' introduced by
    commit:
    
      df054e84 ("sched/topology: Add static_key for asymmetric CPU capacity optimizations")
    
    In this particular case, we enable it because smp_prepare_cpus() will
    end up fetching the capacity-dmips-mhz entry from the devicetree,
    so we already have some asymmetry detected when entering sched_init_smp().
    
    This didn't get detected in tip/sched/core because we were missing:
    
      commit cb538267 ("jump_label/lockdep: Assert we hold the hotplug lock for _cpuslocked() operations")
    
    Calls to build_sched_domains() post sched_init_smp() will hold the
    hotplug lock, it just so happens that this very first call is a
    special case. As stated by a comment in sched_init_smp(), "There's no
    userspace yet to cause hotplug operations" so this is a harmless
    warning.
    
    However, to both respect the semantics of underlying
    callees and make lockdep happy, take the hotplug lock in
    sched_init_smp(). This also satisfies the comment atop
    sched_init_domains() that says "Callers must hold the hotplug lock".
    Reported-by: default avatarSudeep Holla <sudeep.holla@arm.com>
    Tested-by: default avatarSudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Dietmar.Eggemann@arm.com
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: morten.rasmussen@arm.com
    Cc: quentin.perret@arm.com
    Link: http://lkml.kernel.org/r/1540301851-3048-1-git-send-email-valentin.schneider@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    ef8d2a5d
core.c 166 KB