mm: ensure consistency of memory map poisoning
Subsystems (19)
Mike Rapoport
maintainercover mm: ensure consistency of memory map poisoning
From: Mike Rapoport <[email protected]>
Hi,
Currently memory map allocation for FLATMEM case does not poison the struct pages regardless of CONFIG_PAGE_POISON setting.
This happens because allocation of the memory map for FLATMEM and SPARSMEM use different memblock functions and those that are used for SPARSMEM case (namely memblock_alloc_try_nid_raw() and memblock_alloc_exact_nid_raw()) implicitly poison the allocated memory.
Another side effect of this implicit poisoning is that early setup code that uses the same functions to allocate memory burns cycles for the memory poisoning even if it was not intended.
These patches introduce memmap_alloc() wrapper that ensure that the memory map allocation is consistent for different memory models.
Mike Rapoport (4):
mm/page_alloc: always initialize memory map for the holes
microblaze: simplify pte_alloc_one_kernel()
mm: introduce memmap_alloc() to unify memory map allocation
memblock: stop poisoning raw allocations
arch/microblaze/include/asm/pgtable.h | 2 -- arch/microblaze/mm/init.c | 12 ---------- arch/microblaze/mm/pgtable.c | 17 +++++++------- mm/internal.h | 4 ++++ mm/memblock.c | 20 ++++------------- mm/page_alloc.c | 32 ++++++++++++++++++--------- mm/sparse.c | 6 ++--- 7 files changed, 40 insertions(+), 53 deletions(-)
base-commit: e73f0f0ee7541171d89f2e2491130c7771ba58d3
Signature · 1 line
2.28.0
Mike Rapoport
maintainerPATCH 1/4 mm/page_alloc: always initialize memory map for the holes
From: Mike Rapoport <[email protected]>
Currently memory map for the holes is initialized only when SPARSEMEM memory model is used. Yet, even with FLATMEM there could be holes in the physical memory layout that have memory map entries.
For instance, the memory reserved using e820 API on i386 or "reserved-memory" nodes in device tree would not appear in memblock.memory and hence the struct pages for such holes will be skipped during memory map initialization.
These struct pages will be zeroed because the memory map for FLATMEM systems is allocated with memblock_alloc_node() that clears the allocated memory. While zeroed struct pages do not cause immediate problems, the correct behaviour is to initialize every page using __init_single_page(). Besides, enabling page poison for FLATMEM case will trigger PF_POISONED_CHECK() unless the memory map is properly initialized.
Make sure init_unavailable_range() is called for both SPARSEMEM and FLATMEM so that struct pages representing memory holes would appear as PG_Reserved with any memory layout.
--- mm/page_alloc.c | 8 -------- 1 file changed, 8 deletions(-)
mm/page_alloc.c +0 -8
@@ -6624,7 +6624,6 @@ static void __meminit zone_init_free_lists(struct zone *zone) } } -#if !defined(CONFIG_FLATMEM )/* * Only struct pages that correspond to ranges defined by memblock.memory * are zeroed and initialized by going through __init_single_page() during
@@ -6669,13 +6668,6 @@ static void __init init_unavailable_range(unsigned long spfn,pr_info ("On node %d, zone %s: %lld pages in unavailable ranges" , node, zone_names[zone], pgcnt); } -#else -static inline void init_unavailable_range (unsigned long spfn, -unsigned long epfn, -int zone,int node) -{ -} -#endif static void __init memmap_init_zone_range(struct zone *zone, unsigned long start_pfn,
Signature · 1 line
2.28.0
Re: [PATCH 1/4] mm/page_alloc: always initialize memory map for the holes
Hi,
Quoted 18 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Currently memory map for the holes is initialized only when SPARSEMEM memory model is used. Yet, even with FLATMEM there could be holes in the physical memory layout that have memory map entries.
For instance, the memory reserved using e820 API on i386 or "reserved-memory" nodes in device tree would not appear in memblock.memory and hence the struct pages for such holes will be skipped during memory map initialization.
These struct pages will be zeroed because the memory map for FLATMEM systems is allocated with
memblock_alloc_node()that clears the allocated memory. While zeroed struct pages do not cause immediate problems, the correct behaviour is to initialize every page using__init_single_page(). Besides, enabling page poison for FLATMEM case will triggerPF_POISONED_CHECK()unless the memory map is properly initialized.
Quoted 5 lines
Make sure
init_unavailable_range()is called for both SPARSEMEM and FLATMEM so that struct pages representing memory holes would appear asPG_Reservedwith any memory layout.Signed-off-by Mike Rapoport <[email protected]>
This patch causes microblaze petalogix-ml605 qemu emulations to fail silently (no console output). Reverting it fixes the problem.
Guenter
---
Bisect log:
# bad: [8d4b477da1a807199ca60e0829357ce7aa6758d5] Add linux-next specific files for 20210730
# good: [ff1176468d368232b684f75e82563369208bc371] Linux 5.14-rc3
git bisect start 'HEAD' 'v5.14-rc3'
# good: [8f3eb1f5c702ef868d89799b03c21d122f2fe197] Merge remote-tracking branch 'bpf-next/for-next'
git bisect good 8f3eb1f5c702ef868d89799b03c21d122f2fe197
# good: [32286c7080c56c835f25302c38eebccf41b7b576] Merge remote-tracking branch 'tip/auto-latest'
git bisect good 32286c7080c56c835f25302c38eebccf41b7b576
# good: [70c40604c7d393f95171f49717a27bf8e05b5439] Merge remote-tracking branch 'dmaengine/next'
git bisect good 70c40604c7d393f95171f49717a27bf8e05b5439
# good: [b038834891b35ec410693028a500f769db132a81] Merge remote-tracking branch 'rust/rust-next'
git bisect good b038834891b35ec410693028a500f769db132a81
# bad: [d8f4e506a9ba375110945d75573b3304491e6350] memory-hotplug.rst: complete admin-guide overhaul
git bisect bad d8f4e506a9ba375110945d75573b3304491e6350
# good: [bef692dcfb7cdb5c960abfc31e2386a0ff41af54] lazy tlb: shoot lazies, a non-refcounting lazy tlb option git bisect good bef692dcfb7cdb5c960abfc31e2386a0ff41af54
# bad: [5fcd957e2f0dc4cb25a6ee60ebfb1200de09c9d1] mm-migrate-demote-pages-during-reclaim-v11
git bisect bad 5fcd957e2f0dc4cb25a6ee60ebfb1200de09c9d1
# good: [8c2a82ab20eb09d217446989ae209f5ff19a64ac] mm/vmalloc: use batched page requests in bulk-allocator
git bisect good 8c2a82ab20eb09d217446989ae209f5ff19a64ac
# bad: [c36a5446e29f1461780b06785769b9402522f847] mm/page_alloc.c: fix 'zone_id' may be used uninitialized in this function warning git bisect bad c36a5446e29f1461780b06785769b9402522f847
# good: [05e358c552628e26be3985933bea88e7512414c0] mm/kasan: move kasan.fault to mm/kasan/report.c
git bisect good 05e358c552628e26be3985933bea88e7512414c0
# bad: [b467ff7f560908e60ca181658b7ee48e5da94da1] microblaze: simplify pte_alloc_one_kernel()
git bisect bad b467ff7f560908e60ca181658b7ee48e5da94da1
# bad: [d2a572bf593a57246827bd79c91fe2ee6b7af1f0] mm/page_alloc: always initialize memory map for the holes git bisect bad d2a572bf593a57246827bd79c91fe2ee6b7af1f0
# first bad commit: [d2a572bf593a57246827bd79c91fe2ee6b7af1f0] mm/page_alloc: always initialize memory map for the holes
Mike Rapoport
maintainerRe: [PATCH 1/4] mm/page_alloc: always initialize memory map for the holes
Quoted 21 lines · Guenter Roeck
Hi,
Quoted 18 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Currently memory map for the holes is initialized only when SPARSEMEM memory model is used. Yet, even with FLATMEM there could be holes in the physical memory layout that have memory map entries.
For instance, the memory reserved using e820 API on i386 or "reserved-memory" nodes in device tree would not appear in memblock.memory and hence the struct pages for such holes will be skipped during memory map initialization.
These struct pages will be zeroed because the memory map for FLATMEM systems is allocated with
memblock_alloc_node()that clears the allocated memory. While zeroed struct pages do not cause immediate problems, the correct behaviour is to initialize every page using__init_single_page(). Besides, enabling page poison for FLATMEM case will triggerPF_POISONED_CHECK()unless the memory map is properly initialized.
Quoted 8 lines
Quoted 5 lines
Make sure
init_unavailable_range()is called for both SPARSEMEM and FLATMEM so that struct pages representing memory holes would appear asPG_Reservedwith any memory layout.Signed-off-by Mike Rapoport <[email protected]>This patch causes microblaze petalogix-ml605 qemu emulations to fail silently (no console output). Reverting it fixes the problem.
It appears that petalogix-ml605 memory starts at 0x50000, but microblaze's pfn_valid does not reject pfns < ARCH_PFN_OFFSET.
This should fix the issue:
arch/microblaze/include/asm/page.h +1 -2
@@ -112,8 +112,7 @@ extern int page_is_ram(unsigned long pfn);# define page_to_phys (page) (page_to_pfn(page) << PAGE_SHIFT)# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT) -# define pfn_valid (pfn) ((pfn) < (max_mapnr + ARCH_PFN_OFFSET)) - +# define pfn_valid (pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < (max_mapnr + ARCH_PFN_OFFSET))# endif /* __ASSEMBLY__ */ #define virt_addr_valid (vaddr) (pfn_valid(virt_to_pfn(vaddr)))
Quoted 33 lines
Guenter
---
Bisect log:# bad: [
8d4b477da1a807199ca60e0829357ce7aa6758d5] Add linux-next specific files for 20210730
# good: [ff1176468d368232b684f75e82563369208bc371] Linux 5.14-rc3
git bisect start 'HEAD' 'v5.14-rc3'
# good: [8f3eb1f5c702ef868d89799b03c21d122f2fe197] Merge remote-tracking branch 'bpf-next/for-next'
git bisect good8f3eb1f5c702ef868d89799b03c21d122f2fe197
# good: [32286c7080c56c835f25302c38eebccf41b7b576] Merge remote-tracking branch 'tip/auto-latest'
git bisect good32286c7080c56c835f25302c38eebccf41b7b576
# good: [70c40604c7d393f95171f49717a27bf8e05b5439] Merge remote-tracking branch 'dmaengine/next'
git bisect good70c40604c7d393f95171f49717a27bf8e05b5439
# good: [b038834891b35ec410693028a500f769db132a81] Merge remote-tracking branch 'rust/rust-next'
git bisect goodb038834891b35ec410693028a500f769db132a81
# bad: [d8f4e506a9ba375110945d75573b3304491e6350]memory-hotplug.rst: complete admin-guide overhaul
git bisect badd8f4e506a9ba375110945d75573b3304491e6350
# good: [bef692dcfb7cdb5c960abfc31e2386a0ff41af54] lazy tlb: shoot lazies, a non-refcounting lazy tlb option git bisect goodbef692dcfb7cdb5c960abfc31e2386a0ff41af54
# bad: [5fcd957e2f0dc4cb25a6ee60ebfb1200de09c9d1] mm-migrate-demote-pages-during-reclaim-v11
git bisect bad5fcd957e2f0dc4cb25a6ee60ebfb1200de09c9d1
# good: [8c2a82ab20eb09d217446989ae209f5ff19a64ac] mm/vmalloc: use batched page requests in bulk-allocator
git bisect good8c2a82ab20eb09d217446989ae209f5ff19a64ac
# bad: [c36a5446e29f1461780b06785769b9402522f847]mm/page_alloc.c: fix 'zone_id' may be used uninitialized in this function warning git bisect badc36a5446e29f1461780b06785769b9402522f847
# good: [05e358c552628e26be3985933bea88e7512414c0] mm/kasan: move kasan.fault tomm/kasan/report.c
git bisect good05e358c552628e26be3985933bea88e7512414c0
# bad: [b467ff7f560908e60ca181658b7ee48e5da94da1] microblaze: simplifypte_alloc_one_kernel()
git bisect badb467ff7f560908e60ca181658b7ee48e5da94da1
# bad: [d2a572bf593a57246827bd79c91fe2ee6b7af1f0]mm/page_alloc: always initialize memory map for the holes git bisect badd2a572bf593a57246827bd79c91fe2ee6b7af1f0# first bad commit: [d2a572bf593a57246827bd79c91fe2ee6b7af1f0] mm/page_alloc: always initialize memory map for the holes
Signature · 2 lines
Sincerely yours, Mike.
Guenter Roeck
Tested-byRe: [PATCH 1/4] mm/page_alloc: always initialize memory map for the holes
Hi,
Quoted 41 lines · Mike Rapoport
Quoted 21 lines · Guenter Roeck
Hi,
Quoted 18 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Currently memory map for the holes is initialized only when SPARSEMEM memory model is used. Yet, even with FLATMEM there could be holes in the physical memory layout that have memory map entries.
For instance, the memory reserved using e820 API on i386 or "reserved-memory" nodes in device tree would not appear in memblock.memory and hence the struct pages for such holes will be skipped during memory map initialization.
These struct pages will be zeroed because the memory map for FLATMEM systems is allocated with
memblock_alloc_node()that clears the allocated memory. While zeroed struct pages do not cause immediate problems, the correct behaviour is to initialize every page using__init_single_page(). Besides, enabling page poison for FLATMEM case will triggerPF_POISONED_CHECK()unless the memory map is properly initialized.Quoted 8 lines
Quoted 5 lines
Make sure
init_unavailable_range()is called for both SPARSEMEM and FLATMEM so that struct pages representing memory holes would appear asPG_Reservedwith any memory layout.Signed-off-by Mike Rapoport <[email protected]>This patch causes microblaze petalogix-ml605 qemu emulations to fail silently (no console output). Reverting it fixes the problem.
It appears that petalogix-ml605 memory starts at
0x50000, but microblaze'spfn_validdoes not reject pfns <ARCH_PFN_OFFSET.This should fix the issue:
arch/microblaze/include/asm/page.h +0
-0
arch/microblaze/include/asm/page.h extern int page_is_ram(unsigned long pfn); · line 118
Quoted 9 lines
arch/microblaze/include/asm/page.h +1
-2@@ -112,8 +112,7 @@ extern int page_is_ram(unsigned long pfn);# define page_to_phys (page) (page_to_pfn(page) << PAGE_SHIFT)# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT) -# define pfn_valid (pfn) ((pfn) < (max_mapnr + ARCH_PFN_OFFSET)) - +# define pfn_valid (pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < (max_mapnr + ARCH_PFN_OFFSET))# endif /* __ASSEMBLY__ */ #define virt_addr_valid (vaddr) (pfn_valid(virt_to_pfn(vaddr)))
Indeed, that does the trick.
Feel free to add
to the patch.
Thanks,
Guenter
Quoted 34 lines
Quoted 33 lines
Guenter
---
Bisect log:# bad: [
8d4b477da1a807199ca60e0829357ce7aa6758d5] Add linux-next specific files for 20210730
# good: [ff1176468d368232b684f75e82563369208bc371] Linux 5.14-rc3
git bisect start 'HEAD' 'v5.14-rc3'
# good: [8f3eb1f5c702ef868d89799b03c21d122f2fe197] Merge remote-tracking branch 'bpf-next/for-next'
git bisect good8f3eb1f5c702ef868d89799b03c21d122f2fe197
# good: [32286c7080c56c835f25302c38eebccf41b7b576] Merge remote-tracking branch 'tip/auto-latest'
git bisect good32286c7080c56c835f25302c38eebccf41b7b576
# good: [70c40604c7d393f95171f49717a27bf8e05b5439] Merge remote-tracking branch 'dmaengine/next'
git bisect good70c40604c7d393f95171f49717a27bf8e05b5439
# good: [b038834891b35ec410693028a500f769db132a81] Merge remote-tracking branch 'rust/rust-next'
git bisect goodb038834891b35ec410693028a500f769db132a81
# bad: [d8f4e506a9ba375110945d75573b3304491e6350]memory-hotplug.rst: complete admin-guide overhaul
git bisect badd8f4e506a9ba375110945d75573b3304491e6350
# good: [bef692dcfb7cdb5c960abfc31e2386a0ff41af54] lazy tlb: shoot lazies, a non-refcounting lazy tlb option git bisect goodbef692dcfb7cdb5c960abfc31e2386a0ff41af54
# bad: [5fcd957e2f0dc4cb25a6ee60ebfb1200de09c9d1] mm-migrate-demote-pages-during-reclaim-v11
git bisect bad5fcd957e2f0dc4cb25a6ee60ebfb1200de09c9d1
# good: [8c2a82ab20eb09d217446989ae209f5ff19a64ac] mm/vmalloc: use batched page requests in bulk-allocator
git bisect good8c2a82ab20eb09d217446989ae209f5ff19a64ac
# bad: [c36a5446e29f1461780b06785769b9402522f847]mm/page_alloc.c: fix 'zone_id' may be used uninitialized in this function warning git bisect badc36a5446e29f1461780b06785769b9402522f847
# good: [05e358c552628e26be3985933bea88e7512414c0] mm/kasan: move kasan.fault tomm/kasan/report.c
git bisect good05e358c552628e26be3985933bea88e7512414c0
# bad: [b467ff7f560908e60ca181658b7ee48e5da94da1] microblaze: simplifypte_alloc_one_kernel()
git bisect badb467ff7f560908e60ca181658b7ee48e5da94da1
# bad: [d2a572bf593a57246827bd79c91fe2ee6b7af1f0]mm/page_alloc: always initialize memory map for the holes git bisect badd2a572bf593a57246827bd79c91fe2ee6b7af1f0# first bad commit: [d2a572bf593a57246827bd79c91fe2ee6b7af1f0] mm/page_alloc: always initialize memory map for the holes
Re: [PATCH 1/4] mm/page_alloc: always initialize memory map for the holes
In reply to Mike RapoportQuoted 44 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Currently memory map for the holes is initialized only when SPARSEMEM memory model is used. Yet, even with FLATMEM there could be holes in the physical memory layout that have memory map entries.
For instance, the memory reserved using e820 API on i386 or "reserved-memory" nodes in device tree would not appear in memblock.memory and hence the struct pages for such holes will be skipped during memory map initialization.
These struct pages will be zeroed because the memory map for FLATMEM systems is allocated with
memblock_alloc_node()that clears the allocated memory. While zeroed struct pages do not cause immediate problems, the correct behaviour is to initialize every page using__init_single_page(). Besides, enabling page poison for FLATMEM case will triggerPF_POISONED_CHECK()unless the memory map is properly initialized.Make sure
init_unavailable_range()is called for both SPARSEMEM and FLATMEM so that struct pages representing memory holes would appear asPG_Reservedwith any memory layout.Signed-off-by Mike Rapoport <[email protected]>--- mm/page_alloc.c | 8 -------- 1 file changed, 8 deletions(-)mm/page_alloc.c +0
-1@@ -6624,7 +6624,6 @@ static void __meminit zone_init_free_lists(struct zone *zone) } } -#if !defined(CONFIG_FLATMEM )/* * Only struct pages that correspond to ranges defined by memblock.memory * are zeroed and initialized by going through __init_single_page() during @@ -6669,13 +6668,6 @@ static void __init init_unavailable_range(unsigned long spfn,pr_info ("On node %d, zone %s: %lld pages in unavailable ranges" , node, zone_names[zone], pgcnt); }
mm/page_alloc.c static void __init init_unavailable_range(unsigned long spfn, · line 6673
Quoted 10 lines
mm/page_alloc.c +0
-7-#else -static inline void init_unavailable_range (unsigned long spfn, -unsigned long epfn, -int zone,int node) -{ -} -#endif static void __init memmap_init_zone_range(struct zone *zone, unsigned long start_pfn,
Signature · 3 lines
Thanks, David / dhildenb
Mike Rapoport
maintainerPATCH 2/4 microblaze: simplify pte_alloc_one_kernel()
In reply to Mike RapoportFrom: Mike Rapoport <[email protected]>
The microblaze's implementation of pte_alloc_one_kernel() used memblock_alloc_try_nid_raw() along with clear_page() to allocated a zeroed page during early setup.
Replace calls of these functions with a call to memblock_alloc_try_nid() that already returns zeroed page and respects the same allocation limits as memblock_alloc_try_nid_raw().
While on it drop early_get_page() wrapper that was only used in pte_alloc_one_kernel().
--- arch/microblaze/include/asm/pgtable.h | 2 -- arch/microblaze/mm/init.c | 12 ------------ arch/microblaze/mm/pgtable.c | 17 ++++++++--------- 3 files changed, 8 insertions(+), 23 deletions(-)
arch/microblaze/include/asm/pgtable.h +0 -2
@@ -443,8 +443,6 @@ extern int mem_init_done; asmlinkage void __init mmu_init(void); -void __init *early_get_page (void ); -#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/microblaze/mm/init.c +0 -12
@@ -265,18 +265,6 @@ asmlinkage void __init mmu_init(void)dma_contiguous_reserve (memory_start + lowmem_size -1 ); } -/* This is only called until mem_init is done. */ -void __init *early_get_page (void ) -{ -/* -* Mem start + kernel_tlb -> here is limit -* because of mem mapping from head.S -*/ -return memblock_alloc_try_nid_raw (PAGE_SIZE ,PAGE_SIZE , -MEMBLOCK_LOW_LIMIT , memory_start + kernel_tlb, -NUMA_NO_NODE ); -} -void *__ref zalloc_maybe_bootmem (size_t size,gfp_t mask) {void *p;
arch/microblaze/mm/pgtable.c +8 -9
@@ -33,6 +33,7 @@#include <linux/init.h> #include <linux/mm_types.h> #include <linux/pgtable.h> +#include <linux/memblock.h> #include <asm/pgalloc.h> #include <linux/io.h>
@@ -242,15 +243,13 @@ unsigned long iopa(unsigned long addr)__ref pte_t *pte_alloc_one_kernel (struct mm_struct *mm) { -pte_t *pte; -if (mem_init_done) { - pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); - }else { - pte = (pte_t *)early_get_page (); -if (pte) -clear_page (pte); - } -return pte; +if (mem_init_done) +return (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); +else +return memblock_alloc_try_nid (PAGE_SIZE ,PAGE_SIZE , +MEMBLOCK_LOW_LIMIT , + memory_start + kernel_tlb, +NUMA_NO_NODE ); }void __set_fixmap (enum fixed_addresses idx,phys_addr_t phys,pgprot_t flags)
Signature · 1 line
2.28.0
Re: [PATCH 2/4] microblaze: simplify pte_alloc_one_kernel()
Quoted 82 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
The microblaze's implementation of
pte_alloc_one_kernel()usedmemblock_alloc_try_nid_raw()along withclear_page()to allocated a zeroed page during early setup.Replace calls of these functions with a call to
memblock_alloc_try_nid()that already returns zeroed page and respects the same allocation limits asmemblock_alloc_try_nid_raw().While on it drop
early_get_page()wrapper that was only used inpte_alloc_one_kernel().Signed-off-by Mike Rapoport <[email protected]>--- arch/microblaze/include/asm/pgtable.h | 2 -- arch/microblaze/mm/init.c | 12 ------------ arch/microblaze/mm/pgtable.c | 17 ++++++++--------- 3 files changed, 8 insertions(+), 23 deletions(-)arch/microblaze/include/asm/pgtable.h +0
-2@@ -443,8 +443,6 @@ extern int mem_init_done; asmlinkage void __init mmu_init(void); -void __init *early_get_page (void ); -#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ arch/microblaze/mm/init.c +0
-12@@ -265,18 +265,6 @@ asmlinkage void __init mmu_init(void)dma_contiguous_reserve (memory_start + lowmem_size -1 ); } -/* This is only called until mem_init is done. */ -void __init *early_get_page (void ) -{ -/* -* Mem start + kernel_tlb -> here is limit -* because of mem mapping from head.S -*/ -return memblock_alloc_try_nid_raw (PAGE_SIZE ,PAGE_SIZE , -MEMBLOCK_LOW_LIMIT , memory_start + kernel_tlb, -NUMA_NO_NODE ); -} -void *__ref zalloc_maybe_bootmem (size_t size,gfp_t mask) {void *p;arch/microblaze/mm/pgtable.c +1
-9@@ -33,6 +33,7 @@#include <linux/init.h> #include <linux/mm_types.h> #include <linux/pgtable.h> +#include <linux/memblock.h> #include <asm/pgalloc.h> #include <linux/io.h> @@ -242,15 +243,13 @@ unsigned long iopa(unsigned long addr)__ref pte_t *pte_alloc_one_kernel (struct mm_struct *mm) { -pte_t *pte; -if (mem_init_done) { - pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); - }else { - pte = (pte_t *)early_get_page (); -if (pte) -clear_page (pte); - } -return pte;
arch/microblaze/mm/pgtable.c unsigned long iopa(unsigned long addr) · line 255
Quoted 10 lines
arch/microblaze/mm/pgtable.c +7
-0+if (mem_init_done) +return (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); +else +return memblock_alloc_try_nid (PAGE_SIZE ,PAGE_SIZE , +MEMBLOCK_LOW_LIMIT , + memory_start + kernel_tlb, +NUMA_NO_NODE ); }void __set_fixmap (enum fixed_addresses idx,phys_addr_t phys,pgprot_t flags)
I have tested 1/4 with/without the fix from Guenter and also 2/4 and I can't see any issue on real HW.
That's why feel free to add my
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
Re: [PATCH 2/4] microblaze: simplify pte_alloc_one_kernel()
In reply to Mike RapoportQuoted 82 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
The microblaze's implementation of
pte_alloc_one_kernel()usedmemblock_alloc_try_nid_raw()along withclear_page()to allocated a zeroed page during early setup.Replace calls of these functions with a call to
memblock_alloc_try_nid()that already returns zeroed page and respects the same allocation limits asmemblock_alloc_try_nid_raw().While on it drop
early_get_page()wrapper that was only used inpte_alloc_one_kernel().Signed-off-by Mike Rapoport <[email protected]>--- arch/microblaze/include/asm/pgtable.h | 2 -- arch/microblaze/mm/init.c | 12 ------------ arch/microblaze/mm/pgtable.c | 17 ++++++++--------- 3 files changed, 8 insertions(+), 23 deletions(-)arch/microblaze/include/asm/pgtable.h +0
-2@@ -443,8 +443,6 @@ extern int mem_init_done; asmlinkage void __init mmu_init(void); -void __init *early_get_page (void ); -#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ arch/microblaze/mm/init.c +0
-12@@ -265,18 +265,6 @@ asmlinkage void __init mmu_init(void)dma_contiguous_reserve (memory_start + lowmem_size -1 ); } -/* This is only called until mem_init is done. */ -void __init *early_get_page (void ) -{ -/* -* Mem start + kernel_tlb -> here is limit -* because of mem mapping from head.S -*/ -return memblock_alloc_try_nid_raw (PAGE_SIZE ,PAGE_SIZE , -MEMBLOCK_LOW_LIMIT , memory_start + kernel_tlb, -NUMA_NO_NODE ); -} -void *__ref zalloc_maybe_bootmem (size_t size,gfp_t mask) {void *p;arch/microblaze/mm/pgtable.c +1
-9@@ -33,6 +33,7 @@#include <linux/init.h> #include <linux/mm_types.h> #include <linux/pgtable.h> +#include <linux/memblock.h> #include <asm/pgalloc.h> #include <linux/io.h> @@ -242,15 +243,13 @@ unsigned long iopa(unsigned long addr)__ref pte_t *pte_alloc_one_kernel (struct mm_struct *mm) { -pte_t *pte; -if (mem_init_done) { - pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); - }else { - pte = (pte_t *)early_get_page (); -if (pte) -clear_page (pte); - } -return pte;
arch/microblaze/mm/pgtable.c unsigned long iopa(unsigned long addr) · line 255
Quoted 10 lines
arch/microblaze/mm/pgtable.c +7
-0+if (mem_init_done) +return (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); +else +return memblock_alloc_try_nid (PAGE_SIZE ,PAGE_SIZE , +MEMBLOCK_LOW_LIMIT , + memory_start + kernel_tlb, +NUMA_NO_NODE ); }void __set_fixmap (enum fixed_addresses idx,phys_addr_t phys,pgprot_t flags)
Signature · 3 lines
Thanks, David / dhildenb
Mike Rapoport
maintainerPATCH 3/4 mm: introduce memmap_alloc() to unify memory map allocation
In reply to Mike RapoportFrom: Mike Rapoport <[email protected]>
There are several places that allocate memory for the memory map:alloc_node_mem_map() for FLATMEM, sparse_buffer_init() and __populate_section_memmap() for SPARSEMEM.
The memory allocated in the FLATMEM case is zeroed and it is never poisoned, regardless of CONFIG_PAGE_POISON setting.
The memory allocated in the SPARSEMEM cases is not zeroed and it is implicitly poisoned inside memblock if CONFIG_PAGE_POISON is set.
Introduce memmap_alloc() wrapper for memblock allocators that will be used for both FLATMEM and SPARSEMEM cases and will makei memory map zeroing and poisoning consistent for different memory models.
--- mm/internal.h | 4 ++++ mm/page_alloc.c | 24 ++++++++++++++++++++++-- mm/sparse.c | 6 ++---- 3 files changed, 28 insertions(+), 6 deletions(-)
mm/internal.h +4 -0
@@ -211,6 +211,10 @@ extern void zone_pcp_reset(struct zone *zone);extern void zone_pcp_disable (struct zone *zone);extern void zone_pcp_enable (struct zone *zone); +extern void *memmap_alloc (phys_addr_t size,phys_addr_t align, +phys_addr_t min_addr, +int nid,bool exact_nid); +#if definedCONFIG_COMPACTION || definedCONFIG_CMA /*
mm/page_alloc.c +22 -2
@@ -6730,6 +6730,26 @@ static void __init memmap_init(void)init_unavailable_range (hole_pfn, end_pfn, zone_id, nid); } +void __init *memmap_alloc (phys_addr_t size,phys_addr_t align, +phys_addr_t min_addr,int nid,bool exact_nid) +{ +void *ptr; + +if (exact_nid) + ptr =memblock_alloc_exact_nid_raw (size, align, min_addr, +MEMBLOCK_ALLOC_ACCESSIBLE , + nid); +else + ptr =memblock_alloc_try_nid_raw (size, align, min_addr, +MEMBLOCK_ALLOC_ACCESSIBLE , + nid); + +if (ptr && size >0 ) +page_init_poison (ptr, size); + +return ptr; +} +static int zone_batchsize (struct zone *zone) {#ifdef CONFIG_MMU
@@ -7501,8 +7521,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) end =pgdat_end_pfn (pgdat); end =ALIGN (end,MAX_ORDER_NR_PAGES ); size = (end - start) *sizeof (struct page ); - map =memblock_alloc_node (size,SMP_CACHE_BYTES , - pgdat->node_id); + map =memmap_alloc (size,SMP_CACHE_BYTES ,MEMBLOCK_LOW_LIMIT , + pgdat->node_id, false);if (!map)panic ("Failed to allocate %ld bytes for node %d memory map\n" , size, pgdat->node_id);
mm/sparse.c +2 -4
@@ -462,8 +462,7 @@ struct page __init *__populate_section_memmap(unsigned long pfn,if (map)return map; - map =memblock_alloc_try_nid_raw (size, size, addr, -MEMBLOCK_ALLOC_ACCESSIBLE , nid); + map =memmap_alloc (size, size, addr, nid, false);if (!map)panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%pa\n" , __func__, size,PAGE_SIZE , nid, &addr);
@@ -490,8 +489,7 @@ static void __init sparse_buffer_init(unsigned long size, int nid)* and we want it to be properly aligned to the section size - this is * especially the case for VMEMMAP which maps memmap to PMDs */ - sparsemap_buf =memblock_alloc_exact_nid_raw (size,section_map_size (), - addr,MEMBLOCK_ALLOC_ACCESSIBLE , nid); + sparsemap_buf =memmap_alloc (size,section_map_size (), addr, nid, true); sparsemap_buf_end = sparsemap_buf + size; }
Signature · 1 line
2.28.0
Andrew Morton
maintainerRe: [PATCH 3/4] mm: introduce memmap_alloc() to unify memory map allocation
Quoted 48 lines · On Wed, 14 Jul 2021 15:37:38 +0300 Mike Rapoport <[email protected]> wrote:
From: Mike Rapoport <[email protected]>
There are several places that allocate memory for the memory map:
alloc_node_mem_map()for FLATMEM,sparse_buffer_init()and__populate_section_memmap()for SPARSEMEM.The memory allocated in the FLATMEM case is zeroed and it is never poisoned, regardless of
CONFIG_PAGE_POISONsetting.The memory allocated in the SPARSEMEM cases is not zeroed and it is implicitly poisoned inside memblock if
CONFIG_PAGE_POISONis set.Introduce
memmap_alloc()wrapper for memblock allocators that will be used for both FLATMEM and SPARSEMEM cases and will makei memory map zeroing and poisoning consistent for different memory models....
mm/page_alloc.c +20
-0@@ -6730,6 +6730,26 @@ static void __init memmap_init(void)init_unavailable_range (hole_pfn, end_pfn, zone_id, nid); } +void __init *memmap_alloc (phys_addr_t size,phys_addr_t align, +phys_addr_t min_addr,int nid,bool exact_nid) +{ +void *ptr; + +if (exact_nid) + ptr =memblock_alloc_exact_nid_raw (size, align, min_addr, +MEMBLOCK_ALLOC_ACCESSIBLE , + nid); +else + ptr =memblock_alloc_try_nid_raw (size, align, min_addr, +MEMBLOCK_ALLOC_ACCESSIBLE , + nid); + +if (ptr && size >0 ) +page_init_poison (ptr, size); + +return ptr; +} +static int zone_batchsize (struct zone *zone) {#ifdef CONFIG_MMU
mm/page_alloc.c static void __ref alloc_node_mem_map(struct pglist_data *pgdat) · line 7525
Quoted 7 lines
mm/page_alloc.c +2
-2@@ -7501,8 +7521,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) end =pgdat_end_pfn (pgdat); end =ALIGN (end,MAX_ORDER_NR_PAGES ); size = (end - start) *sizeof (struct page ); - map =memblock_alloc_node (size,SMP_CACHE_BYTES , - pgdat->node_id); + map =memmap_alloc (size,SMP_CACHE_BYTES ,MEMBLOCK_LOW_LIMIT , + pgdat->node_id, false);
Mostly offtopic, but... Why is alloc_node_mem_map() marked __ref? afaict it can be __init?
Mike Rapoport
maintainerRe: [PATCH 3/4] mm: introduce memmap_alloc() to unify memory map allocation
Quoted 51 lines · Andrew Morton
Quoted 49 lines · On Wed, 14 Jul 2021 15:37:38 +0300 Mike Rapoport <[email protected]> wrote:
From: Mike Rapoport <[email protected]>
There are several places that allocate memory for the memory map:
alloc_node_mem_map()for FLATMEM,sparse_buffer_init()and__populate_section_memmap()for SPARSEMEM.The memory allocated in the FLATMEM case is zeroed and it is never poisoned, regardless of
CONFIG_PAGE_POISONsetting.The memory allocated in the SPARSEMEM cases is not zeroed and it is implicitly poisoned inside memblock if
CONFIG_PAGE_POISONis set.Introduce
memmap_alloc()wrapper for memblock allocators that will be used for both FLATMEM and SPARSEMEM cases and will makei memory map zeroing and poisoning consistent for different memory models....
mm/page_alloc.c +20
-0@@ -6730,6 +6730,26 @@ static void __init memmap_init(void)init_unavailable_range (hole_pfn, end_pfn, zone_id, nid); } +void __init *memmap_alloc (phys_addr_t size,phys_addr_t align, +phys_addr_t min_addr,int nid,bool exact_nid) +{ +void *ptr; + +if (exact_nid) + ptr =memblock_alloc_exact_nid_raw (size, align, min_addr, +MEMBLOCK_ALLOC_ACCESSIBLE , + nid); +else + ptr =memblock_alloc_try_nid_raw (size, align, min_addr, +MEMBLOCK_ALLOC_ACCESSIBLE , + nid); + +if (ptr && size >0 ) +page_init_poison (ptr, size); + +return ptr; +} +static int zone_batchsize (struct zone *zone) {#ifdef CONFIG_MMU @@ -7501,8 +7521,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) end =pgdat_end_pfn (pgdat);
Quoted 8 lines
mm/page_alloc.c static void __ref alloc_node_mem_map(struct pglist_data *pgdat) · line 7525
Quoted 6 lines
mm/page_alloc.c +2
-2end =ALIGN (end,MAX_ORDER_NR_PAGES ); size = (end - start) *sizeof (struct page ); - map =memblock_alloc_node (size,SMP_CACHE_BYTES , - pgdat->node_id); + map =memmap_alloc (size,SMP_CACHE_BYTES ,MEMBLOCK_LOW_LIMIT , + pgdat->node_id, false);Mostly offtopic, but... Why is
alloc_node_mem_map()marked__ref?
Once free_area_init_node() was __meminit, I stopped digging at that point.
Quoted 1 line
afaict it can be
__init?
Yes.
Signature · 2 lines
Sincerely yours, Mike.
Mike Rapoport
maintainerPATCH 4/4 memblock: stop poisoning raw allocations
In reply to Mike RapoportFrom: Mike Rapoport <[email protected]>
Functions memblock_alloc_exact_nid_raw() and memblock_alloc_try_nid_raw() are intended for early memory allocation without overhead of zeroing the allocated memory. Since these functions were used to allocate the memory map, they have ended up with addition of a call to page_init_poison() that poisoned the allocated memory when CONFIG_PAGE_POISON was set.
Since the memory map is allocated using a dedicated memmep_alloc() function that takes care of the poisoning, remove page poisoning from the memblock_alloc_*_raw() functions.
--- mm/memblock.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
mm/memblock.c +4 -16
@@ -1490,18 +1490,12 @@ void * __init memblock_alloc_exact_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { - void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64 )size, (u64 )align, nid, &min_addr, &max_addr, (void *)_RET_IP_); - ptr =memblock_alloc_internal (size, align, - min_addr, max_addr, nid, true); -if (ptr && size >0 ) -page_init_poison (ptr, size); - -return ptr; +return memblock_alloc_internal (size, align, min_addr, max_addr, nid, + true); }/**
@@ -1528,18 +1522,12 @@ void * __init memblock_alloc_try_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { - void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64 )size, (u64 )align, nid, &min_addr, &max_addr, (void *)_RET_IP_); - ptr =memblock_alloc_internal (size, align, - min_addr, max_addr, nid, false); -if (ptr && size >0 ) -page_init_poison (ptr, size); - -return ptr; +return memblock_alloc_internal (size, align, min_addr, max_addr, nid, + false); }/**
Signature · 1 line
2.28.0
Re: [PATCH 4/4] memblock: stop poisoning raw allocations
Quoted 11 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Functions
memblock_alloc_exact_nid_raw()andmemblock_alloc_try_nid_raw()are intended for early memory allocation without overhead of zeroing the allocated memory. Since these functions were used to allocate the memory map, they have ended up with addition of a call topage_init_poison()that poisoned the allocated memory whenCONFIG_PAGE_POISONwas set.Since the memory map is allocated using a dedicated
memmep_alloc()function that takes care of the poisoning, remove page poisoning from the memblock_alloc_*_raw() functions.
[]
mm/memblock.c
Quoted 1 line
mm/memblock.c +0
-0
[]
mm/memblock.c void * __init memblock_alloc_exact_nid_raw( · line 1495
Quoted 9 lines
mm/memblock.c +0
-2@@ -1490,18 +1490,12 @@ void * __init memblock_alloc_exact_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { -void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr, (void *)_RET_IP_);
unassociated trivia:
casting _RET_IP_ back to void * seems odd as the define is
include/linux/kernel.h:#define _RET_IP_ (unsigned long)__builtin_return_address(0)
It's probably easier to understand as just __builtin_return_address(0)
mm/memblock.c void * __init memblock_alloc_try_nid_raw( · line 1527
Quoted 9 lines
mm/memblock.c +0
-2@@ -1528,18 +1522,12 @@ void * __init memblock_alloc_try_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { -void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr, (void *)_RET_IP_);
here too
Mike Rapoport
maintainerRe: [PATCH 4/4] memblock: stop poisoning raw allocations
Quoted 27 lines · Joe Perches
Quoted 11 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Functions
memblock_alloc_exact_nid_raw()andmemblock_alloc_try_nid_raw()are intended for early memory allocation without overhead of zeroing the allocated memory. Since these functions were used to allocate the memory map, they have ended up with addition of a call topage_init_poison()that poisoned the allocated memory whenCONFIG_PAGE_POISONwas set.Since the memory map is allocated using a dedicated
memmep_alloc()function that takes care of the poisoning, remove page poisoning from the memblock_alloc_*_raw() functions.[]
mm/memblock.c
Quoted 1 line
mm/memblock.c +0
-0[]
mm/memblock.c void * __init memblock_alloc_exact_nid_raw( · line 1495
Quoted 9 lines
mm/memblock.c +0
-2@@ -1490,18 +1490,12 @@ void * __init memblock_alloc_exact_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { -void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr, (void *)_RET_IP_);unassociated trivia:
Quoted 4 lines
casting _RET_IP_ back to void * seems odd as the define is
include/linux/kernel.h:#define _RET_IP_ (unsigned long)__builtin_return_address(0)It's probably easier to understand as just
__builtin_return_address(0)
Maybe, but I'm not sure it's worth the churn.
Quoted 12 lines
mm/memblock.c void * __init memblock_alloc_try_nid_raw( · line 1527
Quoted 9 lines
mm/memblock.c +0
-2@@ -1528,18 +1522,12 @@ void * __init memblock_alloc_try_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { -void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr, (void *)_RET_IP_);here too
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 4/4] memblock: stop poisoning raw allocations
Quoted 28 lines · Mike Rapoport
Quoted 27 lines · Joe Perches
Quoted 11 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Functions
memblock_alloc_exact_nid_raw()andmemblock_alloc_try_nid_raw()are intended for early memory allocation without overhead of zeroing the allocated memory. Since these functions were used to allocate the memory map, they have ended up with addition of a call topage_init_poison()that poisoned the allocated memory whenCONFIG_PAGE_POISONwas set.Since the memory map is allocated using a dedicated
memmep_alloc()function that takes care of the poisoning, remove page poisoning from the memblock_alloc_*_raw() functions.[]
mm/memblock.c
Quoted 1 line
mm/memblock.c +0
-0[]
mm/memblock.c void * __init memblock_alloc_exact_nid_raw( · line 1495
Quoted 9 lines
mm/memblock.c +0
-2@@ -1490,18 +1490,12 @@ void * __init memblock_alloc_exact_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { -void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr, (void *)_RET_IP_);unassociated trivia:
Quoted 7 lines
Quoted 4 lines
casting _RET_IP_ back to void * seems odd as the define is
include/linux/kernel.h:#define _RET_IP_ (unsigned long)__builtin_return_address(0)It's probably easier to understand as just
__builtin_return_address(0)Maybe, but I'm not sure it's worth the churn.
I think churn is overused as a blocking mechanism over readability. I prefer readability.
$ git grep -P --name-only '\(\s*void\s*\*\s*\)\s*_RET_IP_' | \ xargs sed -r -i -e 's/\(\s*void\s*\*\s*\)\s*_RET_IP_/__builtin_return_address(0)/' --- arch/arm/mm/init.c | 2 +- arch/powerpc/kernel/irq.c | 2 +- arch/powerpc/kernel/setup_32.c | 2 +- arch/x86/mm/kasan_init_64.c | 2 +- drivers/block/drbd/drbd_actlog.c | 2 +- drivers/char/random.c | 2 +- drivers/firmware/arm_scmi/driver.c | 2 +- drivers/firmware/ti_sci.c | 2 +- drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/i915_utils.c | 2 +- drivers/soc/ti/smartreflex.c | 10 +++++----- mm/memblock.c | 20 ++++++++++---------- mm/util.c | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-)
arch/arm/mm/init.c +1 -1
@@ -156,7 +156,7 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align) phys =memblock_phys_alloc (size, align);if (!phys)panic ("Failed to steal %pa bytes at %pS\n" , - &size, (void *)_RET_IP_); + &size,__builtin_return_address (0 ));memblock_free (phys, size);memblock_remove (phys, size);
arch/powerpc/kernel/irq.c +1 -1
@@ -777,7 +777,7 @@ DEFINE_INTERRUPT_HANDLER_ASYNC(do_IRQ)static void *__init alloc_vm_stack (void ) {return __vmalloc_node (THREAD_SIZE ,THREAD_ALIGN ,THREADINFO_GFP , -NUMA_NO_NODE , (void *)_RET_IP_); +NUMA_NO_NODE ,__builtin_return_address (0 )); }static void __init vmap_irqstack_init (void )
arch/powerpc/kernel/setup_32.c +1 -1
@@ -143,7 +143,7 @@ static void *__init alloc_stack(void)if (!ptr)panic ("cannot allocate %d bytes for stack at %pS\n" , -THREAD_SIZE , (void *)_RET_IP_); +THREAD_SIZE ,__builtin_return_address (0 ));return ptr; }
arch/x86/mm/kasan_init_64.c +1 -1
@@ -30,7 +30,7 @@ static __init void *early_alloc(size_t size, int nid, bool should_panic)if (!ptr && should_panic)panic ("%pS: Failed to allocate page, nid=%d from=%lx\n" , - (void *)_RET_IP_, nid,__pa (MAX_DMA_ADDRESS )); +__builtin_return_address (0 ), nid,__pa (MAX_DMA_ADDRESS ));return ptr; }
drivers/block/drbd/drbd_actlog.c +1 -1
@@ -185,7 +185,7 @@ int drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev *bddynamic_drbd_dbg (device,"meta_data io: %s [%d]:%s(,%llus,%s) %pS\n" , current->comm, current->pid, __func__, (unsigned long long )sector, (op ==REQ_OP_WRITE ) ?"WRITE" :"READ" , - (void *)_RET_IP_ ); +__builtin_return_address (0 ) );if (sector <drbd_md_first_sector (bdev) || sector +7 >drbd_md_last_sector (bdev))
drivers/char/random.c +1 -1
@@ -1487,7 +1487,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf, }#define warn_unseeded_randomness (previous) \ - _warn_unseeded_randomness(__func__, (void *) _RET_IP_, (previous)) + _warn_unseeded_randomness(__func__, __builtin_return_address(0), (previous))static void _warn_unseeded_randomness (const char *func_name,void *caller,void **previous)
drivers/firmware/arm_scmi/driver.c +1 -1
@@ -468,7 +468,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph, timeout =msecs_to_jiffies (info->desc->max_rx_timeout_ms);if (!wait_for_completion_timeout (&xfer->done, timeout)) {dev_err (dev,"timed out in resp(caller: %pS)\n" , - (void *)_RET_IP_); +__builtin_return_address (0 )); ret = -ETIMEDOUT ; } }
drivers/firmware/ti_sci.c +1 -1
@@ -417,7 +417,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info, timeout =msecs_to_jiffies (info->desc->max_rx_timeout_ms);if (!wait_for_completion_timeout (&xfer->done, timeout)) {dev_err (dev,"Mbox timedout in resp(caller: %pS)\n" , - (void *)_RET_IP_); +__builtin_return_address (0 )); ret = -ETIMEDOUT ; }/*
drivers/gpu/drm/i915/gt/intel_reset.c +1 -1
@@ -925,7 +925,7 @@ void intel_gt_set_wedged(struct intel_gt *gt)struct intel_engine_cs *engine;enum intel_engine_id id; -drm_printf (&p,"called from %pS\n" , (void *)_RET_IP_); +drm_printf (&p,"called from %pS\n" ,__builtin_return_address (0 ));for_each_engine (engine, gt, id) {if (intel_engine_is_idle (engine))continue ;
drivers/gpu/drm/i915/i915_utils.c +1 -1
@@ -52,7 +52,7 @@ __i915_printk(struct drm_i915_private *dev_priv, const char *level,void add_taint_for_CI (struct drm_i915_private *i915,unsigned int taint) {__i915_printk (i915,KERN_NOTICE ,"CI tainted:%#x by %pS\n" , - taint, (void *)_RET_IP_); + taint,__builtin_return_address (0 ));/* Failures that occur during fault injection testing are expected */ if (!i915_error_injected ())
drivers/soc/ti/smartreflex.c +5 -5
@@ -357,7 +357,7 @@ int sr_configure_errgen(struct omap_sr *sr)if (!sr) {pr_warn ("%s: NULL omap_sr from %pS\n" , - __func__, (void *)_RET_IP_); + __func__,__builtin_return_address (0 ));return -EINVAL ; }
@@ -424,7 +424,7 @@ int sr_disable_errgen(struct omap_sr *sr)if (!sr) {pr_warn ("%s: NULL omap_sr from %pS\n" , - __func__, (void *)_RET_IP_); + __func__,__builtin_return_address (0 ));return -EINVAL ; }
@@ -479,7 +479,7 @@ int sr_configure_minmax(struct omap_sr *sr)if (!sr) {pr_warn ("%s: NULL omap_sr from %pS\n" , - __func__, (void *)_RET_IP_); + __func__,__builtin_return_address (0 ));return -EINVAL ; }
@@ -564,7 +564,7 @@ int sr_enable(struct omap_sr *sr, unsigned long volt)if (!sr) {pr_warn ("%s: NULL omap_sr from %pS\n" , - __func__, (void *)_RET_IP_); + __func__,__builtin_return_address (0 ));return -EINVAL ; }
@@ -616,7 +616,7 @@ void sr_disable(struct omap_sr *sr) {if (!sr) {pr_warn ("%s: NULL omap_sr from %pS\n" , - __func__, (void *)_RET_IP_); + __func__,__builtin_return_address (0 ));return ; }
mm/memblock.c +10 -10
@@ -684,7 +684,7 @@ int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size)phys_addr_t end = base + size -1 ;memblock_dbg ("%s: [%pa-%pa] %pS\n" , __func__, - &base, &end, (void *)_RET_IP_); + &base, &end,__builtin_return_address (0 ));return memblock_add_range (&memblock.memory, base, size,MAX_NUMNODES ,0 ); }
@@ -785,7 +785,7 @@ int __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)phys_addr_t end = base + size -1 ;memblock_dbg ("%s: [%pa-%pa] %pS\n" , __func__, - &base, &end, (void *)_RET_IP_); + &base, &end,__builtin_return_address (0 ));return memblock_remove_range (&memblock.memory, base, size); }
@@ -803,7 +803,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)phys_addr_t end = base + size -1 ;memblock_dbg ("%s: [%pa-%pa] %pS\n" , __func__, - &base, &end, (void *)_RET_IP_); + &base, &end,__builtin_return_address (0 ));kmemleak_free_part_phys (base, size);return memblock_remove_range (&memblock.reserved, base, size);
@@ -814,7 +814,7 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)phys_addr_t end = base + size -1 ;memblock_dbg ("%s: [%pa-%pa] %pS\n" , __func__, - &base, &end, (void *)_RET_IP_); + &base, &end,__builtin_return_address (0 ));return memblock_add_range (&memblock.reserved, base, size,MAX_NUMNODES ,0 ); }
@@ -825,7 +825,7 @@ int __init_memblock memblock_physmem_add(phys_addr_t base, phys_addr_t size)phys_addr_t end = base + size -1 ;memblock_dbg ("%s: [%pa-%pa] %pS\n" , __func__, - &base, &end, (void *)_RET_IP_); + &base, &end,__builtin_return_address (0 ));return memblock_add_range (&physmem, base, size,MAX_NUMNODES ,0 ); }
@@ -1392,7 +1392,7 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size, {memblock_dbg ("%s: %llu bytes align=0x%llx from=%pa max_addr=%pa %pS\n" , __func__, (u64 )size, (u64 )align, &start, &end, - (void *)_RET_IP_); +__builtin_return_address (0 ));return memblock_alloc_range_nid (size, align, start, end,NUMA_NO_NODE , false); }
@@ -1493,7 +1493,7 @@ void * __init memblock_alloc_exact_nid_raw( {memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n" , __func__, (u64 )size, (u64 )align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); + &max_addr,__builtin_return_address (0 ));return memblock_alloc_internal (size, align, min_addr, max_addr, nid, true);
@@ -1525,7 +1525,7 @@ void * __init memblock_alloc_try_nid_raw( {memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n" , __func__, (u64 )size, (u64 )align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); + &max_addr,__builtin_return_address (0 ));return memblock_alloc_internal (size, align, min_addr, max_addr, nid, false);
@@ -1557,7 +1557,7 @@ void * __init memblock_alloc_try_nid(memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n" , __func__, (u64 )size, (u64 )align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); + &max_addr,__builtin_return_address (0 )); ptr =memblock_alloc_internal (size, align, min_addr, max_addr, nid, false);if (ptr)
@@ -1581,7 +1581,7 @@ void __init __memblock_free_late(phys_addr_t base, phys_addr_t size) end = base + size -1 ;memblock_dbg ("%s: [%pa-%pa] %pS\n" , - __func__, &base, &end, (void *)_RET_IP_); + __func__, &base, &end,__builtin_return_address (0 ));kmemleak_free_part_phys (base, size); cursor =PFN_UP (base); end =PFN_DOWN (base + size);
mm/util.c +1 -1
@@ -492,7 +492,7 @@ int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc, }pr_debug ("%s: [%d] caller %ps %c%lu %lu/%lu%s\n" , __func__, task->pid, - (void *)_RET_IP_, (inc) ?'+' :'-' , pages <<PAGE_SHIFT , +__builtin_return_address (0 ), (inc) ?'+' :'-' , pages <<PAGE_SHIFT , locked_vm <<PAGE_SHIFT ,task_rlimit (task,RLIMIT_MEMLOCK ), ret ?" - exceeded" :"" );