From patchwork Wed Apr 15 10:00:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 47171 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 274D52121F for ; Wed, 15 Apr 2015 10:00:56 +0000 (UTC) Received: by widjs5 with SMTP id js5sf10145535wid.3 for ; Wed, 15 Apr 2015 03:00:55 -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; bh=20iDr+NjyY0TTnFVzx+24PC6vTHYkEzj9yFjMhZmCTY=; b=eozIT6bjLjC0s2w1ZmcO/mQ+9y5kXY1enms0+OngFLs2aqQVl6xMeuXgC+6GjprS9S 7vuJtz/el9V2k9ujwm64KBPsTU61GVqZuRbe4xUmiL2iq/3NXhysqyWGw/yRFgVgax/d p6EioRlqHMlWVqSrWIj+agf5AarT7DobN/a/ZFJJHjDGMy/Sn+hg94fiKIw1PM0RAhXo j+LVYaTpq0HC+G2c12+a/rATrJvqJhER5/kk04RHEXAOx/ma10F3UIyJeS6rtVqfeHqk LlUyqOYXKfgnigCH+qi3+pukuG2MOKPVCP8+kV4k6hY5v9w2mufzHusSmFznU4OrxRFW 5/yQ== X-Gm-Message-State: ALoCoQkiwUBA6hELJTuf1LThud/xhGR8YUmpu7Tx9KDobIXGPUPyGcJG5qZBXscJsAZiAMGpSW3N X-Received: by 10.194.236.230 with SMTP id ux6mr4406488wjc.5.1429092054467; Wed, 15 Apr 2015 03:00:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.36 with SMTP id yf4ls173813lab.43.gmail; Wed, 15 Apr 2015 03:00:54 -0700 (PDT) X-Received: by 10.112.181.68 with SMTP id du4mr22219820lbc.11.1429092054305; Wed, 15 Apr 2015 03:00:54 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id r7si3470736laa.83.2015.04.15.03.00.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2015 03:00:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by layy10 with SMTP id y10so28620787lay.0 for ; Wed, 15 Apr 2015 03:00:53 -0700 (PDT) X-Received: by 10.112.204.72 with SMTP id kw8mr3166710lbc.88.1429092053847; Wed, 15 Apr 2015 03:00:53 -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 l1csp2400251lbt; Wed, 15 Apr 2015 03:00:52 -0700 (PDT) X-Received: by 10.68.137.70 with SMTP id qg6mr44951552pbb.125.1429092051656; Wed, 15 Apr 2015 03:00:51 -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.50; Wed, 15 Apr 2015 03:00:51 -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 S1754493AbbDOKAo (ORCPT + 11 others); Wed, 15 Apr 2015 06:00:44 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:32769 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754435AbbDOKAg (ORCPT ); Wed, 15 Apr 2015 06:00:36 -0400 Received: by wiax7 with SMTP id x7so108076434wia.0 for ; Wed, 15 Apr 2015 03:00:35 -0700 (PDT) X-Received: by 10.194.62.83 with SMTP id w19mr49030729wjr.40.1429092035201; Wed, 15 Apr 2015 03:00:35 -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.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Apr 2015 03:00:34 -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 2/3] cpuidle: Add some comments in the cpuidle_enter function Date: Wed, 15 Apr 2015 12:00:23 +0200 Message-Id: <1429092024-20498-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429092024-20498-1-git-send-email-daniel.lezcano@linaro.org> References: <1429092024-20498-1-git-send-email-daniel.lezcano@linaro.org> 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.215.47 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 code is a bit poor in comments. Fix that by adding some comments in the cpuidle enter function. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 1220dac..5e6c6be 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -162,19 +162,50 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, trace_cpu_idle_rcuidle(index, dev->cpu); + /* + * Store the idle start time for this cpu, this information + * will be used by cpuidle to measure how long the cpu has + * been idle and by the scheduler to prevent to wake it up too + * early + */ target_state->idle_stamp = ktime_to_us(ktime_get()); + /* + * The enter to the low level idle routine. This call will block + * until an interrupt occurs meaning it is the end of the idle + * period + */ entered_state = target_state->enter(dev, drv, index); + /* + * Measure as soon as possible the duration of the idle + * period. It MUST be done before re-enabling the interrupt in + * order to prevent to add in the idle time measurement the + * interrupt handling duration + */ diff = ktime_to_us(ktime_sub_us(ktime_get(), target_state->idle_stamp)); + /* + * Reset the idle time stamp as the scheduler may think the cpu is idle + * while it is in the process of waking up + */ target_state->idle_stamp = 0; trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); + /* + * The cpuidle_enter_coupled uses the cpuidle_enter function. + * Don't re-enable the interrupts and let the enter_coupled + * function to wait for all cpus to sync and to enable the + * interrupts again from there + */ if (!cpuidle_state_is_coupled(dev, drv, entered_state)) local_irq_enable(); + /* + * The idle duration will be casted to an integer, prevent to + * overflow by setting a boundary to INT_MAX + */ if (diff > INT_MAX) diff = INT_MAX;