Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2842490ybh; Sat, 25 Jul 2020 03:21:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZsfgfLXMXL4TfoiFMEB+h8Xc/a/EaoA/QMNSmsCJCLpyZkmle4pUViXKw5TTHvrFwQXbs X-Received: by 2002:a17:907:42cc:: with SMTP id nz20mr6430839ejb.429.1595672513720; Sat, 25 Jul 2020 03:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595672513; cv=none; d=google.com; s=arc-20160816; b=s8ibTg6jjbXfSzXyHebFDrSmRusLDqcFS5IQoXM90ksefPab0+q8nH+NP1tIQefEei e7mDytu2narxMEYPhFExa++9LirSQFxlN5P6oIvnIZgHBax0XlKIQ/uzef3qLJkaIo/1 AhPWGwefq3ah+1WzXG3MemyWsK3GIuHRc+ckQQL5rnohAU2iUQ7i7hRwKcLNa9rjEgKr ALmmqOpIT58lEGwuw+eC5PT72DpiCAq0s8IWgq/3jE6FlG31hpfpjpZ5wuoD+Okg/0oi XEhDJXikzYTprj7+oT48bDrcG4YAhE4rccn5klSEiGd4ohVIlrLDOKSV0+mvDdGekVnW 2t0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=missdBsNUzT7ukHWexKwYjiaX2t9R6jTrHE5vOnris8=; b=uAlRRUh64RYrNFkTzrEvJ7eQkODEwxuopgAkh/SV9jFswVQc1ad+ZpAYUYrNIrMbqf typYySVFFODrDqsfvaXT0SllMPO6ffR90vnMjGCq1Y1ZYcj34+v4VpDo0AW9gDiwyhub S58uPCoW4VHf1/SSMDEKdxJTf9xJqLRjq3pdfm6/WXtw/7z+T1V9FtEM9qVqzrSFinOu yUtRYp5mI2XEA0EoSVlfpGNVy+O6VrGHCuFn5I5eV0Hu/CEE4jr2+apodKo2Gk1MxKwd YQjNxFawnAYTxn6Sbi5a2sUZd6AQwQDq1t7VTS409c/qSHPkNz5a3mvkNjtNL/miU39o Knng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fCRC7859; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si2209267ejq.283.2020.07.25.03.21.31; Sat, 25 Jul 2020 03:21:53 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fCRC7859; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbgGYKVO (ORCPT + 99 others); Sat, 25 Jul 2020 06:21:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgGYKVO (ORCPT ); Sat, 25 Jul 2020 06:21:14 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F7E4C0619D3 for ; Sat, 25 Jul 2020 03:21:14 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id lx13so12390650ejb.4 for ; Sat, 25 Jul 2020 03:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=missdBsNUzT7ukHWexKwYjiaX2t9R6jTrHE5vOnris8=; b=fCRC7859xWOSbmhU4JKMCe+akFDWIyPM7HAKB7nU55UPjnpS/tGtO7rZE+MhfZB0Bt 8U8Wz/5zhFEDQfnQH8/dZhyml4+1go+4t2QL13eB53s1B3OgARiKuu0ARZrm4ZVZMAvG pqUh3m+EzE04nIceDtofchMlX3oNWsSqEDUrd6tZlexJw85bhjKQ30Tqu4D0FUtrJG1+ /DCqtBGF0sp3p1Gqh92PRQ/SUEpgqaOfBY1NSn/fcLC7rzifhOmIoIjLlm76s/Zp0H7I fNVMy1K/Naw5Q08yS5vesNwJnwxu0iuONkI4J9Dt2RccNkL/6ynBNcCgJwfFxkTy56yD MFTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=missdBsNUzT7ukHWexKwYjiaX2t9R6jTrHE5vOnris8=; b=CZ3xZXfPkDX8eIgZsUVPFIukqds1ZI2jKWcVRIWeG2bqaP2m7I9UunQhVPheaQKOMQ M6NQD0w1TUKUfv4xtvnFJqREveauhQRpjBOA2/j9h24xtqLJu1sJVIF0zaxtezw6zEDb 9ELFGZeqE5d6fUB+6ZmaCL/yHWRjC6kXXb1gr+e4kFnTTH1TKrMv6qLLGfCmLQ8va+nC TQMvp4XB3qm2E2ZoRrCS5IIDSBtSVr5lC43C5DIHXiQdGagYqecOihsD4+yah/3/IuDg n4qatA94aLLJlPni48OJhqoAz4cUoBVsYOjC+kEUIXGDASd+XqnS2UFnxyv+x5ulkuvC A04g== X-Gm-Message-State: AOAM532fwj6D8ZPug2etGUrEMqch7rHgdScMec6RApYJUsFgzVlBz1UO 6OC/4Eqjwr6QYD6Zghc5QRhE07SN X-Received: by 2002:a17:906:8595:: with SMTP id v21mr13457349ejx.333.1595672473007; Sat, 25 Jul 2020 03:21:13 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id i7sm2605033eds.91.2020.07.25.03.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2020 03:21:12 -0700 (PDT) Date: Sat, 25 Jul 2020 12:21:10 +0200 From: Ingo Molnar To: Jarkko Sakkinen 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: <20200725102110.GA757173@gmail.com> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-2-jarkko.sakkinen@linux.intel.com> <20200724091711.GB517988@gmail.com> <20200725030107.GF17052@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200725030107.GF17052@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Jarkko Sakkinen wrote: > 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. If it's unnecessary, then it needs to be removed. If it's necessary, then it needs to be documented better. Thanks, Ingo