PM: Use WQ_MEM_RECLAIM flag for PM workqueue
Subsystems (2)
PATCH 1/1 PM: Use WQ_MEM_RECLAIM flag for PM workqueue
Deadlock is seen under below high memory usage scenario.
kswapd waiting to reclaim memory is blocked on i/o kworker and pm_wq context which needs to wakeup i/o kworker is waiting for kthread creation which is again blocked in memory reclaim path.
Use WQ_MEM_RECLAIM flag for PM workqueue to avoid this deadlock.
--- kernel/power/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/main.c +1 -1
@@ -933,7 +933,7 @@ EXPORT_SYMBOL_GPL(pm_wq);static int __init pm_start_workqueue (void ) { - pm_wq =alloc_workqueue ("pm" ,WQ_FREEZABLE ,0 ); + pm_wq =alloc_workqueue ("pm" ,WQ_FREEZABLE |WQ_MEM_RECLAIM ,0 );return pm_wq ?0 : -ENOMEM ; }
Signature · 1 line
2.17.1
Rafael J. Wysocki
maintainerQuoted 2 lines · On Tue, Oct 27, 2020 at 11:15 AM <[email protected]> wrote:
Deadlock is seen under below high memory usage scenario.
I'm not sure what the "under below high" means.
Quoted 3 lines
kswapd waiting to reclaim memory is blocked on i/o kworker and
pm_wqcontext which needs to wakeup i/o kworker is waiting for kthread creation which is again blocked in memory reclaim path.
Can you explain in more detail how exactly you end up in that situation?
Quoted 1 line
Use
WQ_MEM_RECLAIMflag for PM workqueue to avoid this deadlock.
This works, but this flag doesn't seem to be appropriate here, because pm_wq doesn't actually participate in memory reclaim.
Quoted 21 lines
Signed-off-by Ravisankar Reddy (Sony) <[email protected]>--- kernel/power/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/power/main.c +1
-2@@ -933,7 +933,7 @@ EXPORT_SYMBOL_GPL(pm_wq);static int __init pm_start_workqueue (void ) { - pm_wq =alloc_workqueue ("pm" ,WQ_FREEZABLE ,0 ); + pm_wq =alloc_workqueue ("pm" ,WQ_FREEZABLE |WQ_MEM_RECLAIM ,0 );return pm_wq ?0 : -ENOMEM ; } --2.17.1