mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@amd.com>
To: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: Luo Gengkun <luogengkun@huaweicloud.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"acme@kernel.org" <acme@kernel.org>,
	"namhyung@kernel.org" <namhyung@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"alexander.shishkin@linux.intel.com"
	<alexander.shishkin@linux.intel.com>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"irogers@google.com" <irogers@google.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH] perf/x86: Fix open counting event error
Date: Fri, 25 Apr 2025 15:42:39 +0530	[thread overview]
Message-ID: <a04c37c6-8f83-45e9-a39f-1e1ba613f7f4@amd.com> (raw)
In-Reply-To: <1d1cb14f-5729-4200-af20-d66b4feebe94@linux.intel.com>

Hi Kan,

>>> Perf doesn't work at perf stat for hardware events:
>>>
>>>  $perf stat -- sleep 1
>>>  Performance counter stats for 'sleep 1':
>>>              16.44 msec task-clock                       #    0.016 CPUs utilized
>>>                  2      context-switches                 #  121.691 /sec
>>>                  0      cpu-migrations                   #    0.000 /sec
>>>                 54      page-faults                      #    3.286 K/sec
>>>    <not supported>	cycles
>>>    <not supported>	instructions
>>>    <not supported>	branches
>>>    <not supported>	branch-misses
>>
>> Wondering if it is worth to add this in perf test. Something like
>> below?
>>
>> --- a/tools/perf/tests/shell/stat.sh
>> +++ b/tools/perf/tests/shell/stat.sh
>> @@ -16,6 +16,24 @@ test_default_stat() {
>>    echo "Basic stat command test [Success]"
>>  }
>>  
>> +test_stat_count() {
>> +  echo "stat count test"
>> +
>> +  if ! perf list | grep -q "cpu-cycles OR cycles"
>> +  then
>> +    echo "stat count test [Skipped cpu-cycles event missing]"
>> +    return
>> +  fi
>> +
>> +  if perf stat -e cycles true 2>&1 | grep -E -q "<not supported>"
>> +  then
>> +    echo "stat count test [Failed]"
>> +    err=1
>> +    return
>> +  fi
>> +  echo "stat count test [Success]"
>> +}
>> +
>>  test_stat_record_report() {
>>    echo "stat record and report test"
>>    if ! perf stat record -o - true | perf stat report -i - 2>&1 | \
>> @@ -201,6 +219,7 @@ test_hybrid() {
>>  }
>>  
>>  test_default_stat
>> +test_stat_count
> 
> I think the perf stat default should always be supported, not just cycles.
> Maybe we should add the check in test_default_stat?

Do you mean:

  if perf stat true 2>&1 | grep -E -q "<not supported>"
    err=1

Isn't this ambiguous? Also, this fails on machines where HW pmu
is not supported. For ex, on my qemu guest with `-cpu pmu=off`:

  $ ./perf list | grep "cpu-cycles OR cycles"
  <empty output>

  $ ./perf stat true
   Performance counter stats for 'true':
                0.42 msec task-clock:u                     #    0.470 CPUs utilized
                   0      context-switches:u               #    0.000 /sec
                   0      cpu-migrations:u                 #    0.000 /sec
                  48      page-faults:u                    #  113.874 K/sec
     <not supported>      cycles:u

Thanks,
Ravi

  reply	other threads:[~2025-04-25 10:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23  6:47 Luo Gengkun
2025-04-23 13:51 ` Liang, Kan
2025-04-24  6:52 ` Ravi Bangoria
2025-04-24 17:15   ` Liang, Kan
2025-04-25 10:12     ` Ravi Bangoria [this message]
2025-04-30 14:12       ` Liang, Kan
2025-04-24 16:20 ` Ingo Molnar
2025-04-24 17:08   ` Liang, Kan
2025-04-24 18:14     ` Ingo Molnar
2025-04-24 18:22 ` [tip: perf/urgent] perf/x86: Fix non-sampling (counting) events on certain x86 platforms tip-bot2 for Luo Gengkun

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=a04c37c6-8f83-45e9-a39f-1e1ba613f7f4@amd.com \
    --to=ravi.bangoria@amd.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=luogengkun@huaweicloud.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®