Attached below (merged with 2/2). I haven't checked that it does fix theE.g. suppose processes areExcept that kswapd runs as SCHED_NORMAL with 0 priority.
governed by FIFO and kswapd happens to have a higher prio than the
process killed by OOM. Then after cond_resched kswapd will be picked for
execution again, and the killing process won't have a chance to remove
itself from the wait queue.
So you are relying on scheduling points somewhere down theThey will get woken up a bit later in balanced_pgdat. This might resultdiff --git a/mm/vmscan.c b/mm/vmscan.cWhat would be consequences of not waking up pfmemalloc waiters while the
index 744e2b491527..2a123634c220 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2984,6 +2984,9 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,
if (remaining)
return false;
+ if (!pgdat_balanced(pgdat, order, classzone_idx))
+ return false;
+
node is not balanced?
in latency spikes though. In order not to change the original behaviour
we could always wake all pfmemalloc waiters no matter if we are going to
sleep or not:
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 744e2b491527..a21e0bd563c3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2993,10 +2993,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,
* so wake them now if necessary. If necessary, processes will wake
* kswapd and get throttled again
*/
- if (waitqueue_active(&pgdat->pfmemalloc_wait)) {
- wake_up(&pgdat->pfmemalloc_wait);
- return false;
- }
+ wake_up_all(&pgdat->pfmemalloc_wait);
return pgdat_balanced(pgdat, order, classzone_idx);
balance_pgdat. That should be sufficient. I am still quite surprised
that we have an OOM victim still on the queue and balanced pgdat here
because OOM victim didn't have chance to free memory. So somebody else
must have released a lot of memory after OOM.
This patch seems better than the one from Vlastimil. Care to post it
with the full changelog, please?
issue, because I don't have the reproducer, so it should be committed
only if Vlastimil approves it.