Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1388535ybh; Thu, 16 Jul 2020 10:40:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTU8nd+9+irga5q8wJtyzm6+mX9O7qqrr0GA6JWoFkTOEyJdP2eyA7FIbC8gbovg7oXXeW X-Received: by 2002:a05:6402:1ade:: with SMTP id ba30mr5277462edb.231.1594921235267; Thu, 16 Jul 2020 10:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594921235; cv=none; d=google.com; s=arc-20160816; b=aTC9kXqnfNBMkumta97WkLsoUoiH5sDzkLqXiKhxUWc7CgByPlYfdOnckrZSXjnYlK 1dErR37H/QLOF/5RdXPL5+J/wckmzdyn1jx7oRI1gbAawtny+FRTHvWJ9+r2CYyqY6cN ssZubolKI9U678MslWDROb/SG9FLnnpO9TafgWie49mGprs2Tkf+ZbDmWxxuWkUIgMvc VjRIjrfxPdMn5Ym6MjwcelIC/IKBWofk3VuQE3viH0lYFB48Iq4PeLxdNSN2jS/HOiD0 v8IZ0wUFvXwirs6pjCS+VcLUfW6C0W3NZJWJW6+iWrOOENP2qHrNta6tTZpbd1Q4JYIk zkkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=leFWiZxwOGRigW+fslstsx47iii4psKl1tBUBK5MvXI=; b=Kg3AmU85vLUwVcLpUNHe8YVIcWi8l2RvPkSapSV5PaKUReOxbwo4xPKCAhHutN1lTe e0cBH7e7Lj9LSCA6tZ6Ewz4UHFkbc7fszQygBtn/PNZOnlp8LSMjl/DG0KpfdYEIC5kt 4MdWgJBAtN+5RLnKMHDlIN+G4J6cOEwBMJ5UX8rMUANyyKY/+zRqsZsjTUssfFNg7ZBE zf/NjPERH/zkQ76lzA6I5VlqxI182yV903CSFsJ1ckaw7eMntELvwsapSaWzEdvIHmpg jvCulfx2QSz47Yuz92ZheXBAhRfBVqggXDac0JWsvIPJ0wxwcVRW7xnTEYNocDespWFS p+wQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd17si3749007ejb.306.2020.07.16.10.40.11; Thu, 16 Jul 2020 10:40:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728807AbgGPRho (ORCPT + 99 others); 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