From: Ravi Bangoria <ravi.bangoria@amd.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@redhat.com, namhyung@kernel.org, acme@kernel.org,
eranian@google.com, irogers@google.com,
kan.liang@linux.intel.com, bp@alien8.de, x86@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
santosh.shukla@amd.com, ananth.narayan@amd.com,
sandipan.das@amd.com, Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH v4 5/9] perf/amd/ibs: Don't allow freq mode event creation through ->config interface
Date: Fri, 17 Jan 2025 10:21:28 +0530 [thread overview]
Message-ID: <337e17e7-b3db-44a1-9493-495b4c7313eb@amd.com> (raw)
In-Reply-To: <20250116210959.GB7232@noisy.programming.kicks-ass.net>
On 17-Jan-25 2:39 AM, Peter Zijlstra wrote:
> On Wed, Jan 15, 2025 at 05:44:34AM +0000, Ravi Bangoria wrote:
>> Most perf_event_attr->config bits directly maps to IBS_{FETCH|OP}_CTL
>> MSR. Since the sample period is programmed in these control registers,
>> IBS PMU driver allows opening an IBS event by setting sample period
>> value directly in perf_event_attr->config instead of using explicit
>> perf_event_attr->sample_period interface.
>>
>> However, this logic is not applicable for freq mode events since the
>> semantics of control register fields are applicable only to fixed
>> sample period whereas the freq mode event adjusts sample period after
>> each and every sample. Currently, IBS driver (unintentionally) allows
>> creating freq mode event via ->config interface, which is semantically
>> wrong as well as detrimental because it can be misused to bypass
>> perf_event_max_sample_rate checks.
>>
>> Don't allow freq mode event creation through perf_event_attr->config
>> interface.
>
> So this is the case where:
>
> perf_event_attr = {
> .freq = 1.
> .sample_freq = 0,
> }
>
> Right, where we would then take the period from the .config fields?
>
> So that seems sensible enough; but does this not break existing users?
> Or are we lucky enough to not have any users of this borken behaviour,
> unlike the earlier broken behaviour that we now have to live with?
I'm not aware of any existing tools using the ->config interface.
Also, I can't think of any advantage of the ->config interface over
stranded one. So, if anyone is using it and start seeing an error, they
can switch to { attr->freq=1, attr->sample_freq=xxx } and there is no
functional breakage.
Thanks for the review,
Ravi
next prev parent reply other threads:[~2025-01-17 4:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 5:44 [PATCH v4 0/9] perf/amd/ibs: Fix sample period computations Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 1/9] perf/amd/ibs: Remove IBS_{FETCH|OP}_CONFIG_MASK macros Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 2/9] perf/amd/ibs: Remove pointless sample period check Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 3/9] perf/amd/ibs: Fix ->config to sample period calculation for OP PMU Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 4/9] perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 5/9] perf/amd/ibs: Don't allow freq mode event creation through ->config interface Ravi Bangoria
2025-01-16 21:09 ` Peter Zijlstra
2025-01-17 4:51 ` Ravi Bangoria [this message]
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 6/9] perf/amd/ibs: Add PMU specific minimum period Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 7/9] perf/amd/ibs: Add ->check_period() callback Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 8/9] perf/amd/ibs: Ceil sample_period to min_period Ravi Bangoria
2025-02-03 12:48 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2025-01-15 5:44 ` [PATCH v4 9/9] perf test amd ibs: Add sample period unit test Ravi Bangoria
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=337e17e7-b3db-44a1-9493-495b4c7313eb@amd.com \
--to=ravi.bangoria@amd.com \
--cc=acme@kernel.org \
--cc=ananth.narayan@amd.com \
--cc=bp@alien8.de \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=sandipan.das@amd.com \
--cc=santosh.shukla@amd.com \
--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®