From patchwork Thu Apr 25 03:43:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 16387 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D1C8525DF4 for ; Thu, 25 Apr 2013 03:44:40 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id r3sf394930wey.9 for ; Wed, 24 Apr 2013 20:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=nKhXPgsWXB7Co8vXgXxrE4XABwKvCLJv+F7uio5j950=; b=Ot6PEFLCEEkoFwn2oPXqXw/7y+5HFcCz6GNvL2C46hQUhB/ZXHVC46umYqmYnLMZRI lZWi2w/X89ubw8zwbHziNGsTum8WgWbtCTDbcIWGG8kpudvPGtR8yImsab2rYY5s4e9b P8zE50genqkJxfBjmjcn08aC+zkfiqgilGA+/sBzRQYM0dfhpcgO/DK/YTgJ7+Uq0IWf nE8f9y+UsO8+fRCo4ix0Thi07HZp6Z9gYTIJyFawnOt9dV0w5Dj8GO0y8K/zxmxz8ZZf davcCNRXsVxfs2KmqBLihB2nBQie70RDrI7A2Obc26SH1BTW2D/s85zXVUchVhllw3N6 LcAA== X-Received: by 10.180.10.230 with SMTP id l6mr213324wib.3.1366861427802; Wed, 24 Apr 2013 20:43:47 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.81.8 with SMTP id v8ls687153wix.34.gmail; Wed, 24 Apr 2013 20:43:47 -0700 (PDT) X-Received: by 10.180.21.193 with SMTP id x1mr48475672wie.31.1366861427698; Wed, 24 Apr 2013 20:43:47 -0700 (PDT) Received: from mail-ve0-x231.google.com (mail-ve0-x231.google.com [2607:f8b0:400c:c01::231]) by mx.google.com with ESMTPS id c8si1851648wje.133.2013.04.24.20.43.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Apr 2013 20:43:47 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::231 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::231; Received: by mail-ve0-f177.google.com with SMTP id cy12so1056711veb.8 for ; Wed, 24 Apr 2013 20:43:46 -0700 (PDT) X-Received: by 10.58.173.36 with SMTP id bh4mr12437010vec.9.1366861426187; Wed, 24 Apr 2013 20:43:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp2936veb; Wed, 24 Apr 2013 20:43:44 -0700 (PDT) X-Received: by 10.182.128.105 with SMTP id nn9mr14362239obb.10.1366861424647; Wed, 24 Apr 2013 20:43:44 -0700 (PDT) Received: from mail-oa0-f53.google.com (mail-oa0-f53.google.com [209.85.219.53]) by mx.google.com with ESMTPS id yc10si2775045obc.196.2013.04.24.20.43.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Apr 2013 20:43:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.219.53 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.219.53; Received: by mail-oa0-f53.google.com with SMTP id m6so2450675oag.26 for ; Wed, 24 Apr 2013 20:43:44 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.58.99 with SMTP id p3mr5075156oeq.23.1366861424314; Wed, 24 Apr 2013 20:43:44 -0700 (PDT) Received: by 10.182.240.129 with HTTP; Wed, 24 Apr 2013 20:43:44 -0700 (PDT) In-Reply-To: References: <480f5d6da920e2f2b868f311228c81635727799e.1366803121.git.viresh.kumar@linaro.org> <20130424161208.GA16991@mtj.dyndns.org> Date: Thu, 25 Apr 2013 09:13:44 +0530 Message-ID: Subject: Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues From: Viresh Kumar To: Tejun Heo , Amit Kucheria Cc: davem@davemloft.net, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, Robin Randhawa , Charles Garcia-Tobin , Steve Bannister , Peter Zijlstra , Steven Rostedt , Arvind Chauhan , Patch Tracking , airlied@redhat.com, mingo@redhat.com, Jens Axboe , Liviu Dudau , Lists linaro-kernel X-Gm-Message-State: ALoCoQlHJqb0DLjAtV1ZZhPSum2NO2qbcsUcfJYkEIa3awPHOWSa5EjhiacTHZQ6mY9Sht+LhqS/ X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::231 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 25 April 2013 09:00, Amit Kucheria wrote: > Yes. That was my intention - preventing a prompt on existing defconfigs and > there by maintaining current behavior. Hmm... Following is the version after fixing all problems you reported. @Tejun: I have attached it too as gmail's copy-paste may break it. Please consider applying this series if it looks fine to you. ---------------x----------------x--------------------- From: Viresh Kumar Date: Mon, 8 Apr 2013 16:45:40 +0530 Subject: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake. Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter. Signed-off-by: Viresh Kumar Reviewed-by: Amit Kucheria --- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+) exclusion */ @@ -4085,6 +4093,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, struct workqueue_struct *wq; struct pool_workqueue *pwq; + if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient) + flags |= WQ_UNBOUND; + /* allocate wq and format name */ if (flags & WQ_UNBOUND) tbl_size = wq_numa_tbl_len * sizeof(wq->numa_pwq_tbl[0]); diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index c4fa000..22edc83 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -3312,6 +3312,23 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/. + workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they + were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores just to process some work. To save + power, we can allow the work to be rescheduled on a core + that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow + some power savings. However, we don't change the + default behaviour of the system. To enable power-saving + behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT + needs to be turned on. This option can also be + overridden by the workqueue.power_efficient boot + parameter. + x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic. diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 623488f..83fa570 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -302,6 +302,9 @@ enum { WQ_HIGHPRI = 1 << 4, /* high priority */ WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */ WQ_SYSFS = 1 << 6, /* visible in sysfs, see wq_sysfs_register() */ + WQ_POWER_EFFICIENT = 1 << 7, /* WQ_UNBOUND, for power + * saving, if wq_power_efficient is + * enabled. Unused otherwise. */ __WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */ diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 5dfdc9e..018f039 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig @@ -263,6 +263,25 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + default n + help + Workqueues can be performance or power-oriented. Currently, most + workqueues are bound to the CPU they were created on. This gives good + performance (due to cache effects) at the cost of potentially waking + up otherwise idle cores just to process some work. To save power, we + can allow the work to be rescheduled on a core that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow some power + savings. However, we don't change the default behaviour of the + system. To enable power-saving behaviour, a new config option + CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also + be overridden by the workqueue.power_efficient boot parameter. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 4aa9f5b..a327027 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask; static bool wq_disable_numa; module_param_named(disable_numa, wq_disable_numa, bool, 0444); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named(power_efficient, wq_power_efficient, bool, 0444); + static bool wq_numa_enabled; /* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug