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=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 6E6C1C433DF for ; Sat, 25 Jul 2020 03:01:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B2DA206EB for ; Sat, 25 Jul 2020 03:01:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B2DA206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AC8B26B002C; Fri, 24 Jul 2020 23:01:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A52E56B002D; Fri, 24 Jul 2020 23:01:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 918EE6B002E; Fri, 24 Jul 2020 23:01:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 78F966B002C for ; Fri, 24 Jul 2020 23:01:18 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2C3551923A for ; Sat, 25 Jul 2020 03:01:18 +0000 (UTC) X-FDA: 77075097036.01.smoke52_3208e5626f4c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id F31771004D19D for ; Sat, 25 Jul 2020 03:01:17 +0000 (UTC) X-HE-Tag: smoke52_3208e5626f4c X-Filterd-Recvd-Size: 3621 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Sat, 25 Jul 2020 03:01:17 +0000 (UTC) IronPort-SDR: 2KW7ZenYuF4t0xcZ/lxNxC91ZrCKUNQ4Zf4DjjNdhT9QA1GrxH1MCQkSuboy1UhRsMQgv8EClK EMntyUWJM8CQ== X-IronPort-AV: E=McAfee;i="6000,8403,9692"; a="138320332" X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="138320332" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2020 20:01:15 -0700 IronPort-SDR: Zb1abh/qM98LiRVzVkmiiDoP7rGOSDUXza0TOyRuPkDFnnvZt/7ajicbDb/7B1D/7SWcoRNjF5 0l5d4ObrS97A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="311611969" Received: from jcrametz-mobl.ger.corp.intel.com (HELO localhost) ([10.252.58.73]) by fmsmga004.fm.intel.com with ESMTP; 24 Jul 2020 20:01:09 -0700 Date: Sat, 25 Jul 2020 06:01:07 +0300 From: Jarkko Sakkinen To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andi Kleen , Peter Zijlstra , Masami Hiramatsu , Jessica Yu , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Steven Rostedt , Ingo Molnar Subject: Re: [PATCH v5 1/6] kprobes: Remove dependency to the module_mutex Message-ID: <20200725030107.GF17052@linux.intel.com> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-2-jarkko.sakkinen@linux.intel.com> <20200724091711.GB517988@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200724091711.GB517988@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Rspamd-Queue-Id: F31771004D19D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jul 24, 2020 at 11:17:11AM +0200, Ingo Molnar wrote: > > * Jarkko Sakkinen wrote: > > > --- a/kernel/kprobes.c > > +++ b/kernel/kprobes.c > > @@ -564,7 +564,7 @@ static void kprobe_optimizer(struct work_struct *work) > > cpus_read_lock(); > > mutex_lock(&text_mutex); > > /* Lock modules while optimizing kprobes */ > > - mutex_lock(&module_mutex); > > + lock_modules(); > > > > /* > > * Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed) > > @@ -589,7 +589,7 @@ static void kprobe_optimizer(struct work_struct *work) > > /* Step 4: Free cleaned kprobes after quiesence period */ > > do_free_cleaned_kprobes(); > > > > - mutex_unlock(&module_mutex); > > + unlock_modules(); > > mutex_unlock(&text_mutex); > > cpus_read_unlock(); > > BTW., it would be nice to expand on the comments above - exactly which > parts of the modules code is being serialized against and why? > > We already hold the text_mutex here, which should protect against most > kprobes related activities interfering - and it's unclear (to me) > which part of the modules code is being serialized with here, and the > 'lock modules while optimizing kprobes' comments is unhelpful. :-) > > Thanks, > > Ingo AFAIK, only if you need to call find_module(), you ever need to acquire this mutex. 99% of time it is internally taken care by kernel/module.c. I cannot make up any obvious reason to acquire it here. /Jarkko