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

Submitted by Pavel Tikhomirov on Sept. 21, 2019, 8:32 a.m.

Details

Message ID 20190921083227.8990-6-ptikhomirov@virtuozzo.com
State New
Series "block: backport writeback throttling"
Headers show

Commit Message

Pavel Tikhomirov Sept. 21, 2019, 8:32 a.m.
From: Jens Axboe <axboe@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@fb.com>
Reviewed-by: Jan Kara <jack@suse.cz>

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

(cherry picked from commit b57d74aff9ab92fbfb7c197c384d1adfa2827b2e)
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@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(-)

Patch hide | download patch | download mbox

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;