Re: [PATCH] perf tools: makes CPUINFO_PROC to array for different kernel version

From: Wang Nan
Date: Wed Oct 22 2014 - 03:49:52 EST


On 2014/10/22 14:44, Namhyung Kim wrote:
> Hi Wang,
>
> On Thu, 16 Oct 2014 11:08:43 +0800, Wang Nan wrote:
>> After kerne 3.7 (commit b4b8f770eb10a1bccaf8aa0ec1956e2dd7ed1e0a),
>> /proc/cpuinfo replcae 'Processor' to 'model name'. This patch makes
>> CPUINFO_PROC to an array and provides two choices for ARM, make it
>> compatible for different kernel version.
>>
>> Signed-off-by: Wang Nan <wangnan0@xxxxxxxxxx>
>> -static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
>> - struct perf_evlist *evlist __maybe_unused)
>> +static int __write_cpudesc(int fd, struct perf_header *h __maybe_unused,
>> + struct perf_evlist *evlist __maybe_unused, const char *cpuinfo_proc)
>
> You don't need to pass @h and @evlist if they're not used.
>
>
>> {
>> -#ifndef CPUINFO_PROC
>> -#define CPUINFO_PROC NULL
>> -#endif
>> FILE *file;
>> char *buf = NULL;
>> char *s, *p;
>> - const char *search = CPUINFO_PROC;
>> + const char *search = cpuinfo_proc;
>> size_t len = 0;
>> int ret = -1;
>>
>> @@ -640,6 +637,23 @@ done:
>> return ret;
>> }
>>
>> +static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
>> + struct perf_evlist *evlist __maybe_unused)
>> +{
>> +#ifndef CPUINFO_PROC
>> +#define CPUINFO_PROC {"model name", }
>> +#endif
>> + const char *cpuinfo_procs[] = CPUINFO_PROC;
>> + unsigned int i;
>
> Please put a blank line between declaration and the function body.
>
> Other than that, looks good to me.
>
> Thanks,
> Namhyung
>

I posted a v2 patch, please refer to https://lkml.org/lkml/2014/10/22/85 .

Thanks.

>
>> + for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) {
>> + int ret;
>> + ret = __write_cpudesc(fd, h, evlist, cpuinfo_procs[i]);
>> + if (ret >= 0)
>> + return ret;
>> + }
>> + return -1;
>> +}
>> +
>> static int write_nrcpus(int fd, struct perf_header *h __maybe_unused,
>> struct perf_evlist *evlist __maybe_unused)
>> {


--
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/