From patchwork Thu Oct 3 15:56:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20803 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B1B2E25CAB for ; Thu, 3 Oct 2013 15:58:37 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id i72sf5696246yha.5 for ; Thu, 03 Oct 2013 08:58:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=5+XC8I7PVGM0wCmKBWxhZ3c6JNsaTlI+KtNHmcTJoiE=; b=ZH0HtmzKFwWIMSE9wLrl/ITWymYtRsJ6aCjjgfgw20Aw4mCrunzwBHnFkNlscuE6f1 7i4/GbFvDThw5PntUgseFgRBxUugsSECF5PaZu4zz2HLbM64FX24zjSsxUjppE964sIm e1uqw1TKxU04Vva7IJxsw+KOrlxAjznZYk4GvgPjM/CkYqLzXZr/mmsKcoPnQqcBYxU7 UmUuRf90TarEL7ZYCm111xtha0oT/PIJQjbCZOCUON4CnVE7Em2Pj3+CCc1JGL8Y8bAN GPYFgu1VckRAiAszbdFIx0U2Vb1YX7QkuR2Yy0v1kuMoXV4ybFxCpE0AgzUMHhWBvtnk 3Ozw== X-Received: by 10.58.118.173 with SMTP id kn13mr1400895veb.1.1380815917507; Thu, 03 Oct 2013 08:58:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.2.166 with SMTP id 6ls931567qev.69.gmail; Thu, 03 Oct 2013 08:58:37 -0700 (PDT) X-Received: by 10.58.75.131 with SMTP id c3mr8089305vew.12.1380815917399; Thu, 03 Oct 2013 08:58:37 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id zw10si1881512vdb.70.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.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.220.174; Received: by mail-vc0-f174.google.com with SMTP id gd11so1082912vcb.19 for ; Thu, 03 Oct 2013 08:58:37 -0700 (PDT) X-Gm-Message-State: ALoCoQnBfGYzTbgqRh9y2KkWLfxJfKUplh/R7SsWFdRGzt33f/QOvlQDHe/q4iZq2zBqzTNVpy1x X-Received: by 10.58.168.205 with SMTP id zy13mr8048228veb.19.1380815917306; Thu, 03 Oct 2013 08:58:37 -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 u4csp189263vcz; Thu, 3 Oct 2013 08:58:36 -0700 (PDT) X-Received: by 10.68.168.99 with SMTP id zv3mr1324872pbb.144.1380815916341; Thu, 03 Oct 2013 08:58:36 -0700 (PDT) Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by mx.google.com with ESMTPS id sl4si6799735pac.271.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.174 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.174; Received: by mail-pd0-f174.google.com with SMTP id y13so2665415pdi.19 for ; Thu, 03 Oct 2013 08:58:35 -0700 (PDT) X-Received: by 10.68.211.233 with SMTP id nf9mr9323245pbc.85.1380815915302; Thu, 03 Oct 2013 08:58:35 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id ed3sm9089325pbc.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:34 -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 V2 14/16] cpuidle: don't calculate time-diff if entered_state < 0 Date: Thu, 3 Oct 2013 21:26:53 +0530 Message-Id: <0a0c8e4c6fbf681d375f25b0c0eba036b8eaadf7.1380815504.git.viresh.kumar@linaro.org> 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.220.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. Acked-by: Daniel Lezcano 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 b45257a..1a6e9f5 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; }