mirror of https://github.com/torvalds/linux.git
bcache: WQ_PERCPU added to alloc_workqueue users
Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. alloc_workqueue() treats all queues as per-CPU by default, while unbound workqueues must opt-in via WQ_UNBOUND. This default is suboptimal: most workloads benefit from unbound queues, allowing the scheduler to place worker threads where they’re needed and reducing noise when CPUs are isolated. This patch continues the effort to refactor worqueue APIs, which has begun with the change introducing new workqueues and a new alloc_workqueue flag: commit128ea9f6cc("workqueue: Add system_percpu_wq and system_dfl_wq") commit930c2ea566("workqueue: Add new WQ_PERCPU flag") This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified. With the introduction of the WQ_PERCPU flag (equivalent to !WQ_UNBOUND), any alloc_workqueue() caller that doesn’t explicitly specify WQ_UNBOUND must now use WQ_PERCPU. Once migration is complete, WQ_UNBOUND can be removed and unbound will become the implicit default. Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Marco Crivellari <marco.crivellari@suse.com> Signed-off-by: Coly Li <colyli@fnnas.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
fd82071814
commit
c0c8082142
|
|
@ -2822,7 +2822,8 @@ void bch_btree_exit(void)
|
||||||
|
|
||||||
int __init bch_btree_init(void)
|
int __init bch_btree_init(void)
|
||||||
{
|
{
|
||||||
btree_io_wq = alloc_workqueue("bch_btree_io", WQ_MEM_RECLAIM, 0);
|
btree_io_wq = alloc_workqueue("bch_btree_io",
|
||||||
|
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||||
if (!btree_io_wq)
|
if (!btree_io_wq)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1939,7 +1939,8 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
|
||||||
if (!c->uuids)
|
if (!c->uuids)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
c->moving_gc_wq = alloc_workqueue("bcache_gc", WQ_MEM_RECLAIM, 0);
|
c->moving_gc_wq = alloc_workqueue("bcache_gc",
|
||||||
|
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||||
if (!c->moving_gc_wq)
|
if (!c->moving_gc_wq)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
@ -2902,7 +2903,7 @@ static int __init bcache_init(void)
|
||||||
if (bch_btree_init())
|
if (bch_btree_init())
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0);
|
bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||||
if (!bcache_wq)
|
if (!bcache_wq)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
@ -2915,11 +2916,12 @@ static int __init bcache_init(void)
|
||||||
*
|
*
|
||||||
* We still want to user our own queue to not congest the `system_percpu_wq`.
|
* We still want to user our own queue to not congest the `system_percpu_wq`.
|
||||||
*/
|
*/
|
||||||
bch_flush_wq = alloc_workqueue("bch_flush", 0, 0);
|
bch_flush_wq = alloc_workqueue("bch_flush", WQ_PERCPU, 0);
|
||||||
if (!bch_flush_wq)
|
if (!bch_flush_wq)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
bch_journal_wq = alloc_workqueue("bch_journal", WQ_MEM_RECLAIM, 0);
|
bch_journal_wq = alloc_workqueue("bch_journal",
|
||||||
|
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||||
if (!bch_journal_wq)
|
if (!bch_journal_wq)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1075,7 +1075,7 @@ void bch_cached_dev_writeback_init(struct cached_dev *dc)
|
||||||
int bch_cached_dev_writeback_start(struct cached_dev *dc)
|
int bch_cached_dev_writeback_start(struct cached_dev *dc)
|
||||||
{
|
{
|
||||||
dc->writeback_write_wq = alloc_workqueue("bcache_writeback_wq",
|
dc->writeback_write_wq = alloc_workqueue("bcache_writeback_wq",
|
||||||
WQ_MEM_RECLAIM, 0);
|
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||||
if (!dc->writeback_write_wq)
|
if (!dc->writeback_write_wq)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue