Commit d4880868 authored by Marco Crivellari's avatar Marco Crivellari Committed by Mikulas Patocka
Browse files

dm: add WQ_PERCPU to alloc_workqueue users

This continues the effort to refactor workqueue APIs, which began with
the introduction of new workqueues and a new alloc_workqueue flag in:

   commit 128ea9f6 ("workqueue: Add system_percpu_wq and system_dfl_wq")
   commit 930c2ea5 ("workqueue: Add new WQ_PERCPU flag")

The refactoring is going to alter the default behavior of
alloc_workqueue() to be unbound by default.

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. For more details see the Link tag below.

In order to keep alloc_workqueue() behavior identical, explicitly request
WQ_PERCPU.

Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/


Suggested-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarMarco Crivellari <marco.crivellari@suse.com>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent c698b7f4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2833,7 +2833,8 @@ static int __init dm_bufio_init(void)
	__cache_size_refresh();
	mutex_unlock(&dm_bufio_clients_lock);

	dm_bufio_wq = alloc_workqueue("dm_bufio_cache", WQ_MEM_RECLAIM, 0);
	dm_bufio_wq = alloc_workqueue("dm_bufio_cache",
				      WQ_MEM_RECLAIM | WQ_PERCPU, 0);
	if (!dm_bufio_wq)
		return -ENOMEM;

+2 −1
Original line number Diff line number Diff line
@@ -2526,7 +2526,8 @@ static int cache_create(struct cache_args *ca, struct cache **result)
		goto bad;
	}

	cache->wq = alloc_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM, 0);
	cache->wq = alloc_workqueue("dm-" DM_MSG_PREFIX,
				    WQ_MEM_RECLAIM | WQ_PERCPU, 0);
	if (!cache->wq) {
		*error = "could not create workqueue for metadata object";
		goto bad;
+2 −1
Original line number Diff line number Diff line
@@ -1861,7 +1861,8 @@ static int clone_ctr(struct dm_target *ti, unsigned int argc, char **argv)
	clone->hydration_offset = 0;
	atomic_set(&clone->hydrations_in_flight, 0);

	clone->wq = alloc_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM, 0);
	clone->wq = alloc_workqueue("dm-" DM_MSG_PREFIX,
				    WQ_MEM_RECLAIM | WQ_PERCPU, 0);
	if (!clone->wq) {
		ti->error = "Failed to allocate workqueue";
		r = -ENOMEM;
+4 −2
Original line number Diff line number Diff line
@@ -3400,7 +3400,9 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
	if (test_bit(DM_CRYPT_HIGH_PRIORITY, &cc->flags))
		common_wq_flags |= WQ_HIGHPRI;

	cc->io_queue = alloc_workqueue("kcryptd_io-%s-%d", common_wq_flags, 1, devname, wq_id);
	cc->io_queue = alloc_workqueue("kcryptd_io-%s-%d",
				       common_wq_flags | WQ_PERCPU, 1,
				       devname, wq_id);
	if (!cc->io_queue) {
		ti->error = "Couldn't create kcryptd io queue";
		goto bad;
@@ -3408,7 +3410,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)

	if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags)) {
		cc->crypt_queue = alloc_workqueue("kcryptd-%s-%d",
						  common_wq_flags | WQ_CPU_INTENSIVE,
						  common_wq_flags | WQ_CPU_INTENSIVE | WQ_PERCPU,
						  1, devname, wq_id);
	} else {
		/*
+3 −1
Original line number Diff line number Diff line
@@ -290,7 +290,9 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
	} else {
		timer_setup(&dc->delay_timer, handle_delayed_timer, 0);
		INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);
		dc->kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
		dc->kdelayd_wq = alloc_workqueue("kdelayd",
						 WQ_MEM_RECLAIM | WQ_PERCPU,
						 0);
		if (!dc->kdelayd_wq) {
			ret = -EINVAL;
			DMERR("Couldn't start kdelayd");
Loading