Am Fr., 29. Jan. 2021 um 16:30 Uhr schrieb Coly Li <colyli@xxxxxxx>: > > On 1/29/21 7:28 AM, Kai Krakow wrote: > > This reverts commit 56b30770b27d54d68ad51eccc6d888282b568cee. > > > > With the btree using the `system_wq`, I seem to see a lot more desktop > > latency than I should. > > > > After some more investigation, it looks like the original assumption > > of 56b3077 no longer is true, and bcache has a very high potential of > > congesting the `system_wq`. In turn, this introduces laggy desktop > > performance, IO stalls (at least with btrfs), and input events may be > > delayed. > > > > So let's revert this. It's important to note that the semantics of > > using `system_wq` previously mean that `btree_io_wq` should be created > > before and destroyed after other bcache wqs to keep the same > > assumptions. > > > > Cc: Coly Li <colyli@xxxxxxx> > > Signed-off-by: Kai Krakow <kai@xxxxxxxxxxx> > > The patch is OK to me in general. I just feel it might be unnecessary to > use ordered work queue. The out-of-order system_wq is used for many > years and works well with bcache journal. This is why in v3 and later, I migrated this to an unordered queue. I just wanted to keep the revert as-is, and then the follow-up patch will fix this. Is that okay or should I squash both commits? Thanks, Kai > > --- > > 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 1d57f48307e66..b1ed16c7a5341 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 910df242c83df..952f022db5a5f 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 2047a9cccdb5d..77c5d8b6d4316 100644 > > --- a/drivers/md/bcache/super.c > > +++ b/drivers/md/bcache/super.c > > @@ -2821,6 +2821,7 @@ static void bcache_exit(void) > > destroy_workqueue(bcache_wq); > > if (bch_journal_wq) > > destroy_workqueue(bch_journal_wq); > > + bch_btree_exit(); > > > > if (bcache_major) > > unregister_blkdev(bcache_major, "bcache"); > > @@ -2876,6 +2877,9 @@ static int __init bcache_init(void) > > return bcache_major; > > } > > > > + if (bch_btree_init()) > > + goto err; > > + > > bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0); > > if (!bcache_wq) > > goto err; > > >