linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org, namhyung@kernel.org,
	ak@linux.intel.com
Subject: Re: [PATCH 1/2] perf vendor events: Add stepping in CPUID string for x86
Date: Thu, 15 Nov 2018 10:18:27 -0500	[thread overview]
Message-ID: <58a3caa6-0ba9-773b-9f99-1e4be5ff77fb@linux.intel.com> (raw)
In-Reply-To: <7a63fdf4-828f-0685-e146-6d3d86d8655b@linux.intel.com>



On 11/15/2018 9:26 AM, Liang, Kan wrote:
> 
> 
> On 11/15/2018 8:53 AM, Jiri Olsa wrote:
>> On Wed, Nov 14, 2018 at 01:24:15PM -0800, kan.liang@linux.intel.com 
>> wrote:
>>
>> SNIP
>>
>>> diff --git a/tools/perf/arch/x86/util/header.c 
>>> b/tools/perf/arch/x86/util/header.c
>>> index fb0d71afee8b..b428a4b00bf7 100644
>>> --- a/tools/perf/arch/x86/util/header.c
>>> +++ b/tools/perf/arch/x86/util/header.c
>>> @@ -4,6 +4,7 @@
>>>   #include <stdio.h>
>>>   #include <stdlib.h>
>>>   #include <string.h>
>>> +#include <regex.h>
>>>   #include "../../util/header.h"
>>> @@ -70,9 +71,73 @@ get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
>>>   {
>>>       char *buf = malloc(128);
>>> -    if (buf && __get_cpuid(buf, 128, "%s-%u-%X$") < 0) {
>>> +    if (buf && __get_cpuid(buf, 128, "%s-%u-%X-%X$") < 0) {
>>>           free(buf);
>>>           return NULL;
>>>       }
>>>       return buf;
>>>   }
>>> +
>>> +/* Full CPUID format for x86 is vendor-family-model-stepping */
>>> +static bool is_full_cpuid(const char *cpuid)
>>> +{
>>> +    const char *tmp = cpuid;
>>> +    int count = 0;
>>> +
>>> +    while ((tmp = strchr(tmp, '-')) != NULL) {
>>> +        count++;
>>> +        tmp++;
>>> +    }
>>> +
>>> +    if (count == 3)
>>> +        return true;
>>> +
>>> +    return false;
>>> +}
>>> +
>>> +int strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
>>> +{
>>> +    regex_t re;
>>> +    regmatch_t pmatch[1];
>>> +    int match;
>>> +    bool full_mapcpuid = is_full_cpuid(mapcpuid);
>>> +    bool full_cpuid = is_full_cpuid(cpuid);
>>
>> cpuid will be always full from now right? why do we need to check it?
>>
> 
> User may set cpuid by environment string "PERF_CPUID", which may not be 
> full format.
> 
>> also please move this to arch/x86/util/pmu.c
>> so it matches the weak function object
> 
> Sure.
> 

It looks like both pmu.c and header.c have cpuid related functions.
For example,
get_cpuid_str() has weak function in pmu.c. It's declaration in 
header.h. It's x86 specific function in x86/util/header.c
get_cpuid() has weak function in header.c. It's declaration in header.h. 
It's x86 specific function in x86/util/header.c

It looks like most of the cpuid related functions are in header.c/h.
I think it may be better to move all the cpuid related functions to 
header.c/h.

If it's OK for you, I will send a clean up patch later to move the weak 
functions strcmp_cpuid_str() and get_cpuid_str() to header.c

What do you think?

Thanks,
Kan

  reply	other threads:[~2018-11-15 15:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 21:24 [PATCH 1/2] perf vendor events: Add stepping in CPUID string for x86 kan.liang
     [not found] ` <20181114212416.15665-2-kan.liang@linux.intel.com>
2018-11-15 13:21   ` [PATCH 2/2] perf vendor events: Add JSON metrics for Cascadelake server Jiri Olsa
     [not found]     ` <3ab97c73-c197-8555-1a35-b54636e667e6@linux.intel.com>
2018-11-15 15:14       ` Jiri Olsa
2018-11-21 12:51         ` Arnaldo Carvalho de Melo
2018-11-21 12:54           ` Arnaldo Carvalho de Melo
2018-11-21 13:02             ` Jiri Olsa
2018-11-21 13:10               ` Arnaldo Carvalho de Melo
2018-11-15 13:53 ` [PATCH 1/2] perf vendor events: Add stepping in CPUID string for x86 Jiri Olsa
2018-11-15 14:26   ` Liang, Kan
2018-11-15 15:18     ` Liang, Kan [this message]
2018-11-15 15:33       ` Jiri Olsa
2018-11-15 15:25     ` Jiri Olsa
2018-11-15 15:53       ` Liang, Kan
2018-11-15 20:02         ` Jiri Olsa
2018-11-15 20:44 ` Jiri Olsa
2018-11-15 21:01   ` Liang, Kan
2018-11-16  2:14     ` Arnaldo Carvalho de Melo
2018-11-20 13:55       ` Liang, Kan
2018-11-21 12:22     ` Arnaldo Carvalho de Melo
2018-11-22  7:14 ` [tip:perf/core] " tip-bot for Kan Liang

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=58a3caa6-0ba9-773b-9f99-1e4be5ff77fb@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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).