From patchwork Thu Jan 16 12:45:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 3498251 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F176C02DC for ; Thu, 16 Jan 2014 12:45:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27B132015E for ; Thu, 16 Jan 2014 12:45:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 156E520142 for ; Thu, 16 Jan 2014 12:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352AbaAPMpl (ORCPT ); Thu, 16 Jan 2014 07:45:41 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:52684 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbaAPMph (ORCPT ); Thu, 16 Jan 2014 07:45:37 -0500 Received: by mail-pa0-f46.google.com with SMTP id rd3so2634761pab.33 for ; Thu, 16 Jan 2014 04:45:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=X1ZK0VzWRmmc4B5zJIgi6a6+0ybuuLMIR5yV1CXfffU=; b=LoHsGiHV1LaPOfpK8bU8vrp1ndefCM1/gAHIHvKMvM8d6doLsp3hgebWyjuk0rsw02 f5jEbTUy+qv4+HpGrV7OQnXfPAQZi1nsi4Kv0sSBb3uhOKm6f/Lm8mubsgpTcX3DfQID SbUOKCz2bLmFWnL5WXQCgaa6rH2IV64907p8AjWsMgNt0bbsrQAFHpk51z0SUvQ3ET0t YE3Um5KZoNue5zhupv0QRQYaom46Q/AQjiR3N/x8PgCz1+uVU2sQAm0VH3gC72lkfd5G RdJH/K/dMz3J03vwXxkMChHKa2UWRfyZWyUNYmhu4eyx9OKkIl9JrkIv+n8v5rH+t/BJ 0TnQ== X-Gm-Message-State: ALoCoQlL8l6wRPu7t/ERNJJDn+BUqDNKaAlO6R+NoD6dE06800XZ7dVaBZUDobwflAsZHeOohz27 X-Received: by 10.68.211.1 with SMTP id my1mr9773073pbc.55.1389876336516; Thu, 16 Jan 2014 04:45:36 -0800 (PST) Received: from alex-shi.Home ([162.243.130.63]) by mx.google.com with ESMTPSA id yi8sm19448511pab.16.2014.01.16.04.45.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Jan 2014 04:45:35 -0800 (PST) From: Alex Shi To: rjw@rjwysocki.net, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, Alex Shi Subject: [RFC PATCH] cpuidle: reduce unnecessary loop in c-state selection Date: Thu, 16 Jan 2014 20:45:16 +0800 Message-Id: <1389876316-27161-1-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 1.8.1.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All deeper c-state have the longer target_residency and exit_latency So, if the one can not meet our prediction, neither any later. So, just break out the for loop to save few checking instructions. Signed-off-by: Alex Shi --- drivers/cpuidle/governors/menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index cf7f2f0..48ed3fb 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -352,11 +352,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) if (s->disabled || su->disable) continue; if (s->target_residency > data->predicted_us) - continue; + break; if (s->exit_latency > latency_req) - continue; + break; if (s->exit_latency * multiplier > data->predicted_us) - continue; + break; data->last_state_idx = i; data->exit_us = s->exit_latency;