From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947234AbdEZHrf (ORCPT ); Fri, 26 May 2017 03:47:35 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:39959 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1947199AbdEZHrC (ORCPT ); Fri, 26 May 2017 03:47:02 -0400 Date: Fri, 26 May 2017 09:47:00 +0200 (CEST) From: Thomas Gleixner To: Masami Hiramatsu cc: LKML , Peter Zijlstra , Ingo Molnar , Steven Rostedt , Sebastian Siewior , Paul McKenney Subject: Re: [patch V3 25/32] kprobes: Cure hotplug lock ordering issues In-Reply-To: <20170525005410.f7142f05cd5d248600c61f96@kernel.org> Message-ID: References: <20170524081511.203800767@linutronix.de> <20170524081549.104864779@linutronix.de> <20170525005410.f7142f05cd5d248600c61f96@kernel.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 25 May 2017, Masami Hiramatsu wrote: > On Wed, 24 May 2017 10:15:36 +0200 > Thomas Gleixner wrote: > > > Converting the cpu hotplug locking to a percpu rwsem unearthed hidden lock > > ordering problems. > > > > There is a wide range of locks involved in this: kprobe_mutex, > > jump_label_mutex, ftrace_lock, text_mutex, event_mutex, > > func_hash->regex_lock and a gazillion of lock order permutations with > > nested get_online_cpus() calls. > > And module_mutex too ;-) Indeed. > > Some of those permutations are potential deadlocks even with the current > > nesting hotplug locking scheme, but they can't be discovered by lockdep. > > > > The conversion of the hotplug locking to a percpu rwsem requires to prevent > > nested locking, so it's required to take the hotplug rwsem early in the > > call chain and establish a proper lock order. > > > > After quite some analysis and going down the wrong road severa times the > > following lock order has been chosen: > > > > kprobe_mutex -> cpus_rwsem -> jump_label_mutex -> text_mutex > > This seems only change the locking order of module_mutex and > cpus_rwsem. Previously module_mutex -> cpus_rwsem, now > cpus_rwsem -> module_mutex. and it seems OK to me. > (checked in module.c and other use cases of module_mutex) This also changes the jump label / text mutex interaction with hotplug locking if you look closely :)