All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-writecache: use low watermark
@ 2018-06-07 19:58 Mikulas Patocka
  2018-06-07 22:51 ` [PATCH v2] " Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2018-06-07 19:58 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: dm-devel

Fix a bug that low watermark was ignored and high watermark was used as
both low and high.

The patch also verifies that high watermark is greater or equal than low
watermark - if this condition is violated, the driver would consume too
much CPU.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-writecache.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c	2018-06-07 21:21:47.000000000 +0200
+++ linux-2.6/drivers/md/dm-writecache.c	2018-06-07 21:23:21.000000000 +0200
@@ -1590,7 +1590,7 @@ restart:
 	wbl.size = 0;
 	while (!list_empty(&wc->lru) &&
 	       (wc->writeback_all ||
-		wc->freelist_size + wc->writeback_size <= wc->freelist_high_watermark)) {
+		wc->freelist_size + wc->writeback_size <= wc->freelist_low_watermark)) {
 
 		n_walked++;
 		if (unlikely(n_walked > WRITEBACK_LATENCY) &&
@@ -2033,6 +2033,12 @@ invalid_optional:
 		}
 	}
 
+	if (high_wm_percent < low_wm_percent) {
+		r = -EINVAL;
+		ti->error = "High watermark must be greater or equal than low watermark";
+		goto bad;
+	}
+
 	if (!WC_MODE_PMEM(wc)) {
 		struct dm_io_region region;
 		struct dm_io_request req;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] dm-writecache: use low watermark
  2018-06-07 19:58 [PATCH] dm-writecache: use low watermark Mikulas Patocka
@ 2018-06-07 22:51 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2018-06-07 22:51 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: dm-devel

This is a second version of the patche - it changes the condition in 
writecache_pop_from_freelist, to avoid wakeup storm if wc->writeback_size 
is greater than wc->freelist_low_watermark-wc->freelist_high_watermark.


From: Mikulas Patocka <mpatocka@redhat.com>

Fix a bug that low watermark was ignored and high watermark was used as
both low and high.

The patch also verifies that high watermark is greater or equal than low
watermark - if this condition is violated, the driver would consume too
much CPU.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-writecache.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c	2018-06-07 22:37:48.000000000 +0200
+++ linux-2.6/drivers/md/dm-writecache.c	2018-06-07 22:38:18.000000000 +0200
@@ -644,7 +644,7 @@ static struct wc_entry *writecache_pop_f
 		list_del(&e->lru);
 	}
 	wc->freelist_size--;
-	if (unlikely(wc->freelist_size <= wc->freelist_high_watermark))
+	if (unlikely(wc->freelist_size + wc->writeback_size <= wc->freelist_high_watermark))
 		queue_work(wc->writeback_wq, &wc->writeback_work);
 
 	return e;
@@ -1590,7 +1590,7 @@ restart:
 	wbl.size = 0;
 	while (!list_empty(&wc->lru) &&
 	       (wc->writeback_all ||
-		wc->freelist_size + wc->writeback_size <= wc->freelist_high_watermark)) {
+		wc->freelist_size + wc->writeback_size <= wc->freelist_low_watermark)) {
 
 		n_walked++;
 		if (unlikely(n_walked > WRITEBACK_LATENCY) &&
@@ -2033,6 +2033,12 @@ invalid_optional:
 		}
 	}
 
+	if (high_wm_percent < low_wm_percent) {
+		r = -EINVAL;
+		ti->error = "High watermark must be greater or equal than low watermark";
+		goto bad;
+	}
+
 	if (!WC_MODE_PMEM(wc)) {
 		struct dm_io_region region;
 		struct dm_io_request req;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-07 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 19:58 [PATCH] dm-writecache: use low watermark Mikulas Patocka
2018-06-07 22:51 ` [PATCH v2] " Mikulas Patocka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.