Received: by 10.223.176.5 with SMTP id f5csp198792wra; Fri, 26 Jan 2018 21:11:16 -0800 (PST) X-Google-Smtp-Source: AH8x225D9qCmitwe0iby6+bNLJFd8lmhdBPIu6nhoyreKhFlstyCJohEw6rjCg7U/4nx31RtQ/oM X-Received: by 10.98.68.129 with SMTP id m1mr13123687pfi.171.1517029876280; Fri, 26 Jan 2018 21:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517029876; cv=none; d=google.com; s=arc-20160816; b=HpBvayqwokjVKQOcWbrzxpuMoQIz0+x+4ge6zkZSRN5++QkgguL5h3zsrfApx1YTVH HRJ06ev84uXoTI9pwJ7FKSpbpgPzCtaZrrpSrqIoucjX2ZpZER/wPMyWWgWu/KT9oliC cfgZdeXH48OBtMARczjIb+SnDrkdZZIA7fl2M5VuNeKzaAew0gzK33DMOaPeF4WBH8mK N/eeAGRp0fjGP/7iOccPXWzsOA/767u7xh4cM0hBlV+ZyctFbHcv+hxant4mtUUDQVIV /Qp8fYgrJVITtg3tmhzt854KI3rlZ3VyjGk46KeLiH40U1k2fF88PuLRGwd5G1yekYKk tnaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Jv7it+50QZImtB6pr7p6QxiOlCO+04ngUrHab2PPLrQ=; b=t5IMbo+LUsLIqZi9ZFwKb01z7gPjRH8ahbfJbKu1yAjiLF1rKgmcdmbboWd/IclnlM c1eojFsHwcJGP1B1a9IIdxlqmxOMsB3JSiWApwCKQtK2ZHHOroh/kIcAGwyq5ZrPqiAD NMc5FdZ613Yg+PuL4zGXXKk2p4DY5PJBF0WTnY1Ws24doWKdZZprEzx1r06FLW6H1WBT GPTMYJBt/gDULLE61eDxn7oz+h+zTvYocJfvwLo0DeO8cQM4FxAgXa2dGVlGH6C/zar7 UEmALIM+m19vpnNaAuqYMdFjA3ty3TfB+K3cgatw+XdXAMhWcCkhAX2Jzj9NcHmtQ4Yc AbVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i135si3978695pgc.459.2018.01.26.21.11.01; Fri, 26 Jan 2018 21:11:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751739AbeA0FKi (ORCPT + 99 others); Sat, 27 Jan 2018 00:10:38 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:43426 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbeA0FKe (ORCPT ); Sat, 27 Jan 2018 00:10:34 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id E20FDE37873FDA7F098F; Sat, 27 Jan 2018 13:10:30 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w0R59uNM092782; Sat, 27 Jan 2018 13:09:56 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from localhost.localdomain ([10.75.9.60]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018012713100679-2795350 ; Sat, 27 Jan 2018 13:10:06 +0800 From: Wen Yang To: tj@kernel.org Cc: zhong.weidong@zte.com.cn, wen.yang99@zte.com.cn, Jiang Biao , Tan Hu , Lai Jiangshan , kernel test robot , linux-kernel@vger.kernel.org Subject: [RFC PATCH V5 4/5] workqueue: convert ->nice to ->sched_attr Date: Sat, 27 Jan 2018 13:15:26 +0800 Message-Id: <1517030127-21391-4-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517030127-21391-1-git-send-email-wen.yang99@zte.com.cn> References: <1517030127-21391-1-git-send-email-wen.yang99@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-01-27 13:10:06, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-01-27 13:09:37, Serialize complete at 2018-01-27 13:09:37 X-MAIL: mse01.zte.com.cn w0R59uNM092782 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The possibility of specifying more than just a nice for the wq may be useful for a wide variety of applications. Signed-off-by: Wen Yang Signed-off-by: Jiang Biao Signed-off-by: Tan Hu Suggested-by: Tejun Heo Cc: Tejun Heo Cc: Lai Jiangshan Cc: kernel test robot Cc: linux-kernel@vger.kernel.org --- include/linux/workqueue.h | 5 +++-- kernel/workqueue.c | 27 +++++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 4a54ef9..d9d0f36 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -13,6 +13,7 @@ #include #include #include +#include struct workqueue_struct; @@ -127,9 +128,9 @@ struct delayed_work { */ struct workqueue_attrs { /** - * @nice: nice level + * @sched_attr: kworker's scheduling parameters */ - int nice; + struct sched_attr sched_attr; /** * @cpumask: allowed CPUs diff --git a/kernel/workqueue.c b/kernel/workqueue.c index df22ecb..fca0e30 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1772,7 +1772,7 @@ static struct worker *create_worker(struct worker_pool *pool) if (pool->cpu >= 0) snprintf(id_buf, sizeof(id_buf), "%d:%d%s", pool->cpu, id, - pool->attrs->nice < 0 ? "H" : ""); + pool->attrs->sched_attr.sched_nice < 0 ? "H" : ""); else snprintf(id_buf, sizeof(id_buf), "u%d:%d", pool->id, id); @@ -1781,7 +1781,7 @@ static struct worker *create_worker(struct worker_pool *pool) if (IS_ERR(worker->task)) goto fail; - set_user_nice(worker->task, pool->attrs->nice); + set_user_nice(worker->task, pool->attrs->sched_attr.sched_nice); kthread_bind_mask(worker->task, pool->attrs->cpumask); /* successful, attach the worker to the pool */ @@ -3169,7 +3169,7 @@ struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask) static void copy_workqueue_attrs(struct workqueue_attrs *to, const struct workqueue_attrs *from) { - to->nice = from->nice; + to->sched_attr.sched_nice = from->sched_attr.sched_nice; cpumask_copy(to->cpumask, from->cpumask); /* * Unlike hash and equality test, this function doesn't ignore @@ -3184,7 +3184,7 @@ static u32 wqattrs_hash(const struct workqueue_attrs *attrs) { u32 hash = 0; - hash = jhash_1word(attrs->nice, hash); + hash = jhash_1word(attrs->sched_attr.sched_nice, hash); hash = jhash(cpumask_bits(attrs->cpumask), BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long), hash); return hash; @@ -3194,7 +3194,7 @@ static u32 wqattrs_hash(const struct workqueue_attrs *attrs) static bool wqattrs_equal(const struct workqueue_attrs *a, const struct workqueue_attrs *b) { - if (a->nice != b->nice) + if (a->sched_attr.sched_nice != b->sched_attr.sched_nice) return false; if (!cpumask_equal(a->cpumask, b->cpumask)) return false; @@ -4336,7 +4336,8 @@ static void pr_cont_pool_info(struct worker_pool *pool) pr_cont(" cpus=%*pbl", nr_cpumask_bits, pool->attrs->cpumask); if (pool->node != NUMA_NO_NODE) pr_cont(" node=%d", pool->node); - pr_cont(" flags=0x%x nice=%d", pool->flags, pool->attrs->nice); + pr_cont(" flags=0x%x nice=%d", pool->flags, + pool->attrs->sched_attr.sched_nice); } static void pr_cont_work(bool comma, struct work_struct *work) @@ -5074,7 +5075,8 @@ 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->attrs->nice); + written = scnprintf(buf, PAGE_SIZE, "%d\n", + wq->attrs->sched_attr.sched_nice); mutex_unlock(&wq->mutex); return written; @@ -5108,8 +5110,9 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr, if (!attrs) goto out_unlock; - if (sscanf(buf, "%d", &attrs->nice) == 1 && - attrs->nice >= MIN_NICE && attrs->nice <= MAX_NICE) + if (sscanf(buf, "%d", &attrs->sched_attr.sched_nice) == 1 && + attrs->sched_attr.sched_nice >= MIN_NICE && + attrs->sched_attr.sched_nice <= MAX_NICE) ret = apply_workqueue_attrs_locked(wq, attrs); else ret = -EINVAL; @@ -5573,7 +5576,7 @@ int __init workqueue_init_early(void) BUG_ON(init_worker_pool(pool)); pool->cpu = cpu; cpumask_copy(pool->attrs->cpumask, cpumask_of(cpu)); - pool->attrs->nice = std_nice[i++]; + pool->attrs->sched_attr.sched_nice = std_nice[i++]; pool->node = cpu_to_node(cpu); /* alloc pool ID */ @@ -5588,7 +5591,7 @@ int __init workqueue_init_early(void) struct workqueue_attrs *attrs; BUG_ON(!(attrs = alloc_workqueue_attrs(GFP_KERNEL))); - attrs->nice = std_nice[i]; + attrs->sched_attr.sched_nice = std_nice[i]; unbound_std_wq_attrs[i] = attrs; /* @@ -5597,7 +5600,7 @@ int __init workqueue_init_early(void) * Turn off NUMA so that dfl_pwq is used for all nodes. */ BUG_ON(!(attrs = alloc_workqueue_attrs(GFP_KERNEL))); - attrs->nice = std_nice[i]; + attrs->sched_attr.sched_nice = std_nice[i]; attrs->no_numa = true; ordered_wq_attrs[i] = attrs; } -- 1.8.3.1