Skip to content

Commit 695185f

Browse files
kakragregkh
authored andcommitted
bcache: Move journal work to new flush wq
commit afe78ab upstream. This is potentially long running and not latency sensitive, let's get it out of the way of other latency sensitive events. As observed in the previous commit, the `system_wq` comes easily congested by bcache, and this fixes a few more stalls I was observing every once in a while. Let's not make this `WQ_MEM_RECLAIM` as it showed to reduce performance of boot and file system operations in my tests. Also, without `WQ_MEM_RECLAIM`, I no longer see desktop stalls. This matches the previous behavior as `system_wq` also does no memory reclaim: > // workqueue.c: > system_wq = alloc_workqueue("events", 0, 0); Cc: Coly Li <colyli@suse.de> Cc: stable@vger.kernel.org # 5.4+ Signed-off-by: Kai Krakow <kai@kaishome.de> Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f5ee963 commit 695185f

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎drivers/md/bcache/bcache.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent);
10011001

10021002
extern struct workqueue_struct *bcache_wq;
10031003
extern struct workqueue_struct *bch_journal_wq;
1004+
extern struct workqueue_struct *bch_flush_wq;
10041005
extern struct mutex bch_register_lock;
10051006
extern struct list_head bch_cache_sets;
10061007

‎drivers/md/bcache/journal.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ atomic_t *bch_journal(struct cache_set *c,
932932
journal_try_write(c);
933933
} else if (!w->dirty) {
934934
w->dirty = true;
935-
schedule_delayed_work(&c->journal.work,
936-
msecs_to_jiffies(c->journal_delay_ms));
935+
queue_delayed_work(bch_flush_wq, &c->journal.work,
936+
msecs_to_jiffies(c->journal_delay_ms));
937937
spin_unlock(&c->journal.lock);
938938
} else {
939939
spin_unlock(&c->journal.lock);

‎drivers/md/bcache/super.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static int bcache_major;
4949
static DEFINE_IDA(bcache_device_idx);
5050
static wait_queue_head_t unregister_wait;
5151
struct workqueue_struct *bcache_wq;
52+
struct workqueue_struct *bch_flush_wq;
5253
struct workqueue_struct *bch_journal_wq;
5354

5455

@@ -2833,6 +2834,8 @@ static void bcache_exit(void)
28332834
destroy_workqueue(bcache_wq);
28342835
if (bch_journal_wq)
28352836
destroy_workqueue(bch_journal_wq);
2837+
if (bch_flush_wq)
2838+
destroy_workqueue(bch_flush_wq);
28362839
bch_btree_exit();
28372840

28382841
if (bcache_major)
@@ -2896,6 +2899,19 @@ static int __init bcache_init(void)
28962899
if (!bcache_wq)
28972900
goto err;
28982901

2902+
/*
2903+
* Let's not make this `WQ_MEM_RECLAIM` for the following reasons:
2904+
*
2905+
* 1. It used `system_wq` before which also does no memory reclaim.
2906+
* 2. With `WQ_MEM_RECLAIM` desktop stalls, increased boot times, and
2907+
* reduced throughput can be observed.
2908+
*
2909+
* We still want to user our own queue to not congest the `system_wq`.
2910+
*/
2911+
bch_flush_wq = alloc_workqueue("bch_flush", 0, 0);
2912+
if (!bch_flush_wq)
2913+
goto err;
2914+
28992915
bch_journal_wq = alloc_workqueue("bch_journal", WQ_MEM_RECLAIM, 0);
29002916
if (!bch_journal_wq)
29012917
goto err;

0 commit comments

Comments
 (0)