Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

workqueue: Allow to expose ordered workqueues via sysfs

Ordered workqueues are not exposed via sysfs because the 'max_active'
attribute changes the number actives worker. More than one active worker
can break ordering guarantees.

This can be avoided by forbidding writes the file for ordered
workqueues. Exposing it via sysfs allows to alter other attributes such
as the cpumask on which CPU the worker can run.

The 'max_active' value shouldn't be changed for BH worker because the
core never spawns additional worker and the worker itself can not be
preempted. So this make no sense.

Allow to expose ordered workqueues via sysfs if requested and forbid
changing 'max_active' value for ordered and BH worker.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Sebastian Andrzej Siewior and committed by
Tejun Heo
a4aa8d94 4a91a33f

+20 -8
+20 -8
kernel/workqueue.c
··· 7176 7176 &dev_attr_max_active.attr, 7177 7177 NULL, 7178 7178 }; 7179 - ATTRIBUTE_GROUPS(wq_sysfs); 7179 + 7180 + static umode_t wq_sysfs_is_visible(struct kobject *kobj, struct attribute *a, int n) 7181 + { 7182 + struct device *dev = kobj_to_dev(kobj); 7183 + struct workqueue_struct *wq = dev_to_wq(dev); 7184 + 7185 + /* 7186 + * Adjusting max_active breaks ordering guarantee. Changing it has no 7187 + * effect on BH worker. Limit max_active to RO in such case. 7188 + */ 7189 + if (wq->flags & (WQ_BH | __WQ_ORDERED)) 7190 + return 0444; 7191 + return a->mode; 7192 + } 7193 + 7194 + static const struct attribute_group wq_sysfs_group = { 7195 + .is_visible = wq_sysfs_is_visible, 7196 + .attrs = wq_sysfs_attrs, 7197 + }; 7198 + __ATTRIBUTE_GROUPS(wq_sysfs); 7180 7199 7181 7200 static ssize_t wq_nice_show(struct device *dev, struct device_attribute *attr, 7182 7201 char *buf) ··· 7497 7478 { 7498 7479 struct wq_device *wq_dev; 7499 7480 int ret; 7500 - 7501 - /* 7502 - * Adjusting max_active breaks ordering guarantee. Disallow exposing 7503 - * ordered workqueues. 7504 - */ 7505 - if (WARN_ON(wq->flags & __WQ_ORDERED)) 7506 - return -EINVAL; 7507 7481 7508 7482 wq->wq_dev = wq_dev = kzalloc_obj(*wq_dev); 7509 7483 if (!wq_dev)