From: Andi Kleen <ak@linux.intel.com>
To: kan.liang@linux.intel.com
Cc: peterz@infradead.org, mingo@kernel.org, acme@kernel.org,
namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
linux-kernel@vger.kernel.org, eranian@google.com,
thomas.falcon@intel.com
Subject: Re: [PATCH 3/3] perf/x86/intel: Support auto counter reload
Date: Tue, 1 Oct 2024 04:16:14 -0700 [thread overview]
Message-ID: <ZvvZ78QAH254TiHe@tassilo> (raw)
In-Reply-To: <20240930154122.578924-4-kan.liang@linux.intel.com>
I hope the perf tools will support a nicer syntax, the mask is quite
obscure.
On Mon, Sep 30, 2024 at 08:41:22AM -0700, kan.liang@linux.intel.com wrote:
> }
>
> +static void intel_pmu_config_acr(int idx, u64 mask, u32 reload)
> +{
> + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> + int msr_b, msr_c;
> +
> + if (!mask && cpuc->acr_cfg_b[idx] == mask)
> + return;
if (!mask && !cpuc->acr_cfg_b[idx])
> +
> + if (idx < INTEL_PMC_IDX_FIXED) {
> + msr_b = MSR_IA32_PMC_V6_GP0_CFG_B;
> + msr_c = MSR_IA32_PMC_V6_GP0_CFG_C;
> + } else {
> + msr_b = MSR_IA32_PMC_V6_FX0_CFG_B;
> + msr_c = MSR_IA32_PMC_V6_FX0_CFG_C;
> + idx -= INTEL_PMC_IDX_FIXED;
> + }
Does this handle metrics correctly?
I assume you ran the fuzzer over this.
> + if (cpuc->acr_cfg_b[idx] != mask) {
> + wrmsrl(msr_b + x86_pmu.addr_offset(idx, false), mask);
> + cpuc->acr_cfg_b[idx] = mask;
> + }
> + /* Only need to update the reload value when there is a valid config value. */
> + if (mask && cpuc->acr_cfg_c[idx] != reload) {
> + wrmsrl(msr_c + x86_pmu.addr_offset(idx, false), reload);
> + cpuc->acr_cfg_c[idx] = reload;
Can reload be larger than the counter width? What happens then?
> return c2;
> }
>
> @@ -3948,6 +4004,78 @@ static inline bool intel_pmu_has_cap(struct perf_event *event, int idx)
> return test_bit(idx, (unsigned long *)&intel_cap->capabilities);
> }
>
> +static bool intel_pmu_is_acr_group(struct perf_event *event)
> +{
> + if (!hybrid(event->pmu, acr_cntr_mask64))
> + return false;
Shouldn't this error when the group leader
has the flag set?
> + /* The group leader has the ACR flag set */
> + if (is_acr_event_group(event))
> + return true;
> +
> + /* The acr_mask is set */
> + if (event->attr.config2)
> + return true;
> + * the group. Reconfigure the dyn_mask of each X86 event
> + * every time when add a new event.
> + *
> + * Check whether the reloadable counters is enough and
> + * initialize the dyn_mask.
> + */
> + if (intel_pmu_acr_check_reloadable_event(event))
> + return -EINVAL;
> +
> + /* Reconfigure the dyn_mask for each event */
> + intel_pmu_set_acr_dyn_mask(leader, event_idx++, event);
> + for_each_sibling_event(sibling, leader)
> + intel_pmu_set_acr_dyn_mask(sibling, event_idx++, event);
> + intel_pmu_set_acr_dyn_mask(event, event_idx, event);
> +
Shouldn't there be an error somewhere when a mask bit is set that
exceeds the group? (maybe I missed it)
I assume it could #GP on the MSR write, or maybe even overflow into
some other field.
-Andi
next prev parent reply other threads:[~2024-10-01 11:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 15:41 [PATCH 0/3] Support auto counter reload kan.liang
2024-09-30 15:41 ` [PATCH 1/3] perf/x86/intel: Fix ARCH_PERFMON_NUM_COUNTER_LEAF kan.liang
2024-09-30 15:41 ` [PATCH 2/3] perf/x86/intel: Add the enumeration and flag for the auto counter reload kan.liang
2024-09-30 15:41 ` [PATCH 3/3] perf/x86/intel: Support " kan.liang
2024-10-01 11:16 ` Andi Kleen [this message]
2024-10-01 14:41 ` Liang, Kan
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=ZvvZ78QAH254TiHe@tassilo \
--to=ak@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.