Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbdH2Ttw (ORCPT ); Tue, 29 Aug 2017 15:49:52 -0400 Received: from merlin.infradead.org ([205.233.59.134]:45182 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750822AbdH2Ttv (ORCPT ); Tue, 29 Aug 2017 15:49:51 -0400 Date: Tue, 29 Aug 2017 21:49:48 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Borislav Petkov , Sebastian Andrzej Siewior , lkml Subject: Re: WARNING: possible circular locking dependency detected Message-ID: <20170829194948.GD32112@worktop.programming.kicks-ass.net> References: <20170825100304.5cwrlrfwi7f3zcld@pd.tnic> <20170828145808.btuqpe2bvxymljyg@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1764 Lines: 53 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? > That solves that part of the issue, but it does not solve the > release_ds_buffers() problem. Though with the watchdog_lock() mechanism, it > allows me to do: > > ->park() := watchdog_disable() > perf_event_disable(percpuevt); > cleanup_event = percpuevt; > percpuevt = NULL; > and then > > watchdog_unlock() > if (cleanup_event) { > perf_event_release_ebent(cleanup_event); > cleanup_event = NULL; > } > mutex_unlock(&watchdog_mutex); > > That should do the trick nicely for both user space functions and the cpu > hotplug machinery. > > 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.