linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend] mm/page-writeback.c: make changes of dirty_writeback_centisecs take effect immediately
@ 2017-10-13 16:56 Yafang Shao
  0 siblings, 0 replies; only message in thread
From: Yafang Shao @ 2017-10-13 16:56 UTC (permalink / raw)
  To: akpm
  Cc: jack, hannes, vdavydov.dev, jlayton, nborisov, tytso,
	yamada.masahiro, linux-mm, linux-kernel, laoar.shao

Two problems with /proc/sys/vm/dirty_writeback_centisecs:

- When the tunable is set to 0 (disable), writing a non-zero value
  doesn't restart the flushing operations until the dirty background limit
  is reached or sys_sync is executed or not enough free memory is
  available or vmscan is triggered.

- When the tunable was set to one hour and is reset to one second, the
  new setting will not take effect for up to one hour.

Kicking the flusher threads immediately fixes these issues.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 mm/page-writeback.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 0b9c5cb..4e7e739 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1972,8 +1972,23 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb)
 int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
 	void __user *buffer, size_t *length, loff_t *ppos)
 {
-	proc_dointvec(table, write, buffer, length, ppos);
-	return 0;
+	unsigned int old_interval = dirty_writeback_interval;
+	int ret;
+
+	ret = proc_dointvec(table, write, buffer, length, ppos);
+
+	/*
+	 * Writing 0 to dirty_writeback_interval will disable periodic writeback
+	 * and a different non-zero value will wakeup the writeback threads.
+	 * wb_wakeup_delayed() would be more appropriate, but it's a pain to
+	 * iterate over all bdis and wbs.
+	 * The reason we do this is to make the change take effect immediately.
+	 */
+	if (!ret && write && dirty_writeback_interval &&
+		dirty_writeback_interval != old_interval)
+		wakeup_flusher_threads(0, WB_REASON_PERIODIC);
+
+	return ret;
 }
 
 #ifdef CONFIG_BLOCK
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-13  9:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-13 16:56 [PATCH resend] mm/page-writeback.c: make changes of dirty_writeback_centisecs take effect immediately Yafang Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).