]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: rework accept memory helpers
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Fri, 9 Aug 2024 11:48:51 +0000 (14:48 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 17 Aug 2024 00:53:07 +0000 (17:53 -0700)
Make accept_memory() and range_contains_unaccepted_memory() take 'start'
and 'size' arguments instead of 'start' and 'end'.

Remove accept_page(), replacing it with direct calls to accept_memory().
The accept_page() name is going to be used for a different function.

Link: https://lkml.kernel.org/r/20240809114854.3745464-6-kirill.shutemov@linux.intel.com
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Suggested-by: David Hildenbrand <david@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/x86/boot/compressed/misc.c
arch/x86/boot/compressed/misc.h
drivers/firmware/efi/libstub/efistub.h
drivers/firmware/efi/libstub/unaccepted_memory.c
drivers/firmware/efi/unaccepted_memory.c
include/linux/mm.h
mm/memblock.c
mm/mm_init.c
mm/page_alloc.c
tools/testing/memblock/internal.h

index 944454306ef408ab74f8b7bd620928606e2345fe..04a35b2c26e9be271b1bbe58fbbf8d38a13b1796 100644 (file)
@@ -511,7 +511,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)
 
        if (init_unaccepted_memory()) {
                debug_putstr("Accepting memory... ");
-               accept_memory(__pa(output), __pa(output) + needed_size);
+               accept_memory(__pa(output), needed_size);
        }
 
        entry_offset = decompress_kernel(output, virt_addr, error);
index b353a7be380cb83608cd24067e418d7e7934d1a8..dd8d1a85f6716a2e23a3e74ddd2044f106a93ad8 100644 (file)
@@ -256,6 +256,6 @@ static inline bool init_unaccepted_memory(void) { return false; }
 
 /* Defined in EFI stub */
 extern struct efi_unaccepted_memory *unaccepted_table;
-void accept_memory(phys_addr_t start, phys_addr_t end);
+void accept_memory(phys_addr_t start, unsigned long size);
 
 #endif /* BOOT_COMPRESSED_MISC_H */
index d33ccbc4a2c630a8a8c5fe9ef90b0483eda4e65a..685098f9626f2b8cad9f4f4b33258e03ef741160 100644 (file)
@@ -1229,7 +1229,7 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab);
 efi_status_t allocate_unaccepted_bitmap(__u32 nr_desc,
                                        struct efi_boot_memmap *map);
 void process_unaccepted_memory(u64 start, u64 end);
-void accept_memory(phys_addr_t start, phys_addr_t end);
+void accept_memory(phys_addr_t start, unsigned long size);
 void arch_accept_memory(phys_addr_t start, phys_addr_t end);
 
 #endif
index c295ea3a6efc3703cba84de858c033dbaa0e549c..757dbe734a47afbdf189cf057af366eb1b51f15e 100644 (file)
@@ -177,9 +177,10 @@ void process_unaccepted_memory(u64 start, u64 end)
                   start / unit_size, (end - start) / unit_size);
 }
 
-void accept_memory(phys_addr_t start, phys_addr_t end)
+void accept_memory(phys_addr_t start, unsigned long size)
 {
        unsigned long range_start, range_end;
+       phys_addr_t end = start + size;
        unsigned long bitmap_size;
        u64 unit_size;
 
index 50f6503fe49f5e44474b99a1cc53edf0fa97d283..c2c067eff6345450f8630f0ef457baf5d0cec6e7 100644 (file)
@@ -30,11 +30,12 @@ static LIST_HEAD(accepting_list);
  *  - memory that is below phys_base;
  *  - memory that is above the memory that addressable by the bitmap;
  */
-void accept_memory(phys_addr_t start, phys_addr_t end)
+void accept_memory(phys_addr_t start, unsigned long size)
 {
        struct efi_unaccepted_memory *unaccepted;
        unsigned long range_start, range_end;
        struct accept_range range, *entry;
+       phys_addr_t end = start + size;
        unsigned long flags;
        u64 unit_size;
 
@@ -74,13 +75,13 @@ void accept_memory(phys_addr_t start, phys_addr_t end)
         * "guard" page is accepted in addition to the memory that needs to be
         * used:
         *
-        * 1. Implicitly extend the range_contains_unaccepted_memory(start, end)
-        *    checks up to end+unit_size if 'end' is aligned on a unit_size
-        *    boundary.
+        * 1. Implicitly extend the range_contains_unaccepted_memory(start, size)
+        *    checks up to the next unit_size if 'start+size' is aligned on a
+        *    unit_size boundary.
         *
-        * 2. Implicitly extend accept_memory(start, end) to end+unit_size if
-        *    'end' is aligned on a unit_size boundary. (immediately following
-        *    this comment)
+        * 2. Implicitly extend accept_memory(start, size) to the next unit_size
+        *    if 'size+end' is aligned on a unit_size boundary. (immediately
+        *    following this comment)
         */
        if (!(end % unit_size))
                end += unit_size;
@@ -156,9 +157,10 @@ retry:
        spin_unlock_irqrestore(&unaccepted_memory_lock, flags);
 }
 
-bool range_contains_unaccepted_memory(phys_addr_t start, phys_addr_t end)
+bool range_contains_unaccepted_memory(phys_addr_t start, unsigned long size)
 {
        struct efi_unaccepted_memory *unaccepted;
+       phys_addr_t end = start + size;
        unsigned long flags;
        bool ret = false;
        u64 unit_size;
index ee8cea73d415b0c7be52fc1cb35470e2f94eaff8..b1eed30fdc06b0c427f4b42943d89bf6444c08ca 100644 (file)
@@ -4062,18 +4062,18 @@ madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
 
 #ifdef CONFIG_UNACCEPTED_MEMORY
 
-bool range_contains_unaccepted_memory(phys_addr_t start, phys_addr_t end);
-void accept_memory(phys_addr_t start, phys_addr_t end);
+bool range_contains_unaccepted_memory(phys_addr_t start, unsigned long size);
+void accept_memory(phys_addr_t start, unsigned long size);
 
 #else
 
 static inline bool range_contains_unaccepted_memory(phys_addr_t start,
-                                                   phys_addr_t end)
+                                                   unsigned long size)
 {
        return false;
 }
 
-static inline void accept_memory(phys_addr_t start, phys_addr_t end)
+static inline void accept_memory(phys_addr_t start, unsigned long size)
 {
 }
 
@@ -4081,9 +4081,7 @@ static inline void accept_memory(phys_addr_t start, phys_addr_t end)
 
 static inline bool pfn_is_unaccepted_memory(unsigned long pfn)
 {
-       phys_addr_t paddr = pfn << PAGE_SHIFT;
-
-       return range_contains_unaccepted_memory(paddr, paddr + PAGE_SIZE);
+       return range_contains_unaccepted_memory(pfn << PAGE_SHIFT, PAGE_SIZE);
 }
 
 void vma_pgtable_walk_begin(struct vm_area_struct *vma);
index 3b9dc2d89b8a08aec17444e735ab3ef8d6fc07d7..0a77a748a8eb3271d7a7f46ed5491d5cbb57e1a5 100644 (file)
@@ -1500,7 +1500,7 @@ done:
         *
         * Accept the memory of the allocated buffer.
         */
-       accept_memory(found, found + size);
+       accept_memory(found, size);
 
        return found;
 }
