Commit b8c67448 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: stats: return -EEXIST when stats are already allocated

__cpufreq_stats_create_table() is called from:

- cpufreq notifier on creation of a new policy. Stats will always be
  NULL here.
- cpufreq_stats_init() for all CPUs as cpufreq-stats might have been
  initialized after cpufreq driver. For any policy, 'stats' will be
  NULL for the first CPU only and will be valid for all other CPUs
  managed by the same policy.

While we return for other CPUs, we don't return the right error value.
It's not that we would fail with -EBUSY. But generally, this is what
these return values mean:
- EBUSY: we are busy right now, try again. And the retry attempt might
  be immediate.
- EEXIST: We already have what you are trying to create and there is no
  need to create it again, and so no more tries are required.
Reviewed-by: default avatarPrarit Bhargava <prarit@redhat.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 00d0b294
...@@ -192,8 +192,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) ...@@ -192,8 +192,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)
if (unlikely(!table)) if (unlikely(!table))
return 0; return 0;
/* stats already initialized */
if (per_cpu(cpufreq_stats_table, cpu)) if (per_cpu(cpufreq_stats_table, cpu))
return -EBUSY; return -EEXIST;
stat = kzalloc(sizeof(*stat), GFP_KERNEL); stat = kzalloc(sizeof(*stat), GFP_KERNEL);
if ((stat) == NULL) if ((stat) == NULL)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment