Re: [PATCH] Revert "mm/page_isolation: unset migratetype directly for non Buddy page"

From: Dong Aisheng
Date: Tue Jan 18 2022 - 08:56:22 EST


On Mon, Jan 17, 2022 at 10:12 PM Chen Wandun <chenwandun@xxxxxxxxxx> wrote:
>
> This reverts commit 075782149abff45ee22f27315eced44d02b96779.
>
> commit 075782149abf ("mm/page_isolation: unset migratetype directly for
> non Buddy page") will result memory that should in buddy disappear by
> mistake. move_freepages_block move all pages in pageblock instead of
> pages indicated by input parameter, so if input pages is not in buddy
> but other pages in pageblock is in buddy, it will result in page out of
> control.
>
> Reported-by: "kernelci.org bot" <bot@xxxxxxxxxxxx>
> Signed-off-by: Chen Wandun <chenwandun@xxxxxxxxxx>

The original patch broke imx6ul evk booting up.
Bisect shows it was caused by that patch.
After reverting, it works again.

So:
Tested-by: Dong Aisheng <aisheng.dong@xxxxxxx>

Below is the original error log:
[ 8.710031] kworker/u2:2 invoked oom-killer:
gfp_mask=0xcc0(GFP_KERNEL), order=0, oom_score_adj=0
[ 8.719920] CPU: 0 PID: 29 Comm: kworker/u2:2 Not tainted
5.16.0-00095-g721fb891ad0b #95
[ 8.728093] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[ 8.734322] Workqueue: events_unbound deferred_probe_work_func
[ 8.740258] [<c0111640>] (unwind_backtrace) from [<c010ba84>]
(show_stack+0x10/0x14)
[ 8.748080] [<c010ba84>] (show_stack) from [<c0f38aa4>]
(dump_stack_lvl+0x58/0x70)
[ 8.755725] [<c0f38aa4>] (dump_stack_lvl) from [<c0f32f60>]
(dump_header+0x54/0x3cc)
[ 8.763534] [<c0f32f60>] (dump_header) from [<c02aec94>]
(out_of_memory+0x54c/0x5f0)
[ 8.771351] [<c02aec94>] (out_of_memory) from [<c030166c>]
(__alloc_pages+0xda8/0x1224)
[ 8.779427] [<c030166c>] (__alloc_pages) from [<c03102f4>]
(new_slab+0x200/0x288)
[ 8.786983] [<c03102f4>] (new_slab) from [<c03129ec>]
(___slab_alloc.constprop.0+0x5b0/0xea4)
[ 8.795585] [<c03129ec>] (___slab_alloc.constprop.0) from
[<c031331c>] (__slab_alloc.constprop.0+0x3c/0x5c)
[ 8.805399] [<c031331c>] (__slab_alloc.constprop.0) from
[<c03135a0>] (__kmalloc_track_caller+0x264/0x3a4)
[ 8.815125] [<c03135a0>] (__kmalloc_track_caller) from [<c02c8cec>]
(kstrdup_const+0x4c/0x7c)
[ 8.823719] [<c02c8cec>] (kstrdup_const) from [<c03cf890>]
(__kernfs_new_node.constprop.0+0x30/0x260)
[ 8.833009] [<c03cf890>] (__kernfs_new_node.constprop.0) from
[<c03d0c4c>] (kernfs_new_node+0x30/0x50)
[ 8.842384] [<c03d0c4c>] (kernfs_new_node) from [<c03d2e24>]
(kernfs_create_link+0x40/0xac)
[ 8.850804] [<c03d2e24>] (kernfs_create_link) from [<c03d419c>]
(sysfs_do_create_link_sd+0x5c/0xd8)
[ 8.859921] [<c03d419c>] (sysfs_do_create_link_sd) from
[<c086e9a4>] (device_add+0x264/0x8a8)
[ 8.868518] [<c086e9a4>] (device_add) from [<c09f99dc>]
(usb_add_gadget+0xd0/0x180)
[ 8.876246] [<c09f99dc>] (usb_add_gadget) from [<c09fa124>]
(usb_add_gadget_udc+0x78/0xb4)
[ 8.884580] [<c09fa124>] (usb_add_gadget_udc) from [<c09ec674>]
(ci_hdrc_gadget_init+0x368/0x3e0)
[ 8.893522] [<c09ec674>] (ci_hdrc_gadget_init) from [<c09e7870>]
(ci_hdrc_probe+0x6c8/0x8b8)
[ 8.902025] [<c09e7870>] (ci_hdrc_probe) from [<c08756f4>]
(platform_probe+0x58/0xbc)
[ 8.909919] [<c08756f4>] (platform_probe) from [<c0872e14>]
(really_probe.part.0+0x9c/0x32c)
[ 8.918427] [<c0872e14>] (really_probe.part.0) from [<c0873144>]
(__driver_probe_device+0xa0/0x138)
[ 8.927544] [<c0873144>] (__driver_probe_device) from [<c087320c>]
(driver_probe_device+0x30/0x10c)
[ 8.936661] [<c087320c>] (driver_probe_device) from [<c08737dc>]
(__device_attach_driver+0xb0/0xf8)
[ 8.945778] [<c08737dc>] (__device_attach_driver) from [<c0870ec8>]
(bus_for_each_drv+0x80/0xd0)
[ 8.954631] [<c0870ec8>] (bus_for_each_drv) from [<c08734f0>]
(__device_attach+0xd0/0x19c)
[ 8.962965] [<c08734f0>] (__device_attach) from [<c0871f5c>]
(bus_probe_device+0x88/0x90)
[ 8.971212] [<c0871f5c>] (bus_probe_device) from [<c086ead0>]
(device_add+0x390/0x8a8)
[ 8.979195] [<c086ead0>] (device_add) from [<c0875370>]
(platform_device_add+0x100/0x208)
[ 8.987436] [<c0875370>] (platform_device_add) from [<c09e686c>]
(ci_hdrc_add_device+0x400/0x538)
[ 8.996369] [<c09e686c>] (ci_hdrc_add_device) from [<c09eee90>]
(ci_hdrc_imx_probe+0x250/0x62c)
[ 9.005133] [<c09eee90>] (ci_hdrc_imx_probe) from [<c08756f4>]
(platform_probe+0x58/0xbc)
[ 9.013375] [<c08756f4>] (platform_probe) from [<c0872e14>]
(really_probe.part.0+0x9c/0x32c)
[ 9.021880] [<c0872e14>] (really_probe.part.0) from [<c0873144>]
(__driver_probe_device+0xa0/0x138)
[ 9.030995] [<c0873144>] (__driver_probe_device) from [<c087320c>]
(driver_probe_device+0x30/0x10c)
[ 9.040110] [<c087320c>] (driver_probe_device) from [<c08737dc>]
(__device_attach_driver+0xb0/0xf8)
[ 9.049225] [<c08737dc>] (__device_attach_driver) from [<c0870ec8>]
(bus_for_each_drv+0x80/0xd0)
[ 9.058081] [<c0870ec8>] (bus_for_each_drv) from [<c08734f0>]
(__device_attach+0xd0/0x19c)
[ 9.066414] [<c08734f0>] (__device_attach) from [<c0871f5c>]
(bus_probe_device+0x88/0x90)
[ 9.074659] [<c0871f5c>] (bus_probe_device) from [<c0872390>]
(deferred_probe_work_func+0x78/0xa8)
[ 9.083691] [<c0872390>] (deferred_probe_work_func) from
[<c0149174>] (process_one_work+0x294/0x7c0)
[ 9.092896] [<c0149174>] (process_one_work) from [<c01496ec>]
(worker_thread+0x4c/0x554)
[ 9.101052] [<c01496ec>] (worker_thread) from [<c01525c8>]
(kthread+0x16c/0x194)
[ 9.108515] [<c01525c8>] (kthread) from [<c010011c>]
(ret_from_fork+0x14/0x38)
[ 9.115800] Exception stack(0xc4349fb0 to 0xc4349ff8)
[ 9.120906] 9fa0: 00000000
00000000 00000000 00000000
[ 9.129138] 9fc0: 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000
[ 9.137364] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 9.145304] Mem-Info:
[ 9.147682] active_anon:0 inactive_anon:0 isolated_anon:0
[ 9.147682] active_file:0 inactive_file:0 isolated_file:0
[ 9.147682] unevictable:0 dirty:0 writeback:0
[ 9.147682] slab_reclaimable:2805 slab_unreclaimable:1466
[ 9.147682] mapped:0 shmem:0 pagetables:0 bounce:0
[ 9.147682] kernel_misc_reclaimable:0
[ 9.147682] free:0 free_pcp:5 free_cma:0
[ 9.182265] Node 0 active_anon:0kB inactive_anon:0kB
active_file:0kB inactive_file:0kB unevictable:0kB isolated(anon):0kB
isolated(file):0kB mapped:0kB dirty:0kB writeback:0kB shmem:0kB
writeback_tmp:0kB kerno
[ 9.205657] Normal free:0kB boost:0kB min:2780kB low:3472kB
high:4164kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB
active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB
present:524B
[ 9.232095] lowmem_reserve[]: 0 0 0
[ 9.235772] Normal: 5*4kB (UMI) 5*8kB (UEI) 10*16kB (UMEI) 9*32kB
(UME) 5*64kB (UME) 7*128kB (UMEI) 7*256kB (UMEI) 4*512kB (MEI)
2*1024kB (M) 4*2048kB (UMI) 5*4096kB (UMEI) 2*8192kB (MI) 5*16384kB
(UMEI) 10*3B
[ 9.257621] 0 total pagecache pages
[ 9.261441] 0 pages in swap cache
[ 9.264820] Swap cache stats: add 0, delete 0, find 0/0
[ 9.270258] Free swap = 0kB
[ 9.273199] Total swap = 0kB
[ 9.276133] 131072 pages RAM
[ 9.279293] 0 pages HighMem/MovableOnly
[ 9.283188] 10061 pages reserved
[ 9.286468] 16384 pages cma reserved
[ 9.290239] Tasks state (memory values in pages):
[ 9.295087] [ pid ] uid tgid total_vm rss pgtables_bytes
swapents oom_score_adj name
[ 9.303927] Out of memory and no killable processes...
[ 9.309285] Kernel panic - not syncing: System is deadlocked on memory

Regards
Aisheng

> ---
> mm/page_isolation.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index 6a0ddda6b3c5..f67c4c70f17f 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -115,7 +115,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)
> * onlining - just onlined memory won't immediately be considered for
> * allocation.
> */
> - if (!isolated_page && PageBuddy(page)) {
> + if (!isolated_page) {
> nr_pages = move_freepages_block(zone, page, migratetype, NULL);
> __mod_zone_freepage_state(zone, nr_pages, migratetype);
> }
> --
> 2.18.0.huawei.25
>
>