From patchwork Thu Jul 27 15:31:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13330306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77F69C001DC for ; Thu, 27 Jul 2023 15:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rjITNHlt53WAeZ3INDJ1Kc9upMSY32fUxhXRSTRx6+s=; b=ytkJd+lnsNvgC8 uNWBSgjsY7K8VhL9+U2HnObgqpuUQlCtRAs5kwLjjtHqOTuhaxLwZ9KpErWTje7dJteikcaaKgj80 /PFJVZeiyQbUvwO8XdLDioCvXe8vCFy2TxUUoxdnt9sWR/9vGFdLE39+Vpxq73QcLabBlxlOifsTZ PT0huKl4nuujmNM43QbVRm/w50fkvKXgIRX3TiBdfS5WRU/aXNHf++kvBdceml/2pHEHnNfbtzrhO Je5I80/Z1OZgYPgK9o3egT8FIJ5gkM/IeVaee/SzpJkoZIo6KuHIOd4G2a4RyB/cVZqURZ39oxwgg a4HY5wi/hRkh61/2o3MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qP2xa-00FvJT-1n; Thu, 27 Jul 2023 15:31:26 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qP2xQ-00Fv85-0F for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2023 15:31:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=w3WzY4I9PxfqVxgI2q1t7Icd6Vj1ik9I7ne5m3k+cAI=; b=hK09aIoxoOrzdtLHG39/OOSptn Lc0WX0s+CRjPQnAcGAQ8hOgN0Z2Akvhtxrh9WHA9TmjcSMZV6w+Mi6YgBNYWTiPRLwAg02juWgbGY 1EMVKvzKZbzHQQg/qnTua5LOC054uv3mdENvkbPn8LUtW7biwQIukrSbeNq393OlF+IMI3i1FvYWq jUX25jPuSXc2e2WAqho0x518WbphFq8QDcxDXP2F4mkfgjGRQ3UWBlX50SdZ0T8vzIJ0pQ4jYt1v8 9WA4Fbs2EicKuMPAKURj6Ta5kD+nv+yPRRY6bzkDPhFduNuedS5MwYqDqavoreUaALV90eqmFqPFA gIhqSc1A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48400 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qP2xM-00065K-21; Thu, 27 Jul 2023 16:31:13 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qP2xM-001CYM-Mq; Thu, 27 Jul 2023 16:31:12 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Catalin Marinas , Jonathan Corbet , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org Subject: [PATCH v2 15/16] arm64: text replication: early kernel option to enable replication MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Jul 2023 16:31:12 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230727_083116_254835_2EFD8AF5 X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide an early kernel option "ktext=" which allows the kernel text replication to be enabled. This takes a boolean argument. The way this has been implemented means that we take all the same paths through the kernel at runtime whether kernel text replication has been enabled or not; this allows the performance effects of the code changes to be evaluated separately from the act of running with replicating the kernel text. Signed-off-by: Russell King (Oracle) --- .../admin-guide/kernel-parameters.txt | 5 +++++ arch/arm64/mm/ktext.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index a1457995fd41..ceb351a6ff2a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2494,6 +2494,11 @@ 0: force disabled 1: force enabled + ktext= [ARM64] Control kernel text replication on NUMA + machines. Default: disabled. + 0: disable kernel text replication + 1: enable kernel text replication + kunit.enable= [KUNIT] Enable executing KUnit tests. Requires CONFIG_KUNIT to be set to be fully enabled. The default value can be overridden via diff --git a/arch/arm64/mm/ktext.c b/arch/arm64/mm/ktext.c index 6265a2db449b..f5580ae14ca4 100644 --- a/arch/arm64/mm/ktext.c +++ b/arch/arm64/mm/ktext.c @@ -98,6 +98,21 @@ void ktext_replication_patch_alternative(__le32 *src, int nr_inst) } } +static bool ktext_enabled; + +static int __init parse_ktext(char *str) +{ + bool enabled; + int ret = strtobool(str, &enabled); + + if (ret) + return ret; + + ktext_enabled = enabled; + return 0; +} +early_param("ktext", parse_ktext); + /* Allocate page tables and memory for the replicated kernel texts. */ void __init ktext_replication_init(void) { @@ -119,6 +134,9 @@ void __init ktext_replication_init(void) return; } + if (!ktext_enabled) + return; + for_each_node(nid) { /* Nothing to do for node 0 */ if (!nid)