From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932455AbbDMPkQ (ORCPT ); Mon, 13 Apr 2015 11:40:16 -0400 Received: from casper.infradead.org ([85.118.1.10]:50790 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753826AbbDMPkN (ORCPT ); Mon, 13 Apr 2015 11:40:13 -0400 Date: Mon, 13 Apr 2015 17:40:02 +0200 From: Peter Zijlstra To: Ingo Molnar Cc: rusty@rustcorp.com.au, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, laijs@cn.fujitsu.com, linux@horizon.com Subject: Re: [PATCH v5 01/10] module: Sanitize RCU usage and locking Message-ID: <20150413154002.GI23123@twins.programming.kicks-ass.net> References: <20150413141126.756350256@infradead.org> <20150413141213.241687161@infradead.org> <20150413153229.GA6040@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150413153229.GA6040@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 13, 2015 at 05:32:29PM +0200, Ingo Molnar wrote: > > +static void module_assert_mutex_or_preempt(void) > > +{ > > +#ifdef CONFIG_LOCKDEP > > + int rcu_held = rcu_read_lock_sched_held(); > > + int mutex_held = 1; > > + > > + if (debug_locks) > > + mutex_held = lockdep_is_held(&module_mutex); > > + > > + WARN_ON(!rcu_held && !mutex_held); > > So because rcu_read_lock_sched_held() also depends on debug_locks > being on to be fully correct, shouldn't the warning also be within the > debug_locks condition? Ah, see how mutex_held will be true for !debug_locks and therefore we'll not trigger the warn. Maybe not the best way to code that though. Something like so perhaps: static void module_assert_mutex_or_preempt(void) { #ifdef CONFIG_LOCKDEP if (!debug_locks) return; WARN_ON(!rcu_held_lock_sched_held() && !lockdep_is_held(&module_mutex)); #endif }