Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1094840rwb; Tue, 27 Sep 2022 08:20:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM575D8fxsqd6hiS6qB7nL3N14Z0C3/0VdOMwqOrD45FK3WaatFD2jGv0YXjqx9ZTNFMN3/I X-Received: by 2002:a05:6a00:d60:b0:53e:576e:bd8c with SMTP id n32-20020a056a000d6000b0053e576ebd8cmr30336062pfv.4.1664292038864; Tue, 27 Sep 2022 08:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664292038; cv=none; d=google.com; s=arc-20160816; b=zp/5Xz4sVlLLgEWkyXCXEkSGUTDwGrHE0iQ2laaSxRXaJmdT7YJUzM2jJ436isqDg+ HdhhLEvVCYzhKsdRu3sYd+NabvvkhUnxgqIyMHOLpvRCy7KEJLRMcRs4yBhVa7hra2kO dupG3Y7FKEb0i4NPxWljHCjOUYTKRj6Y1ZjO0txgUKX2GJA8aGXiUx/3H3Y6vuRdRatj YqRo2arR3V/pfw4M+LrTjW6//wAHYresvRlv3NuW4ZyJyOuywAPoRxeAVnxk1Up8f2HF POg+G2kQYhAlIn4h9cqJ8N9/2BItK0qRxcc1rUYbIpDPd3Si3aXSYg7JHILzHX+W0FDJ DPqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fRIV/bVDi7Gso3Ll6UAjqQjEjOYh1jsfGgaEmzvFs4g=; b=AeyA+ec/fM6vFdf91355It/+crs25nIbo95xh4eng0zCqkZUo9NKBwfCfupo/DFrMP a4nHo3n2LwEkKTqlZBsSACKi/qEIwhIgBNnvInJ8cDxNsVfZ1BR4/tFBPpLjwHqOCjXC nkTkmpuH39NZAOXrwY7vBXjXx3PPv6fKNrAS/CGUaPHhmY3d0gMqvtUsVeOs8SCykK9N BgikU6+JvlBkBr9lV5I7M01FjdJSzOylksws4VmVQVQeGnubtdW23hwkEijIUzvhqxCD ZLdXuOIEz/kmagks3OvIOVZpLMDa7RmzKNzzO8UA/UfV6noR/PSjzTY38B7LzegOf9s/ 0Q0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a636206000000b00439fbc1b5absi2086797pgb.797.2022.09.27.08.20.25; Tue, 27 Sep 2022 08:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232974AbiI0Ogc (ORCPT + 99 others); Tue, 27 Sep 2022 10:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233135AbiI0Oe4 (ORCPT ); Tue, 27 Sep 2022 10:34:56 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C1B52FD8 for ; Tue, 27 Sep 2022 07:33:47 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4McMYk0fN4z9snl; Tue, 27 Sep 2022 16:33:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id biIyK2QFn12v; Tue, 27 Sep 2022 16:33:30 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4McMYh2f3Bz9sp2; Tue, 27 Sep 2022 16:33:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 497AF8B77A; Tue, 27 Sep 2022 16:33:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id L6VIRAJnhDY4; Tue, 27 Sep 2022 16:33:28 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.232.35]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D0DF08B763; Tue, 27 Sep 2022 16:33:27 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 28REXGNI351152 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Sep 2022 16:33:16 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 28REXG2x351151; Tue, 27 Sep 2022 16:33:16 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Benjamin Gray , Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v1 1/6] powerpc/code-patching: Use pte_offset_kernel() instead of virt_to_kpte() Date: Tue, 27 Sep 2022 16:33:03 +0200 Message-Id: X-Mailer: git-send-email 2.37.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1664289185; l=1173; s=20211009; h=from:subject:message-id; bh=TJVSTY+u+eC9uArZy9PxzVn61RI81XijmNXf2efdcos=; b=08CC8l68eApcHJPLy8Uoi3pBgKeJMQt7S/0XYtHT5hyjeQHdPw5dydIjDArIGHqKtojqoVA+Xgzg oUVdU+sJDHtK33eq+EIDnzFKzOt0PawN6ufwTE4NyUYdA/GP3QKt X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org virt_to_kpte() checks pmd_none() and returns NULL in that case. __do_patch_instruction() doesn't expect the pmd to be none and doesn't handle the case anyway. So avoid the pmd_none() check by using pte_offset_kernel() directly. It improves ftrace activation by approx 1% on an 8xx. Signed-off-by: Christophe Leroy --- arch/powerpc/lib/code-patching.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index ad0cf3108dd0..0f3acb0534b6 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -158,7 +158,7 @@ static int __do_patch_instruction(u32 *addr, ppc_inst_t instr) text_poke_addr = (unsigned long)__this_cpu_read(text_poke_area)->addr & PAGE_MASK; patch_addr = (u32 *)(text_poke_addr + offset_in_page(addr)); - pte = virt_to_kpte(text_poke_addr); + pte = pte_offset_kernel(pmd_off_k(text_poke_addr), text_poke_addr); __set_pte_at(&init_mm, text_poke_addr, pte, pfn_pte(pfn, PAGE_KERNEL), 0); /* See ptesync comment in radix__set_pte_at() */ if (radix_enabled()) -- 2.37.1