From patchwork Wed Apr 24 11:42:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 16373 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 35E0E23918 for ; Wed, 24 Apr 2013 11:47:25 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id v20sf2610443qcm.5 for ; Wed, 24 Apr 2013 04:46:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references: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; bh=aeL3c2iWwkQ/vNVDn2+8KH40Zir0XYFkpRWrtIHRRxQ=; b=geZkNFuVGD9vPe9ZLEbnCTKn29gPwO1byEc6UR2/4lirJaP0H4qej7f2kUbg7G2adu cJGjNrBf1mowGWX1oYi65dNkq+OiUaZqkSTNpvc1VEaQ/SoOmIbdbYcjopd2sqG6x9g2 V3CBP2QKszKmOs1ZNRkS+PH+0Y0+Rc8pvKINnFevNeBPDuqMfEz0W8ivUtcfNJlr3oH4 d5XZExwxVOZOS5jK/6Gl23kLit77uGLbfTJMTEEKLqLD6Kor0eH4NYzD9ME0EE9tbwsK sJN93/CjGqcgsm4m5k+VLZdCnh0Kp8bV7S08exZralo+kpUCni9OYHSqUsOIoXtCFHgI YQGQ== X-Received: by 10.224.217.195 with SMTP id hn3mr24675856qab.5.1366803994011; Wed, 24 Apr 2013 04:46:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.202 with SMTP id x10ls780098qeu.56.gmail; Wed, 24 Apr 2013 04:46:33 -0700 (PDT) X-Received: by 10.52.100.5 with SMTP id eu5mr21128670vdb.66.1366803993825; Wed, 24 Apr 2013 04:46:33 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id gr7si1097446vdc.38.2013.04.24.04.46.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Apr 2013 04:46:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id gf11so974745vcb.8 for ; Wed, 24 Apr 2013 04:46:33 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr21347418vdb.94.1366803993662; Wed, 24 Apr 2013 04:46:33 -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 nf2csp169517veb; Wed, 24 Apr 2013 04:46:33 -0700 (PDT) X-Received: by 10.67.10.133 with SMTP id ea5mr18961586pad.135.1366803992565; Wed, 24 Apr 2013 04:46:32 -0700 (PDT) Received: from mail-da0-x229.google.com (mail-da0-x229.google.com [2607:f8b0:400e:c00::229]) by mx.google.com with ESMTPS id iw4si2701252pac.8.2013.04.24.04.46.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Apr 2013 04:46:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::229 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:400e:c00::229; Received: by mail-da0-f41.google.com with SMTP id p8so852652dan.0 for ; Wed, 24 Apr 2013 04:46:31 -0700 (PDT) X-Received: by 10.66.121.36 with SMTP id lh4mr18521999pab.208.1366803991646; Wed, 24 Apr 2013 04:46:31 -0700 (PDT) Received: from localhost ([122.172.242.146]) by mx.google.com with ESMTPSA id fm2sm3344084pab.13.2013.04.24.04.46.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 24 Apr 2013 04:46:31 -0700 (PDT) From: Viresh Kumar To: tj@kernel.org Cc: davem@davemloft.net, airlied@redhat.com, axboe@kernel.dk, tglx@linutronix.de, peterz@infradead.org, mingo@redhat.com, rostedt@goodmis.org, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, linaro-kernel@lists.linaro.org, patches@linaro.org, Viresh Kumar Subject: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues Date: Wed, 24 Apr 2013 17:12:53 +0530 Message-Id: <480f5d6da920e2f2b868f311228c81635727799e.1366803121.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQk72q8AgkSiO1u72fnAiPNou4i5J7fYprCLFuBFTMrkUpi68I3hZXacM2b8xn3u6K0OAlQm X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 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: , Workqueues can be performance or power oriented. For performance we may want to keep them running on a single cpu, so that it remains cache hot. For power we can give scheduler the liberty to choose target cpu for running work handler. Later one (Power oriented WQ) can be achieved if the workqueue is allocated with WQ_UNBOUND flag. Enabling CONFIG_WQ_POWER_EFFICIENT will set 'wq_power_efficient' to 'true'. Setting 'power_efficient' boot param will override value of 'wq_power_efficient' variable. When 'wq_power_efficient' is set to 'true', we will convert WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. And so scheduler will have the liberty to choose where to run this work. Signed-off-by: Viresh Kumar --- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index c4fa000..a9040fa 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. For + performance we may want to keep them running on a single + cpu, so that it remains cache hot. For power we can give + scheduler the liberty to choose target cpu for running + work handler. + + Later one (Power oriented WQ) can be achieved if the + workqueue is allocated with WQ_UNBOUND flag. Enabling + CONFIG_WQ_POWER_EFFICIENT will set 'wq_power_efficient' + to 'true'. Setting 'power_efficient' boot param will + override value of 'wq_power_efficient' variable. When + 'wq_power_efficient' is set to 'true', we will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. + And so scheduler will have the liberty to choose where + to run this work. + 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..e1e9c8b 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 + help + Workqueues can be performance or power oriented. For performance we + may want to keep them running on a single cpu, so that it remains + cache hot. For power we can give scheduler the liberty to choose + target cpu for running work handler. + + Later one (Power oriented WQ) can be achieved if the workqueue is + allocated with WQ_UNBOUND flag. Enabling CONFIG_WQ_POWER_EFFICIENT + will set 'wq_power_efficient' to 'true'. Setting 'power_efficient' + boot param will override value of 'wq_power_efficient' variable. When + 'wq_power_efficient' is set to 'true', we will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. And so + scheduler will have the liberty to choose where to run this work. + + 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 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]);