From patchwork Wed Apr 15 10:00:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 47170 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0C0B2121F for ; Wed, 15 Apr 2015 10:00:53 +0000 (UTC) Received: by laat2 with SMTP id t2sf8683911laa.2 for ; Wed, 15 Apr 2015 03:00:52 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=/kJRdfKthNCBxGXRCCQk51Q2IV37UsDzmAfAL7xWjz8=; b=juUDFW2C4xUIQH/1/FLRId4tqcKV0rHp5qAJQlE0JBaIhJLD15O+gdKQD4XwY3PdGU l0POMUIiGjXvw48k6JrPNLuVOvxDK2tlHAsayXScTAvyuNA/PmMuzIZKl9T+YFIJ3ffO lE9yP7q1HGCBCyh06Sjuxgm5IIM0/1UhIS0raZVUNrG0vJTcnRqwi11pD8nOXGg7h7Tc y28Nu3UtkN8YF4Zfnxbb/AYLNDU8JPa5DynZNd+ezlD3jq9J+9tNOEkIv8PDSd9aD3Ie 25vSKt3bdkcpTfATa5ML1ueBSzLIgYfr7jtXSZKo0x+tRI42ofszEWOvvfs7o+3RT0IH hrNQ== X-Gm-Message-State: ALoCoQmQGJvJeXjiZ47OFjdiuLEmpfaHMkgI4YLj9qKEIJPrBJeIf9tzpGXLFS7imMckC5mm++pu X-Received: by 10.194.241.200 with SMTP id wk8mr3243830wjc.7.1429092052782; Wed, 15 Apr 2015 03:00:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.229 with SMTP id jf5ls161768lac.56.gmail; Wed, 15 Apr 2015 03:00:52 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr23117522lae.64.1429092052621; Wed, 15 Apr 2015 03:00:52 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id ko5si3479754lbb.43.2015.04.15.03.00.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2015 03:00:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbzk7 with SMTP id zk7so29835509lbb.0 for ; Wed, 15 Apr 2015 03:00:52 -0700 (PDT) X-Received: by 10.112.184.70 with SMTP id es6mr22652682lbc.117.1429092052533; Wed, 15 Apr 2015 03:00:52 -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.112.67.65 with SMTP id l1csp2400242lbt; Wed, 15 Apr 2015 03:00:51 -0700 (PDT) X-Received: by 10.70.41.38 with SMTP id c6mr45064565pdl.69.1429092050717; Wed, 15 Apr 2015 03:00:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qb9si6235585pbb.228.2015.04.15.03.00.49; Wed, 15 Apr 2015 03:00:50 -0700 (PDT) Received-SPF: none (google.com: linux-pm-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 S1754464AbbDOKAl (ORCPT + 11 others); Wed, 15 Apr 2015 06:00:41 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:33106 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754372AbbDOKAf (ORCPT ); Wed, 15 Apr 2015 06:00:35 -0400 Received: by wgin8 with SMTP id n8so40886311wgi.0 for ; Wed, 15 Apr 2015 03:00:33 -0700 (PDT) X-Received: by 10.194.110.69 with SMTP id hy5mr49143728wjb.121.1429092033424; Wed, 15 Apr 2015 03:00:33 -0700 (PDT) Received: from mai.lan (135-224-190-109.dsl.ovh.fr. [109.190.224.135]) by mx.google.com with ESMTPSA id z13sm5233590wjr.44.2015.04.15.03.00.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Apr 2015 03:00:32 -0700 (PDT) From: Daniel Lezcano To: peterz@infradead.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, nicolas.pitre@linaro.org Subject: [PATCH 1/3] cpuidle: Store the idle start time stamp Date: Wed, 15 Apr 2015 12:00:22 +0200 Message-Id: <1429092024-20498-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 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: , The scheduler uses the idle timestamp stored in the struct rq to retrieve the time when the cpu went idle in order to find the idlest cpu. Unfortunately this information is wrong as it does not have the same meaning from the cpuidle point of view. The idle_stamp in the struct rq gives the information when the idle task has been scheduled while the idle task could be interrupted several times and the cpu going through an idle/wakeup multiple times. Add the idle start time in the idle state structure. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 10 ++++++---- include/linux/cpuidle.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 080bd2d..1220dac 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -158,21 +158,23 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int entered_state; struct cpuidle_state *target_state = &drv->states[index]; - ktime_t time_start, time_end; s64 diff; trace_cpu_idle_rcuidle(index, dev->cpu); - time_start = ktime_get(); + + target_state->idle_stamp = ktime_to_us(ktime_get()); entered_state = target_state->enter(dev, drv, index); - time_end = ktime_get(); + diff = ktime_to_us(ktime_sub_us(ktime_get(), target_state->idle_stamp)); + + target_state->idle_stamp = 0; + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); if (!cpuidle_state_is_coupled(dev, drv, entered_state)) local_irq_enable(); - diff = ktime_to_us(ktime_sub(time_end, time_start)); if (diff > INT_MAX) diff = INT_MAX; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 306178d..2facce6 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -44,6 +44,7 @@ struct cpuidle_state { int power_usage; /* in mW */ unsigned int target_residency; /* in US */ bool disabled; /* disabled on all CPUs */ + u64 idle_stamp; int (*enter) (struct cpuidle_device *dev, struct cpuidle_driver *drv,