Re: [PATCH v3] perf evsel: Fix missing exclude_{host,guest} setting

From: Arnaldo Carvalho de Melo
Date: Thu Nov 04 2021 - 13:40:09 EST


Em Wed, Nov 03, 2021 at 03:29:50PM -0700, Stephane Eranian escreveu:
> On Wed, Nov 3, 2021 at 2:03 PM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> > Em Wed, Nov 03, 2021 at 10:35:04AM -0700, Stephane Eranian escreveu:
> > > On Wed, Nov 3, 2021 at 4:32 AM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> > > > Em Wed, Nov 03, 2021 at 12:44:12AM -0700, Stephane Eranian escreveu:
> > > > > On Wed, Nov 3, 2021 at 12:24 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> > > > > > > If the pmu doesn't support host/guest filtering, pmu/bla1/G
> > > > > > > may count something. Not sure if it's better to error out.
> > > > > > > But the cycles:G and instructions:G should result in 0
> > > > > > > in case there's no VM running.

> > > > > > hm, I think if pmu doesn't support host/guest filtering then
> > > > > > I think 'pmu/bla1/G' should error, no? better no number than
> > > > > > bad number

> > > > > Yes, it should in my opinion.

> > > > Yeah, I thought about this yesterday (holiday here).

> > > Otherwise you create the illusion that you are monitoring in guest
> > > mode when you are not.

> > > The question is: how can the tool know which modifiers are supported
> > > per pmu model?

> > As things stand kernel-wise, we should just do capability querying, i.e.
> > if the user asks for a feature not available for a specific PMU, we
> > should refuse and provide a helpful error message to the user.

> > If the PMUs in the kernel had some kind of mask that stated what of the
> > 'struct perf_event_attr' selectable features are supported, then we
> > would just be able to avoid bothering the kernel asking for unsupported
> > stuff.

> I think we could add something like that in the sysfs entry for each
> PMU instance.
> that would avoid all these perf_event_open() calls and trying to
> decipher the error
> code.

That would speed up these checks with newer kernels, yeah, with older
kernels we'd fall back to what we have now + bailing out in the current
case (PMUs not supporting exclude_guest).

- Arnaldo

> > Just for exclude_guest we don't even need to have
> > evsel->pmu->missing_features.exclude_guest, as this is a hard error, no
> > point in caching previous capability queries.