From patchwork Fri May 23 18:16:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 30848 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0FEA320369 for ; Fri, 23 May 2014 18:18:40 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id w7sf16811040qcr.0 for ; Fri, 23 May 2014 11:18:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=fbhFbcehV3wJM7WOHqtEmxxwRiKg5vxwf95+6eDtpUI=; b=dldq7NCRDxMyQFtu4B1WyDOVVIXZmg7YFEpxFDnfiJzqaBFzQADC08hmDh+KfO6KPX K07GAGclQIto7vONmCFGFrSB5p1PSaikeTs3oFY9v18OTILTO0GRjQ2JhQd+O6qtQPTm BkHDW/X08TOMQ9gc+VxDVKCh5R4phTx38t5MH3oQaDeOm5ap/InVRWaBufe3h/Ouypvw tmwtPHmpSQLKDo/tr78gQm8lGf4Gq47bB9zNfFuVho7+7d2tJcjkdJHNz6s2XkS+mYQQ GsQcm5ErsiN/WSUk+EIgMVxJQmEqyOIfrO//JUjzTHV3co+oF2JDJbbDUKFfV0mHHpz9 +adg== X-Gm-Message-State: ALoCoQmj0uIMsFX1ymawi7ve0TgGw2+X0xOAJcK0bfM49UBjrFe1iYF/XFodtUCRqXr5W0pz3sXu X-Received: by 10.236.231.52 with SMTP id k50mr2502050yhq.52.1400869119913; Fri, 23 May 2014 11:18:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.131 with SMTP id d3ls1867061qge.52.gmail; Fri, 23 May 2014 11:18:39 -0700 (PDT) X-Received: by 10.221.40.193 with SMTP id tr1mr5612241vcb.31.1400869119802; Fri, 23 May 2014 11:18:39 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id dj5si2126930vcb.21.2014.05.23.11.18.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 11:18:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so6676094veb.20 for ; Fri, 23 May 2014 11:18:39 -0700 (PDT) X-Received: by 10.52.190.138 with SMTP id gq10mr1798467vdc.47.1400869119728; Fri, 23 May 2014 11:18:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp52377vcb; Fri, 23 May 2014 11:18:39 -0700 (PDT) X-Received: by 10.67.4.169 with SMTP id cf9mr8007278pad.45.1400869118922; Fri, 23 May 2014 11:18:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dq2si4937936pbb.118.2014.05.23.11.18.38 for ; Fri, 23 May 2014 11:18:38 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752058AbaEWSSb (ORCPT + 27 others); Fri, 23 May 2014 14:18:31 -0400 Received: from service87.mimecast.com ([91.220.42.44]:36326 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbaEWSQ4 (ORCPT ); Fri, 23 May 2014 14:16:56 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 23 May 2014 19:16:54 +0100 Received: from e103034-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 23 May 2014 19:16:54 +0100 From: Morten Rasmussen To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, peterz@infradead.org, mingo@kernel.org Cc: rjw@rjwysocki.net, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, preeti@linux.vnet.ibm.com, dietmar.eggemann@arm.com Subject: [RFC PATCH 12/16] sched: Task wakeup tracking Date: Fri, 23 May 2014 19:16:39 +0100 Message-Id: <1400869003-27769-13-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400869003-27769-1-git-send-email-morten.rasmussen@arm.com> References: <1400869003-27769-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 23 May 2014 18:16:54.0213 (UTC) FILETIME=[2CEF2F50:01CF76B3] X-MC-Unique: 114052319165415001 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: morten.rasmussen@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Track task wakeup rate in wakeup_avg_sum by counting wakeups. Note that this is _not_ cpu wakeups (idle exits). Task wakeups only cause cpu wakeups if the cpu is idle when the task wakeup occurs. The wakeup rate decays over time at the same rate as used for the existing entity load tracking. Unlike runnable_avg_sum, wakeup_avg_sum is counting events, not time, and is therefore theoretically unbounded and should be used with care. Signed-off-by: Morten Rasmussen --- include/linux/sched.h | 3 +++ kernel/sched/fair.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 727b936..d7b032f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1109,6 +1109,9 @@ struct sched_avg { u64 last_runnable_update; s64 decay_count; unsigned long load_avg_contrib; + + unsigned long last_wakeup_update; + u32 wakeup_avg_sum; }; #ifdef CONFIG_SCHEDSTATS diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 09e5232..39e9cd8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -679,6 +679,8 @@ void init_task_runnable_average(struct task_struct *p) p->se.avg.runnable_avg_sum = slice; p->se.avg.runnable_avg_period = slice; __update_task_entity_contrib(&p->se); + + p->se.avg.last_wakeup_update = jiffies; } #else void init_task_runnable_average(struct task_struct *p) @@ -4025,6 +4027,21 @@ static void record_wakee(struct task_struct *p) } } +static void update_wakeup_avg(struct task_struct *p) +{ + struct sched_entity *se = &p->se; + struct sched_avg *sa = &se->avg; + unsigned long now = ACCESS_ONCE(jiffies); + + if (time_after(now, sa->last_wakeup_update)) { + sa->wakeup_avg_sum = decay_load(sa->wakeup_avg_sum, + jiffies_to_msecs(now - sa->last_wakeup_update)); + sa->last_wakeup_update = now; + } + + sa->wakeup_avg_sum += 1024; +} + static void task_waking_fair(struct task_struct *p) { struct sched_entity *se = &p->se; @@ -4045,6 +4062,7 @@ static void task_waking_fair(struct task_struct *p) se->vruntime -= min_vruntime; record_wakee(p); + update_wakeup_avg(p); } #ifdef CONFIG_FAIR_GROUP_SCHED