Re: [PATCH v3] cpufreq: stats: Add 'load_table' debugfs file to showaccumulated data of CPUs

From: Viresh Kumar
Date: Thu Jun 27 2013 - 06:23:56 EST


On 27 June 2013 15:44, Chanwoo Choi <cw00.choi@xxxxxxxxxxx> wrote:
> On 06/26/2013 05:04 PM, Viresh Kumar wrote:
>> On 24 June 2013 14:32, Chanwoo Choi <cw00.choi@xxxxxxxxxxx> wrote:

>> Maybe 10 to 1000.. Lets give others a chance to see long logs :)
>>
>
> OK, I'll extend the maximum value from 100 to 1000.

10-1000 please.

>>> + freq.old = freq.new = policy->cur;
>>
>> No need to set freq.new here.
>
> If cpufreq governor don't change cpu frequency on specific situation,
> cpufreq SoC driver won't send CPUFREQ_POSTCHANGE. In case of this situation,
> I store current cpu frequency to freq.new field.

You are doing this at the time of LOADCHECK notification :)

stat->load_table[last_idx].new = freq->old;

>>> +static ssize_t load_table_read(struct file *file, char __user *user_buf,
>>> + size_t count, loff_t *ppos)
>>> +{
>>> + struct cpufreq_policy *policy = file->private_data;
>>> + struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
>>> + struct cpufreq_freqs *load_table = stat->load_table;
>>> + ssize_t len = 0;
>>> + char *buf;
>>> + int i, cpu, ret;
>>> +
>>> + buf = kzalloc(MAX_LINE_SIZE * stat->load_max_index, GFP_KERNEL);
>>> + if (!buf)
>>> + return 0;
>>
>> Above use of stat->load_max_index must be inside locks I guess. Otherwise
>> you may allocate memory for 10 lines and by the time lock is taken, we
>> already have 12 entries. And so, below loop will go beyond array limits.
>>
>
> I store CONFIG_NR_CPU_LOAD_STORAGE to stat->load_max_index in cpufreq_stats_create_debugfs()
> So, stat->load_max_index value isn't always 10.
>
> If I misunderstood for your comment, I'd like you to explain more detailed about this comment.

No you didn't but looking second time at the code, i couldn't find a
problem with it.

You allocate memory for max entries and so shouldn't be a problem.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/