Re: kcompactd hang during memory offlining

From: Vlastimil Babka
Date: Tue May 03 2016 - 18:16:52 EST


On 05/03/2016 07:02 PM, Reza Arbab wrote:
> Assume memory47 is the last online block left in node1. This will hang:
>
> # echo offline > /sys/devices/system/node/node1/memory47/state
>
> After a couple of minutes, the following pops up in dmesg:
>
> INFO: task bash:957 blocked for more than 120 seconds.

Damn, can you test this patch? I hope it's just the simple mistake and kcompactd is
waiting for the kcompactd_max_order > 0 when it's woken up to actually exit.
No idea what happens if memory actually gets offlined during compaction's pfn scan...
but that wouldn't be new or specific to kcompactd...

----8<----
diff --git a/mm/compaction.c b/mm/compaction.c
index 481004c73c90..0e28981d4510 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1852,7 +1852,7 @@ void compaction_unregister_node(struct node *node)

static inline bool kcompactd_work_requested(pg_data_t *pgdat)
{
- return pgdat->kcompactd_max_order > 0;
+ return pgdat->kcompactd_max_order > 0 || kthread_should_stop();
}

static bool kcompactd_node_suitable(pg_data_t *pgdat)
@@ -1916,6 +1916,8 @@ static void kcompactd_do_work(pg_data_t *pgdat)
INIT_LIST_HEAD(&cc.freepages);
INIT_LIST_HEAD(&cc.migratepages);

+ if (kthread_should_stop())
+ return;
status = compact_zone(zone, &cc);

if (zone_watermark_ok(zone, cc.order, low_wmark_pages(zone),