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 A1277C433E1 for ; Sat, 25 Jul 2020 03:19:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6C3D52070C for ; Sat, 25 Jul 2020 03:19:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C3D52070C 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 060946B002F; Fri, 24 Jul 2020 23:19:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00FD26B0031; Fri, 24 Jul 2020 23:19:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E902E8D0002; Fri, 24 Jul 2020 23:19:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id D37936B002F for ; Fri, 24 Jul 2020 23:19:23 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4F39E18404087 for ; Sat, 25 Jul 2020 03:19:23 +0000 (UTC) X-FDA: 77075142606.25.rod15_4f09e8626f4c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 222041840491E for ; Sat, 25 Jul 2020 03:19:23 +0000 (UTC) X-HE-Tag: rod15_4f09e8626f4c X-Filterd-Recvd-Size: 4527 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Sat, 25 Jul 2020 03:19:22 +0000 (UTC) IronPort-SDR: KHnYjuT3uZiRxaf+d7OGAXfpGA77AQeOTeOSfDl9dSuO4ly0mztO0Fg7ws8bEigQ2WNx1wFvbK QOOXftDVGEcg== X-IronPort-AV: E=McAfee;i="6000,8403,9692"; a="215387023" X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="215387023" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2020 20:19:19 -0700 IronPort-SDR: rF/DkQl54TI4Kf7+dlXHs3+a+C2DbqtD6D7pz5Fjiclb1b+Wq8Nd2Ee4WrJzgbyUzdgZM1Szvp tE+SJlCJ+m1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="363549309" Received: from jcrametz-mobl.ger.corp.intel.com (HELO localhost) ([10.252.58.73]) by orsmga001.jf.intel.com with ESMTP; 24 Jul 2020 20:19:13 -0700 Date: Sat, 25 Jul 2020 06:19:11 +0300 From: Jarkko Sakkinen To: Ard Biesheuvel Cc: Ingo Molnar , Linux Kernel Mailing List , linux-mm@kvack.org, Andi Kleen , Masami Hiramatsu , Peter Zijlstra , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jessica Yu Subject: Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free()] Message-ID: <20200725031911.GH17052@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: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Rspamd-Queue-Id: 222041840491E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 03:16:08PM +0300, Ard Biesheuvel wrote: > On Fri, 24 Jul 2020 at 12:27, 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... > > > > Also, as I attempted to explain before, there is no reason to allocate > kasan shadow for any of these use cases, so cloning module_alloc() to > implement text_alloc() is not the correct approach even on x86. > > I suppose module_alloc() could be reimplemented in terms of > text_alloc() in this case, but simply relabelling it like this seems > inappropriate on all architectures. I agree with this. Even if there was chance to do a merge of some kind, it should probably happen over time and accept some redundancy first. /Jarkko