s390/cmma: move arch_set_page_dat() to header file
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 27 Oct 2023 12:12:38 +0000 (14:12 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Sun, 5 Nov 2023 21:34:58 +0000 (22:34 +0100)
In order to be usable for early boot code move the simple
arch_set_page_dat() function to header file, and add its counter-part
arch_set_page_nodat(). Also change the parameters, and the function name
slightly.

This is required since there aren't any struct pages available in early
boot code, and renaming of functions is done to make sure that all users
are converted to the new API.

Instead of a pointer to a struct page a virtual address is passed, and
instead of an order the number of pages for which the page state needs be
set.

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/page-states.h
arch/s390/include/asm/page.h
arch/s390/mm/gmap.c
arch/s390/mm/page-states.c
arch/s390/mm/pgalloc.c
arch/s390/mm/vmem.c

index 1eae404..08fcbd6 100644 (file)
@@ -60,4 +60,21 @@ static inline void __set_page_stable_nodat(void *addr, unsigned long num_pages)
        __set_page_state(addr, num_pages, ESSA_SET_STABLE_NODAT);
 }
 
+static inline void __arch_set_page_nodat(void *addr, unsigned long num_pages)
+{
+       if (!cmma_flag)
+               return;
+       if (cmma_flag < 2)
+               __set_page_stable_dat(addr, num_pages);
+       else
+               __set_page_stable_nodat(addr, num_pages);
+}
+
+static inline void __arch_set_page_dat(void *addr, unsigned long num_pages)
+{
+       if (!cmma_flag)
+               return;
+       __set_page_stable_dat(addr, num_pages);
+}
+
 #endif
index cfec074..73b9c3b 100644 (file)
@@ -164,7 +164,6 @@ static inline int page_reset_referenced(unsigned long addr)
 struct page;
 void arch_free_page(struct page *page, int order);
 void arch_alloc_page(struct page *page, int order);
-void arch_set_page_dat(struct page *page, int order);
 
 static inline int devmem_is_allowed(unsigned long pfn)
 {
index 20786f6..6f96b5a 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/ksm.h>
 #include <linux/mman.h>
 #include <linux/pgtable.h>
-
+#include <asm/page-states.h>
 #include <asm/pgalloc.h>
 #include <asm/gmap.h>
 #include <asm/page.h>
@@ -33,7 +33,7 @@ static struct page *gmap_alloc_crst(void)
        page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
        if (!page)
                return NULL;
-       arch_set_page_dat(page, CRST_ALLOC_ORDER);
+       __arch_set_page_dat(page_to_virt(page), 1UL << CRST_ALLOC_ORDER);
        return page;
 }
 
index 7dc75dd..511c43a 100644 (file)
@@ -153,10 +153,3 @@ void arch_alloc_page(struct page *page, int order)
        else
                __set_page_stable_nodat(page_to_virt(page), 1UL << order);
 }
-
-void arch_set_page_dat(struct page *page, int order)
-{
-       if (!cmma_flag)
-               return;
-       __set_page_stable_dat(page_to_virt(page), 1UL << order);
-}
index 15f6a3e..e7f0dee 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <asm/mmu_context.h>
+#include <asm/page-states.h>
 #include <asm/pgalloc.h>
 #include <asm/gmap.h>
 #include <asm/tlb.h>
@@ -43,11 +44,13 @@ __initcall(page_table_register_sysctl);
 unsigned long *crst_table_alloc(struct mm_struct *mm)
 {
        struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, CRST_ALLOC_ORDER);
+       unsigned long *table;
 
        if (!ptdesc)
                return NULL;
-       arch_set_page_dat(ptdesc_page(ptdesc), CRST_ALLOC_ORDER);
-       return (unsigned long *) ptdesc_to_virt(ptdesc);
+       table = ptdesc_to_virt(ptdesc);
+       __arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER);
+       return table;
 }
 
 void crst_table_free(struct mm_struct *mm, unsigned long *table)
@@ -145,7 +148,7 @@ struct page *page_table_alloc_pgste(struct mm_struct *mm)
        ptdesc = pagetable_alloc(GFP_KERNEL, 0);
        if (ptdesc) {
                table = (u64 *)ptdesc_to_virt(ptdesc);
-               arch_set_page_dat(virt_to_page(table), 0);
+               __arch_set_page_dat(table, 1);
                memset64(table, _PAGE_INVALID, PTRS_PER_PTE);
                memset64(table + PTRS_PER_PTE, 0, PTRS_PER_PTE);
        }
@@ -285,9 +288,9 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
                pagetable_free(ptdesc);
                return NULL;
        }
-       arch_set_page_dat(ptdesc_page(ptdesc), 0);
        /* Initialize page table */
-       table = (unsigned long *) ptdesc_to_virt(ptdesc);
+       table = ptdesc_to_virt(ptdesc);
+       __arch_set_page_dat(table, 1);
        if (mm_alloc_pgste(mm)) {
                /* Return 4K page table with PGSTEs */
                INIT_LIST_HEAD(&ptdesc->pt_list);
index 2e8a106..b139907 100644 (file)
@@ -51,7 +51,7 @@ void *vmem_crst_alloc(unsigned long val)
                return NULL;
        crst_table_init(table, val);
        if (slab_is_available())
-               arch_set_page_dat(virt_to_page(table), CRST_ALLOC_ORDER);
+               __arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER);
        return table;
 }