linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai Krakow <kai@kaishome.de>
To: linux-bcache@vger.kernel.org
Cc: Kai Krakow <kai@kaishome.de>
Subject: [PATCH 1/2] Revert "bcache: Kill btree_io_wq"
Date: Wed, 27 Jan 2021 14:23:49 +0100	[thread overview]
Message-ID: <20210127132350.557935-2-kai@kaishome.de> (raw)
In-Reply-To: <20210127132350.557935-1-kai@kaishome.de>

This reverts commit 56b30770b27d54d68ad51eccc6d888282b568cee.

With the btree using the system_wq, I seem to see a lot more desktop
latency than I should. So let's revert this.
---
 drivers/md/bcache/bcache.h |  2 ++
 drivers/md/bcache/btree.c  | 21 +++++++++++++++++++--
 drivers/md/bcache/super.c  |  4 ++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 1d57f48307e6..b1ed16c7a534 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -1042,5 +1042,7 @@ void bch_debug_exit(void);
 void bch_debug_init(void);
 void bch_request_exit(void);
 int bch_request_init(void);
+void bch_btree_exit(void);
+int bch_btree_init(void);
 
 #endif /* _BCACHE_H */
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 910df242c83d..952f022db5a5 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -99,6 +99,8 @@
 #define PTR_HASH(c, k)							\
 	(((k)->ptr[0] >> c->bucket_bits) | PTR_GEN(k, 0))
 
+static struct workqueue_struct *btree_io_wq;
+
 #define insert_lock(s, b)	((b)->level <= (s)->lock)
 
 
@@ -308,7 +310,7 @@ static void __btree_node_write_done(struct closure *cl)
 	btree_complete_write(b, w);
 
 	if (btree_node_dirty(b))
-		schedule_delayed_work(&b->work, 30 * HZ);
+		queue_delayed_work(btree_io_wq, &b->work, 30 * HZ);
 
 	closure_return_with_destructor(cl, btree_node_write_unlock);
 }
@@ -481,7 +483,7 @@ static void bch_btree_leaf_dirty(struct btree *b, atomic_t *journal_ref)
 	BUG_ON(!i->keys);
 
 	if (!btree_node_dirty(b))
-		schedule_delayed_work(&b->work, 30 * HZ);
+		queue_delayed_work(btree_io_wq, &b->work, 30 * HZ);
 
 	set_btree_node_dirty(b);
 
@@ -2764,3 +2766,18 @@ void bch_keybuf_init(struct keybuf *buf)
 	spin_lock_init(&buf->lock);
 	array_allocator_init(&buf->freelist);
 }
+
+void bch_btree_exit(void)
+{
+	if (btree_io_wq)
+		destroy_workqueue(btree_io_wq);
+}
+
+int __init bch_btree_init(void)
+{
+	btree_io_wq = create_singlethread_workqueue("bch_btree_io");
+	if (!btree_io_wq)
+		return -ENOMEM;
+
+	return 0;
+}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 2047a9cccdb5..dc4fe7eeda81 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2815,6 +2815,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
+	bch_btree_exit();
 	if (bcache_kobj)
 		kobject_put(bcache_kobj);
 	if (bcache_wq)
@@ -2880,6 +2881,9 @@ static int __init bcache_init(void)
 	if (!bcache_wq)
 		goto err;
 
+	if (bch_btree_init())
+		goto err;
+
 	bch_journal_wq = alloc_workqueue("bch_journal", WQ_MEM_RECLAIM, 0);
 	if (!bch_journal_wq)
 		goto err;
-- 
2.26.2


  reply	other threads:[~2021-01-27 13:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 13:23 Fix degraded system performance due to workqueue overload Kai Krakow
2021-01-27 13:23 ` Kai Krakow [this message]
2021-01-27 16:28   ` [PATCH 1/2] Revert "bcache: Kill btree_io_wq" Kai Krakow
2021-01-27 13:23 ` [PATCH 2/2] bcache: Move journal work to new background wq Kai Krakow
2021-01-27 16:28   ` Kai Krakow
2021-01-27 15:27 ` Fix degraded system performance due to workqueue overload Coly Li
2021-01-27 16:39 ` [PATCH 1/2] Revert "bcache: Kill btree_io_wq" Kai Krakow
2021-01-27 16:39   ` [PATCH 2/2] bcache: Move journal work to new background wq Kai Krakow
2021-01-28 10:09 ` Fix degraded system performance due to workqueue overload Kai Krakow
2021-01-28 10:50 ` [PATCH v2 1/2] Revert "bcache: Kill btree_io_wq" Kai Krakow
2021-01-28 10:50   ` [PATCH v2 2/2] bcache: Move journal work to new background wq Kai Krakow
2021-01-28 16:37     ` Kai Krakow
2021-01-28 16:41       ` Kai Krakow
     [not found]         ` <988ba514-c607-688b-555d-18fbbb069f48@suse.de>
2021-01-29 16:36           ` Kai Krakow
2021-01-28 23:28 ` [PATCH v3 1/3] Revert "bcache: Kill btree_io_wq" Kai Krakow
2021-01-28 23:28   ` [PATCH v3 2/3] bcache: Give btree_io_wq correct semantics again Kai Krakow
2021-01-28 23:28   ` [PATCH v3 3/3] bcache: Move journal work to new background wq Kai Krakow
     [not found]     ` <a52b9107-7e84-0fea-6095-84a9576d7cc4@suse.de>
2021-01-29 16:37       ` Kai Krakow
     [not found]   ` <4fe07714-e5bf-4be3-6023-74b507ee54be@suse.de>
2021-01-29 16:59     ` [PATCH v3 1/3] Revert "bcache: Kill btree_io_wq" Kai Krakow
2021-01-29 16:40 ` [PATCH v4 " Kai Krakow
2021-01-29 16:40   ` [PATCH v4 2/3] bcache: Give btree_io_wq correct semantics again Kai Krakow
2021-01-29 16:40   ` [PATCH v4 3/3] bcache: Move journal work to new flush wq Kai Krakow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127132350.557935-2-kai@kaishome.de \
    --to=kai@kaishome.de \
    --cc=linux-bcache@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).