Skip to content

Commit 0921af6

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: Use static defined zero page rather than allocated
On LoongArch system, there is only one page needed for zero page (no cache synonyms), and there is no COLOR_ZERO_PAGE, so zero_page_mask is useless and the macro __HAVE_COLOR_ZERO_PAGE is not necessary. Like other popular architectures, It is simpler to define the zero page in kernel BSS code segment rather than dynamically allocate. Signed-off-by: Bibo Mao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 2bb20d2 commit 0921af6

File tree

4 files changed

+3
-35
lines changed

4 files changed

+3
-35
lines changed

arch/loongarch/include/asm/mmzone.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ extern struct pglist_data *node_data[];
1313

1414
#define NODE_DATA(nid) (node_data[(nid)])
1515

16-
extern void setup_zero_pages(void);
17-
1816
#endif /* _ASM_MMZONE_H_ */

arch/loongarch/include/asm/pgtable.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,9 @@ struct vm_area_struct;
7070
* for zero-mapped memory areas etc..
7171
*/
7272

73-
extern unsigned long empty_zero_page;
74-
extern unsigned long zero_page_mask;
73+
extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
7574

76-
#define ZERO_PAGE(vaddr) \
77-
(virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
78-
#define __HAVE_COLOR_ZERO_PAGE
75+
#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
7976

8077
/*
8178
* TLB refill handlers may also map the vmalloc area into xkvrange.

arch/loongarch/kernel/numa.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ void __init mem_init(void)
438438
{
439439
high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
440440
memblock_free_all();
441-
setup_zero_pages(); /* This comes from node 0 */
442441
}
443442

444443
int pcibus_to_node(struct pci_bus *bus)

arch/loongarch/mm/init.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,8 @@
3535
#include <asm/pgalloc.h>
3636
#include <asm/tlb.h>
3737

38-
/*
39-
* We have up to 8 empty zeroed pages so we can map one of the right colour
40-
* when needed. Since page is never written to after the initialization we
41-
* don't have to care about aliases on other CPUs.
42-
*/
43-
unsigned long empty_zero_page, zero_page_mask;
38+
unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
4439
EXPORT_SYMBOL(empty_zero_page);
45-
EXPORT_SYMBOL(zero_page_mask);
46-
47-
void setup_zero_pages(void)
48-
{
49-
unsigned int order, i;
50-
struct page *page;
51-
52-
order = 0;
53-
54-
empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
55-
if (!empty_zero_page)
56-
panic("Oh boy, that early out of memory?");
57-
58-
page = virt_to_page((void *)empty_zero_page);
59-
split_page(page, order);
60-
for (i = 0; i < (1 << order); i++, page++)
61-
mark_page_reserved(page);
62-
63-
zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
64-
}
6540

6641
void copy_user_highpage(struct page *to, struct page *from,
6742
unsigned long vaddr, struct vm_area_struct *vma)
@@ -106,7 +81,6 @@ void __init mem_init(void)
10681
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
10782

10883
memblock_free_all();
109-
setup_zero_pages(); /* Setup zeroed pages. */
11084
}
11185
#endif /* !CONFIG_NUMA */
11286

0 commit comments

Comments
 (0)