Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp119051rwb; Tue, 27 Sep 2022 23:42:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4k1jTl6xZ1UgPWRJcyAGXVz2v7PqWC9Becv/6+UW+vRkr5pHxRteQLKPyqSzbJHxsxzFEj X-Received: by 2002:a05:6402:298e:b0:451:129e:1b35 with SMTP id eq14-20020a056402298e00b00451129e1b35mr31369065edb.79.1664347344802; Tue, 27 Sep 2022 23:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664347344; cv=none; d=google.com; s=arc-20160816; b=s7TxTIHE/JjQ1NVVRHpfLLnKHkmGhXOKMjLAeuPLmU0WRtTVbbsZbMb4tBp6P/H9lJ 5w8TML46QrD6toF2/DMgLhVsZa+IjP0lilV5+eOyh/UOez1hOTJLX1PCfJDzWhNLO4nI i2KIVoBrHsl18d/IQUiP4XXf96ipwq3QCpP3uXFeGi4Otgb7QOS8YL6l/4F0/GknM02q SdmP8UP0XxJRXRK9sbwQMKFhw8VD8lpPtmR+SmiXaRVQVpxRPbAoDR5+kGyhzA+CGZqo hbDRmq6mb7jmynRbPnsno+pFfwbR6CVtaSdz897sRceTPcBztAcODlrqjl3FOx5a+rpl 4NQg== 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 :message-id:date:subject:cc:to:from; bh=CSCmWqtVyUfVjKEcVf39y12OjtAgFmQ8LBHGvGyA9LM=; b=PIezbc+Ag73m3cQY8gVPhRCl0XRq5Wd284rAudZouRuFUgK484yEimklGA20y9M8T3 yyJ4nytl3JaLTVnNZ9SzXMgvKyfmvGDjUooJqNkgFbYrw9b9si74fbfbIxTabPSJOed/ 7aDe9JBSYTAItSXFk2sDloAuk23cAbPJWXQRPcmXrJ43lXRSmEhx9cYuUSDpQt2ceIs2 z9w8WwX0elYAM6YVIOyqQkKNKKFZeYFpBpW71Drffh4f7DI1YgHa0NXCkO+UByT0r/aO R8Kucmiw/fgCsDRCvElLRt3UUa1YY0RMJgUgVomP6MIgXmEPqp/6chXwLKgFiE45iAXy mNYA== 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 ht10-20020a170907608a00b00782b10a7ff3si3602155ejc.89.2022.09.27.23.41.59; Tue, 27 Sep 2022 23:42:24 -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 S233017AbiI1G3Z (ORCPT + 99 others); Wed, 28 Sep 2022 02:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232905AbiI1G3Y (ORCPT ); Wed, 28 Sep 2022 02:29:24 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A801EAD4E for ; Tue, 27 Sep 2022 23:29:20 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Mcmmb1CnWz9smH; Wed, 28 Sep 2022 08:29:19 +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 2mTkLnVdGBwG; Wed, 28 Sep 2022 08:29:19 +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 4Mcmmb0QNqz9sm8; Wed, 28 Sep 2022 08:29:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E55CA8B776; Wed, 28 Sep 2022 08:29:18 +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 G2sli3qU7am1; Wed, 28 Sep 2022 08:29:18 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.232.79]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B2D6C8B763; Wed, 28 Sep 2022 08:29:18 +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 28S6T81H420548 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Sep 2022 08:29:08 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 28S6T6A3420543; Wed, 28 Sep 2022 08:29:06 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/8xx: Simplify pte_update() with 16k pages Date: Wed, 28 Sep 2022 08:29:00 +0200 Message-Id: <65f76300de07091a59a042a3db2d0ce9b939a05c.1664346532.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1664346539; l=1661; s=20211009; h=from:subject:message-id; bh=Lr8XahhYObOfzO5oPsqbgqOUCyBYxfNYnveRrwOm2sU=; b=XzTB8nyhZpJHQBEnqrFzGfTYexL6o+RStqeFlKPBVi1IqgcLoqYAfrPab+bXLb/sOFwSWjFoexBA Ncpm+3UkCEJv/geDDdmspWD17TX3plxzB7ariBr4glrf3PH+Sup8 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 While looking at code generated for code patching, I saw that pte_clear generated: 2d8: 38 a0 00 00 li r5,0 2dc: 38 e0 10 00 li r7,4096 2e0: 39 00 20 00 li r8,8192 2e4: 39 40 30 00 li r10,12288 2e8: 90 a9 00 00 stw r5,0(r9) 2ec: 90 e9 00 04 stw r7,4(r9) 2f0: 91 09 00 08 stw r8,8(r9) 2f4: 91 49 00 0c stw r10,12(r9) With 16k pages, only the first entry is used by the kernel, so no need to adapt the address of other entries. Only duplicate the first entry for hardware. Now it is: 2cc: 39 40 00 00 li r10,0 2d0: 91 49 00 00 stw r10,0(r9) 2d4: 91 49 00 04 stw r10,4(r9) 2d8: 91 49 00 08 stw r10,8(r9) 2dc: 91 49 00 0c stw r10,12(r9) Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/nohash/32/pgtable.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h index 9091e4904a6b..981e414bdeef 100644 --- a/arch/powerpc/include/asm/nohash/32/pgtable.h +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -256,8 +256,14 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p num = number_of_cells_per_pte(pmd, new, huge); - for (i = 0; i < num; i++, entry++, new += SZ_4K) - *entry = new; + for (i = 0; i < num; i += PAGE_SIZE / SZ_4K, new += PAGE_SIZE) { + *entry++ = new; + if (IS_ENABLED(CONFIG_PPC_16K_PAGES) && num != 1) { + *entry++ = new; + *entry++ = new; + *entry++ = new; + } + } return old; } -- 2.37.1