From patchwork Thu Apr 25 17:23:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 16404 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A75E52395D for ; Thu, 25 Apr 2013 17:26:03 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id 11sf5594018vbe.3 for ; Thu, 25 Apr 2013 10:25:10 -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: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=xPZRij73XJhUQmfI2iK0B4k2cK+AQVL5VJr2oz4Af2Q=; b=dl6iRTQ6ckg2G+eSFV42xsSwN5IckpPSipd/1D2UOum4bnsT5QNykOIXiyNQUSl1g7 1TBa1Jj9ppRgHjMAeeQ63b6jhIeorjii4i4qANrtWy9nCSpcXA6XhC1Vhujyk8P/A8ED iBZ2Oyxs8nkYWGL2xwDZ4+k8z+9UD6RKScFNz0fErT1j36qtmU5WaM5SMh19JXg/herY y4WQz/qyXR9DyVrPld4w483x/NkIoBbJ6nPZg9f6jGNH++SNYMW8BpGKURo3suAhhggN /8lLDCtA4DPj2FXQZcFxFoQwXaaxz9lLr9YdfHDC1yorS/7lZQ4lVD+HL3hnexw23heH XliQ== X-Received: by 10.236.32.67 with SMTP id n43mr20194423yha.0.1366910709684; Thu, 25 Apr 2013 10:25:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.27.10 with SMTP id p10ls1503647qeg.60.gmail; Thu, 25 Apr 2013 10:25:09 -0700 (PDT) X-Received: by 10.52.33.236 with SMTP id u12mr23077208vdi.101.1366910709508; Thu, 25 Apr 2013 10:25:09 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ha8si3694265vdb.22.2013.04.25.10.25.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Apr 2013 10:25:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 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.178; Received: by mail-vc0-f178.google.com with SMTP id ib11so3033655vcb.23 for ; Thu, 25 Apr 2013 10:25:09 -0700 (PDT) X-Received: by 10.52.69.109 with SMTP id d13mr1180997vdu.75.1366910709434; Thu, 25 Apr 2013 10:25:09 -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 nf2csp32667veb; Thu, 25 Apr 2013 10:25:08 -0700 (PDT) X-Received: by 10.180.21.193 with SMTP id x1mr53275007wie.31.1366910708375; Thu, 25 Apr 2013 10:25:08 -0700 (PDT) Received: from mail-we0-x234.google.com (mail-we0-x234.google.com [2a00:1450:400c:c03::234]) by mx.google.com with ESMTPS id ho10si9541547wib.91.2013.04.25.10.25.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Apr 2013 10:25:08 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::234 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=2a00:1450:400c:c03::234; Received: by mail-we0-f180.google.com with SMTP id x43so2775349wey.39 for ; Thu, 25 Apr 2013 10:25:08 -0700 (PDT) X-Received: by 10.194.90.108 with SMTP id bv12mr59545483wjb.4.1366910707981; Thu, 25 Apr 2013 10:25:07 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id q13sm12311485wie.8.2013.04.25.10.25.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Apr 2013 10:25:07 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, peterz@infradead.org, mingo@kernel.org, linux@arm.linux.org.uk, pjt@google.com, santosh.shilimkar@ti.com, Morten.Rasmussen@arm.com, chander.kashyap@linaro.org, cmetcalf@tilera.com, tony.luck@intel.com, alex.shi@intel.com, preeti@linux.vnet.ibm.com Cc: paulmck@linux.vnet.ibm.com, tglx@linutronix.de, len.brown@intel.com, arjan@linux.intel.com, amit.kucheria@linaro.org, corbet@lwn.net, l.majewski@samsung.com, Vincent Guittot Subject: [PATCH 09/14] sched: evaluate the activity level of the system Date: Thu, 25 Apr 2013 19:23:25 +0200 Message-Id: <1366910611-20048-10-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366910611-20048-1-git-send-email-vincent.guittot@linaro.org> References: <1366910611-20048-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQlWc5JW5qYWmeU8xQb1vlM/9X2K9ihOgovkYTaUSQKmC774Op2pJHgb+b0BVztxPophoL2z X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 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: , We evaluate the activity level of CPUs, groups and domains in order to define how many CPUs are required to handle the current activity. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 954adfd..234ecdd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3465,7 +3465,22 @@ static int check_pack_buddy(int cpu, struct task_struct *p) return true; return false; +} + +static int get_cpu_activity(int cpu) +{ + struct rq *rq = cpu_rq(cpu); + u32 sum = rq->avg.runnable_avg_sum; + u32 period = rq->avg.runnable_avg_period; + + sum = min(sum, period); + + if (sum == period) { + u32 overload = rq->nr_running > 1 ? 1 : 0; + return power_of(cpu) + overload; + } + return (sum * power_of(cpu)) / period; } /* @@ -4355,6 +4370,7 @@ struct sd_lb_stats { struct sched_group *busiest; /* Busiest group in this sd */ struct sched_group *this; /* Local group in this sd */ unsigned long total_load; /* Total load of all groups in sd */ + unsigned long total_activity; /* Total activity of all groups in sd */ unsigned long total_pwr; /* Total power of all groups in sd */ unsigned long avg_load; /* Average load across all groups in sd */ @@ -4383,6 +4399,7 @@ struct sd_lb_stats { struct sg_lb_stats { unsigned long avg_load; /*Avg load across the CPUs of the group */ unsigned long group_load; /* Total load over the CPUs of the group */ + unsigned long group_activity; /* Total activity of the group */ unsigned long sum_nr_running; /* Nr tasks running in the group */ unsigned long sum_weighted_load; /* Weighted load of group's tasks */ unsigned long group_capacity; @@ -4629,6 +4646,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, } sgs->group_load += load; + sgs->group_activity += get_cpu_activity(i); sgs->sum_nr_running += nr_running; sgs->sum_weighted_load += weighted_cpuload(i); if (idle_cpu(i)) @@ -4752,6 +4770,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, return; sds->total_load += sgs.group_load; + sds->total_activity += sgs.group_activity; sds->total_pwr += sg->sgp->power; /*