From patchwork Thu Feb 19 11:32:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 44832 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CC6D421554 for ; Thu, 19 Feb 2015 11:34:47 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf5194845wiv.3 for ; Thu, 19 Feb 2015 03:34:47 -0800 (PST) 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 :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=5V/KJFH5+RNdeHIo/pmOgzUUbEFoSAUXLyIaurIvMZE=; b=NimKI5EDad4Q4PeN0n0FY7ZeU7IBD9rbHJrtSImYrPd+UiS1FMt+QCthtBTuihcV8+ Y4YcB67s49T9jYBIimY5JZR8eNMzGD77Mft9sEC6pH51eox0RYkWjyGr1PP/Q5amgSl1 hh7rLpONzR1tCclENMEm96mrAkMjWYkGAtg7MI4bRWxYKYtp/AqY+niEh6+cZYUPcz1a Hm0isekgIzHo9IbiCklUBjG3Nc7Wbn7JwzMTmytDZdXGWO6rPQJAb09IprOsw8/g0Far Q0tTI2L4TeLgT5PZcUMcnoWS+L9cQSJmMPsXIQGmlvVYsj967BYNZOBgV+50LmKSc2Rw grzg== X-Gm-Message-State: ALoCoQlRZF08zkqqwCLBa16ZSDvZHQMA5mj2fdgcohnqZIJw72wl3QU90a6TX5WuUfuLTK8R5WS1 X-Received: by 10.152.1.5 with SMTP id 5mr518978lai.4.1424345687165; Thu, 19 Feb 2015 03:34:47 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.68 with SMTP id y4ls150648lay.12.gmail; Thu, 19 Feb 2015 03:34:46 -0800 (PST) X-Received: by 10.112.78.37 with SMTP id y5mr3363675lbw.91.1424345686948; Thu, 19 Feb 2015 03:34:46 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id yl7si15593982lab.116.2015.02.19.03.34.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 03:34:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbiw7 with SMTP id w7so6809356lbi.10 for ; Thu, 19 Feb 2015 03:34:46 -0800 (PST) X-Received: by 10.152.116.18 with SMTP id js18mr3583020lab.106.1424345686851; Thu, 19 Feb 2015 03:34:46 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp432031lbj; Thu, 19 Feb 2015 03:34:45 -0800 (PST) X-Received: by 10.67.30.34 with SMTP id kb2mr6630282pad.137.1424345682767; Thu, 19 Feb 2015 03:34:42 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bm5si944378pbd.217.2015.02.19.03.34.41; Thu, 19 Feb 2015 03:34:42 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485AbbBSLei (ORCPT + 11 others); Thu, 19 Feb 2015 06:34:38 -0500 Received: from mail-pd0-f179.google.com ([209.85.192.179]:40671 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753483AbbBSLeh (ORCPT ); Thu, 19 Feb 2015 06:34:37 -0500 Received: by pdev10 with SMTP id v10so8267285pde.7 for ; Thu, 19 Feb 2015 03:34:37 -0800 (PST) X-Received: by 10.68.135.37 with SMTP id pp5mr6669141pbb.105.1424345677117; Thu, 19 Feb 2015 03:34:37 -0800 (PST) Received: from localhost ([122.172.249.58]) by mx.google.com with ESMTPSA id fx10sm14779436pac.35.2015.02.19.03.34.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 03:34:36 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH V2 19/20] cpufreq: Restart governor as soon as possible Date: Thu, 19 Feb 2015 17:02:21 +0530 Message-Id: <05018c29d0f8802898b096d4d461ef1434b2ae62.1424345053.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On cpu hot-unplug, we don't need to wait for POST_DEAD notification to restart the governor if the policy has atleast one online cpu left. We can restart the governor right from the DOWN_PREPARE notification instead. [ Something similar attempted by Saravana earlier ] Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 58 ++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b6d5d94a0d3b..ffb6700c7195 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1394,8 +1394,8 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) static int __cpufreq_remove_dev_prepare(struct device *dev, struct subsys_interface *sif) { - unsigned int cpu = dev->id, cpus; - int ret; + unsigned int cpu = dev->id; + int ret = 0; struct cpufreq_policy *policy; pr_debug("%s: unregistering CPU %u\n", __func__, cpu); @@ -1415,26 +1415,33 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, } down_write(&policy->rwsem); - cpus = cpumask_weight(policy->cpus); + cpumask_clear_cpu(cpu, policy->cpus); - if (has_target() && cpus == 1) - strncpy(policy->last_governor, policy->governor->name, - CPUFREQ_NAME_LEN); + if (policy_is_inactive(policy)) { + if (has_target()) + strncpy(policy->last_governor, policy->governor->name, + CPUFREQ_NAME_LEN); + } else if (cpu == policy->cpu) { + /* Nominate new CPU */ + policy->cpu = cpumask_any(policy->cpus); + } up_write(&policy->rwsem); - if (cpu != policy->cpu) - return 0; + /* Start governor again for active policy */ + if (!policy_is_inactive(policy)) { + if (has_target()) { + ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); + if (!ret) + ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); - if (cpus > 1) { - /* Nominate new CPU */ - down_write(&policy->rwsem); - policy->cpu = cpumask_any_but(policy->cpus, cpu); - up_write(&policy->rwsem); + if (ret) + pr_err("%s: Failed to start governor\n", __func__); + } } else if (cpufreq_driver->stop_cpu) { cpufreq_driver->stop_cpu(policy); } - return 0; + return ret; } static int __cpufreq_remove_dev_finish(struct device *dev, @@ -1442,33 +1449,16 @@ static int __cpufreq_remove_dev_finish(struct device *dev, { unsigned int cpu = dev->id; int ret; - struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu); + struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); if (!policy) { pr_debug("%s: No cpu_data found\n", __func__); return -EINVAL; } - down_write(&policy->rwsem); - cpumask_clear_cpu(cpu, policy->cpus); - up_write(&policy->rwsem); - - /* Not the last cpu of policy, start governor again ? */ - if (!policy_is_inactive(policy)) { - if (!has_target()) - return 0; - - ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); - if (!ret) - ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); - - if (ret) { - pr_err("%s: Failed to start governor\n", __func__); - return ret; - } - + /* Only proceed for inactive policies */ + if (!policy_is_inactive(policy)) return 0; - } /* If cpu is last user of policy, free policy */ if (has_target()) {