Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2660990ybh; Fri, 24 Jul 2020 20:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH7FSlLJf1/m6FTcx6SbVgqz1JMQ5yONt8XiF4UUzD5eGFNo8JLKej0qREt9hBINBiUOOk X-Received: by 2002:a17:906:547:: with SMTP id k7mr11553595eja.287.1595647055223; Fri, 24 Jul 2020 20:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595647055; cv=none; d=google.com; s=arc-20160816; b=RUX0dLy0BEz7xkbUe57CLmiwSQfmTv+IqZ+pCDCCzQ7MMvBAczf1/NYen4o7rkMCrh HFeasD9gkJ6dtO69UX7jWXfsEmr2dFVusdReYF/WN2TBxgnW4N6olXNoisHLGM07lnKg V/3delW6PxO7U4/KPeMJtAR1t1ftdndXOk7RzlLKCUevb2/n+KFOSYbXK/XD3FU9cUCT sR29uHtDXzduLy8PGYCLdnSuG2h1lYQilOTBy2Kr89WvT4z8Cf7KdNzHsM4mROkby/Np JZhYAEFxPnO8wQbIUsA5ZNOulFrYDb/vEuKPjkfp1r4IULjex2fPDVOWCoShUd/rXs0+ 0cEw== 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=f8ufhmt8iUQwv1Fp73xBXhMVGxogVsT7pi0Ip9hgjPM=; b=Ezq1vf8jeaTokmNeJEAE9dYA2hDm2Al/sOGirud/BPJT4NZWg5m++VBH9zH2UOD3Bb emDlmSD3Ofn/V4vvn1VKGerFxQQr/EWXGKSrwT1SVKOoj5NoYH7zGL12s/sjMiYGcPRL cESWVhs6t9JKFUnpoe/dBT6G7pkPVj74QMNSEz1bWaexZXf+qiiYE8e5sNoAEyyaIE8G HwBVFgbqKp/ysLVqctYL7Xwx8luX6h3eAd8ehugH1DzKtQdcl0OqnNGz91jKI2CMErQM AhEbkq0VxYI5w0Q38/FvuZtb4HZZV1aSoKzbKf1EqNjsKVMJ6Sg/wERXE/7epDay7zaB g97g== 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 k12si1589312edl.489.2020.07.24.20.17.12; Fri, 24 Jul 2020 20:17: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 S1726696AbgGYDQ4 (ORCPT + 99 others); Fri, 24 Jul 2020 23:16:56 -0400 Received: from mga04.intel.com ([192.55.52.120]:9484 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgGYDQ4 (ORCPT ); Fri, 24 Jul 2020 23:16:56 -0400 IronPort-SDR: 76meH047grQ2p5ubJdRPHAmNe4hyvfDlE847EQKvFfwLfauxZ++rj5wwkN7amGNprDizw1qhex ZHjZsOQud2uQ== X-IronPort-AV: E=McAfee;i="6000,8403,9692"; a="148297183" X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="148297183" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2020 20:16:55 -0700 IronPort-SDR: TPy3bdlix38xGITNy8b49N+M72nPVehIVpdQv/yMQGR8+GoOVEvNHVvW+P4lbRVn6pVZ+l/SIJ BCqZpmBL98gA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="289177446" Received: from jcrametz-mobl.ger.corp.intel.com (HELO localhost) ([10.252.58.73]) by orsmga006.jf.intel.com with ESMTP; 24 Jul 2020 20:16:50 -0700 Date: Sat, 25 Jul 2020 06:16:48 +0300 From: Jarkko Sakkinen To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andi Kleen , Masami Hiramatsu , Peter Zijlstra , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jessica Yu , Ard Biesheuvel Subject: Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free() Message-ID: <20200725031648.GG17052@linux.intel.com> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-6-jarkko.sakkinen@linux.intel.com> <20200724092746.GD517988@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200724092746.GD517988@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:27:46AM +0200, Ingo Molnar wrote: > > * Jarkko Sakkinen wrote: > > > Use text_alloc() and text_free() instead of module_alloc() and > > module_memfree() when an arch provides them. > > > > Cc: linux-mm@kvack.org > > Cc: Andi Kleen > > Cc: Masami Hiramatsu > > Cc: Peter Zijlstra > > Signed-off-by: Jarkko Sakkinen > > --- > > kernel/kprobes.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > > index 4e46d96d4e16..611fcda9f6bf 100644 > > --- a/kernel/kprobes.c > > +++ b/kernel/kprobes.c > > @@ -40,6 +40,7 @@ > > #include > > #include > > #include > > +#include > > > > #define KPROBE_HASH_BITS 6 > > #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) > > @@ -111,12 +112,20 @@ enum kprobe_slot_state { > > > > void __weak *alloc_insn_page(void) > > { > > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC > > + return text_alloc(PAGE_SIZE); > > +#else > > return module_alloc(PAGE_SIZE); > > +#endif > > } > > > > void __weak free_insn_page(void *page) > > { > > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC > > + text_free(page); > > +#else > > module_memfree(page); > > +#endif > > } > > I've read the observations in the other threads, but this #ifdef > jungle is silly, it's a de-facto open coded text_alloc() with a > module_alloc() fallback... In the previous version I had: https://lore.kernel.org/lkml/20200717030422.679972-4-jarkko.sakkinen@linux.intel.com/ and I had just calls to text_alloc() and text_free() in corresponding snippet to the above. I got this feedback from Mike: https://lore.kernel.org/lkml/20200718162359.GA2919062@kernel.org/ I'm not still sure that I fully understand this feedback as I don't see any inherent and obvious difference to the v4. In that version fallbacks are to module_alloc() and module_memfree() and text_alloc() and text_memfree() can be overridden by arch. > Thanks, > > Ingo /Jarkko