From patchwork Tue Oct 18 22:25:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 4348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp13430wrs; Tue, 18 Oct 2022 15:27:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44ZVhNLJZDFRgHH50Zr/DA6EzOY8y/hdOGLD5zHO51XvgX3XySydTmtMoxGoaeZYvx5Sba X-Received: by 2002:a17:906:ee81:b0:77e:829a:76e9 with SMTP id wt1-20020a170906ee8100b0077e829a76e9mr4455289ejb.207.1666132061340; Tue, 18 Oct 2022 15:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666132061; cv=none; d=google.com; s=arc-20160816; b=CY9ofkGNuOiEn5SEjTnUW1VppR+E55spPpwgmKDtk5rfPd8UE/GbqHvEjQI5K/KeS9 5y36fjrLIoTUys9i2p24UR1MoxdNlRqKvk2rirFHTCvZg4q4qd0vN20ikRMfSYjzJ9nC y90FrJw1GxOn2/X0iNoOIAKL6JSTFby2Kg/WgtXIBc4IG8cd3TblsOcKeuU0pIkWq7Lz 9VJ3K2hogtofRAndF47cJYB43NR7ceMLHI/OhUG8RSUI3sFOhPnTTjqEhonz99cZRWam qNJCb1Rtulfly2o0w3ro0vv5di9kXpQ1O04oi8LT+pLqxBdgF1BWo2lVZu5+VXwO+uls Pd7Q== 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 :dkim-signature; bh=YYCYL+xhswx1j5PQYBQO66vrNS6Fdt5zXqgAgZhDftk=; b=jxYO+H4jf68nrtLt6CcEnT7hGJOACNuwSnY84uQogMIkEFrcUDJxi5BYO381wKNMa7 Wh571/2zY4IpCH9FIsPBuEnTeLV9vL9uIsr4vTg2WT5F3OR90c/jD+7IUxnlSwwoIUa4 kb7Fgu+Xu+fuKOKZzF6cdcKc+DT6liYPZ3LKfa7TSpwXtsiwMW9Z6wpVKXxJbfiL5DAL SfBI0UU6iEQKs20ASB9+a0hZ5I2ilfopT9qz/R4dESU2aPMe3z/Epd90izBHKHRfMfAu QblUIU4yqp4Vyhc1p9OvL6L9RGkz0oDGGdco8Z5p3AbKsniX3lRyOraLGyYdgoaptlqy Ebcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=Ud6pBCkO; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a17090630ce00b00782da4ff18dsi11318338ejb.668.2022.10.18.15.27.06; Tue, 18 Oct 2022 15:27:41 -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; dkim=pass header.i=@aruba.it header.s=a1 header.b=Ud6pBCkO; 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 S229929AbiJRWZZ (ORCPT + 99 others); Tue, 18 Oct 2022 18:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbiJRWZM (ORCPT ); Tue, 18 Oct 2022 18:25:12 -0400 Received: from smtpcmd0987.aruba.it (smtpcmd0987.aruba.it [62.149.156.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 605F84AD4F for ; Tue, 18 Oct 2022 15:25:08 -0700 (PDT) Received: from localhost.localdomain ([146.241.87.206]) by Aruba Outgoing Smtp with ESMTPSA id kv1EovliYaWj1kv1HoELBg; Wed, 19 Oct 2022 00:25:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1666131907; bh=G21UWZTIRbOHhkWY/cfvy0aqZyPYcJqojzWjie6A3oY=; h=From:To:Subject:Date:MIME-Version; b=Ud6pBCkOhW9bvos1H1dj4qs8CCcCVVIt69Nxys7taT6ylik0WXRGxKFSJxG8sYeUf JbJMIBUYCt1jkpq3lcR57QYVfTl5gTurPUNuelLPh6ymK5jj35Mb9d3JMLGZn55sOY 3XwP95JCvof1pl5GjeXqt204+FvRC3Xwre65boVIoMMF2NnWbTdwjnbwDd7HejtON4 bXM0GF57lBL3PIjwRtKUIqJRu9u8SUQ/R3McRIvSt/tLNAROw3TIS3g4W0+H7hFz0f E8GGWftaxRtwmbrGvtPZeCYvhUfjaz7EBNJdswcgwuMxmjYPQ3k8N49qdL4J8JdMnq YcYCx1oBvw2KA== From: Giulio Benetti To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Russell King , Giulio Benetti , Anshuman Khandual , Andrew Morton , Kefeng Wang , Russell King , Arnd Bergmann , Will Deacon Subject: [PATCH v2 2/2] ARM: mm: convert empty_zero_page to array for consistency Date: Wed, 19 Oct 2022 00:25:03 +0200 Message-Id: <20221018222503.90118-2-giulio.benetti@benettiengineering.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018222503.90118-1-giulio.benetti@benettiengineering.com> References: <20221018222503.90118-1-giulio.benetti@benettiengineering.com> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfPZlKIhA9QmVEJg8TyQBw3iOkBHZPOM6fAPP7UVSbA59v5ex4MI480bxgNdmo8uHnNiksDWqvpGUvjzux5YgGrteQPR5O48noLtBaTn1TidfdU+mLXi/ FFtW/XkJQDDRzYNqBcP6279UyKprwgLo3h5hGUB2sfHoYxuhC8MpaLZy9WTMmtwSsSBHv/Wa19QXWDMy9MWX7lGH862VbgubxMzq55a3PtL4HadLBBpjxxPf MzfXXUphB7jB5T7JVxZf9Nl6/ch6X3KpE3T00QtMyr1EJm9ATRYwfOYkkmMhx3Dha4DBBMJlVD7ClieCQKKu5XfjYGeLYjfl0mFtha9uUEM6KtvVaP4d/JZ+ LxiNlwaXaEeQ017keBant8uTh5J4txIvAB/z4TrTLyC18pEZfkAu3ubfDF6iL24AIdyF/LrA8FatnhlM+m6MpMezt0V9n1U0lOAcCBep2+a7US/j/iQZFlBu G1V7fNAJTLTe2e8Cb87lLxqv+3TCOnUYs5NaKR9GsYQ1T7a1ZgR5r7FGMAIA9TyC8LNCvSvzohoUY3KTmTbA5Vvmz7gJYU9dnnhVKhfUrRihsYgNRMgSg6D0 38s= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747066092218217101?= X-GMAIL-MSGID: =?utf-8?q?1747066092218217101?= ARM architecture is the only one to have empty_zero_page to be a struct page pointer, while in all other implementations empty_zero_page is a data pointer or directly an array(the zero page itself). So let's convert empty_zero_page to an array for consistency and to avoid an early allocation+dcache flush. Being the array in .bss it will be cleared earlier in a more linear way(and a bit faster) way. Suggested-by: Arnd Bergmann Signed-off-by: Giulio Benetti --- V1->V2: * create patch suggested by Arnd Bergmann --- arch/arm/include/asm/pgtable.h | 4 ++-- arch/arm/mm/mmu.c | 10 +--------- arch/arm/mm/nommu.c | 14 +------------- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index ef48a55e9af8..de402b345f55 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -15,8 +15,8 @@ * ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -extern struct page *empty_zero_page; -#define ZERO_PAGE(vaddr) (empty_zero_page) +extern unsigned long empty_zero_page[]; +#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) #endif #ifndef CONFIG_MMU diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 463fc2a8448f..f05a5471a45a 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -45,7 +45,7 @@ extern unsigned long __atags_pointer; * empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss; EXPORT_SYMBOL(empty_zero_page); /* @@ -1760,8 +1760,6 @@ static void __init early_fixmap_shutdown(void) */ void __init paging_init(const struct machine_desc *mdesc) { - void *zero_page; - pr_debug("physical kernel sections: 0x%08llx-0x%08llx\n", kernel_sec_start, kernel_sec_end); @@ -1782,13 +1780,7 @@ void __init paging_init(const struct machine_desc *mdesc) top_pmd = pmd_off_k(0xffff0000); - /* allocate the zero page. */ - zero_page = early_alloc(PAGE_SIZE); - bootmem_init(); - - empty_zero_page = virt_to_page(zero_page); - __flush_dcache_page(NULL, empty_zero_page); } void __init early_mm_init(const struct machine_desc *mdesc) diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index c1494a4dee25..e0c3f59d1c5a 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -30,7 +30,7 @@ unsigned long vectors_base; * empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss; EXPORT_SYMBOL(empty_zero_page); #ifdef CONFIG_ARM_MPU @@ -155,21 +155,9 @@ void __init adjust_lowmem_bounds(void) */ void __init paging_init(const struct machine_desc *mdesc) { - void *zero_page; - early_trap_init((void *)vectors_base); mpu_setup(); - - /* allocate the zero page. */ - zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); - if (!zero_page) - panic("%s: Failed to allocate %lu bytes align=0x%lx\n", - __func__, PAGE_SIZE, PAGE_SIZE); - bootmem_init(); - - empty_zero_page = virt_to_page(zero_page); - flush_dcache_page(empty_zero_page); } /*