[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxgmHJooUPE5-i0O@google.com>
Date: Tue, 22 Oct 2024 15:24:28 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Ravi Bangoria <ravi.bangoria@....com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...nel.org>,
Kan Liang <kan.liang@...ux.intel.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Stephane Eranian <eranian@...gle.com>,
Ananth Narayan <ananth.narayan@....com>,
Sandipan Das <sandipan.das@....com>
Subject: Re: [PATCH 5/5] perf/x86: Relax privilege filter restriction on AMD
IBS
Hello,
On Mon, Sep 23, 2024 at 04:03:47PM +0530, Ravi Bangoria wrote:
> Hi Namhyung,
>
> > While IBS is available for per-thread profiling, still regular users
> > cannot open an event due to the default paranoid setting (2) which
> > doesn't allow unprivileged users to get kernel samples. That means
> > it needs to set exclude_kernel bit in the attribute but IBS driver
> > would reject it since it has PERF_PMU_CAP_NO_EXCLUDE. This is not what
> > we want and I've been getting requests to fix this issue.
>
> I'm working on some IBS improvements that impacts this change as well.
> Is it be possible to hold off this patch for some time. I'll try to
> post my patches soon.
>
> > @@ -1111,6 +1127,12 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
> > regs.flags |= PERF_EFLAGS_EXACT;
> > }
> >
> > + if ((event->attr.config2 & IBS_SW_FILTER_MASK) &&
> > + perf_exclude_event(event, ®s)) {
> > + throttle = perf_event_account_interrupt(event);
> > + goto out;
> > + }
>
> Throttling can give surprises when the sample period is very small.
> For ex,
>
> $ ./perf record -e cycles:uh -c 192 -- make
> [ perf record: Woken up 52 times to write data ]
> [ perf record: Captured and wrote 23.016 MB perf.data (705634 samples) ]
>
> $ ./perf record -e ibs_op/swfilt=1/uh -c 192 -- make
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 1.608 MB perf.data (19 samples) ]
>
> It seems like the IBS event gets throttled (and disabled) before the
> cpu get a chance to go back to userspace), hence we end up with very
> few samples.
Thanks for raising this issue. This indeed looks like a surprising
result. Not sure what we can do here other than adding a documentation
to refrain from using such a small period. I don't think we want to
skip the throttling logic for the filtered samples. Otherwise it can be
used for DoS-like attacks IMHO.
Thanks,
Namhyung
Powered by blists - more mailing lists