From patchwork Sun Sep 22 01:21:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20523 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 7724F25E85 for ; Sun, 22 Sep 2013 01:23:41 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id a41sf1937723yho.6 for ; Sat, 21 Sep 2013 18:23:41 -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=OjBMKYtLualSKHAvPN4IsJQQkkc/NboCCzBlOgwoCLw=; b=FT9sxZZ78CJN8Z4yFQNDPqTNrwu5NO+/9tSwspA0FZrXGhbkixlAONiPvtp801S4J4 dEImgRbd0bBITPeKd5NA+DwrH/KgSH3s9AUBLCbFRW0pBK0EKg1dmWtm0K2zRxzrALaM hQzUNwkxOcgIAoSZKqDpaPQC0Gjap7dWl3dmNuYeOTqXbSMRGoOCG8cJedPo/Cv71F2G Mdn5C0z5P00IOfzXXLfnR6dJsJZ8rghYRvrpW8OClAq2CGqYyE4RE6Va1jf34qMA/0Ql vAMuC/4gH4wXRN9Uo7rodyfkwa7coG/D3lrdUzDp+oidLXgHvopkyaeECaG5Aq/FJskp M+Xw== X-Gm-Message-State: ALoCoQnhUBY8mrV+MVLQpuBc+VV0QtRMnR0odyDt9NKOF6NIm4plhUWbR8K1b0lRSGmJGdF2VNqk X-Received: by 10.224.126.137 with SMTP id c9mr6654034qas.2.1379813021311; Sat, 21 Sep 2013 18:23:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.76.100 with SMTP id j4ls779044qew.29.gmail; Sat, 21 Sep 2013 18:23:41 -0700 (PDT) X-Received: by 10.220.74.69 with SMTP id t5mr46680vcj.18.1379813021239; Sat, 21 Sep 2013 18:23:41 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id wp10si4536977vdb.58.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 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.182; Received: by mail-ve0-f182.google.com with SMTP id oy12so1383714veb.41 for ; Sat, 21 Sep 2013 18:23:41 -0700 (PDT) X-Received: by 10.52.227.6 with SMTP id rw6mr11913189vdc.19.1379813021141; Sat, 21 Sep 2013 18:23:41 -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 u4csp91774vcz; Sat, 21 Sep 2013 18:23:40 -0700 (PDT) X-Received: by 10.66.145.132 with SMTP id su4mr17053302pab.11.1379813020315; Sat, 21 Sep 2013 18:23:40 -0700 (PDT) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by mx.google.com with ESMTPS id pi7si15845010pbc.141.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.44 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.44; Received: by mail-pb0-f44.google.com with SMTP id xa7so1831555pbc.3 for ; Sat, 21 Sep 2013 18:23:39 -0700 (PDT) X-Received: by 10.68.125.226 with SMTP id mt2mr16159742pbb.115.1379813019923; Sat, 21 Sep 2013 18:23:39 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id nj9sm24676002pbc.13.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:39 -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 21/21] cpuidle: change governor from within cpuidle_replace_governor() Date: Sun, 22 Sep 2013 06:51:13 +0530 Message-Id: <5b758e21eeb97f5f68191819c0820673692b6b75.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.182 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: , When I first read cpuidle_replace_governor()'s name I thought it will replace the governor (as per its name) but then found that it just returns the next best governor. And cpuidle_unregister_governor() actually replaces it. We always replace current governor with the next best and this information is already present with cpuidle_replace_governor() and so we don't really need to send an additional argument for it. Also, it makes sense to actually call cpuidle_switch_governor() from within cpuidle_replace_governor() instead. Along with this ret_gov is now renamed as new_gov to better suit its purpose. Signed-off-by: Viresh Kumar --- drivers/cpuidle/governor.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index ea2f8e7..deb6e50 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c @@ -98,26 +98,27 @@ int cpuidle_register_governor(struct cpuidle_governor *gov) } /** - * cpuidle_replace_governor - find a replacement governor - * @exclude_rating: the rating that will be skipped while looking for - * new governor. + * cpuidle_replace_governor - replace governor with highest rating one + * + * Finds governor (excluding cpuidle_curr_governor) with highest rating and + * replaces cpuidle_curr_governor with it. */ -static struct cpuidle_governor *cpuidle_replace_governor(int exclude_rating) +static inline void cpuidle_replace_governor(void) { struct cpuidle_governor *gov; - struct cpuidle_governor *ret_gov = NULL; + struct cpuidle_governor *new_gov = NULL; unsigned int max_rating = 0; list_for_each_entry(gov, &cpuidle_governors, governor_list) { - if (gov->rating == exclude_rating) + if (gov == cpuidle_curr_governor) continue; if (gov->rating > max_rating) { max_rating = gov->rating; - ret_gov = gov; + new_gov = gov; } } - return ret_gov; + cpuidle_switch_governor(new_gov); } /** @@ -130,11 +131,8 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov) return; mutex_lock(&cpuidle_lock); - if (gov == cpuidle_curr_governor) { - struct cpuidle_governor *new_gov; - new_gov = cpuidle_replace_governor(gov->rating); - cpuidle_switch_governor(new_gov); - } + if (gov == cpuidle_curr_governor) + cpuidle_replace_governor(); list_del(&gov->governor_list); mutex_unlock(&cpuidle_lock); }