From patchwork Mon Apr 3 21:54:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 9660663 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 526E86032D for ; Mon, 3 Apr 2017 21:54:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 440DE2817F for ; Mon, 3 Apr 2017 21:54:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38F1628488; Mon, 3 Apr 2017 21:54:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE8A92817F for ; Mon, 3 Apr 2017 21:54:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751384AbdDCVye (ORCPT ); Mon, 3 Apr 2017 17:54:34 -0400 Received: from ozlabs.org ([103.22.144.67]:47869 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210AbdDCVye (ORCPT ); Mon, 3 Apr 2017 17:54:34 -0400 Received: by ozlabs.org (Postfix, from userid 1010) id 3vxm944c1nz9s80; Tue, 4 Apr 2017 07:54:32 +1000 (AEST) From: Anton Blanchard To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, svaidy@linux.vnet.ibm.com, ego@linux.vnet.ibm.com, rjw@rjwysocki.net, daniel.lezcano@linaro.org, npiggin@gmail.com Cc: linuxppc-dev@lists.ozlabs.org, linux-pm@vger.kernel.org Subject: [PATCH 3/3] cpuidle: powernv: Avoid a branch in the core snooze_loop() loop Date: Tue, 4 Apr 2017 07:54:14 +1000 Message-Id: <20170403215414.16951-3-anton@ozlabs.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170403215414.16951-1-anton@ozlabs.org> References: <20170403215414.16951-1-anton@ozlabs.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anton Blanchard When in the snooze_loop() we want to take up the least amount of resources. On my version of gcc (6.3), we end up with an extra branch because it predicts snooze_timeout_en to be false, whereas it is almost always true. Use likely() to avoid the branch and be a little nicer to the other non idle threads on the core. Signed-off-by: Anton Blanchard Reviewed-by: Vaidyanathan Srinivasan --- drivers/cpuidle/cpuidle-powernv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index 8c991c254b95..251a60bfa8ee 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -58,7 +58,7 @@ static int snooze_loop(struct cpuidle_device *dev, ppc64_runlatch_off(); HMT_very_low(); while (!need_resched()) { - if (snooze_timeout_en && get_tb() > snooze_exit_time) + if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) break; }