From patchwork Tue Apr 9 07:30:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 15988 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-gh0-f200.google.com (mail-gh0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DB2B023970 for ; Tue, 9 Apr 2013 07:31:18 +0000 (UTC) Received: by mail-gh0-f200.google.com with SMTP id 10sf9248023ghy.3 for ; Tue, 09 Apr 2013 00:31:02 -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=PnuRMubGyGMWfinCbmV57mWSyIO4vRP6YClapkGvT0U=; b=J9a1pKt7UpTyu8RlmNW5zacRVH2K8HiYKO56en2t7dEgzvq6M7j61CjAzkfTaUeATb +gCAHFpTjQPkYbmkKlJAcKMTVPRn89JXP98/u1j72PP3y9gUcHKIIiTn91ukK8Uo56VE qfOfWQW10VMHdvD7nZfe4omFaWUAtsLNsRLBPPhYG0PH6xePskmaoER2XJ+iGiBqLWbU 0m0ysG2OQIbxtI0XzfOJyLnIbDhJtpLS8dc/Dj5y5Jd+R2RP6wjxpNOPm0QyfsFvbHW1 LSAjqxpHo66MnQY3jptcVg+6Tos8GvPoBoSsE7sMyn3HIB8y3WQOZ5XRpD8B1Q+ylfkY XFlw== X-Received: by 10.236.123.239 with SMTP id v75mr10817567yhh.37.1365492662179; Tue, 09 Apr 2013 00:31:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.103 with SMTP id b7ls3391886qeg.96.gmail; Tue, 09 Apr 2013 00:31:02 -0700 (PDT) X-Received: by 10.52.28.139 with SMTP id b11mr2051178vdh.4.1365492662010; Tue, 09 Apr 2013 00:31:02 -0700 (PDT) Received: from mail-vb0-x22d.google.com (mail-vb0-x22d.google.com [2607:f8b0:400c:c02::22d]) by mx.google.com with ESMTPS id a1si20840030vef.11.2013.04.09.00.31.01 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Apr 2013 00:31:02 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22d 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:c02::22d; Received: by mail-vb0-f45.google.com with SMTP id w15so4455933vbf.18 for ; Tue, 09 Apr 2013 00:31:01 -0700 (PDT) X-Received: by 10.52.93.20 with SMTP id cq20mr15708553vdb.38.1365492661797; Tue, 09 Apr 2013 00:31:01 -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.85.136 with SMTP id h8csp49780vez; Tue, 9 Apr 2013 00:31:01 -0700 (PDT) X-Received: by 10.60.79.69 with SMTP id h5mr17330465oex.49.1365492660595; Tue, 09 Apr 2013 00:31:00 -0700 (PDT) Received: from mail-ob0-x233.google.com (mail-ob0-x233.google.com [2607:f8b0:4003:c01::233]) by mx.google.com with ESMTPS id tu4si18592371obb.164.2013.04.09.00.31.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Apr 2013 00:31:00 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:4003:c01::233 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:4003:c01::233; Received: by mail-ob0-f179.google.com with SMTP id tb18so2861030obb.10 for ; Tue, 09 Apr 2013 00:31:00 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.60.136 with SMTP id h8mr14528942obr.47.1365492660177; Tue, 09 Apr 2013 00:31:00 -0700 (PDT) Received: by 10.182.128.228 with HTTP; Tue, 9 Apr 2013 00:30:59 -0700 (PDT) In-Reply-To: <20130331181931.GA7533@htj.dyndns.org> References: <91239cde99aaba2715f63db1f88241d9f4a36e13.1364740180.git.viresh.kumar@linaro.org> <20130331181931.GA7533@htj.dyndns.org> Date: Tue, 9 Apr 2013 13:00:59 +0530 Message-ID: Subject: Re: [PATCH V4 3/4] block: queue work on unbound wq From: Viresh Kumar To: Tejun Heo Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, 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 X-Gm-Message-State: ALoCoQn6viO9v3PiT+jluXEA2SmhiqlF/AIvqSOzAIif+mowwT/a1fhnZ9mZ1fEf4eksSMPeMCgO X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22d 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 31 March 2013 23:49, Tejun Heo wrote: > So, let's please introduce a new flag to mark these workqueues, say, > WQ_UNBOUND_FOR_POWER_SAVE or whatever (please come up with a better > name) and provide a compile time switch with boot time override. Hi Tejun, I have written a patch to get this done and want to get that a some review before touching other drivers and spamming LKML with other patches :) Here it is: From: Viresh Kumar Date: Mon, 8 Apr 2013 16:45:40 +0530 Subject: [PATCH] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues 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. To make this compile time configurable with boot time override this patch adds in another flag WQ_POWER_EFFICIENT. This will be converted to WQ_UNBOUND (on wq allocation) if CONFIG_WQ_POWER_EFFICIENT is enabled and bootargs contain workqueue.power_efficient=1. It is unused otherwise and normal behavior of WQ without this flag is expected. CONFIG option is currently added under kernel/power/Kconfig and is looking for relevant Kconfig file. Signed-off-by: Viresh Kumar --- Documentation/kernel-parameters.txt | 15 +++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 18 ++++++++++++++++++ kernel/workqueue.c | 14 ++++++++++++++ 4 files changed, 50 insertions(+) exclusion */ @@ -4085,6 +4090,15 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, struct workqueue_struct *wq; struct pool_workqueue *pwq; + if (flags & WQ_POWER_EFFICIENT) { + flags &= ~WQ_POWER_EFFICIENT; + +#ifdef CONFIG_WQ_POWER_EFFICIENT + if (wq_power_efficient) + flags |= WQ_UNBOUND; +#endif + } + /* 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 12c42a5..210e5fc 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -3249,6 +3249,21 @@ 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 + power_efficient boot param will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. + This requires CONFIG_WQ_POWER_EFFICIENT to be enabled. + WQ_POWER_EFFICIENT is unused if power_efficient is not + set in boot params. + 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 1a53816..168b5be 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -299,6 +299,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..8d62400 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig @@ -263,6 +263,24 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND 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 power_efficient boot param + will convert WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. + This requires CONFIG_WQ_POWER_EFFICIENT to be enabled. + WQ_POWER_EFFICIENT is unused if power_efficient is not set in boot + params. + + 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 1228fd7..590e333 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -271,6 +271,11 @@ 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 = 0; +module_param_named(power_efficient, wq_power_efficient, bool, 0444); +#endif + static bool wq_numa_enabled; /* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug