From patchwork Fri Oct 21 16:57:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 4787 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 B0D1C23DEF for ; Fri, 21 Oct 2011 16:57:32 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 7F705A182E3 for ; Fri, 21 Oct 2011 16:57:32 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id 39so2125223ywm.11 for ; Fri, 21 Oct 2011 09:57:32 -0700 (PDT) Received: by 10.223.77.69 with SMTP id f5mr26010006fak.3.1319216251984; Fri, 21 Oct 2011 09:57:31 -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.152.1.71 with SMTP id 7cs22936lak; Fri, 21 Oct 2011 09:57:31 -0700 (PDT) Received: by 10.227.129.77 with SMTP id n13mr5814069wbs.37.1319216251470; Fri, 21 Oct 2011 09:57:31 -0700 (PDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id fc16si10176533wbb.51.2011.10.21.09.57.31 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Oct 2011 09:57:31 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by mail-wy0-f178.google.com with SMTP id 28so4820029wyf.37 for ; Fri, 21 Oct 2011 09:57:31 -0700 (PDT) Received: by 10.227.11.12 with SMTP id r12mr5884199wbr.26.1319216249894; Fri, 21 Oct 2011 09:57:29 -0700 (PDT) Received: from localhost.localdomain (pas72-1-88-161-60-229.fbx.proxad.net. [88.161.60.229]) by mx.google.com with ESMTPS id x40sm16600810wbn.19.2011.10.21.09.57.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Oct 2011 09:57:29 -0700 (PDT) From: Vincent Guittot To: linaro-dev@lists.linaro.org Cc: patches@linaro.org, Vincent Guittot Subject: [RFC PATCH 10/11] sched: Ensure cpu_power periodic update Date: Fri, 21 Oct 2011 18:57:21 +0200 Message-Id: <1319216241-2736-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.4.1 With a lot of small tasks, the softirq sched is nearly never called when no_hz is enable. The load_balance is mainly called with the newly_idle mode which doesn't update the cpu_power. Add a next_update field which ensures a maximum update period when there is short activity Signed-off-by: Vincent Guittot --- include/linux/sched.h | 1 + kernel/sched_fair.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 41d0237..8610921 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -901,6 +901,7 @@ struct sched_group_power { * single CPU. */ unsigned int power, power_orig; + unsigned long next_update; }; struct sched_group { diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index bc8ee99..3961876 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -2667,6 +2667,11 @@ static void update_group_power(struct sched_domain *sd, int cpu) struct sched_domain *child = sd->child; struct sched_group *group, *sdg = sd->groups; unsigned long power; + unsigned long interval; + + interval = msecs_to_jiffies(sd->balance_interval); + interval = clamp(interval, 1UL, max_load_balance_interval); + sdg->sgp->next_update = jiffies + interval; if (!child) { update_cpu_power(sd, cpu); @@ -2774,12 +2779,15 @@ static inline void update_sg_lb_stats(struct sched_domain *sd, * domains. In the newly idle case, we will allow all the cpu's * to do the newly idle load balance. */ - if (idle != CPU_NEWLY_IDLE && local_group) { - if (balance_cpu != this_cpu) { - *balance = 0; - return; - } - update_group_power(sd, this_cpu); + if (local_group) { + if (idle != CPU_NEWLY_IDLE) { + if (balance_cpu != this_cpu) { + *balance = 0; + return; + } + update_group_power(sd, this_cpu); + } else if (time_after_eq(jiffies, group->sgp->next_update)) + update_group_power(sd, this_cpu); } /* Adjust by relative CPU power of the group */