[Devel] [PATCH RH7 5/9] writeback: track if we're sleeping on progress in balance_dirty_pages()

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Sat Sep 21 11:32:23 MSK 2019


From: Jens Axboe <axboe at fb.com>

Note in the bdi_writeback structure whenever a task ends up sleeping
waiting for progress. We can use that information in the lower layers
to increase the priority of writes.

Signed-off-by: Jens Axboe <axboe at fb.com>
Reviewed-by: Jan Kara <jack at suse.cz>

https://jira.sw.ru/browse/PSBM-96243

(cherry picked from commit b57d74aff9ab92fbfb7c197c384d1adfa2827b2e)
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 include/linux/backing-dev.h | 3 +++
 mm/backing-dev.c            | 3 ++-
 mm/page-writeback.c         | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index e0c1edf7dd80..dfb80fc7068d 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -55,6 +55,9 @@ struct bdi_writeback {
 	unsigned long last_old_flush;	/* last old data flush */
 
 	struct delayed_work dwork;	/* work item used for writeback */
+
+	unsigned long dirty_sleep;	/* last wait */
+
 	struct list_head b_dirty;	/* dirty inodes */
 	struct list_head b_io;		/* parked for writeback */
 	struct list_head b_more_io;	/* parked for more writeback */
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 4efa4ec27a76..395d5615c972 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -439,7 +439,8 @@ static void bdi_wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi)
 	memset(wb, 0, sizeof(*wb));
 
 	wb->bdi = bdi;
-	wb->last_old_flush = jiffies;
+	wb->dirty_sleep = wb->last_old_flush = jiffies;
+
 	INIT_LIST_HEAD(&wb->b_dirty);
 	INIT_LIST_HEAD(&wb->b_io);
 	INIT_LIST_HEAD(&wb->b_more_io);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 7bb373b945fa..2ef54089261b 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1515,6 +1515,7 @@ static void balance_dirty_pages(struct address_space *mapping,
 	unsigned long dirty_ratelimit;
 	unsigned long pos_ratio;
 	struct backing_dev_info *bdi = mapping->backing_dev_info;
+	struct bdi_writeback *wb = &bdi->wb;
 	bool strictlimit = bdi->capabilities & BDI_CAP_STRICTLIMIT;
 	unsigned long start_time = jiffies;
 
@@ -1653,6 +1654,7 @@ static void balance_dirty_pages(struct address_space *mapping,
 					  pause,
 					  start_time);
 		__set_current_state(TASK_KILLABLE);
+		wb->dirty_sleep = now;
 		io_schedule_timeout(pause);
 
 		current->dirty_paused_when = now + pause;
-- 
2.21.0



More information about the Devel mailing list