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 1eae4046c07dd68c7ba8ba4494e8ef4a461d76ff..08fcbd6281208ef89151f4dbcd41737270b9a56e 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 cfec0743314eaa507999c36fe346d84fdbe0f95d..73b9c3bf377f886411b687992024217e4371e08b 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 20786f6883b299f1af02411b7e8dc2151e762433..6f96b5a71c6383d07eb447cb80df70214bdd1910 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 7dc75dd05f48f5d7352b3789d390e5ca8c6e7762..511c43aad5dfbf0a4791c767f7c3c19ae548f9c2 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 15f6a3ef40e8d85956671864afdc335bf48b186d..e7f0deef71c7cf430e7c7e324657842eb104a509 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 2e8a1064f103ace6d861016aa521e16239dd9738..b13990776fae3ac5f74840c7c1be21700f4a8af5 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;
 }