index 11767ca6ba38d158edbb7a9acdd1cda6937ffbdb..4ba5607aaf1943214c7f79f2a52e17eefac2ad79 100644 (file)
@@ -1933,7 +1933,7 @@ static void __init deferred_free_pages(unsigned long pfn,
        }
 
        /* Accept chunks smaller than MAX_PAGE_ORDER upfront */
-       accept_memory(PFN_PHYS(pfn), PFN_PHYS(pfn + nr_pages));
+       accept_memory(PFN_PHYS(pfn), nr_pages * PAGE_SIZE);
 
        for (i = 0; i < nr_pages; i++, page++, pfn++) {
                if (pageblock_aligned(pfn))
index d8bc99e3c78c41f8a981c621fda3b2861d8b280d..e7fccd5eb6d08b7d3b7c399b503ce5187f8a5a36 100644 (file)
@@ -286,7 +286,6 @@ EXPORT_SYMBOL(nr_online_nodes);
 #endif
 
 static bool page_contains_unaccepted(struct page *page, unsigned int order);
-static void accept_page(struct page *page, unsigned int order);
 static bool cond_accept_memory(struct zone *zone, unsigned int order);
 static inline bool has_unaccepted_memory(void);
 static bool __free_unaccepted(struct page *page);
@@ -1268,7 +1267,7 @@ void __meminit __free_pages_core(struct page *page, unsigned int order,
                if (order == MAX_PAGE_ORDER && __free_unaccepted(page))
                        return;
 
-               accept_page(page, order);
+               accept_memory(page_to_phys(page), PAGE_SIZE << order);
        }
 
        /*
@@ -6934,16 +6933,8 @@ early_param("accept_memory", accept_memory_parse);
 static bool page_contains_unaccepted(struct page *page, unsigned int order)
 {
        phys_addr_t start = page_to_phys(page);
-       phys_addr_t end = start + (PAGE_SIZE << order);
 
-       return range_contains_unaccepted_memory(start, end);
-}
-
-static void accept_page(struct page *page, unsigned int order)
-{
-       phys_addr_t start = page_to_phys(page);
-
-       accept_memory(start, start + (PAGE_SIZE << order));
+       return range_contains_unaccepted_memory(start, PAGE_SIZE << order);
 }
 
 static bool try_to_accept_memory_one(struct zone *zone)
@@ -6968,7 +6959,7 @@ static bool try_to_accept_memory_one(struct zone *zone)
        __ClearPageUnaccepted(page);
        spin_unlock_irqrestore(&zone->lock, flags);
 
-       accept_page(page, MAX_PAGE_ORDER);
+       accept_memory(page_to_phys(page), PAGE_SIZE << MAX_PAGE_ORDER);
 
        __free_pages_ok(page, MAX_PAGE_ORDER, FPI_TO_TAIL);
 
@@ -7040,10 +7031,6 @@ static bool page_contains_unaccepted(struct page *page, unsigned int order)
        return false;
 }
 
-static void accept_page(struct page *page, unsigned int order)
-{
-}
-
 static bool cond_accept_memory(struct zone *zone, unsigned int order)
 {
        return false;
index f6c6e5474c3afbcb238eae15e71cadb4c986f411..1cf82acb2a3e4d4613441b68bd43bb1566f456d9 100644 (file)
@@ -20,7 +20,7 @@ void memblock_free_pages(struct page *page, unsigned long pfn,
 {
 }
 
-static inline void accept_memory(phys_addr_t start, phys_addr_t end)
+static inline void accept_memory(phys_addr_t start, unsigned long size)
 {
 }