From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Russell King <linux@armlinux.org.uk>,
Giulio Benetti <giulio.benetti@benettiengineering.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Russell King <rmk+kernel@armlinux.org.uk>,
Arnd Bergmann <arnd@arndb.de>, Will Deacon <will@kernel.org>
Subject: [PATCH v2 2/2] ARM: mm: convert empty_zero_page to array for consistency
Date: Wed, 19 Oct 2022 00:25:03 +0200 [thread overview]
Message-ID: <20221018222503.90118-2-giulio.benetti@benettiengineering.com> (raw)
In-Reply-To: <20221018222503.90118-1-giulio.benetti@benettiengineering.com>
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 <arnd@arndb.de>
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
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);
}
/*
--
2.34.1
next prev parent reply other threads:[~2022-10-18 22:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 22:25 [PATCH v2 1/2] ARM: mm: fix no-MMU ZERO_PAGE() implementation Giulio Benetti
2022-10-18 22:25 ` Giulio Benetti [this message]
2022-10-19 14:44 ` [PATCH v2 2/2] ARM: mm: convert empty_zero_page to array for consistency Russell King (Oracle)
2022-10-19 16:29 ` Giulio Benetti
2022-11-04 20:07 ` [PATCH v2 1/2] ARM: mm: fix no-MMU ZERO_PAGE() implementation Giulio Benetti
2022-11-04 20:28 ` Arnd Bergmann
2022-11-04 20:51 ` Giulio Benetti
2022-11-04 20:16 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221018222503.90118-2-giulio.benetti@benettiengineering.com \
--to=giulio.benetti@benettiengineering.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=rmk+kernel@armlinux.org.uk \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome