From patchwork Thu Sep 26 10:29:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20583 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1F65423A4E for ; Thu, 26 Sep 2013 10:32:52 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id l13sf776489qcy.5 for ; Thu, 26 Sep 2013 03:32:52 -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=I74V5E9bYI0PjF2NzR/+oGcNCaOC2ukkUxCULIZsxJ0=; b=RZctgdPmhImfNbXQWm7Qascasgzjvu0Yt7VJFCPmQg9cwvpAFuiVSR9eZId4Rfjn+f okQRoZILnvv2+3sf6mrqhbwJVFcodwq3RYcVi0qI7xjK40N4PB8Sd1ZMFvvCVlhYZMzK CA7IrXtIY5tMPF6hFdr9U6tjMlzWXgp0dhg2CU5II6pkZxJYi7wzgrtpvIY5xifFrk9e YduVuOgumbK/n8TNtaOaC9yicgjI/59RKeUhVfjVLpTZ4tlHS1SEYXA4+n2SIzn0Dx0t OtnziT70Hs7pwKxjGOUvd1V/XwS+P7/RudAJGejpo9phL1Xs1ENKB1vNnxzjw/N8kzaq hxKg== X-Gm-Message-State: ALoCoQlVdcv/60Sh/unVgJAWNtNzfLTcxSykVP7qrG1isqsSS40514C2k7Z0+ViD9tYUQPtNQgZR X-Received: by 10.236.163.67 with SMTP id z43mr24294yhk.27.1380191571786; Thu, 26 Sep 2013 03:32:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.30.35 with SMTP id p3ls830577qeh.97.gmail; Thu, 26 Sep 2013 03:32:51 -0700 (PDT) X-Received: by 10.52.228.202 with SMTP id sk10mr24267vdc.111.1380191571705; Thu, 26 Sep 2013 03:32:51 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id d14si225940veh.1.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 03:32:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 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.179; Received: by mail-ve0-f179.google.com with SMTP id c14so709309vea.24 for ; Thu, 26 Sep 2013 03:32:21 -0700 (PDT) X-Received: by 10.220.50.10 with SMTP id x10mr72950vcf.86.1380191541578; Thu, 26 Sep 2013 03:32:21 -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 u4csp357968vcz; Thu, 26 Sep 2013 03:32:21 -0700 (PDT) X-Received: by 10.68.98.36 with SMTP id ef4mr193624pbb.27.1380191540715; Thu, 26 Sep 2013 03:32:20 -0700 (PDT) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by mx.google.com with ESMTPS id xn6si1021163pbc.62.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 03:32:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.182 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.182; Received: by mail-pd0-f182.google.com with SMTP id r10so974984pdi.27 for ; Thu, 26 Sep 2013 03:32:20 -0700 (PDT) X-Received: by 10.68.219.33 with SMTP id pl1mr108055pbc.147.1380191540315; Thu, 26 Sep 2013 03:32:20 -0700 (PDT) Received: from localhost ([223.238.78.153]) by mx.google.com with ESMTPSA id gh2sm1304926pbc.40.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 03:32:19 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, srivatsa.bhat@linux.vnet.ibm.com, nicolas.pitre@linaro.org, Viresh Kumar Subject: [PATCH 3/4] cpufreq: stats: free table and remove sysfs entry in a single routine Date: Thu, 26 Sep 2013 15:59:53 +0530 Message-Id: <0564543fdd76697816de4cbeaedf823fb709f12d.1380190886.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.179 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. 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 ");