Re: [PATCH v2 3/4] mm/vmscan: Don't change pgdat state on base of a single LRU list state.

From: Andrey Ryabinin
Date: Fri Apr 06 2018 - 13:24:37 EST




On 04/06/2018 07:28 PM, Johannes Weiner wrote:
>
> This isn't quite equivalent to what we have right now.
>
> Yes, nr_dirty, nr_unqueued_dirty and nr_congested apply to file pages
> only. That part is about waking the flushers and avoiding writing
> files in 4k chunks from reclaim context. So those numbers do need to
> be compared against scanned *file* pages.
>
> But nr_writeback and nr_immediate is about throttling reclaim when we
> hit too many pages under writeout, and that applies to both file and
> anonymous/swap pages. We do want to throttle on swapout, too.
>
> So nr_writeback needs to check against all nr_taken, not just file.
>

Agreed, the fix bellow. It causes conflict in the next 4/4 patch,
so I'll just send v3 with all fixes folded.

---
mm/vmscan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4d848b8df01f..c45497475e84 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -124,6 +124,7 @@ struct scan_control {
unsigned int writeback;
unsigned int immediate;
unsigned int file_taken;
+ unsigned int taken;
} nr;
};

@@ -1771,6 +1772,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
sc->nr.unqueued_dirty += stat.nr_unqueued_dirty;
sc->nr.writeback += stat.nr_writeback;
sc->nr.immediate += stat.nr_immediate;
+ sc->nr.taken += nr_taken;
if (file)
sc->nr.file_taken += nr_taken;

@@ -2553,7 +2555,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
* number of pages under pages flagged for immediate reclaim and
* stall if any are encountered in the nr_immediate check below.
*/
- if (sc->nr.writeback && sc->nr.writeback == sc->nr.file_taken)
+ if (sc->nr.writeback && sc->nr.writeback == sc->nr.taken)
set_bit(PGDAT_WRITEBACK, &pgdat->flags);

/*
--
2.16.1