From patchwork Sun Sep 22 01:21:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20522 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3079325E85 for ; Sun, 22 Sep 2013 01:23:35 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf1850386vcb.3 for ; Sat, 21 Sep 2013 18:23:35 -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:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=eq2mfUsmE2WUqLdW76exVWSwoucZtZxyRjDmpFvlna4=; b=fH0XZImCwq5CYE2oPi72AIXBYEzbC90iZSKZF4wgDe9YHOeXAjqwAe5unH8WxgUc1E vJ6GfCQCcvOMuy9Gq1BAd+mtJrLyCrVoIutsZq52IMtcES5B6Ub7vbWHBQifJxl+1r8Y a9lozuDD9fqiBy9ZYVP3es2uprQpes1Rq3Z3z3P4AyY1UxfluaunX2lUzczHU/HsTi6A hlOSPs3Ytu9T0vq4gcUUymUgeLfYGyGeyJV1jIBZrSVKR9WX3o1koFoVxfDls8ylt0FX KrReNyGRhfRfRhX0DgmpBbN42q2k3nUrSCVf7lOAijhzlxfO+94CcuybzFwKgAbE8n7e tDIg== X-Gm-Message-State: ALoCoQnO6o+DtFHpp9jrF97g+0eaqbOoSc6Wv1SDVJ8QmQ5hB3fEowJsoeszbo5nm5sTAqCsLzro X-Received: by 10.224.51.68 with SMTP id c4mr6589305qag.7.1379813015022; Sat, 21 Sep 2013 18:23:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.74.69 with SMTP id r5ls813394qev.1.gmail; Sat, 21 Sep 2013 18:23:34 -0700 (PDT) X-Received: by 10.221.47.193 with SMTP id ut1mr14075771vcb.8.1379813014932; Sat, 21 Sep 2013 18:23:34 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id bp7si4540370vcb.82.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jy13so1429838veb.33 for ; Sat, 21 Sep 2013 18:23:34 -0700 (PDT) X-Received: by 10.58.77.65 with SMTP id q1mr14051519vew.8.1379813014838; Sat, 21 Sep 2013 18:23:34 -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.220.174.196 with SMTP id u4csp91771vcz; Sat, 21 Sep 2013 18:23:34 -0700 (PDT) X-Received: by 10.66.118.129 with SMTP id km1mr78453pab.127.1379813013910; Sat, 21 Sep 2013 18:23:33 -0700 (PDT) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by mx.google.com with ESMTPS id uh5si17443320pab.325.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.178; Received: by mail-pd0-f178.google.com with SMTP id w10so1822315pde.23 for ; Sat, 21 Sep 2013 18:23:33 -0700 (PDT) X-Received: by 10.66.162.167 with SMTP id yb7mr17203592pab.16.1379813013516; Sat, 21 Sep 2013 18:23:33 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id go4sm24673262pbb.15.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:33 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl, daniel.lezcano@linaro.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 20/21] cpuidle: don't calculate time-diff if entered_state == 0 Date: Sun, 22 Sep 2013 06:51:12 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 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: , If entered_state == 0, we don't need to set dev->last_residency to 'diff' as we will be setting it to zero without using its new value. And so move calculation of diff also inside the "if" statement. Signed-off-by: Viresh Kumar --- drivers/cpuidle/cpuidle.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index bf80236..cb81689 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -77,23 +77,22 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, struct cpuidle_state *target_state = &drv->states[index]; ktime_t time_start, time_end; - s64 diff; time_start = ktime_get(); entered_state = target_state->enter(dev, drv, index); - time_end = ktime_get(); + if (entered_state >= 0) { + s64 diff; - local_irq_enable(); + time_end = ktime_get(); + diff = ktime_to_us(ktime_sub(time_end, time_start)); - diff = ktime_to_us(ktime_sub(time_end, time_start)); - if (diff > INT_MAX) - diff = INT_MAX; + if (diff > INT_MAX) + diff = INT_MAX; - dev->last_residency = (int) diff; + dev->last_residency = (int) diff; - if (entered_state >= 0) { /* Update cpuidle counters */ /* This can be moved to within driver enter routine * but that results in multiple copies of same code. @@ -104,6 +103,8 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, dev->last_residency = 0; } + local_irq_enable(); + return entered_state; }