From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69257C433E0 for ; Thu, 16 Jul 2020 17:37:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EF3D2071B for ; Thu, 16 Jul 2020 17:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgGPRho (ORCPT ); Thu, 16 Jul 2020 13:37:44 -0400 Received: from mga17.intel.com ([192.55.52.151]:8831 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbgGPRhn (ORCPT ); Thu, 16 Jul 2020 13:37:43 -0400 IronPort-SDR: tW7gg4/KGkl+DzODuKNzzPTwnvp75POsfYZYNAsUIcMYlH3ND1qiuiiJYz9dI8kWECCdZoEKUS 0wEM3mzxqPCg== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129531979" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="129531979" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 10:37:42 -0700 IronPort-SDR: Yht4DgPOikZmYOd5giPSDZealJ80taRpkvvN+/vv7pCF3nVML6W661HGp0qnX0rlQpJuE/YTYO 0Y5jTTZUuQeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="325207690" Received: from unknown (HELO localhost) ([10.249.34.156]) by FMSMGA003.fm.intel.com with ESMTP; 16 Jul 2020 10:37:35 -0700 Date: Thu, 16 Jul 2020 20:37:34 +0300 From: Jarkko Sakkinen To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, x86@vger.kernel.org, Andi Kleen , Jessica Yu , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Steven Rostedt , Ingo Molnar , "open list:LIVE PATCHING" Subject: Re: [PATCH v3 2/3] module: Add lock_modules() and unlock_modules() Message-ID: <20200716173734.GF14135@linux.intel.com> References: <20200714223239.1543716-1-jarkko.sakkinen@linux.intel.com> <20200714223239.1543716-3-jarkko.sakkinen@linux.intel.com> <20200715173939.40e235a5035ea698e38b7ee7@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200715173939.40e235a5035ea698e38b7ee7@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 05:39:39PM +0900, Masami Hiramatsu wrote: > On Wed, 15 Jul 2020 01:32:28 +0300 > Jarkko Sakkinen wrote: > > > Add wrappers to take the modules "big lock" in order to encapsulate > > conditional compilation (CONFIG_MODULES) inside the wrapper. > > > > Cc: Andi Kleen > > Suggested-by: Masami Hiramatsu > > Signed-off-by: Jarkko Sakkinen > > --- > > include/linux/module.h | 15 ++++++++++ > > kernel/kprobes.c | 4 +-- > > kernel/livepatch/core.c | 8 ++--- > > kernel/module.c | 60 ++++++++++++++++++------------------- > > kernel/trace/trace_kprobe.c | 4 +-- > > 5 files changed, 53 insertions(+), 38 deletions(-) > > > > diff --git a/include/linux/module.h b/include/linux/module.h > > index 2e6670860d27..857b84bf9e90 100644 > > --- a/include/linux/module.h > > +++ b/include/linux/module.h > > @@ -902,4 +902,19 @@ static inline bool module_sig_ok(struct module *module) > > } > > #endif /* CONFIG_MODULE_SIG */ > > > > +#ifdef CONFIG_MODULES > > +static inline void lock_modules(void) > > +{ > > + mutex_lock(&module_mutex); > > +} > > + > > +static inline void unlock_modules(void) > > +{ > > + mutex_unlock(&module_mutex); > > +} > > +#else > > +static inline void lock_modules(void) { } > > +static inline void unlock_modules(void) { } > > +#endif > > You don't need to add new #ifdefs. There is a room for dummy prototypes > for !CONFIG_MODULES already in modules.h. > > ----- > struct notifier_block; > > #ifdef CONFIG_MODULES > > extern int modules_disabled; /* for sysctl */ > > ... > #else /* !CONFIG_MODULES... */ > > static inline struct module *__module_address(unsigned long addr) > { > ----- > > So you can just put those inlines in the appropriate places ;) > > Thank you, Rrright. /Jarkko