Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2242327ybh; Fri, 24 Jul 2020 07:58:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVRd+w4TrQ8xps8jvzKEdP3Z+cd+OimT/KjkKiRT7EgEl6ZIRc1w0zFnxiJmnFQTyjOGx2 X-Received: by 2002:a05:6402:8d6:: with SMTP id d22mr2286525edz.285.1595602685278; Fri, 24 Jul 2020 07:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595602685; cv=none; d=google.com; s=arc-20160816; b=Bmj97/0Oq5YVEeu7ZZGGi0l601VgL/eGo3MwThBV4Lq5yoBm4xi3yx3aA7h0v/RMNw fkp4GZp9RDGFO6ZKWCK7lkJC6EpY6Ea3KHttmqLv/DggO3MJOZLaO9O7J09uj5vJ+rPD jRSKIZqMS8QB86A6xMaeGbFFWyristPn+oFRQuOA3Ct5fsGyEMC87C7mirTF5FkK3Mi8 VunfVfV5DyI2WI6B5+AqKRKwCe3V6WDNs3XFQbbwZ8W1tNlxt8G/b7FU297EO44uOp3L Dy9HHPnmOjIsHQweM+1R51PXnBBngil926yQ4rdBQBfRt2519E9A2M3QGbTXGYPgyBY7 qerw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=PHtF4450KoZG3aSa4k09/J+sMGsSnDi6bJ28FldZy4A=; b=DnoIcGaenxGc2epccsVFJlccPZGzXNl5UPbxWS7vmOCNjKpoGbmQcRPQ0IDOuX6eiB 0iqIiZdp1sO2HyNo4j3E7FdtljOW/3uyvsWfxJ5wMznfWGqnnsPx2PExN/d13jvLPUzq fWgS9ulY08dISweL3C4lkc9PjzSY7h2xR++o0P1wd7y+dwDwRGUYiuASUdM89DVvgkcA zuFvLXT69oHUQBNwQqdI/teQieu4/akezWxgwl5HNY0zAkGbPymg9jvuwTZC7Qy88k/b c0Nn5gqj/l3quQzm5ALYBWSAn0P8PihJLacqnXmi6LjgAqIoRJyTNqWqS9wT00eehFh8 dnVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="crC5S/FG"; 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 d23si719917ejz.145.2020.07.24.07.57.43; Fri, 24 Jul 2020 07:58:05 -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=pass header.i=@kernel.org header.s=default header.b="crC5S/FG"; 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 S1726717AbgGXO5Y (ORCPT + 99 others); Fri, 24 Jul 2020 10:57:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:36758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbgGXO5Y (ORCPT ); Fri, 24 Jul 2020 10:57:24 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4FF1B206D8; Fri, 24 Jul 2020 14:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595602643; bh=UAvrshxQEJ0Ykt7yvu37iIenplAoYeh9Ny04iEuSMGc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=crC5S/FGJPAWRBT9ywxQN/+7BmOHwIP6uS8JJxRhcF24ZZFiW7/n6ooDey+u2lHjL +Z9LNEz5VWQTMMlZj1QTz5KdYzPnqSv2afZS3EfbTpgwlcwuhYfMhXRAFfWIaJO64+ 9jnMvXCY8vIBQoQCZnMZtHvWrU031I+B42EQBeu0= Date: Fri, 24 Jul 2020 23:57:19 +0900 From: Masami Hiramatsu To: Mike Rapoport Cc: Jarkko Sakkinen , 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: <20200724235719.a64952a8a92a42db9ea0cd94@kernel.org> In-Reply-To: <20200724102748.GD2831654@kernel.org> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-6-jarkko.sakkinen@linux.intel.com> <20200724102748.GD2831654@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Jul 2020 13:27:48 +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. No, we can't use module_alloc/memfree() without CONFIG_MODULES, so we can not escape from this #ifdefs. (and I think this is not so bad.) Thank you, -- Masami Hiramatsu