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=-10.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 DEE16C433F4 for ; Fri, 24 Jul 2020 23:38:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB49E20737 for ; Fri, 24 Jul 2020 23:38:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB49E20737 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 4ABBA8D0005; Fri, 24 Jul 2020 19:38:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45BD08D0003; Fri, 24 Jul 2020 19:38:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 372668D0005; Fri, 24 Jul 2020 19:38:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 2142E8D0003 for ; Fri, 24 Jul 2020 19:38:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D2B42180998C1 for ; Fri, 24 Jul 2020 23:38:54 +0000 (UTC) X-FDA: 77074586988.09.iron03_2e07d7826f4b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id B34D018001176 for ; Fri, 24 Jul 2020 23:38:54 +0000 (UTC) X-HE-Tag: iron03_2e07d7826f4b X-Filterd-Recvd-Size: 3721 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Jul 2020 23:38:53 +0000 (UTC) IronPort-SDR: JYB0E+gr5mMKVdzb8jJYhLoF0aUVa7K1Zsf03G/tzkAcwFG5coHISqf7HcWiEkkFQl2f1HZiEf Nl6lIyt0D/qQ== X-IronPort-AV: E=McAfee;i="6000,8403,9692"; a="138308825" X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="138308825" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2020 16:38:50 -0700 IronPort-SDR: FHY2QQkrnx0GfAGNW9L2qgado7yMVapEjpsegNmidntYGOZEDhGLPi0Y8c41n6UXiBarj0ycdG zyYD4SMfVQ3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="463392443" Received: from assenmac-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.38.15]) by orsmga005.jf.intel.com with ESMTP; 24 Jul 2020 16:38:46 -0700 Date: Sat, 25 Jul 2020 02:38:45 +0300 From: Jarkko Sakkinen To: Mike Rapoport 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" Subject: Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free() Message-ID: <20200724233845.GB1903189@linux.intel.com> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-6-jarkko.sakkinen@linux.intel.com> <20200724102748.GD2831654@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200724102748.GD2831654@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Rspamd-Queue-Id: B34D018001176 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 01:27:48PM +0300, Mike Rapoport wrote: > On Fri, Jul 24, 2020 at 08:05:52AM +0300, 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 > > } > > Both alloc_insn_page() and free_insn_page() are __weak and can be simple > overriden in arch/x86 code. That is correct, but the override is obviously happening at linking time. module_alloc() and module_memfree() will still leave a compile time dependency to CONFIG_MODULES. /Jarkko