Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2654709ybh; Fri, 24 Jul 2020 20:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwR9PbUVuWTPnjSepmHimebCBzTTnhPf6+vOTiU0JepqphWDFgvu8NO2js5sAaKbJOG/L+ X-Received: by 2002:a17:906:408c:: with SMTP id u12mr11607274ejj.162.1595646234772; Fri, 24 Jul 2020 20:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595646234; cv=none; d=google.com; s=arc-20160816; b=ztWGWnQPuUpmg1zAViPnP+HRESzTxqcYgA8eF5nIf9qL8uY4Wi+nYqaarBVn+g4oId Muf5esoWhzdhZ5MTLAFG7xbqEBpb/xGCCXHO11V4k85P1Eumnqwm5NPRLmQDxQTbuMbb ELrGeN5/u6pTKMftlF22Td0oggn8JQy9h3Mlq1+nZEqgXKDA7VgPBkd6hZT62WeBL35P f6zP06K2gUvzLAdWYQi0+zRD/sPV1DiwatZ3tg1UTZB+zj1xbdumfOysKUw9HNmPE8vN FdHiOqnphZMk6w9jlqfz5GzbRnia3Db9ZwBhkCkojkuTW0FqVrO18kgOdlvJHqbC2B+Z aU8A== 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=UgWT7af+Wy16ClhHs+qNDalOY7kmZsnhWaZ15MBczp0=; b=LIr0ygcti9VwJwujyQPJ8py11oHcVw3lmkFI1UocsyF/m/RdGSwlHabgIYFYdzw1Rs +jN8zgEQAle7sQJ1KMi0NO6JeiyI0SzKKAgA0c9rRr7Z9kH//UPbLbkh5IxxKHfIikDR 7VaV7T+YWRRQjn/OolwoPo94/lINsP3DtyBnn+Astwa7+x8BHepGWWVWYXOhMv/KGJHF WEV9ersWC5/nOr8pVMiVlqSSdIKjBt0BpE6V8UVCmM4gDH55/Tq+CldPs0wooFtnJqoh q310LzNzK8t3nph6BhdrU3ter9Le5bmjDvMyTWHdxf+7nL6485mvEKAybqUIOjBxsT5l wdpQ== 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 g15si1741877ejo.44.2020.07.24.20.03.32; Fri, 24 Jul 2020 20:03:54 -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 S1726730AbgGYDBP (ORCPT + 99 others); Fri, 24 Jul 2020 23:01:15 -0400 Received: from mga11.intel.com ([192.55.52.93]:1363 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgGYDBP (ORCPT ); Fri, 24 Jul 2020 23:01:15 -0400 IronPort-SDR: 2WFHRbUfifyDb0LFVipTnlThgRhZ4C44Zzw2TeObdPSzO2DYE3+/iEX/5QqP8+ix07Mxsq6oKK d+0HLcMhvOFA== X-IronPort-AV: E=McAfee;i="6000,8403,9692"; a="148715924" X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="148715924" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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