From patchwork Thu Jul 3 16:26:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 33042 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB207203AC for ; Thu, 3 Jul 2014 16:27:47 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wm4sf2100478obc.11 for ; Thu, 03 Jul 2014 09:27:47 -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=DuHvIKJykxnts//P2SUNU+RRzboPIV6wPrJwzuuj6vY=; b=DXWL4V0LBN+hEQqmY93Vd+cgl42j1Y90JgmzMgdD3ibjBAkZD9ayQCyHkdjyE+AwFk e/jIkiRGtbT5JrEITxgVOKYileEcsnDTmQJge7N1ln4j9QZoZlsl8uVV1WeNrKHaCt0W TW/4DLSLVBf/fZg58xHmTI4ESbO7+/Hju7mnUg6+LRwdcNSmR5bfr4/7uFFaPHL7xpYH fCFgNO2RIMd3lTcWQTwfLiBiNrnVoUM6OSh9LelkHpsr+8gHJVUk8rQCw33t6xyVL/ua bRnIFvO7hZmeWFpeXPEA5RWn+ILFUapngr3xbQw9/5Svl+g46Yfzs7t2sM9HvaaZU1oM ecbA== X-Gm-Message-State: ALoCoQklDNJIDas4RlcANzYZ6ubZUFy7/bf5Gi5zykI5PqKKrWLAcm3l54ZU4bs0Y7halsXDqJas X-Received: by 10.182.241.33 with SMTP id wf1mr2535830obc.37.1404404867593; Thu, 03 Jul 2014 09:27:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.85 with SMTP id s79ls551702qgd.77.gmail; Thu, 03 Jul 2014 09:27:47 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr4064614vdc.24.1404404867495; Thu, 03 Jul 2014 09:27:47 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id k4si14410024vch.63.2014.07.03.09.27.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:27:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so485887veb.32 for ; Thu, 03 Jul 2014 09:27:47 -0700 (PDT) X-Received: by 10.221.20.199 with SMTP id qp7mr4837997vcb.24.1404404867300; Thu, 03 Jul 2014 09:27:47 -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.221.37.5 with SMTP id tc5csp390414vcb; Thu, 3 Jul 2014 09:27:46 -0700 (PDT) X-Received: by 10.67.2.34 with SMTP id bl2mr5737619pad.58.1404404865329; Thu, 03 Jul 2014 09:27:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ho4si33280366pbc.180.2014.07.03.09.27.44; Thu, 03 Jul 2014 09:27:44 -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 S1759520AbaGCQ1k (ORCPT + 27 others); Thu, 3 Jul 2014 12:27:40 -0400 Received: from service87.mimecast.com ([91.220.42.44]:50181 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759486AbaGCQ1h (ORCPT ); Thu, 3 Jul 2014 12:27:37 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 03 Jul 2014 17:26:22 +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); Thu, 3 Jul 2014 17:26:21 +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, pjt@google.com Subject: [RFCv2 PATCH 19/23] sched: Task wakeup tracking Date: Thu, 3 Jul 2014 17:26:06 +0100 Message-Id: <1404404770-323-20-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> References: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 03 Jul 2014 16:26:21.0881 (UTC) FILETIME=[86B16290:01CF96DB] X-MC-Unique: 114070317262200601 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.173 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 faebd87..5f854b2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1107,6 +1107,9 @@ struct sched_avg { s64 decay_count; unsigned long load_avg_contrib; unsigned long uw_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 44ba754..6da8e2b 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) @@ -4112,6 +4114,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; @@ -4132,6 +4149,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