2014-10-07 19:43:18

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support

On Wed, Sep 24, 2014 at 03:04:12PM +0100, Matt Fleming wrote:
> +/*
> + * Determine if @a and @b measure the same set of tasks.
> + */
> +static bool __match_event(struct perf_event *a, struct perf_event *b)
> +{
> + if ((a->attach_state & PERF_ATTACH_TASK) !=
> + (b->attach_state & PERF_ATTACH_TASK))
> + return false;
> +
> + /* not task */
> +
> + return true; /* if not task, we're machine wide */
> +}

You cut too much out there. That first test checks weather the two
events are of the same type; ie. both tasks or both cpu. After that you
still need to verify that they are indeed the same target.


2014-10-08 10:37:04

by Matt Fleming

[permalink] [raw]
Subject: Re: [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support

On Tue, 07 Oct, at 09:43:10PM, Peter Zijlstra wrote:
> On Wed, Sep 24, 2014 at 03:04:12PM +0100, Matt Fleming wrote:
> > +/*
> > + * Determine if @a and @b measure the same set of tasks.
> > + */
> > +static bool __match_event(struct perf_event *a, struct perf_event *b)
> > +{
> > + if ((a->attach_state & PERF_ATTACH_TASK) !=
> > + (b->attach_state & PERF_ATTACH_TASK))
> > + return false;
> > +
> > + /* not task */
> > +
> > + return true; /* if not task, we're machine wide */
> > +}
>
> You cut too much out there. That first test checks weather the two
> events are of the same type; ie. both tasks or both cpu. After that you
> still need to verify that they are indeed the same target.

This gets fixed in PATCH 10 where we actually implement monitoring of
task events. At this point in the series, we'll return -EINVAL from
intel_cqm_event_init() for anything other than a cpu event.

--
Matt Fleming, Intel Open Source Technology Center

2014-10-08 12:15:39

by Matt Fleming

[permalink] [raw]
Subject: Re: [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support

On Wed, 08 Oct, at 11:36:58AM, Matt Fleming wrote:
> On Tue, 07 Oct, at 09:43:10PM, Peter Zijlstra wrote:
> > On Wed, Sep 24, 2014 at 03:04:12PM +0100, Matt Fleming wrote:
> > > +/*
> > > + * Determine if @a and @b measure the same set of tasks.
> > > + */
> > > +static bool __match_event(struct perf_event *a, struct perf_event *b)
> > > +{
> > > + if ((a->attach_state & PERF_ATTACH_TASK) !=
> > > + (b->attach_state & PERF_ATTACH_TASK))
> > > + return false;
> > > +
> > > + /* not task */
> > > +
> > > + return true; /* if not task, we're machine wide */
> > > +}
> >
> > You cut too much out there. That first test checks weather the two
> > events are of the same type; ie. both tasks or both cpu. After that you
> > still need to verify that they are indeed the same target.
>
> This gets fixed in PATCH 10 where we actually implement monitoring of
> task events. At this point in the series, we'll return -EINVAL from
> intel_cqm_event_init() for anything other than a cpu event.

I was having an interesting discussion with one of the teams using this
stuff at Intel and they made the suggestion that when using,

perf stat -p <pid>

we should by default opt for sharing an RMID between all tasks in that
thread group, rather that assigning a new RMID for each task, which is
what we do currently.

Right now, it's like the Oprah Winfrey of RMID assignment, "You get an
RMID, and you get an RMID!"

Which means we'll run out of RMIDs quicker, and enable the rotation code
sooner.

I'm wondering whether we should require that the user specify whether
they want per-thread monitoring if using -p, via some perf tools event
modifier, and make the record-per-thread-data scenario the exceptional
case, rather than the default?

--
Matt Fleming, Intel Open Source Technology Center

2014-10-08 14:47:16

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support

On Wed, Oct 08, 2014 at 01:15:35PM +0100, Matt Fleming wrote:
> I was having an interesting discussion with one of the teams using this
> stuff at Intel and they made the suggestion that when using,
>
> perf stat -p <pid>
>
> we should by default opt for sharing an RMID between all tasks in that
> thread group, rather that assigning a new RMID for each task, which is
> what we do currently.
>
> Right now, it's like the Oprah Winfrey of RMID assignment, "You get an
> RMID, and you get an RMID!"
>
> Which means we'll run out of RMIDs quicker, and enable the rotation code
> sooner.
>
> I'm wondering whether we should require that the user specify whether
> they want per-thread monitoring if using -p, via some perf tools event
> modifier, and make the record-per-thread-data scenario the exceptional
> case, rather than the default?

Right so perf cannot do this. And I'm not sure that's fixable, it
depends a bit on how the cqm thing deals with inherited events, IFF it
can reuse RMIDs for inherited events we might be able to extend the
syscall to install 'inherited' events throughout the process group,
instead of just the one thread.

2014-10-08 20:51:23

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support

On Wed, Oct 08, 2014 at 04:47:04PM +0200, Peter Zijlstra wrote:
> On Wed, Oct 08, 2014 at 01:15:35PM +0100, Matt Fleming wrote:
> > I was having an interesting discussion with one of the teams using this
> > stuff at Intel and they made the suggestion that when using,
> >
> > perf stat -p <pid>
> >
> > we should by default opt for sharing an RMID between all tasks in that
> > thread group, rather that assigning a new RMID for each task, which is
> > what we do currently.
> >
> > Right now, it's like the Oprah Winfrey of RMID assignment, "You get an
> > RMID, and you get an RMID!"
> >
> > Which means we'll run out of RMIDs quicker, and enable the rotation code
> > sooner.
> >
> > I'm wondering whether we should require that the user specify whether
> > they want per-thread monitoring if using -p, via some perf tools event
> > modifier, and make the record-per-thread-data scenario the exceptional
> > case, rather than the default?
>
> Right so perf cannot do this. And I'm not sure that's fixable, it
> depends a bit on how the cqm thing deals with inherited events, IFF it
> can reuse RMIDs for inherited events we might be able to extend the
> syscall to install 'inherited' events throughout the process group,
> instead of just the one thread.

Right, so inherited events aren't going to work right for this. Look at
patch 10, these events target a different task and will not match, so
we'll not share RMIDs.

The only way to make this happen is stuff the process in a cgroup and
measure the cgroup.