lkml.org 
[lkml]   [2014]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tools: makes CPUINFO_PROC to array for different kernel version
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@huawei.com>
>> -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)
>> {




\
 
 \ /
  Last update: 2014-10-22 10:21    [W:0.129 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site