From patchwork Fri Sep 28 06:03:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11831 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B9AB123EFD for ; Fri, 28 Sep 2012 06:03:26 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5F726A18514 for ; Fri, 28 Sep 2012 06:03:26 +0000 (UTC) Received: by ieje10 with SMTP id e10so6141884iej.11 for ; Thu, 27 Sep 2012 23:03:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=mXvrAHjlCc7vf3EVvL3A3cA4TM1xpp6kiFEYAk4/1gA=; b=GurNVf+WDHRbSN41sIXD3Lcke8lxkeEynfXa3Ys0XIamQmGp1ffGIuJYdh+JdGN4/S ID+jHdeR9NYQEtAHAGk6A//sODC2+54CgxJ7rtTwMDkq61mtX0YFoiZnBrxLz8rkJwkU S0igSs0usDlxFYoE73Jhe+UwzALJs9Iuad7NFcDJWgpeiQKMDrlsGrRIt3lbo9C6neT0 TPRrw68lRbz7lmrQp5Xc+06Yxexr0z7vG3yRgIBIBfnmzkYq1aBkwa3z2zPlp/YmtT6/ 6ZiBvHCw9UAuG1EsereOOfeBQZOY+XpeJT9gWGjhVCyK8bwNhBnRDuFifWA0izqRpQEN Y4HA== Received: by 10.50.154.227 with SMTP id vr3mr648834igb.43.1348812205818; Thu, 27 Sep 2012 23:03:25 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp453865igc; Thu, 27 Sep 2012 23:03:25 -0700 (PDT) Received: by 10.50.104.201 with SMTP id gg9mr606311igb.67.1348812204653; Thu, 27 Sep 2012 23:03:24 -0700 (PDT) Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com [209.85.223.178]) by mx.google.com with ESMTPS id us2si21155806igc.39.2012.09.27.23.03.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 23:03:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.223.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.223.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) smtp.mail=viresh.kumar@linaro.org Received: by ieje11 with SMTP id e11so7540405iej.37 for ; Thu, 27 Sep 2012 23:03:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.37.196 with SMTP id a4mr682095igk.27.1348812203866; Thu, 27 Sep 2012 23:03:23 -0700 (PDT) Received: by 10.64.166.38 with HTTP; Thu, 27 Sep 2012 23:03:23 -0700 (PDT) In-Reply-To: <7d5c2cac08134446583624cc124d46d9726bdb2d.1348736069.git.viresh.kumar@linaro.org> References: <7d5c2cac08134446583624cc124d46d9726bdb2d.1348736069.git.viresh.kumar@linaro.org> Date: Fri, 28 Sep 2012 11:33:23 +0530 Message-ID: Subject: Re: [PATCH V2 3/3] workqueue: Schedule work on non-idle cpu instead of current one From: Viresh Kumar To: Tejun Heo Cc: pjt@google.com, paul.mckenney@linaro.org, tglx@linutronix.de, Linux Kernel Mailing List , suresh.b.siddha@intel.com, venki@google.com, mingo@redhat.com, peterz@infradead.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Arvind.Chauhan@arm.com, amit.kucheria@linaro.org, vincent.guittot@linaro.org, linaro-dev@lists.linaro.org, patches@linaro.org, Viresh Kumar X-Gm-Message-State: ALoCoQloT8z5LmuOtON59WqBHySqGydYF+Lt1UAeCV3Ydt2AqgRHb2pqaT4Qmrc4xLbhUJnCqGBZ On 27 September 2012 14:34, Viresh Kumar wrote: > Workqueues queues work on current cpu, if the caller haven't passed a preferred > cpu. This may wake up an idle CPU, which is actually not required. > > This work can be processed by any CPU and so we must select a non-idle CPU here. > This patch adds in support in workqueue framework to get preferred CPU details > from the scheduler, instead of using current CPU. > > Most of the time when a work is queued, the current cpu isn't idle and so we > will choose it only. There are cases when a cpu is idle when it queues some > work. For example, consider following scenario: > - A cpu has programmed a timer and is IDLE now. > - CPU gets into interrupt handler due to timer and queues a work. As the CPU is > currently IDLE, we can queue this work to some other CPU. > > Signed-off-by: Viresh Kumar > --- > kernel/workqueue.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 143fd8c..5fa4ba4 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -1238,7 +1238,7 @@ static void __queue_work(unsigned int cpu, struct workqueue_struct *wq, > struct global_cwq *last_gcwq; > > if (cpu == WORK_CPU_UNBOUND) > - cpu = raw_smp_processor_id(); > + cpu = sched_select_cpu(0); Hi Tejun, Following change is also required with this patch: } Otherwise, we will end up running the re-reentrancy check, which we are trying to skip for delayed work. --- viresh --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1383,7 +1383,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, if (gcwq) lcpu = gcwq->cpu; if (lcpu == WORK_CPU_UNBOUND) - lcpu = raw_smp_processor_id(); + lcpu = sched_select_cpu(0); } else { lcpu = WORK_CPU_UNBOUND;