Replace workqueue's unbound_attrs by attrs, so that both unbound
or bound wq can use it.

Signed-off-by: Wen Yang <wen.yan...@zte.com.cn>
Signed-off-by: Jiang Biao <jiang.bi...@zte.com.cn>
Signed-off-by: Tan Hu <tan...@zte.com.cn>
Suggested-by: Tejun Heo <t...@kernel.org>
Cc: Tejun Heo <t...@kernel.org>
Cc: Lai Jiangshan <jiangshan...@gmail.com>
Cc: kernel test robot <xiaolong...@intel.com>
Cc: linux-kernel@vger.kernel.org
---
 kernel/workqueue.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 993f225..e1613d0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -255,7 +255,6 @@ struct workqueue_struct {
        int                     nr_drainers;    /* WQ: drain in progress */
        int                     saved_max_active; /* WQ: saved pwq max_active */
 
-       struct workqueue_attrs  *unbound_attrs; /* PW: only for unbound wqs */
        struct workqueue_attrs  *attrs;
        struct pool_workqueue   *dfl_pwq;       /* PW: only for unbound wqs */
 
@@ -3737,7 +3736,7 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx 
*ctx)
        /* all pwqs have been created successfully, let's install'em */
        mutex_lock(&ctx->wq->mutex);
 
-       copy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs);
+       copy_workqueue_attrs(ctx->wq->attrs, ctx->attrs);
 
        /* save the previous pwq and install the new one */
        for_each_node(node)
@@ -3854,7 +3853,7 @@ static void wq_update_unbound_numa(struct 
workqueue_struct *wq, int cpu,
        lockdep_assert_held(&wq_pool_mutex);
 
        if (!wq_numa_enabled || !(wq->flags & WQ_UNBOUND) ||
-           wq->unbound_attrs->no_numa)
+           wq->attrs->no_numa)
                return;
 
        /*
@@ -3865,7 +3864,7 @@ static void wq_update_unbound_numa(struct 
workqueue_struct *wq, int cpu,
        target_attrs = wq_update_unbound_numa_attrs_buf;
        cpumask = target_attrs->cpumask;
 
-       copy_workqueue_attrs(target_attrs, wq->unbound_attrs);
+       copy_workqueue_attrs(target_attrs, wq->attrs);
        pwq = unbound_pwq_by_node(wq, node);
 
        /*
@@ -3985,12 +3984,6 @@ struct workqueue_struct *__alloc_workqueue_key(const 
char *fmt,
        if (!wq)
                return NULL;
 
-       if (flags & WQ_UNBOUND) {
-               wq->unbound_attrs = alloc_workqueue_attrs(GFP_KERNEL);
-               if (!wq->unbound_attrs)
-                       goto err_free_wq;
-       }
-
        wq->attrs = alloc_workqueue_attrs(GFP_KERNEL);
        if (!wq->attrs)
                goto err_free_wq;
@@ -4069,7 +4062,6 @@ struct workqueue_struct *__alloc_workqueue_key(const char 
*fmt,
        return wq;
 
 err_free_wq:
-       free_workqueue_attrs(wq->unbound_attrs);
        free_workqueue_attrs(wq->attrs);
        kfree(wq);
        return NULL;
@@ -4941,7 +4933,7 @@ static int workqueue_apply_unbound_cpumask(void)
                if (wq->flags & __WQ_ORDERED)
                        continue;
 
-               ctx = apply_wqattrs_prepare(wq, wq->unbound_attrs);
+               ctx = apply_wqattrs_prepare(wq, wq->attrs);
                if (!ctx) {
                        ret = -ENOMEM;
                        break;
@@ -5119,7 +5111,7 @@ static ssize_t wq_nice_show(struct device *dev, struct 
device_attribute *attr,
        int written;
 
        mutex_lock(&wq->mutex);
-       written = scnprintf(buf, PAGE_SIZE, "%d\n", wq->unbound_attrs->nice);
+       written = scnprintf(buf, PAGE_SIZE, "%d\n", wq->attrs->nice);
        mutex_unlock(&wq->mutex);
 
        return written;
@@ -5136,7 +5128,7 @@ static struct workqueue_attrs *wq_sysfs_prep_attrs(struct 
workqueue_struct *wq)
        if (!attrs)
                return NULL;
 
-       copy_workqueue_attrs(attrs, wq->unbound_attrs);
+       copy_workqueue_attrs(attrs, wq->attrs);
        return attrs;
 }
 
@@ -5173,7 +5165,7 @@ static ssize_t wq_cpumask_show(struct device *dev,
 
        mutex_lock(&wq->mutex);
        written = scnprintf(buf, PAGE_SIZE, "%*pb\n",
-                           cpumask_pr_args(wq->unbound_attrs->cpumask));
+                           cpumask_pr_args(wq->attrs->cpumask));
        mutex_unlock(&wq->mutex);
        return written;
 }
@@ -5210,7 +5202,7 @@ static ssize_t wq_numa_show(struct device *dev, struct 
device_attribute *attr,
 
        mutex_lock(&wq->mutex);
        written = scnprintf(buf, PAGE_SIZE, "%d\n",
-                           !wq->unbound_attrs->no_numa);
+                           !wq->attrs->no_numa);
        mutex_unlock(&wq->mutex);
 
        return written;
-- 
1.8.3.1

Reply via email to