All of lore.kernel.org
 help / color / mirror / Atom feed
From: wanghaibin <wanghaibin.wang@huawei.com>
To: <linux-kernel@vger.kernel.org>
Cc: <tj@kernel.org>, <jiangshanlai@gmail.com>,
	<peter.huangpeng@huawei.com>,
	wanghaibin <wanghaibin.wang@huawei.com>
Subject: [RFC PATCH 3/4] workqueue: remove the unbind workqueue attr sys_file before unregister the workqueue device
Date: Thu, 7 Jan 2016 20:38:58 +0800	[thread overview]
Message-ID: <1452170339-26748-4-git-send-email-wanghaibin.wang@huawei.com> (raw)
In-Reply-To: <1452170339-26748-1-git-send-email-wanghaibin.wang@huawei.com>

for workqueue's flag with the WQ_SYSFS | WQ_UNBOUND, the wq_dev will create some sys_files for
unbound attrs, so, remove the unbind workqueue attrs sys_files before unregister the
workqueue device.

Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com>
---
 kernel/workqueue.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 60e192c..d6527dc 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5131,10 +5131,13 @@ int workqueue_sysfs_register(struct workqueue_struct *wq)
 
 	if (wq->flags & WQ_UNBOUND) {
 		struct device_attribute *attr;
+		int cnt = 0, i;
 
-		for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++) {
+		for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++, cnt++) {
 			ret = device_create_file(&wq_dev->dev, attr);
 			if (ret) {
+				for (attr = wq_sysfs_unbound_attrs, i = 0; i < cnt; attr++, i++)
+					device_remove_file(&wq_dev->dev, attr);
 				device_unregister(&wq_dev->dev);
 				wq->wq_dev = NULL;
 				return ret;
@@ -5160,6 +5163,11 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq)
 	if (!wq->wq_dev)
 		return;
 
+	if (wq->flags & WQ_UNBOUND) {
+		struct device_attribute *attr;
+		for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++)
+			device_remove_file(&wq_dev->dev, attr);
+	}
 	wq->wq_dev = NULL;
 	device_unregister(&wq_dev->dev);
 }
-- 
1.8.3.1



  parent reply	other threads:[~2016-01-07 12:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 12:38 [RFC PATCH 0/4] fixs/suggestions for workqueue subsystem wanghaibin
2016-01-07 12:38 ` [RFC PATCH 1/4] workqueue: move the wq_update_unbound_numa_attrs_buf allocation location wanghaibin
2016-01-07 15:48   ` Tejun Heo
2016-01-11  5:21     ` wanghaibin
2016-01-07 12:38 ` [RFC PATCH 2/4] workqueue: free the allocated memory resource when wq_numa_init failed wanghaibin
2016-01-07 15:50   ` Tejun Heo
2016-01-11  4:26     ` wanghaibin
2016-01-07 12:38 ` wanghaibin [this message]
2016-01-07 16:00   ` [RFC PATCH 3/4] workqueue: remove the unbind workqueue attr sys_file before unregister the workqueue device Tejun Heo
2016-01-11 12:23     ` wanghaibin
2016-01-07 12:38 ` [RFC PATCH 4/4] workqueue: simplify the apply_workqueue_attrs_locked function wanghaibin
2016-01-07 16:07   ` Tejun Heo

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=1452170339-26748-4-git-send-email-wanghaibin.wang@huawei.com \
    --to=wanghaibin.wang@huawei.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.huangpeng@huawei.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.