Skip to content

Commit b786405

Browse files
committed
Merge tag 'vfs-6.18-rc1.workqueue' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs workqueue updates from Christian Brauner: "This contains various workqueue changes affecting the filesystem layer. 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 replaces the use of system_wq and system_unbound_wq. system_wq is a per-CPU workqueue which isn't very obvious from the name and system_unbound_wq is to be used when locality is not required. So this renames system_wq to system_percpu_wq, and system_unbound_wq to system_dfl_wq. This also adds a new WQ_PERCPU flag to allow the fs subsystem users to explicitly request the use of per-CPU behavior. Both WQ_UNBOUND and WQ_PERCPU flags coexist for one release cycle to allow callers to transition their calls. WQ_UNBOUND will be removed in a next release cycle" * tag 'vfs-6.18-rc1.workqueue' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: WQ_PERCPU added to alloc_workqueue users fs: replace use of system_wq with system_percpu_wq fs: replace use of system_unbound_wq with system_dfl_wq
2 parents df89726 + 56ce6c8 commit b786405

40 files changed

Lines changed: 79 additions & 65 deletions

fs/afs/callback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void afs_volume_init_callback(struct afs_volume *volume)
4242
list_for_each_entry(vnode, &volume->open_mmaps, cb_mmap_link) {
4343
if (vnode->cb_v_check != atomic_read(&volume->cb_v_break)) {
4444
afs_clear_cb_promise(vnode, afs_cb_promise_clear_vol_init_cb);
45-
queue_work(system_unbound_wq, &vnode->cb_work);
45+
queue_work(system_dfl_wq, &vnode->cb_work);
4646
}
4747
}
4848

@@ -90,7 +90,7 @@ void __afs_break_callback(struct afs_vnode *vnode, enum afs_cb_break_reason reas
9090
if (reason != afs_cb_break_for_deleted &&
9191
vnode->status.type == AFS_FTYPE_FILE &&
9292
atomic_read(&vnode->cb_nr_mmap))
93-
queue_work(system_unbound_wq, &vnode->cb_work);
93+
queue_work(system_dfl_wq, &vnode->cb_work);
9494

9595
trace_afs_cb_break(&vnode->fid, vnode->cb_break, reason, true);
9696
} else {

fs/afs/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ static int __init afs_init(void)
169169

170170
printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n");
171171

172-
afs_wq = alloc_workqueue("afs", 0, 0);
172+
afs_wq = alloc_workqueue("afs", WQ_PERCPU, 0);
173173
if (!afs_wq)
174174
goto error_afs_wq;
175175
afs_async_calls = alloc_workqueue("kafsd", WQ_MEM_RECLAIM | WQ_UNBOUND, 0);
176176
if (!afs_async_calls)
177177
goto error_async;
178-
afs_lock_manager = alloc_workqueue("kafs_lockd", WQ_MEM_RECLAIM, 0);
178+
afs_lock_manager = alloc_workqueue("kafs_lockd", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
179179
if (!afs_lock_manager)
180180
goto error_lockmgr;
181181

fs/afs/write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void afs_issue_write_worker(struct work_struct *work)
172172
void afs_issue_write(struct netfs_io_subrequest *subreq)
173173
{
174174
subreq->work.func = afs_issue_write_worker;
175-
if (!queue_work(system_unbound_wq, &subreq->work))
175+
if (!queue_work(system_dfl_wq, &subreq->work))
176176
WARN_ON_ONCE(1);
177177
}
178178

fs/aio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ static void free_ioctx_reqs(struct percpu_ref *ref)
636636

637637
/* Synchronize against RCU protected table->table[] dereferences */
638638
INIT_RCU_WORK(&ctx->free_rwork, free_ioctx);
639-
queue_rcu_work(system_wq, &ctx->free_rwork);
639+
queue_rcu_work(system_percpu_wq, &ctx->free_rwork);
640640
}
641641

642642
/*

fs/bcachefs/btree_write_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ int bch2_journal_keys_to_write_buffer_end(struct bch_fs *c, struct journal_keys_
827827

828828
if (bch2_btree_write_buffer_should_flush(c) &&
829829
__enumerated_ref_tryget(&c->writes, BCH_WRITE_REF_btree_write_buffer) &&
830-
!queue_work(system_unbound_wq, &c->btree_write_buffer.flush_work))
830+
!queue_work(system_dfl_wq, &c->btree_write_buffer.flush_work))
831831
enumerated_ref_put(&c->writes, BCH_WRITE_REF_btree_write_buffer);
832832

833833
if (dst->wb == &wb->flushing)

fs/bcachefs/io_read.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ static void bch2_rbio_error(struct bch_read_bio *rbio,
684684

685685
if (bch2_err_matches(ret, BCH_ERR_data_read_retry)) {
686686
bch2_rbio_punt(rbio, bch2_rbio_retry,
687-
RBIO_CONTEXT_UNBOUND, system_unbound_wq);
687+
RBIO_CONTEXT_UNBOUND, system_dfl_wq);
688688
} else {
689689
rbio = bch2_rbio_free(rbio);
690690

@@ -921,10 +921,10 @@ static void __bch2_read_endio(struct work_struct *work)
921921
bch2_rbio_error(rbio, -BCH_ERR_data_read_retry_csum_err, BLK_STS_IOERR);
922922
goto out;
923923
decompression_err:
924-
bch2_rbio_punt(rbio, bch2_read_decompress_err, RBIO_CONTEXT_UNBOUND, system_unbound_wq);
924+
bch2_rbio_punt(rbio, bch2_read_decompress_err, RBIO_CONTEXT_UNBOUND, system_dfl_wq);
925925
goto out;
926926
decrypt_err:
927-
bch2_rbio_punt(rbio, bch2_read_decrypt_err, RBIO_CONTEXT_UNBOUND, system_unbound_wq);
927+
bch2_rbio_punt(rbio, bch2_read_decrypt_err, RBIO_CONTEXT_UNBOUND, system_dfl_wq);
928928
goto out;
929929
}
930930

@@ -963,7 +963,7 @@ static void bch2_read_endio(struct bio *bio)
963963
rbio->promote ||
964964
crc_is_compressed(rbio->pick.crc) ||
965965
bch2_csum_type_is_encryption(rbio->pick.crc.csum_type))
966-
context = RBIO_CONTEXT_UNBOUND, wq = system_unbound_wq;
966+
context = RBIO_CONTEXT_UNBOUND, wq = system_dfl_wq;
967967
else if (rbio->pick.crc.csum_type)
968968
context = RBIO_CONTEXT_HIGHPRI, wq = system_highpri_wq;
969969

fs/bcachefs/journal_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ int bch2_journal_read(struct bch_fs *c,
13621362
BCH_DEV_READ_REF_journal_read))
13631363
closure_call(&ca->journal.read,
13641364
bch2_journal_read_device,
1365-
system_unbound_wq,
1365+
system_dfl_wq,
13661366
&jlist.cl);
13671367
else
13681368
degraded = true;

fs/bcachefs/super.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,13 +801,13 @@ int bch2_fs_init_rw(struct bch_fs *c)
801801
if (!(c->btree_update_wq = alloc_workqueue("bcachefs",
802802
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_UNBOUND, 512)) ||
803803
!(c->btree_write_complete_wq = alloc_workqueue("bcachefs_btree_write_complete",
804-
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM, 1)) ||
804+
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_PERCPU, 1)) ||
805805
!(c->copygc_wq = alloc_workqueue("bcachefs_copygc",
806-
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 1)) ||
806+
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE|WQ_PERCPU, 1)) ||
807807
!(c->btree_write_submit_wq = alloc_workqueue("bcachefs_btree_write_sumit",
808-
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM, 1)) ||
808+
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_PERCPU, 1)) ||
809809
!(c->write_ref_wq = alloc_workqueue("bcachefs_write_ref",
810-
WQ_FREEZABLE, 0)))
810+
WQ_FREEZABLE|WQ_PERCPU, 0)))
811811
return bch_err_throw(c, ENOMEM_fs_other_alloc);
812812

813813
int ret = bch2_fs_btree_interior_update_init(c) ?:
@@ -975,7 +975,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts *opts,
975975
sizeof(struct sort_iter_set);
976976

977977
if (!(c->btree_read_complete_wq = alloc_workqueue("bcachefs_btree_read_complete",
978-
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM, 512)) ||
978+
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_PERCPU, 512)) ||
979979
enumerated_ref_init(&c->writes, BCH_WRITE_REF_NR,
980980
bch2_writes_disabled) ||
981981
mempool_init_kmalloc_pool(&c->fill_iter, 1, iter_size) ||

fs/btrfs/block-group.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ void btrfs_reclaim_bgs(struct btrfs_fs_info *fs_info)
20382038
btrfs_reclaim_sweep(fs_info);
20392039
spin_lock(&fs_info->unused_bgs_lock);
20402040
if (!list_empty(&fs_info->reclaim_bgs))
2041-
queue_work(system_unbound_wq, &fs_info->reclaim_bgs_work);
2041+
queue_work(system_dfl_wq, &fs_info->reclaim_bgs_work);
20422042
spin_unlock(&fs_info->unused_bgs_lock);
20432043
}
20442044

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info)
19581958
{
19591959
u32 max_active = fs_info->thread_pool_size;
19601960
unsigned int flags = WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_UNBOUND;
1961-
unsigned int ordered_flags = WQ_MEM_RECLAIM | WQ_FREEZABLE;
1961+
unsigned int ordered_flags = WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_PERCPU;
19621962

19631963
fs_info->workers =
19641964
btrfs_alloc_workqueue(fs_info, "worker", flags, max_active, 16);

0 commit comments

Comments
 (0)