From: Julian Wiedmann <jwi@linux.ibm.com>
To: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Julian Wiedmann <jwi@linux.ibm.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH wq/for-next 2/2] workqueue: let device core create the WQ_UNBOUND attributes
Date: Mon, 7 Jun 2021 11:44:20 +0200 [thread overview]
Message-ID: <20210607094420.2054403-2-jwi@linux.ibm.com> (raw)
In-Reply-To: <20210607094420.2054403-1-jwi@linux.ibm.com>
Wrap the attributes for a WQ_UNBOUND workqueue in ATTRIBUTE_GROUPS(),
and wire them up in dev->groups so that the device core can manage them
for us.
As device_add() will add such attributes _prior_ to raising the KOBJ_ADD
uevent, this also makes the initial uevent suppression unnecessary.
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
---
kernel/workqueue.c | 51 ++++++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 29 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 817dc2d7438a..629859ac5262 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5449,6 +5449,9 @@ static ssize_t wq_pool_ids_show(struct device *dev,
return written;
}
+static struct device_attribute wq_sysfs_unbound_attr_pool_ids =
+ __ATTR(pool_ids, 0444, wq_pool_ids_show, NULL);
+
static ssize_t wq_nice_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -5502,6 +5505,9 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr,
return ret ?: count;
}
+static struct device_attribute wq_sysfs_unbound_attr_nice =
+ __ATTR(nice, 0644, wq_nice_show, wq_nice_store);
+
static ssize_t wq_cpumask_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -5539,6 +5545,9 @@ static ssize_t wq_cpumask_store(struct device *dev,
return ret ?: count;
}
+static struct device_attribute wq_sysfs_unbound_attr_cpumask =
+ __ATTR(cpumask, 0644, wq_cpumask_show, wq_cpumask_store);
+
static ssize_t wq_numa_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -5578,13 +5587,17 @@ static ssize_t wq_numa_store(struct device *dev, struct device_attribute *attr,
return ret ?: count;
}
-static struct device_attribute wq_sysfs_unbound_attrs[] = {
- __ATTR(pool_ids, 0444, wq_pool_ids_show, NULL),
- __ATTR(nice, 0644, wq_nice_show, wq_nice_store),
- __ATTR(cpumask, 0644, wq_cpumask_show, wq_cpumask_store),
- __ATTR(numa, 0644, wq_numa_show, wq_numa_store),
- __ATTR_NULL,
+static struct device_attribute wq_sysfs_unbound_attr_numa =
+ __ATTR(numa, 0644, wq_numa_show, wq_numa_store);
+
+static struct attribute *wq_sysfs_unbound_attrs[] = {
+ &wq_sysfs_unbound_attr_pool_ids.attr,
+ &wq_sysfs_unbound_attr_nice.attr,
+ &wq_sysfs_unbound_attr_cpumask.attr,
+ &wq_sysfs_unbound_attr_numa.attr,
+ NULL,
};
+ATTRIBUTE_GROUPS(wq_sysfs_unbound);
static struct bus_type wq_subsys = {
.name = "workqueue",
@@ -5679,37 +5692,17 @@ int workqueue_sysfs_register(struct workqueue_struct *wq)
wq_dev->wq = wq;
wq_dev->dev.bus = &wq_subsys;
wq_dev->dev.release = wq_device_release;
+ if (wq->flags & WQ_UNBOUND)
+ wq_dev->dev.groups = wq_sysfs_unbound_groups;
dev_set_name(&wq_dev->dev, "%s", wq->name);
- /*
- * unbound_attrs are created separately. Suppress uevent until
- * everything is ready.
- */
- dev_set_uevent_suppress(&wq_dev->dev, true);
-
ret = device_register(&wq_dev->dev);
if (ret) {
put_device(&wq_dev->dev);
wq->wq_dev = NULL;
- return ret;
- }
-
- if (wq->flags & WQ_UNBOUND) {
- struct device_attribute *attr;
-
- for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++) {
- ret = device_create_file(&wq_dev->dev, attr);
- if (ret) {
- device_unregister(&wq_dev->dev);
- wq->wq_dev = NULL;
- return ret;
- }
- }
}
- dev_set_uevent_suppress(&wq_dev->dev, false);
- kobject_uevent(&wq_dev->dev.kobj, KOBJ_ADD);
- return 0;
+ return ret;
}
/**
--
2.25.1
next prev parent reply other threads:[~2021-06-07 9:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-07 9:44 [PATCH wq/for-next 1/2] workqueue: let subsystem core create the cpumask attribute Julian Wiedmann
2021-06-07 9:44 ` Julian Wiedmann [this message]
2021-06-07 10:27 ` [PATCH wq/for-next 2/2] workqueue: let device core create the WQ_UNBOUND attributes Greg Kroah-Hartman
2021-06-07 10:34 ` Julian Wiedmann
2021-06-07 10:41 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210607094420.2054403-2-jwi@linux.ibm.com \
--to=jwi@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox