Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbdH2UKt (ORCPT ); Tue, 29 Aug 2017 16:10:49 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:53234 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbdH2UKs (ORCPT ); Tue, 29 Aug 2017 16:10:48 -0400 Date: Tue, 29 Aug 2017 22:10:37 +0200 (CEST) From: Thomas Gleixner To: Peter Zijlstra cc: Borislav Petkov , Sebastian Andrzej Siewior , lkml Subject: Re: WARNING: possible circular locking dependency detected In-Reply-To: <20170829194948.GD32112@worktop.programming.kicks-ass.net> Message-ID: References: <20170825100304.5cwrlrfwi7f3zcld@pd.tnic> <20170828145808.btuqpe2bvxymljyg@hirez.programming.kicks-ass.net> <20170829194948.GD32112@worktop.programming.kicks-ass.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2087 Lines: 68 On Tue, 29 Aug 2017, Peter Zijlstra wrote: > On Tue, Aug 29, 2017 at 07:40:44PM +0200, Thomas Gleixner wrote: > > > One solution I'm looking into right now is to reverse the lock order and > > actually make the hotplug code do: > > > > watchdog_lock(); > > cpu_write_lock(); > > > > .... > > cpu_write_unlock(); > > watchdog_unlock(); > > > > and get rid of cpu_read_(un)lock() in the sysctl interface completely. I > > know it's ugly, but we have other locks we take in the hotplug path as > > well. > > This is to serialize the sysctl against hotplug? I'm not immediately > seeing why watchdog_lock needs to be the outer most lock, is that > because of vfs locks or something? Well, the watchdog sysctls serialization today is: cpus_read_lock(); mutex_lock(&watchdog_mutex); do_stuff() access -> online_cpu_mask do_stuff() ... ... cpus_read_lock(); So we need watchdog_mutex -> cpuhotplug_rwsem lock order all over the place. > > Though it's quite a rewrite of that mess, which is particularly non trivial > > because that extra non perf implementation in arch/powerpc which has its > > own NMI watchdog thingy wants its calls preserved. But AFAICT so far it > > should just work. Famous last words.... > > > > Thoughts? > > So I have a patch _somewhere_ that preserves the event<->cpu relation > across hotplug and disable/enable would be sufficient. If you want I can > try and dig that out and make it work again. > > That would avoid having to do the destroy/create cycle of the watchdog > events. Yes, that would solve the x86_release_hw() issue, but still lots of the other rework is required in one way or the other. I'm currently trying to avoid that extra lock mess in the cpu hotplug code, which would just open the door for everybody to add his extra locks there, so we end up taking a gazillion locks before we can hotplug :) I think I have an idea how to solve that cleanly, but certainly your offer of preserving the event - cpu relation accross hotplug would help tremendously. Thanks, tglx