From: Chunguang Xu <brookxu@xxxxxxxxxxx> Directly use atomic_read(&frn->done.cnt) == 1 to check whether frn is issued, which makes the code a bit obscure. Maybe we should replace it with a more understandable function. Signed-off-by: Chunguang Xu <brookxu@xxxxxxxxxxx> --- mm/memcontrol.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3e1384a6..464745b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4542,6 +4542,12 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, * As being wrong occasionally doesn't matter, updates and accesses to the * records are lockless and racy. */ + +static inline bool foreign_writeback_in_process(struct memcg_cgwb_frn *frn) +{ + return atomic_read(&frn->done.cnt) != 1; +} + void mem_cgroup_track_foreign_dirty_slowpath(struct page *page, struct bdi_writeback *wb) { @@ -4565,7 +4571,7 @@ void mem_cgroup_track_foreign_dirty_slowpath(struct page *page, frn->memcg_id == wb->memcg_css->id) break; if (time_before64(frn->at, oldest_at) && - atomic_read(&frn->done.cnt) == 1) { + !foreign_writeback_in_process(frn)) { oldest = i; oldest_at = frn->at; } @@ -4612,7 +4618,7 @@ void mem_cgroup_flush_foreign(struct bdi_writeback *wb) * already one in flight. */ if (time_after64(frn->at, now - intv) && - atomic_read(&frn->done.cnt) == 1) { + !foreign_writeback_in_process(frn)) { frn->at = 0; trace_flush_foreign(wb, frn->bdi_id, frn->memcg_id); cgroup_writeback_by_id(frn->bdi_id, frn->memcg_id, -- 1.8.3.1