From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, acme@kernel.org, namhyung@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
ak@linux.intel.com, eranian@google.com
Subject: Re: [RESEND PATCH 01/12] perf/x86/intel: Support the PEBS event mask
Date: Thu, 20 Jun 2024 11:58:42 -0400 [thread overview]
Message-ID: <840ced10-cc0f-4883-8559-772c5521a092@linux.intel.com> (raw)
In-Reply-To: <20240620070215.GP31592@noisy.programming.kicks-ass.net>
On 2024-06-20 3:02 a.m., Peter Zijlstra wrote:
> On Tue, Jun 18, 2024 at 08:10:33AM -0700, kan.liang@linux.intel.com wrote:
>> diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
>> index e010bfed8417..a0104c82baed 100644
>> --- a/arch/x86/events/intel/ds.c
>> +++ b/arch/x86/events/intel/ds.c
>
>> @@ -2157,6 +2157,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d
>> void *base, *at, *top;
>> short counts[INTEL_PMC_IDX_FIXED + MAX_FIXED_PEBS_EVENTS] = {};
>> short error[INTEL_PMC_IDX_FIXED + MAX_FIXED_PEBS_EVENTS] = {};
>> + int max_pebs_events = hweight64(x86_pmu.pebs_events_mask);
>
> Consider pebs_events_mask = 0xf0, then max_pebs_events becomes 4.
The intel_pmu_drain_pebs_nhm() is a NHM specific function. It's
impossible that there is a pebs_events_mask = 0xf0.
There are only 4 counters. The mask should always be 0xf.
>
>> int bit, i, size;
>> u64 mask;
>>
>> @@ -2168,8 +2169,8 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d
>>
>> ds->pebs_index = ds->pebs_buffer_base;
>>
>> - mask = (1ULL << x86_pmu.max_pebs_events) - 1;
>> - size = x86_pmu.max_pebs_events;
>> + mask = x86_pmu.pebs_events_mask;
>> + size = max_pebs_events;
>
> This is wrong.. you have 8 bits to iterate, of which only the top 4 are
> set.
>
>> if (x86_pmu.flags & PMU_FL_PEBS_ALL) {
>> mask |= ((1ULL << x86_pmu.num_counters_fixed) - 1) << INTEL_PMC_IDX_FIXED;
>> size = INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed;
>> @@ -2208,8 +2209,8 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d
>> pebs_status = p->status = cpuc->pebs_enabled;
>>
>> bit = find_first_bit((unsigned long *)&pebs_status,
>> - x86_pmu.max_pebs_events);
>> - if (bit >= x86_pmu.max_pebs_events)
>> + max_pebs_events);
>> + if (bit >= max_pebs_events)
>> continue;
>
> But the bit check here then truncates the thing to the lower 4 bits
> which are all 0.
>
> Should this not be something like:
>
> if (!(pebs_event_mask & (1 << bit)))
> continue;
>
> ?
>
For the existing hardware, I don't think it's necessary. The counters
are contiguous.
Thanks,
Kan
next prev parent reply other threads:[~2024-06-20 15:58 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 15:10 [RESEND PATCH 00/12] Support Lunar Lake and Arrow Lake core PMU kan.liang
2024-06-18 15:10 ` [RESEND PATCH 01/12] perf/x86/intel: Support the PEBS event mask kan.liang
2024-06-20 7:02 ` Peter Zijlstra
2024-06-20 15:58 ` Liang, Kan [this message]
2024-06-21 14:19 ` Liang, Kan
2024-06-24 8:29 ` Peter Zijlstra
2024-06-24 8:21 ` Peter Zijlstra
2024-06-18 15:10 ` [RESEND PATCH 02/12] perf/x86: Support counter mask kan.liang
2024-06-20 7:06 ` Peter Zijlstra
2024-06-20 16:02 ` Liang, Kan
2024-06-18 15:10 ` [RESEND PATCH 03/12] perf/x86: Add Lunar Lake and Arrow Lake support kan.liang
2024-06-18 15:10 ` [RESEND PATCH 04/12] perf/x86/intel: Support new data source for Lunar Lake kan.liang
2024-06-20 7:34 ` Peter Zijlstra
2024-06-20 16:09 ` Liang, Kan
2024-06-18 15:10 ` [RESEND PATCH 05/12] perf/x86: Add config_mask to represent EVENTSEL bitmask kan.liang
2024-06-20 7:44 ` Peter Zijlstra
2024-06-20 16:16 ` Liang, Kan
2024-06-21 18:34 ` Liang, Kan
2024-06-24 8:28 ` Peter Zijlstra
2024-06-24 15:36 ` Liang, Kan
2024-06-24 8:26 ` Peter Zijlstra
2024-06-18 15:10 ` [RESEND PATCH 06/12] perf/x86/intel: Support PERFEVTSEL extension kan.liang
2024-06-18 15:10 ` [RESEND PATCH 07/12] perf/x86/intel: Support Perfmon MSRs aliasing kan.liang
2024-06-20 8:02 ` Peter Zijlstra
2024-06-20 16:17 ` Liang, Kan
2024-06-18 15:10 ` [RESEND PATCH 08/12] perf/x86: Extend event update interface kan.liang
2024-06-20 8:38 ` Peter Zijlstra
2024-06-20 16:18 ` Liang, Kan
2024-06-18 15:10 ` [RESEND PATCH 09/12] perf: Extend perf_output_read kan.liang
2024-06-20 9:00 ` Peter Zijlstra
2024-06-20 10:01 ` Peter Zijlstra
2024-06-18 15:10 ` [RESEND PATCH 10/12] perf/x86/intel: Move PEBS event update after the sample output kan.liang
2024-06-18 15:10 ` [RESEND PATCH 11/12] perf/x86/intel: Support PEBS counters snapshotting kan.liang
2024-06-18 15:10 ` [RESEND PATCH 12/12] perf/x86/intel: Support RDPMC metrics clear mode 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=840ced10-cc0f-4883-8559-772c5521a092@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--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
Powered by JetHome