From patchwork Tue Jan 7 01:40:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 22899 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BCF5C23A3F for ; Tue, 7 Jan 2014 01:40:39 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id v10sf50887808pde.4 for ; Mon, 06 Jan 2014 17:40:39 -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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=Tqh08Yo92Y+nlUFwhGjybbQUMNk76bLYxtJ+9JF/xWA=; b=MOenFBFjZP6ocYKdGc3zooxjuW/CHLAKMt639q0WxDpD7tf7IKamqelFxn+Z8ZHw/o wXmv/Q4Twz5PYDHGow1KTuGR8S4RrKOllQ5h+7Pt1YgDWnnCKzaZklzLoQpG+b3gF1/V x/z4vGXSSvN/u/svJjje1eRFDHh5KStCfHGEaI8MPtmiajvqkIcYmvI/8NzwjszbMmSS 07ZPxe99mzRoJnYtDaIrrBat+cYhkB+iw3Yn56EY2I90wlOrHXcMcpnFQupj9zFEx7Lt 8GsGxXE32fmBi+poio70AMmlA24hN+q3VtkPsozDYeKJU4a+PQKsPZE8GSgYyFxV/k2r WR6g== X-Gm-Message-State: ALoCoQl3NsHwa7DGq7RN9XdrGT+zpfdEB+ncK80vrEpHwroQbGLFtrtXQ6UghGf8uF8YkWrSQmcr X-Received: by 10.66.141.231 with SMTP id rr7mr722447pab.47.1389058839009; Mon, 06 Jan 2014 17:40:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.15.234 with SMTP id a10ls5893917qed.92.gmail; Mon, 06 Jan 2014 17:40:38 -0800 (PST) X-Received: by 10.58.37.67 with SMTP id w3mr462959vej.22.1389058838871; Mon, 06 Jan 2014 17:40:38 -0800 (PST) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id gq1si25829659vec.99.2014.01.06.17.40.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 Jan 2014 17:40:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id p5so9309335vbn.39 for ; Mon, 06 Jan 2014 17:40:38 -0800 (PST) X-Received: by 10.58.57.194 with SMTP id k2mr29055448veq.0.1389058838763; Mon, 06 Jan 2014 17:40:38 -0800 (PST) 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.59.13.131 with SMTP id ey3csp130020ved; Mon, 6 Jan 2014 17:40:38 -0800 (PST) X-Received: by 10.68.239.230 with SMTP id vv6mr104311650pbc.34.1389058837813; Mon, 06 Jan 2014 17:40:37 -0800 (PST) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by mx.google.com with ESMTPS id j8si56630334pad.91.2014.01.06.17.40.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 Jan 2014 17:40:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.173 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.173; Received: by mail-pd0-f173.google.com with SMTP id p10so18926800pdj.32 for ; Mon, 06 Jan 2014 17:40:37 -0800 (PST) X-Received: by 10.68.20.1 with SMTP id j1mr12146333pbe.148.1389058837372; Mon, 06 Jan 2014 17:40:37 -0800 (PST) Received: from localhost ([122.167.240.254]) by mx.google.com with ESMTPSA id yi10sm172725665pab.8.2014.01.06.17.40.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 06 Jan 2014 17:40:36 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH Resend 3/4] cpufreq: stats: free table and remove sysfs entry in a single routine Date: Tue, 7 Jan 2014 07:10:12 +0530 Message-Id: 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.212.52 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 don't have code paths now, where we need to do these two things separately and so better do them in a single routine. Just as they are allocated in a single routine. Acked-and-tested-by: Nicolas Pitre Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 50 ++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 8fa5844..9dd5883 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -151,40 +151,32 @@ static int freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq) return -1; } -/* should be called late in the CPU removal sequence so that the stats - * memory is still available in case someone tries to use it. - */ -static void cpufreq_stats_free_table(unsigned int cpu) +static void __cpufreq_stats_free_table(struct cpufreq_policy *policy) { - struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu); + struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); - if (stat) { - pr_debug("%s: Free stat table\n", __func__); - kfree(stat->time_in_state); - kfree(stat); - per_cpu(cpufreq_stats_table, cpu) = NULL; - } + if (!stat) + return; + + pr_debug("%s: Free stat table\n", __func__); + + sysfs_remove_group(&policy->kobj, &stats_attr_group); + kfree(stat->time_in_state); + kfree(stat); + per_cpu(cpufreq_stats_table, policy->cpu) = NULL; } -/* must be called early in the CPU removal sequence (before - * cpufreq_remove_dev) so that policy is still valid. - */ -static void cpufreq_stats_free_sysfs(unsigned int cpu) +static void cpufreq_stats_free_table(unsigned int cpu) { - struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy; + policy = cpufreq_cpu_get(cpu); if (!policy) return; - if (!cpufreq_frequency_get_table(cpu)) - goto put_ref; - - if (!policy_is_shared(policy)) { - pr_debug("%s: Free sysfs stat\n", __func__); - sysfs_remove_group(&policy->kobj, &stats_attr_group); - } + if (cpufreq_frequency_get_table(policy->cpu)) + __cpufreq_stats_free_table(policy); -put_ref: cpufreq_cpu_put(policy); } @@ -293,10 +285,8 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb, if (val == CPUFREQ_CREATE_POLICY) ret = cpufreq_stats_create_table(policy, table); - else if (val == CPUFREQ_REMOVE_POLICY) { - cpufreq_stats_free_sysfs(cpu); - cpufreq_stats_free_table(cpu); - } + else if (val == CPUFREQ_REMOVE_POLICY) + __cpufreq_stats_free_table(policy); return ret; } @@ -376,10 +366,8 @@ static void __exit cpufreq_stats_exit(void) CPUFREQ_POLICY_NOTIFIER); cpufreq_unregister_notifier(¬ifier_trans_block, CPUFREQ_TRANSITION_NOTIFIER); - for_each_online_cpu(cpu) { + for_each_online_cpu(cpu) cpufreq_stats_free_table(cpu); - cpufreq_stats_free_sysfs(cpu); - } } MODULE_AUTHOR("Zou Nan hai ");