linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saravana Kannan <skannan@codeaurora.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
	linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V3 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus
Date: Fri, 16 Oct 2015 12:50:42 -0700	[thread overview]
Message-ID: <56215512.1080401@codeaurora.org> (raw)
In-Reply-To: <44a5b86d1df41812461630e5a7c5366d276e2855.1444979341.git.viresh.kumar@linaro.org>

On 10/16/2015 12:11 AM, Viresh Kumar wrote:
> The sysfs policy directory is postfixed currently with the CPU number
> for which the policy was created, which isn't necessarily the first CPU
> in related_cpus mask.
>
> To make it more consistent and predictable, lets postfix the policy with
> the first cpu in related-cpus mask.
>
> Suggested-by: Saravana Kannan <skannan@codeaurora.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> V2->V3:
> - Fix error path where we may try to put an uninitialized kobject.
> - Break kobject_init_and_add() to kobject_init() and kobject_add().
>
>   drivers/cpufreq/cpufreq.c | 21 +++++++++++----------
>   1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4fa2215cc6ec..7c48e7316d91 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1022,7 +1022,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
>   {
>   	struct device *dev = get_cpu_device(cpu);
>   	struct cpufreq_policy *policy;
> -	int ret;
>
>   	if (WARN_ON(!dev))
>   		return NULL;
> @@ -1040,13 +1039,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
>   	if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL))
>   		goto err_free_rcpumask;
>
> -	ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
> -				   cpufreq_global_kobject, "policy%u", cpu);
> -	if (ret) {
> -		pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
> -		goto err_free_real_cpus;
> -	}
> -
> +	kobject_init(&policy->kobj, &ktype_cpufreq);

Oh yeah, this works better. I forgot kobject has a separate init and add 
fuctions.

>   	INIT_LIST_HEAD(&policy->policy_list);
>   	init_rwsem(&policy->rwsem);
>   	spin_lock_init(&policy->transition_lock);
> @@ -1057,8 +1050,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
>   	policy->cpu = cpu;
>   	return policy;
>
> -err_free_real_cpus:
> -	free_cpumask_var(policy->real_cpus);
>   err_free_rcpumask:
>   	free_cpumask_var(policy->related_cpus);
>   err_free_cpumask:
> @@ -1163,6 +1154,16 @@ static int cpufreq_online(unsigned int cpu)
>   		cpumask_copy(policy->related_cpus, policy->cpus);
>   		/* Remember CPUs present at the policy creation time. */
>   		cpumask_and(policy->real_cpus, policy->cpus, cpu_present_mask);
> +
> +		/* Name and add the kobject */
> +		ret = kobject_add(&policy->kobj, cpufreq_global_kobject,
> +				  "policy%u",
> +				  cpumask_first(policy->related_cpus));
> +		if (ret) {
> +			pr_err("%s: failed to add policy->kobj: %d\n", __func__,
> +			       ret);
> +			goto out_exit_policy;
> +		}

Another out of patch issue that I see while reviewing this patch:

I think the existing error handling gotos aren't really cleaning things 
up well.

In the lines that follow this code we set the per_cpu(cpufreq_cpu_data) 
to point to the new policy. But if the subsequent cpu->get() fails, we 
goto out_exit_policy. But that label doesn't clean up the 
per_cpu(cpufreq_cpu_data). So, I think we need another label to jump to 
if ->get() fails

>   	}
>
>   	/*
>

Reviewed-by: Saravana Kannan <skannan@codeaurora.org>

-Saravana

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2015-10-16 19:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-15 16:05 [PATCH V2 0/5] cpufreq: sysfs cleanup Viresh Kumar
2015-10-15 16:05 ` [PATCH V2 1/5] cpufreq: Use cpumask_copy instead of cpumask_or to copy a mask Viresh Kumar
2015-10-15 16:05 ` [PATCH V2 2/5] cpufreq: create cpu/cpufreq at boot time Viresh Kumar
2015-10-15 16:05 ` [PATCH V2 3/5] cpufreq: remove cpufreq_sysfs_{create|remove}_file() Viresh Kumar
2015-10-15 16:05 ` [PATCH V2 4/5] cpufreq: create cpu/cpufreq/policyX directories Viresh Kumar
2015-10-15 19:25   ` Saravana Kannan
2015-10-15 21:35     ` Rafael J. Wysocki
2015-10-16  5:51     ` Viresh Kumar
2015-10-28  8:16       ` Rafael J. Wysocki
2015-10-28  8:28         ` Viresh Kumar
2015-10-15 16:05 ` [PATCH V2 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus Viresh Kumar
2015-10-15 19:14   ` Saravana Kannan
2015-10-16  7:08     ` Viresh Kumar
2015-10-16  7:11       ` [PATCH V3 " Viresh Kumar
2015-10-16 19:50         ` Saravana Kannan [this message]
2015-10-17  4:29           ` Viresh Kumar
2015-10-22  1:55 ` [PATCH V2 0/5] cpufreq: sysfs cleanup Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56215512.1080401@codeaurora.org \
    --to=skannan@codeaurora.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).