[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260113105130.GW830755@noisy.programming.kicks-ass.net>
Date: Tue, 13 Jan 2026 11:51:30 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: "Mi, Dapeng" <dapeng1.mi@...ux.intel.com>
Cc: Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>,
Eranian Stephane <eranian@...gle.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, Dapeng Mi <dapeng1.mi@...el.com>,
Zide Chen <zide.chen@...el.com>,
Falcon Thomas <thomas.falcon@...el.com>,
Xudong Hao <xudong.hao@...el.com>
Subject: Re: [Patch v2 7/7] perf/x86/intel: Add support for rdpmc user
disable feature
On Tue, Jan 13, 2026 at 10:29:38AM +0800, Mi, Dapeng wrote:
>
> On 1/12/2026 6:57 PM, Peter Zijlstra wrote:
> > On Mon, Jan 12, 2026 at 01:16:49PM +0800, Dapeng Mi wrote:
> >
> >> +static void intel_pmu_update_rdpmc_user_disable(struct perf_event *event)
> >> +{
> >> + /*
> >> + * Counter scope's user-space rdpmc is disabled by default
> >> + * except two cases.
> >> + * a. rdpmc = 2 (user space rdpmc enabled unconditionally)
> >> + * b. rdpmc = 1 and the event is not a system-wide event.
> >> + * The count of non-system-wide events would be cleared when
> >> + * context switches, so no count data is leaked.
> >> + */
> >> + if (x86_pmu_has_rdpmc_user_disable(event->pmu)) {
> >> + if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_ALWAYS_ENABLE ||
> >> + (x86_pmu.attr_rdpmc == X86_USER_RDPMC_CONDITIONAL_ENABLE &&
> >> + event->ctx->task))
> >> + event->hw.config &= ~ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
> >> + else
> >> + event->hw.config |= ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
> >> + }
> >> +}
> > Is it not simpler to invert that condition?
> >
> > if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_ALWAYS_NEVER ||
> > !event->ctx->task)
> > event->hw.config |= ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
> > else
> > event->hw.config &= ~ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
>
> Hmm, it seems the logic changes along with the code change. The system-wide
> event should be allowed to read with rdpmc from user space when attr_rdpmc
> == X86_USER_RDPMC_ALWAYS_ENABLE, but it doesn't with the new code.
Bah, indeed. Oh well.
Powered by blists - more mailing lists