From patchwork Sun Sep 22 01:21:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20512 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 242D825E85 for ; Sun, 22 Sep 2013 01:22:29 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id a41sf1937551yho.2 for ; Sat, 21 Sep 2013 18:22:29 -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=LmUQdw//sC6mtKaAnyMSGwK1wuAER0pqTgtDUm3OGQ4=; b=mRX0b+9dANEBl6rdd2C84YW7Bvoe6E2+anGfdtaRDe8e6RQNZpGZurKC5lauLVeRys 4r4hBla3OxwIiHUZkQyP66kWsubaqA4RfONBb1yyXTO+/oP+B3eZEp52wbCbEwG9r/pZ +8f2Kr4yIMDvU7qqHa1yCa5vCAUyWh8xQCjlyMPtdxQVS6vUZYiyocQgF2lksBfhba8Z Cgd0Z9pbN7GLf0MdPjKnxEvVfgITYGQDtnA1OTPKwNKvTdZ0TfEa9Htzb17Fl7ZAKP4b QLedKc37rw3Q9vCokWHHXcug81jK5e6IDHis13zQONE8HlF6HauFDslKhp4Mpa0Tpdai 2lng== X-Gm-Message-State: ALoCoQkOD6bq/vaNEeKV7JucbJBO6YSkdt9lar6RbECzG5FadpbRZWZ7OOzUVaQyeWKwcVkyMNey X-Received: by 10.224.112.133 with SMTP id w5mr6587140qap.5.1379812948961; Sat, 21 Sep 2013 18:22:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls736331qeo.28.gmail; Sat, 21 Sep 2013 18:22:28 -0700 (PDT) X-Received: by 10.58.77.65 with SMTP id q1mr14047755vew.8.1379812948880; Sat, 21 Sep 2013 18:22:28 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id m10si4529103vcm.132.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 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.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so1363204veb.26 for ; Sat, 21 Sep 2013 18:22:28 -0700 (PDT) X-Received: by 10.52.230.102 with SMTP id sx6mr11833152vdc.15.1379812948792; Sat, 21 Sep 2013 18:22:28 -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 u4csp91735vcz; Sat, 21 Sep 2013 18:22:28 -0700 (PDT) X-Received: by 10.66.217.166 with SMTP id oz6mr17069217pac.22.1379812947809; Sat, 21 Sep 2013 18:22:27 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id tb4si17483869pab.174.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id fb1so897473pad.9 for ; Sat, 21 Sep 2013 18:22:27 -0700 (PDT) X-Received: by 10.68.33.34 with SMTP id o2mr75963pbi.128.1379812947437; Sat, 21 Sep 2013 18:22:27 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id pu5sm28239396pac.21.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:27 -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 10/21] cpuidle: reduce code duplication inside cpuidle_idle_call() Date: Sun, 22 Sep 2013 06:51:02 +0530 Message-Id: <5e4629515deb76208df205210a77b1e8a9984f79.1379779777.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.128.181 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: , We are doing this twice in cpuidle_idle_call() routine: drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP Would be better if we actually store this in a local variable and use that. That would remove code duplication as well as make this piece of code run fast (in case compiler wasn't able to optimize it earlier) Signed-off-by: Viresh Kumar Acked-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index b8c63cb..ed67e3c 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -118,6 +118,7 @@ int cpuidle_idle_call(void) struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_driver *drv; int next_state, entered_state; + bool broadcast; if (cpuidle_disabled() || !initialized) return -ENODEV; @@ -141,7 +142,9 @@ int cpuidle_idle_call(void) trace_cpu_idle_rcuidle(next_state, dev->cpu); - if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP) + broadcast = drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP; + + if (broadcast) clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu); @@ -151,7 +154,7 @@ int cpuidle_idle_call(void) else entered_state = cpuidle_enter_state(dev, drv, next_state); - if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP) + if (broadcast) clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu);