* [PATCH 1/1] mm: vmalloc: dump page owner info if page is already mapped [not found] <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcas5p4.samsung.com> @ 2024-04-19 4:39 ` Hariom Panthi 2024-04-22 21:28 ` Andrew Morton [not found] ` <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcms5p4> 0 siblings, 2 replies; 3+ messages in thread From: Hariom Panthi @ 2024-04-19 4:39 UTC (permalink / raw) To: akpm, urezki, hch, lstoakes Cc: linux-mm, linux-kernel, maninder1.s, r.thapliyal, Hariom Panthi In vmap_pte_range, BUG_ON is called when page is already mapped, It doesn't give enough information to debug further. Dumping page owner information alongwith BUG_ON will be more useful in case of multiple page mapping. Example: [ 18.258806] page_owner tracks the page as allocated [ 18.258970] page last allocated via order 0, migratetype Unmovable, gfp_mask 0xcc0(GFP_KERNEL), pid 81, tgid 81 (insmod), ts 18257811008, free_ts 0 [ 18.259327] prep_new_page+0xa8/0x10c [ 18.259455] get_page_from_freelist+0x7f8/0x1248 [ 18.259591] __alloc_pages+0x164/0x2b4 [ 18.259703] alloc_pages_mpol+0x88/0x230 [ 18.259821] alloc_pages+0x4c/0x7c [ 18.259923] load_module+0x74/0x1af4 [ 18.260031] __do_sys_init_module+0x190/0x1fc [ 18.260154] __arm64_sys_init_module+0x1c/0x28 [ 18.260280] invoke_syscall+0x44/0x108 [ 18.260394] el0_svc_common.constprop.0+0x40/0xe0 [ 18.260530] do_el0_svc_compat+0x1c/0x34 [ 18.260647] el0_svc_compat+0x2c/0x80 [ 18.260761] el0t_32_sync_handler+0x90/0x140 [ 18.260887] el0t_32_sync+0x194/0x198 [ 18.260996] page_owner free stack trace missing [ 18.261143] ------------[ cut here ]------------ [ 18.261272] kernel BUG at mm/vmalloc.c:113! Signed-off-by: Hariom Panthi <hariom1.p@samsung.com> --- mm/vmalloc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 68fa001648cc..9c91091887de 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -42,6 +42,7 @@ #include <linux/sched/mm.h> #include <asm/tlbflush.h> #include <asm/shmparam.h> +#include <linux/page_owner.h> #define CREATE_TRACE_POINTS #include <trace/events/vmalloc.h> @@ -96,6 +97,7 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, { pte_t *pte; u64 pfn; + struct page *page; unsigned long size = PAGE_SIZE; pfn = phys_addr >> PAGE_SHIFT; @@ -103,7 +105,13 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, if (!pte) return -ENOMEM; do { - BUG_ON(!pte_none(ptep_get(pte))); + if (!pte_none(ptep_get(pte))) { + if (pfn_valid(pfn)) { + page = pfn_to_page(pfn); + dump_page_owner(page); + } + BUG(); + } #ifdef CONFIG_HUGETLB_PAGE size = arch_vmap_pte_range_map_size(addr, end, pfn, max_page_shift); -- 2.25.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mm: vmalloc: dump page owner info if page is already mapped 2024-04-19 4:39 ` [PATCH 1/1] mm: vmalloc: dump page owner info if page is already mapped Hariom Panthi @ 2024-04-22 21:28 ` Andrew Morton [not found] ` <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcms5p4> 1 sibling, 0 replies; 3+ messages in thread From: Andrew Morton @ 2024-04-22 21:28 UTC (permalink / raw) To: Hariom Panthi Cc: urezki, hch, lstoakes, linux-mm, linux-kernel, maninder1.s, r.thapliyal On Fri, 19 Apr 2024 10:09:10 +0530 Hariom Panthi <hariom1.p@samsung.com> wrote: > In vmap_pte_range, BUG_ON is called when page is already mapped, > It doesn't give enough information to debug further. > Dumping page owner information alongwith BUG_ON will be more useful > in case of multiple page mapping. > > Example: > [ 18.258806] page_owner tracks the page as allocated > [ 18.258970] page last allocated via order 0, migratetype Unmovable, gfp_mask 0xcc0(GFP_KERNEL), pid 81, tgid 81 (insmod), ts 18257811008, free_ts 0 > [ 18.259327] prep_new_page+0xa8/0x10c > [ 18.259455] get_page_from_freelist+0x7f8/0x1248 > [ 18.259591] __alloc_pages+0x164/0x2b4 > [ 18.259703] alloc_pages_mpol+0x88/0x230 > [ 18.259821] alloc_pages+0x4c/0x7c > [ 18.259923] load_module+0x74/0x1af4 > [ 18.260031] __do_sys_init_module+0x190/0x1fc > [ 18.260154] __arm64_sys_init_module+0x1c/0x28 > [ 18.260280] invoke_syscall+0x44/0x108 > [ 18.260394] el0_svc_common.constprop.0+0x40/0xe0 > [ 18.260530] do_el0_svc_compat+0x1c/0x34 > [ 18.260647] el0_svc_compat+0x2c/0x80 > [ 18.260761] el0t_32_sync_handler+0x90/0x140 > [ 18.260887] el0t_32_sync+0x194/0x198 > [ 18.260996] page_owner free stack trace missing > [ 18.261143] ------------[ cut here ]------------ > [ 18.261272] kernel BUG at mm/vmalloc.c:113! > > ... > > @@ -103,7 +105,13 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, > if (!pte) > return -ENOMEM; > do { > - BUG_ON(!pte_none(ptep_get(pte))); > + if (!pte_none(ptep_get(pte))) { > + if (pfn_valid(pfn)) { > + page = pfn_to_page(pfn); > + dump_page_owner(page); > + } > + BUG(); > + } Diving straight into dump_page_owner() seems inappropriate. The higher-level dump_page() interface is more typically used. Or, even more common, VM_BUG_ON_PAGE(), but that doesn't look to be a good fit here. ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcms5p4>]
* Re: [PATCH 1/1] mm: vmalloc: dump page owner info if page is already mapped [not found] ` <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcms5p4> @ 2024-04-23 3:50 ` Hariom Panthi 0 siblings, 0 replies; 3+ messages in thread From: Hariom Panthi @ 2024-04-23 3:50 UTC (permalink / raw) To: Andrew Morton Cc: urezki, hch, lstoakes, linux-mm, linux-kernel, Maninder Singh, Rohit Thapliyal Hi, > > ... > > > > @@ -103,7 +105,13 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, > > if (!pte) > > return -ENOMEM; > > do { > > - BUG_ON(!pte_none(ptep_get(pte))); > > + if (!pte_none(ptep_get(pte))) { > > + if (pfn_valid(pfn)) { > > + page = pfn_to_page(pfn); > > + dump_page_owner(page); > > + } > > + BUG(); > > + } > > Diving straight into dump_page_owner() seems inappropriate. The > higher-level dump_page() interface is more typically used. > > Or, even more common, VM_BUG_ON_PAGE(), but that doesn't look to be a > good fit here. Ok I will send V2 with dump_page API. Thanks, Hariom ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-23 3:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcas5p4.samsung.com>
2024-04-19 4:39 ` [PATCH 1/1] mm: vmalloc: dump page owner info if page is already mapped Hariom Panthi
2024-04-22 21:28 ` Andrew Morton
[not found] ` <CGME20240419044047epcas5p4a90ca734d73bc9a87cd1670beaa24d8e@epcms5p4>
2024-04-23 3:50 ` Hariom Panthi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox