Message ID | 1665107561-23030-1-git-send-email-zhaoyang.huang@unisoc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [Resend] mm: add stackdepot information on page->private for tracking | expand |
Greeting, FYI, we noticed the following commit (built with gcc-11): commit: 795534bb6e5a83f062dcec24c28f17e1d8d03d5b ("[Resend PATCH] mm: add stackdepot information on page->private for tracking") url: https://github.com/intel-lab-lkp/linux/commits/zhaoyang-huang/mm-add-stackdepot-information-on-page-private-for-tracking/20221007-095337 base: https://git.kernel.org/cgit/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/linux-mm/1665107561-23030-1-git-send-email-zhaoyang.huang@unisoc.com in testcase: boot on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace): +------------------------------------------------------------------------+------------+------------+ | | 183de549a0 | 795534bb6e | +------------------------------------------------------------------------+------------+------------+ | boot_successes | 14 | 0 | | boot_failures | 0 | 12 | | Kernel_panic-not_syncing:corrupted_stack_end_detected_inside_scheduler | 0 | 12 | +------------------------------------------------------------------------+------------+------------+ If you fix the issue, kindly add following tag | Reported-by: kernel test robot <oliver.sang@intel.com> | Link: https://lore.kernel.org/r/202210072204.cfea59d3-oliver.sang@intel.com [ 1.903497][ T0] Kernel panic - not syncing: corrupted stack end detected inside scheduler [ 1.904137][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc3-00705-g795534bb6e5a #23 [ 1.904818][ T0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-debian-1.16.0-4 04/01/2014 [ 1.905608][ T0] Call Trace: [ 1.905941][ T0] dump_stack_lvl+0x29/0x36 [ 1.906284][ T0] dump_stack+0xd/0x10 [ 1.906293][ T0] panic+0xe2/0x242 [ 1.906293][ T0] schedule_debug+0x1b/0x11d [ 1.906293][ T0] __schedule+0x1b/0x3cb [ 1.906293][ T0] ? trace_hardirqs_on+0x3d/0x3f [ 1.906293][ T0] schedule+0x5f/0x8e [ 1.906293][ T0] schedule_preempt_disabled+0xe/0x16 [ 1.906293][ T0] rest_init+0xb1/0xbb [ 1.906293][ T0] arch_call_rest_init+0x8/0x9 [ 1.906293][ T0] start_kernel+0x458/0x466 [ 1.906293][ T0] i386_start_kernel+0x42/0x44 [ 1.906293][ T0] startup_32_smp+0x161/0x170 To reproduce: # build kernel cd linux cp config-6.0.0-rc3-00705-g795534bb6e5a .config make HOSTCC=gcc-11 CC=gcc-11 ARCH=i386 olddefconfig prepare modules_prepare bzImage modules make HOSTCC=gcc-11 CC=gcc-11 ARCH=i386 INSTALL_MOD_PATH=<mod-install-dir> modules_install cd <mod-install-dir> find lib/ | cpio -o -H newc --quiet | gzip > modules.cgz git clone https://github.com/intel/lkp-tests.git cd lkp-tests bin/lkp qemu -k <bzImage> -m modules.cgz job-script # job-script is attached in this email # if come across any failure that blocks the test, # please remove ~/.lkp and /lkp dir to run from a clean state.
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e5486d4..b79a503 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -75,6 +75,7 @@ #include <linux/khugepaged.h> #include <linux/buffer_head.h> #include <linux/delayacct.h> +#include <linux/stackdepot.h> #include <asm/sections.h> #include <asm/tlbflush.h> #include <asm/div64.h> @@ -2464,6 +2465,25 @@ static inline bool should_skip_init(gfp_t flags) return (flags & __GFP_SKIP_ZERO); } +#ifdef CONFIG_STACKDEPOT +static noinline depot_stack_handle_t set_track_prepare(void) +{ + depot_stack_handle_t trace_handle; + unsigned long entries[16]; + unsigned int nr_entries; + + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 3); + trace_handle = stack_depot_save(entries, nr_entries, GFP_NOWAIT); + + return trace_handle; +} +#else +static inline depot_stack_handle_t set_track_prepare(void) +{ + return 0; +} +#endif + inline void post_alloc_hook(struct page *page, unsigned int order, gfp_t gfp_flags) { @@ -2471,8 +2491,14 @@ inline void post_alloc_hook(struct page *page, unsigned int order, !should_skip_init(gfp_flags); bool init_tags = init && (gfp_flags & __GFP_ZEROTAGS); int i; + depot_stack_handle_t stack_handle = set_track_prepare(); - set_page_private(page, 0); + /* + * Don't worry, user will cover private directly without checking + * this field and has ability to trace the page. This also will not + * affect expected state when freeing + */ + set_page_private(page, stack_handle); set_page_refcounted(page); arch_alloc_page(page, order);