From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754197AbbCBLl2 (ORCPT ); Mon, 2 Mar 2015 06:41:28 -0500 Received: from ozlabs.org ([103.22.144.67]:34031 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753248AbbCBLlW (ORCPT ); Mon, 2 Mar 2015 06:41:22 -0500 From: Rusty Russell To: Peter Zijlstra , mingo@kernel.org, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, peterz@infradead.org Subject: Re: [RFC][PATCH 2/9] module: Sanitize RCU usage and locking In-Reply-To: <20150228213109.952835328@infradead.org> References: <20150228212447.381543289@infradead.org> <20150228213109.952835328@infradead.org> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Mon, 02 Mar 2015 21:46:45 +1030 Message-ID: <87y4nfk5sy.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > Currently the RCU usage in module is an inconsistent mess of RCU and > RCU-sched, this is broken for CONFIG_PREEMPT where synchronize_rcu() > does not imply synchronize_sched(). Huh? It's not "an inconsistent mess". They're all synchronize_rcu(), except one. That one is *specifically* a best effort bandaid for the case where module initialization has failed. It's theoretically racy, so we wait a bit before freeing. That said, I love the new checks, thanks! > +static inline void module_assert_mutex(void) > +{ > + lockdep_assert_held(&module_mutex); > +} > + > +static inline 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); > +#endif > +} Minor nitpick: I generally avoid static inline in C files (unless functions are unused under some config options, which these aren't). In general, they mess up future cleanups, as gcc doesn't warn about unused functions. Thanks, Rusty.