* [PATCH RFC 1/2] HID: hid-oxp: Replace system_wq with system_dfl_wq
2026-07-07 14:53 [PATCH RFC 0/2] HID: Replace system_wq with system_dfl_wq Marco Crivellari
@ 2026-07-07 14:53 ` Marco Crivellari
2026-07-07 14:53 ` [PATCH RFC 2/2] HID: appletb-kdb: " Marco Crivellari
2026-08-03 19:04 ` [PATCH RFC 0/2] HID: " Jiri Kosina
2 siblings, 0 replies; 5+ messages in thread
From: Marco Crivellari @ 2026-07-07 14:53 UTC (permalink / raw)
To: linux-kernel, linux-input
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Jiri Kosina, Benjamin Tissoires, Derek J. Clark
The function end up calling __queue_delayed_work(), which set a global
timer that could fire anywhere, enqueuing the work where the timer fired.
Unbound works could benefit from scheduler task placement, to optimize
performance and power consumption.
Since the workqueue work doesn't rely on per-cpu variables, there is no
obvious reason that justify the use of a per-cpu workqueue. So change the
workqueue with the new unbound version, system_dfl_wq.
Cc: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
drivers/hid/hid-oxp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-oxp.c b/drivers/hid/hid-oxp.c
index 20a54f337220..d2ded6b08ce9 100644
--- a/drivers/hid/hid-oxp.c
+++ b/drivers/hid/hid-oxp.c
@@ -398,7 +398,7 @@ static int oxp_hid_raw_event_gen_2(struct hid_device *hdev,
* Re-apply our settings after this has been received.
*/
if (data[3] == OXP_EFFECT_MONO_TRUE) {
- mod_delayed_work(system_wq, &drvdata.oxp_mcu_init, msecs_to_jiffies(50));
+ mod_delayed_work(system_dfl_wq, &drvdata.oxp_mcu_init, msecs_to_jiffies(50));
return 0;
}
@@ -788,7 +788,7 @@ static ssize_t map_button_store(struct device *dev,
default:
return -EINVAL;
}
- mod_delayed_work(system_wq, &drvdata.oxp_btn_queue, msecs_to_jiffies(50));
+ mod_delayed_work(system_dfl_wq, &drvdata.oxp_btn_queue, msecs_to_jiffies(50));
return count;
}
@@ -1349,7 +1349,7 @@ static void oxp_rgb_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
led_cdev->brightness = brightness;
- mod_delayed_work(system_wq, &drvdata.oxp_rgb_queue, msecs_to_jiffies(50));
+ mod_delayed_work(system_dfl_wq, &drvdata.oxp_rgb_queue, msecs_to_jiffies(50));
}
static struct attribute *oxp_rgb_attrs[] = {
@@ -1502,7 +1502,7 @@ static int oxp_cfg_probe(struct hid_device *hdev, u16 up)
drvdata.rumble_intensity = 5;
INIT_DELAYED_WORK(&drvdata.oxp_mcu_init, oxp_mcu_init_fn);
- mod_delayed_work(system_wq, &drvdata.oxp_mcu_init, msecs_to_jiffies(50));
+ mod_delayed_work(system_dfl_wq, &drvdata.oxp_mcu_init, msecs_to_jiffies(50));
ret = devm_device_add_group(&hdev->dev, &oxp_cfg_attrs_group);
if (ret)
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH RFC 2/2] HID: appletb-kdb: Replace system_wq with system_dfl_wq
2026-07-07 14:53 [PATCH RFC 0/2] HID: Replace system_wq with system_dfl_wq Marco Crivellari
2026-07-07 14:53 ` [PATCH RFC 1/2] HID: hid-oxp: " Marco Crivellari
@ 2026-07-07 14:53 ` Marco Crivellari
2026-08-03 19:04 ` [PATCH RFC 0/2] HID: " Jiri Kosina
2 siblings, 0 replies; 5+ messages in thread
From: Marco Crivellari @ 2026-07-07 14:53 UTC (permalink / raw)
To: linux-kernel, linux-input
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Jiri Kosina, Benjamin Tissoires
Currently the code enqueue work items using mod_delayed_work(), using
system_wq, the old per-CPU Workqueue.
The function end up calling __queue_delayed_work(), which set a global
timer that could fire anywhere, enqueuing the work where the timer fired.
Unbound works could benefit from scheduler task placement, to optimize
performance and power consumption.
Since the workqueue work doesn't rely on per-cpu variables, there is no
obvious reason that justify the use of a per-cpu workqueue. So change the
workqueue with the new unbound version, system_dfl_wq.
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
drivers/hid/hid-appletb-kbd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
index 462010a75899..5cc27066f602 100644
--- a/drivers/hid/hid-appletb-kbd.c
+++ b/drivers/hid/hid-appletb-kbd.c
@@ -175,7 +175,7 @@ static void appletb_inactivity_work(struct work_struct *work)
if (!kbd->has_dimmed) {
backlight_device_set_brightness(kbd->backlight_dev, 1);
kbd->has_dimmed = true;
- mod_delayed_work(system_wq, &kbd->inactivity_work,
+ mod_delayed_work(system_dfl_wq, &kbd->inactivity_work,
secs_to_jiffies(appletb_tb_idle_timeout));
} else if (!kbd->has_turned_off) {
backlight_device_set_brightness(kbd->backlight_dev, 0);
@@ -201,7 +201,7 @@ static void reset_inactivity_timer(struct appletb_kbd *kbd)
kbd->has_turned_off = false;
schedule_work(&kbd->restore_brightness_work);
}
- mod_delayed_work(system_wq, &kbd->inactivity_work,
+ mod_delayed_work(system_dfl_wq, &kbd->inactivity_work,
secs_to_jiffies(appletb_tb_dim_timeout));
}
}
@@ -423,7 +423,7 @@ static int appletb_kbd_probe(struct hid_device *hdev, const struct hid_device_id
INIT_DELAYED_WORK(&kbd->inactivity_work, appletb_inactivity_work);
INIT_WORK(&kbd->restore_brightness_work,
appletb_restore_brightness_work);
- mod_delayed_work(system_wq, &kbd->inactivity_work,
+ mod_delayed_work(system_dfl_wq, &kbd->inactivity_work,
secs_to_jiffies(appletb_tb_dim_timeout));
}
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH RFC 0/2] HID: Replace system_wq with system_dfl_wq
2026-07-07 14:53 [PATCH RFC 0/2] HID: Replace system_wq with system_dfl_wq Marco Crivellari
2026-07-07 14:53 ` [PATCH RFC 1/2] HID: hid-oxp: " Marco Crivellari
2026-07-07 14:53 ` [PATCH RFC 2/2] HID: appletb-kdb: " Marco Crivellari
@ 2026-08-03 19:04 ` Jiri Kosina
2026-08-04 7:05 ` Marco Crivellari
2 siblings, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2026-08-03 19:04 UTC (permalink / raw)
To: Marco Crivellari
Cc: linux-kernel, linux-input, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Benjamin Tissoires, Derek J. Clark
On Tue, 7 Jul 2026, Marco Crivellari wrote:
> Hi,
>
> Currently the code uses the per-cpu workqueue system_wq to schedule
> delayed works.
>
> Unbound works could benefit from scheduler task placement, to optimize
> performance and power consumption. Another good reason to have this unbound,
> is the "queue_delayed_work()" function, used to enqueue the work item.
>
> ~~~ Details about queue_delayed_work ~~~
>
> system_wq is a per-cpu workqueue and it is used as a parameter of
> mod_delayed_work(). This function schedule an item that it will later
> be enqueued (once the timer will fire). __queue_delayed_work() does the job
> receiving as "cpu" WORK_CPU_UNBOUND:
>
> if (housekeeping_enabled(HK_TYPE_TIMER)) {
> // [....]
> } else {
> if (likely(cpu == WORK_CPU_UNBOUND))
> add_timer_global(timer);
> else
> add_timer_on(timer, cpu);
> }
>
> The timer is global, so can fire everywhere, and the work item will be
> enqueued where the timer fired.
>
> Since the workqueue work doesn't rely on per-cpu variables, there is no
> obvious reason that justify the use of a per-cpu workqueue. So change the
> workqueue with system_dfl_wq, so that the used workqueue is now unbound
> and can benefit from scheduler task placement.
This definitely is a step in a right direction, thanks! Now applied (and
sorry for the delay).
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH RFC 0/2] HID: Replace system_wq with system_dfl_wq
2026-08-03 19:04 ` [PATCH RFC 0/2] HID: " Jiri Kosina
@ 2026-08-04 7:05 ` Marco Crivellari
0 siblings, 0 replies; 5+ messages in thread
From: Marco Crivellari @ 2026-08-04 7:05 UTC (permalink / raw)
To: Jiri Kosina
Cc: linux-kernel, linux-input, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Benjamin Tissoires, Derek J. Clark
On Mon, Aug 3, 2026 at 9:04 PM Jiri Kosina <jikos@kernel.org> wrote:
> [...]
> > Since the workqueue work doesn't rely on per-cpu variables, there is no
> > obvious reason that justify the use of a per-cpu workqueue. So change the
> > workqueue with system_dfl_wq, so that the used workqueue is now unbound
> > and can benefit from scheduler task placement.
>
> This definitely is a step in a right direction, thanks! Now applied (and
> sorry for the delay).
Thanks Jiri!
--
Marco Crivellari
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread