2009-06-11 06:30:50

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

>-----Original Message-----
>From: tip-bot for Ingo Molnar [mailto:[email protected]]
>Sent: Thursday, June 11, 2009 1:37 AM
>To: [email protected]
>Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
>[email protected]; [email protected]
>Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
>Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
>Author: Ingo Molnar <[email protected]>
>AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
>Committer: Ingo Molnar <[email protected]>
>CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
>
>Revert "x86, bts: reenable ptrace branch trace support"
>
>This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
>
>A late objection to the ABI has arrived:
>
> http://lkml.org/lkml/2009/6/10/253

I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.

Peters concerns were that Debug Store details are exposed to user space, which is
not the case. Debug Store itself is fully in-kernel and the expectation of a
user-defined buffer can be implemented on top of the Debug Store changes that
Peter expects are needed to support PEBS.

A user-defined trace buffer size is required to support different usage models.
Some users only need a small amount of trace, whereas others need a big amount.
The interface will have to reflect that in some way.


regards,
markus.

---------------------------------------------------------------------Intel GmbHDornacher Strasse 185622 Feldkirchen/Muenchen GermanySitz der Gesellschaft: Feldkirchen bei MuenchenGeschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes SchwadererRegistergericht: Muenchen HRB 47456 Ust.-IdNr.VAT Registration No.: DE129385895Citibank Frankfurt (BLZ 502 109 00) 600119052
This e-mail and any attachments may contain confidential material forthe sole use of the intended recipient(s). Any review or distributionby others is strictly prohibited. If you are not the intendedrecipient, please contact the sender and delete all copies.????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?


2009-06-11 06:36:35

by Peter Zijlstra

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
> >-----Original Message-----
> >From: tip-bot for Ingo Molnar [mailto:[email protected]]
> >Sent: Thursday, June 11, 2009 1:37 AM
> >To: [email protected]
> >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
> >[email protected]; [email protected]
> >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
> >
> >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
> >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
> >Author: Ingo Molnar <[email protected]>
> >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
> >Committer: Ingo Molnar <[email protected]>
> >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
> >
> >Revert "x86, bts: reenable ptrace branch trace support"
> >
> >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
> >
> >A late objection to the ABI has arrived:
> >
> > http://lkml.org/lkml/2009/6/10/253
>
> I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
>
> Peters concerns were that Debug Store details are exposed to user space, which is
> not the case. Debug Store itself is fully in-kernel and the expectation of a
> user-defined buffer can be implemented on top of the Debug Store changes that
> Peter expects are needed to support PEBS.
>
> A user-defined trace buffer size is required to support different usage models.
> Some users only need a small amount of trace, whereas others need a big amount.
> The interface will have to reflect that in some way.

Right, your last email did explain how we could keep per task in-kernel
buffers and fill them from the DS and still have them of user-specified
size.

That would indeed keep the proposed ABI workable, what I'm still not
liking is that this buffer is in-kernel, but I guess that might be
something for other people to have an opinion on.

2009-06-11 07:18:10

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

>-----Original Message-----
>From: Peter Zijlstra [mailto:[email protected]]
>Sent: Thursday, June 11, 2009 8:36 AM
>To: Metzger, Markus T
>Cc: [email protected]; [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]; [email protected]
>Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
>> >-----Original Message-----
>> >From: tip-bot for Ingo Molnar [mailto:[email protected]]
>> >Sent: Thursday, June 11, 2009 1:37 AM
>> >To: [email protected]
>> >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
>> >[email protected]; [email protected]
>> >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>> >
>> >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
>> >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
>> >Author: Ingo Molnar <[email protected]>
>> >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
>> >Committer: Ingo Molnar <[email protected]>
>> >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
>> >
>> >Revert "x86, bts: reenable ptrace branch trace support"
>> >
>> >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
>> >
>> >A late objection to the ABI has arrived:
>> >
>> > http://lkml.org/lkml/2009/6/10/253
>>
>> I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
>>
>> Peters concerns were that Debug Store details are exposed to user space, which is
>> not the case. Debug Store itself is fully in-kernel and the expectation of a
>> user-defined buffer can be implemented on top of the Debug Store changes that
>> Peter expects are needed to support PEBS.
>>
>> A user-defined trace buffer size is required to support different usage models.
>> Some users only need a small amount of trace, whereas others need a big amount.
>> The interface will have to reflect that in some way.
>
>Right, your last email did explain how we could keep per task in-kernel
>buffers and fill them from the DS and still have them of user-specified
>size.
>
>That would indeed keep the proposed ABI workable, what I'm still not
>liking is that this buffer is in-kernel, but I guess that might be
>something for other people to have an opinion on.

The alternative would be to give a user-allocated buffer to the tracing h/w.

We would need to take precautions to prevent the user from messing around
with that buffer while the h/w is writing to it. Other code uses the kernel-
allocated buffer plus copy_to_user() approach, as well.

Further, it would require the user to interpret the various tracing formats,
whereas the existing interface provides an architecture-independent format.


Does anybody have concerns on using an in-kernel buffer and providing a
copy_to_user() interface?


regards,
markus.
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

2009-06-11 08:09:18

by Peter Zijlstra

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

On Thu, 2009-06-11 at 08:17 +0100, Metzger, Markus T wrote:
> >That would indeed keep the proposed ABI workable, what I'm still not
> >liking is that this buffer is in-kernel, but I guess that might be
> >something for other people to have an opinion on.
>
> The alternative would be to give a user-allocated buffer to the tracing h/w.
>
> We would need to take precautions to prevent the user from messing around
> with that buffer while the h/w is writing to it. Other code uses the kernel-
> allocated buffer plus copy_to_user() approach, as well.
>
> Further, it would require the user to interpret the various tracing formats,
> whereas the existing interface provides an architecture-independent format.
>
>
> Does anybody have concerns on using an in-kernel buffer and providing a
> copy_to_user() interface?

Ah, if you mmap() you can do without copy_to_user().

Either way, you have to make sure the buffer is mlocked() anyway, since
you're wanting to fill it from interrupt context.

The advantage (imo) from letting the user set it up is that you don't
need those separate allocation routines.

But yes, it would expose the data to the user, but one could keep it
opaque data, without requiring the user to be able to interpret it.

Of course a data format aligned with the interface capabilities would be
nicer ;-)

2009-06-11 08:31:06

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

>-----Original Message-----
>From: Peter Zijlstra [mailto:[email protected]]
>Sent: Thursday, June 11, 2009 10:09 AM
>To: Metzger, Markus T
>Cc: [email protected]; [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]; [email protected]
>Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>On Thu, 2009-06-11 at 08:17 +0100, Metzger, Markus T wrote:
>> >That would indeed keep the proposed ABI workable, what I'm still not
>> >liking is that this buffer is in-kernel, but I guess that might be
>> >something for other people to have an opinion on.
>>
>> The alternative would be to give a user-allocated buffer to the tracing h/w.
>>
>> We would need to take precautions to prevent the user from messing around
>> with that buffer while the h/w is writing to it. Other code uses the kernel-
>> allocated buffer plus copy_to_user() approach, as well.
>>
>> Further, it would require the user to interpret the various tracing formats,
>> whereas the existing interface provides an architecture-independent format.
>>
>>
>> Does anybody have concerns on using an in-kernel buffer and providing a
>> copy_to_user() interface?
>
>Ah, if you mmap() you can do without copy_to_user().

The user would still need to call the kernel to interpret the trace data,
which would then require copy_to_user() for the interpreted data.


>Either way, you have to make sure the buffer is mlocked() anyway, since
>you're wanting to fill it from interrupt context.
>
>The advantage (imo) from letting the user set it up is that you don't
>need those separate allocation routines.

I would still need to mlock() the buffer. Those separate allocation routines
do the accounting work of mlock() on an already non-pageable buffer.

If you don't like those separate allocation routines, we could extract the
accounting part from mlock() into separate functions and I could use those.
These changes would again be in-kernel without impacting the API.


>But yes, it would expose the data to the user, but one could keep it
>opaque data, without requiring the user to be able to interpret it.

See above, the user would then need to call the kernel to interpret the data.
We would achieve exactly the same thing in a more complicated way:
- there's a buffer which the user cannot use directly
- the buffer must be locked and must not go away
- the user needs to call the kernel to read trace records from the buffer

If we let the user setup the buffer, all we gain is some additional overhead.
The user needs to request pages from the kernel. Malloc needs to administrate
this memory. The user then gives the memory back to the kernel, which locks it
and gives it to the h/w.


regards,
markus.

---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

2009-06-11 10:22:23

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"


* Peter Zijlstra <[email protected]> wrote:

> On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
> > >-----Original Message-----
> > >From: tip-bot for Ingo Molnar [mailto:[email protected]]
> > >Sent: Thursday, June 11, 2009 1:37 AM
> > >To: [email protected]
> > >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
> > >[email protected]; [email protected]
> > >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
> > >
> > >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
> > >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
> > >Author: Ingo Molnar <[email protected]>
> > >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
> > >Committer: Ingo Molnar <[email protected]>
> > >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
> > >
> > >Revert "x86, bts: reenable ptrace branch trace support"
> > >
> > >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
> > >
> > >A late objection to the ABI has arrived:
> > >
> > > http://lkml.org/lkml/2009/6/10/253
> >
> > I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
> >
> > Peters concerns were that Debug Store details are exposed to user space, which is
> > not the case. Debug Store itself is fully in-kernel and the expectation of a
> > user-defined buffer can be implemented on top of the Debug Store changes that
> > Peter expects are needed to support PEBS.
> >
> > A user-defined trace buffer size is required to support
> > different usage models. Some users only need a small amount of
> > trace, whereas others need a big amount. The interface will have
> > to reflect that in some way.
>
> Right, your last email did explain how we could keep per task
> in-kernel buffers and fill them from the DS and still have them of
> user-specified size.
>
> That would indeed keep the proposed ABI workable, what I'm still
> not liking is that this buffer is in-kernel, but I guess that
> might be something for other people to have an opinion on.

Hm. Wrt. the ABI, wouldnt it make more sense to expose this PMU
feature via perfcounters: a sampling hw-branch-executions counter,
with interval=1.

That would give the exact existing semantics, plus a lot lot more.
Markus?

Ingo

2009-06-11 10:39:51

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

>-----Original Message-----
>From: Ingo Molnar [mailto:[email protected]]
>Sent: Thursday, June 11, 2009 12:22 PM
>To: Peter Zijlstra
>Cc: Metzger, Markus T; [email protected]; [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]
>Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>
>* Peter Zijlstra <[email protected]> wrote:
>
>> On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
>> > >-----Original Message-----
>> > >From: tip-bot for Ingo Molnar [mailto:[email protected]]
>> > >Sent: Thursday, June 11, 2009 1:37 AM
>> > >To: [email protected]
>> > >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
>> > >[email protected]; [email protected]
>> > >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>> > >
>> > >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
>> > >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
>> > >Author: Ingo Molnar <[email protected]>
>> > >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
>> > >Committer: Ingo Molnar <[email protected]>
>> > >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
>> > >
>> > >Revert "x86, bts: reenable ptrace branch trace support"
>> > >
>> > >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
>> > >
>> > >A late objection to the ABI has arrived:
>> > >
>> > > http://lkml.org/lkml/2009/6/10/253
>> >
>> > I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
>> >
>> > Peters concerns were that Debug Store details are exposed to user space, which is
>> > not the case. Debug Store itself is fully in-kernel and the expectation of a
>> > user-defined buffer can be implemented on top of the Debug Store changes that
>> > Peter expects are needed to support PEBS.
>> >
>> > A user-defined trace buffer size is required to support
>> > different usage models. Some users only need a small amount of
>> > trace, whereas others need a big amount. The interface will have
>> > to reflect that in some way.
>>
>> Right, your last email did explain how we could keep per task
>> in-kernel buffers and fill them from the DS and still have them of
>> user-specified size.
>>
>> That would indeed keep the proposed ABI workable, what I'm still
>> not liking is that this buffer is in-kernel, but I guess that
>> might be something for other people to have an opinion on.
>
>Hm. Wrt. the ABI, wouldnt it make more sense to expose this PMU
>feature via perfcounters: a sampling hw-branch-executions counter,
>with interval=1.
>
>That would give the exact existing semantics, plus a lot lot more.
>Markus?

What more would we get?

I take it that you don't want to implement branch tracing via PEBS,
which would be possible but rather inefficient since the BTS format
is much more compact than the PEBS format.

So we would still implement it via BTS and we would still like to present
a branch trace specific format to the user.

Are you suggesting to use a common ABI for sampling and branch tracing?

The existing ABI is tailored towards the expected users: debuggers.
I do believe that a ptrace based interface makes a lot of sense for
this debugging-related feature, since debuggers already speak ptrace.

Branch tracing and sampling are used by different classes of user-mode
applications. I don't think that a common ABI would benefit user-mode.
Since we do need different implementations in the kernel, I don't see
how a common ABI would help here, either.


I rather see this as two independent, unrelated hardware features that
happen to use the same technique to allow arbitrary-sized buffers and
that therefore share some hardware real-estate.


regards,
markus.

---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

2009-06-11 21:41:46

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"


* Metzger, Markus T <[email protected]> wrote:

> >-----Original Message-----
> >From: Ingo Molnar [mailto:[email protected]]
> >Sent: Thursday, June 11, 2009 12:22 PM
> >To: Peter Zijlstra
> >Cc: Metzger, Markus T; [email protected]; [email protected]; [email protected]; [email protected];
> >[email protected]; [email protected]
> >Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
> >
> >
> >* Peter Zijlstra <[email protected]> wrote:
> >
> >> On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
> >> > >-----Original Message-----
> >> > >From: tip-bot for Ingo Molnar [mailto:[email protected]]
> >> > >Sent: Thursday, June 11, 2009 1:37 AM
> >> > >To: [email protected]
> >> > >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
> >> > >[email protected]; [email protected]
> >> > >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
> >> > >
> >> > >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
> >> > >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
> >> > >Author: Ingo Molnar <[email protected]>
> >> > >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
> >> > >Committer: Ingo Molnar <[email protected]>
> >> > >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
> >> > >
> >> > >Revert "x86, bts: reenable ptrace branch trace support"
> >> > >
> >> > >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
> >> > >
> >> > >A late objection to the ABI has arrived:
> >> > >
> >> > > http://lkml.org/lkml/2009/6/10/253
> >> >
> >> > I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
> >> >
> >> > Peters concerns were that Debug Store details are exposed to user space, which is
> >> > not the case. Debug Store itself is fully in-kernel and the expectation of a
> >> > user-defined buffer can be implemented on top of the Debug Store changes that
> >> > Peter expects are needed to support PEBS.
> >> >
> >> > A user-defined trace buffer size is required to support
> >> > different usage models. Some users only need a small amount of
> >> > trace, whereas others need a big amount. The interface will have
> >> > to reflect that in some way.
> >>
> >> Right, your last email did explain how we could keep per task
> >> in-kernel buffers and fill them from the DS and still have them of
> >> user-specified size.
> >>
> >> That would indeed keep the proposed ABI workable, what I'm still
> >> not liking is that this buffer is in-kernel, but I guess that
> >> might be something for other people to have an opinion on.
> >
> > Hm. Wrt. the ABI, wouldnt it make more sense to expose this PMU
> > feature via perfcounters: a sampling hw-branch-executions
> > counter, with interval=1.
> >
> > That would give the exact existing semantics, plus a lot lot
> > more. Markus?
>
> What more would we get?

There's numerous direct functionality advantages:

- We will get all the sampling features of perfcounters such as
timed samples, CPU ID samples. Some will be approximate (timing),
some precise (CPU ID).

- We will get the advanced workflow isolation features: we could
sample on a per CPU basis (system-wide BTS), and we could sample
child tasks automatically. The current code is limited to a
single task.

- We will sample other types of information into the same outgoing
event buffer: for example branch-miss events, intermixed with BTS
records. This could help not just the narrow purpose of
debugging, but also the purpose of performance analysis.

- There's a rich and fast/efficient VFS based APIs to wait for
event overflows: poll(), read(), mmap().

- Remote sampling via perfcounters is transparent, while ptrace
sampling can be seen by apps.

There's maintenance advantages as well from the x86 architecture and
scheduler maintenance point of view:

- We would have a single facility handling the Debug Store, and
we'd have almost all pieces in place for PEBS support in
perfcounters as well so there's good synergy.

There are performance advantages as well:

- There's lazy-switching optimizations in perfcounters avoiding the
DS buffer switching overhead.

> I take it that you don't want to implement branch tracing via
> PEBS, which would be possible but rather inefficient since the BTS
> format is much more compact than the PEBS format.

Sampling could be done via PEBS too, if someone wants to take
advantage of the instruction latency field for example on Nehalem.

But yes, i agree that for the simple case of
branch-executions+period=1 case we want that to use BTS, as those
records are a lot more compact than the all-general-purpose-regs
bloated records of PEBS.

> So we would still implement it via BTS and we would still like to
> present a branch trace specific format to the user.
>
> Are you suggesting to use a common ABI for sampling and branch
> tracing?

Yes, that makes sense.

> The existing ABI is tailored towards the expected users:
> debuggers. I do believe that a ptrace based interface makes a lot
> of sense for this debugging-related feature, since debuggers
> already speak ptrace.
>
> Branch tracing and sampling are used by different classes of
> user-mode applications. I don't think that a common ABI would
> benefit user-mode. Since we do need different implementations in
> the kernel, I don't see how a common ABI would help here, either.
>
> I rather see this as two independent, unrelated hardware features
> that happen to use the same technique to allow arbitrary-sized
> buffers and that therefore share some hardware real-estate.

I'd rather not maintain two separate pieces of infrastructure and
ABIs.

We had a _lot_ of problems with the BTS code, and there's still that
unresolved crash from akpm. (i too reported crashes in the past)

That is the problem with such rarely used ABIs: almost nobody tests
them.

With perfcounters that dynamics changes quite profoundly: the DS and
the overflow handling will be used for PEBS anyway, so there's good
overlap and good sharing in facilities.

Ingo

2009-06-12 11:05:23

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

>-----Original Message-----
>From: Ingo Molnar [mailto:[email protected]]
>Sent: Thursday, June 11, 2009 11:41 PM
>To: Metzger, Markus T
>Cc: Peter Zijlstra; [email protected]; [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]
>Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>
>* Metzger, Markus T <[email protected]> wrote:
>
>> >-----Original Message-----
>> >From: Ingo Molnar [mailto:[email protected]]
>> >Sent: Thursday, June 11, 2009 12:22 PM
>> >To: Peter Zijlstra
>> >Cc: Metzger, Markus T; [email protected]; [email protected]; [email protected];
>[email protected];
>> >[email protected]; [email protected]
>> >Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>> >
>> >
>> >* Peter Zijlstra <[email protected]> wrote:
>> >
>> >> On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
>> >> > >-----Original Message-----
>> >> > >From: tip-bot for Ingo Molnar [mailto:[email protected]]
>> >> > >Sent: Thursday, June 11, 2009 1:37 AM
>> >> > >To: [email protected]
>> >> > >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T; [email protected];
>> >> > >[email protected]; [email protected]
>> >> > >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>> >> > >
>> >> > >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
>> >> > >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
>> >> > >Author: Ingo Molnar <[email protected]>
>> >> > >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
>> >> > >Committer: Ingo Molnar <[email protected]>
>> >> > >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
>> >> > >
>> >> > >Revert "x86, bts: reenable ptrace branch trace support"
>> >> > >
>> >> > >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
>> >> > >
>> >> > >A late objection to the ABI has arrived:
>> >> > >
>> >> > > http://lkml.org/lkml/2009/6/10/253
>> >> >
>> >> > I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
>> >> >
>> >> > Peters concerns were that Debug Store details are exposed to user space, which is
>> >> > not the case. Debug Store itself is fully in-kernel and the expectation of a
>> >> > user-defined buffer can be implemented on top of the Debug Store changes that
>> >> > Peter expects are needed to support PEBS.
>> >> >
>> >> > A user-defined trace buffer size is required to support
>> >> > different usage models. Some users only need a small amount of
>> >> > trace, whereas others need a big amount. The interface will have
>> >> > to reflect that in some way.
>> >>
>> >> Right, your last email did explain how we could keep per task
>> >> in-kernel buffers and fill them from the DS and still have them of
>> >> user-specified size.
>> >>
>> >> That would indeed keep the proposed ABI workable, what I'm still
>> >> not liking is that this buffer is in-kernel, but I guess that
>> >> might be something for other people to have an opinion on.
>> >
>> > Hm. Wrt. the ABI, wouldnt it make more sense to expose this PMU
>> > feature via perfcounters: a sampling hw-branch-executions
>> > counter, with interval=1.
>> >
>> > That would give the exact existing semantics, plus a lot lot
>> > more. Markus?
>>
>> What more would we get?
>
>There's numerous direct functionality advantages:
>
> - We will get all the sampling features of perfcounters such as
> timed samples, CPU ID samples. Some will be approximate (timing),
> some precise (CPU ID).
>
> - We will get the advanced workflow isolation features: we could
> sample on a per CPU basis (system-wide BTS), and we could sample
> child tasks automatically. The current code is limited to a
> single task.
>
> - We will sample other types of information into the same outgoing
> event buffer: for example branch-miss events, intermixed with BTS
> records. This could help not just the narrow purpose of
> debugging, but also the purpose of performance analysis.
>
> - There's a rich and fast/efficient VFS based APIs to wait for
> event overflows: poll(), read(), mmap().
>
> - Remote sampling via perfcounters is transparent, while ptrace
> sampling can be seen by apps.
>
>There's maintenance advantages as well from the x86 architecture and
>scheduler maintenance point of view:
>
> - We would have a single facility handling the Debug Store, and
> we'd have almost all pieces in place for PEBS support in
> perfcounters as well so there's good synergy.

I'm not exactly sure what you are proposing.

There currently is a single facility handling Debug Store which is used
by perfmon for PEBS sampling and by BTS for branch tracing. The ptrace
interface is a thin layer that allows debuggers to easily access the
part that is relevant for them.


Are you proposing a single abstraction of sampling and branch tracing events
using records of different sizes in one big stream?

regards,
markus.

---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

2009-06-18 10:24:41

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

>-----Original Message-----
>From: Metzger, Markus T
>Sent: Friday, June 12, 2009 1:05 PM
>To: Ingo Molnar
>Cc: Peter Zijlstra; [email protected]; [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]
>Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>>-----Original Message-----
>>From: Ingo Molnar [mailto:[email protected]]
>>Sent: Thursday, June 11, 2009 11:41 PM
>>To: Metzger, Markus T
>>Cc: Peter Zijlstra; [email protected]; [email protected]; [email protected]; [email protected];
>>[email protected]; [email protected]
>>Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>
>>
>>* Metzger, Markus T <[email protected]> wrote:
>>
>>> >-----Original Message-----
>>> >From: Ingo Molnar [mailto:[email protected]]
>>> >Sent: Thursday, June 11, 2009 12:22 PM
>>> >To: Peter Zijlstra
>>> >Cc: Metzger, Markus T; [email protected]; [email protected]; [email protected];
>>[email protected];
>>> >[email protected]; [email protected]
>>> >Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>> >
>>> >
>>> >* Peter Zijlstra <[email protected]> wrote:
>>> >
>>> >> On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
>>> >> > >-----Original Message-----
>>> >> > >From: tip-bot for Ingo Molnar [mailto:[email protected]]
>>> >> > >Sent: Thursday, June 11, 2009 1:37 AM
>>> >> > >To: [email protected]
>>> >> > >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T;
>[email protected];
>>> >> > >[email protected]; [email protected]
>>> >> > >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>> >> > >
>>> >> > >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
>>> >> > >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
>>> >> > >Author: Ingo Molnar <[email protected]>
>>> >> > >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
>>> >> > >Committer: Ingo Molnar <[email protected]>
>>> >> > >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
>>> >> > >
>>> >> > >Revert "x86, bts: reenable ptrace branch trace support"
>>> >> > >
>>> >> > >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
>>> >> > >
>>> >> > >A late objection to the ABI has arrived:
>>> >> > >
>>> >> > > http://lkml.org/lkml/2009/6/10/253
>>> >> >
>>> >> > I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
>>> >> >
>>> >> > Peters concerns were that Debug Store details are exposed to user space, which is
>>> >> > not the case. Debug Store itself is fully in-kernel and the expectation of a
>>> >> > user-defined buffer can be implemented on top of the Debug Store changes that
>>> >> > Peter expects are needed to support PEBS.
>>> >> >
>>> >> > A user-defined trace buffer size is required to support
>>> >> > different usage models. Some users only need a small amount of
>>> >> > trace, whereas others need a big amount. The interface will have
>>> >> > to reflect that in some way.
>>> >>
>>> >> Right, your last email did explain how we could keep per task
>>> >> in-kernel buffers and fill them from the DS and still have them of
>>> >> user-specified size.
>>> >>
>>> >> That would indeed keep the proposed ABI workable, what I'm still
>>> >> not liking is that this buffer is in-kernel, but I guess that
>>> >> might be something for other people to have an opinion on.
>>> >
>>> > Hm. Wrt. the ABI, wouldnt it make more sense to expose this PMU
>>> > feature via perfcounters: a sampling hw-branch-executions
>>> > counter, with interval=1.
>>> >
>>> > That would give the exact existing semantics, plus a lot lot
>>> > more. Markus?
>>>
>>> What more would we get?
>>
>>There's numerous direct functionality advantages:
>>
>> - We will get all the sampling features of perfcounters such as
>> timed samples, CPU ID samples. Some will be approximate (timing),
>> some precise (CPU ID).
>>
>> - We will get the advanced workflow isolation features: we could
>> sample on a per CPU basis (system-wide BTS), and we could sample
>> child tasks automatically. The current code is limited to a
>> single task.
>>
>> - We will sample other types of information into the same outgoing
>> event buffer: for example branch-miss events, intermixed with BTS
>> records. This could help not just the narrow purpose of
>> debugging, but also the purpose of performance analysis.
>>
>> - There's a rich and fast/efficient VFS based APIs to wait for
>> event overflows: poll(), read(), mmap().
>>
>> - Remote sampling via perfcounters is transparent, while ptrace
>> sampling can be seen by apps.
>>
>>There's maintenance advantages as well from the x86 architecture and
>>scheduler maintenance point of view:
>>
>> - We would have a single facility handling the Debug Store, and
>> we'd have almost all pieces in place for PEBS support in
>> perfcounters as well so there's good synergy.
>
>I'm not exactly sure what you are proposing.
>
>There currently is a single facility handling Debug Store which is used
>by perfmon for PEBS sampling and by BTS for branch tracing. The ptrace
>interface is a thin layer that allows debuggers to easily access the
>part that is relevant for them.
>
>
>Are you proposing a single abstraction of sampling and branch tracing events
>using records of different sizes in one big stream?

Ingo,

I did not hear from you.
Could you be a bit more specific about what you have in mind regarding this?

regards,
markus.
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

2009-06-24 13:10:27

by Metzger, Markus T

[permalink] [raw]
Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"

Ingo,

I did not hear from you.

If you have further concerns regarding the ABI, would you please continue the discussion.
If you don't have further concerns, would you please reenable the feature.

thanks and regards,
markus.


>-----Original Message-----
>From: Metzger, Markus T
>Sent: Thursday, June 18, 2009 12:24 PM
>To: Ingo Molnar
>Cc: Peter Zijlstra; [email protected]; [email protected]; [email protected]; [email protected];
>[email protected]; [email protected]
>Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>
>>-----Original Message-----
>>From: Metzger, Markus T
>>Sent: Friday, June 12, 2009 1:05 PM
>>To: Ingo Molnar
>>Cc: Peter Zijlstra; [email protected]; [email protected]; [email protected]; [email protected];
>>[email protected]; [email protected]
>>Subject: RE: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>
>>>-----Original Message-----
>>>From: Ingo Molnar [mailto:[email protected]]
>>>Sent: Thursday, June 11, 2009 11:41 PM
>>>To: Metzger, Markus T
>>>Cc: Peter Zijlstra; [email protected]; [email protected]; [email protected]; [email protected];
>>>[email protected]; [email protected]
>>>Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>>
>>>
>>>* Metzger, Markus T <[email protected]> wrote:
>>>
>>>> >-----Original Message-----
>>>> >From: Ingo Molnar [mailto:[email protected]]
>>>> >Sent: Thursday, June 11, 2009 12:22 PM
>>>> >To: Peter Zijlstra
>>>> >Cc: Metzger, Markus T; [email protected]; [email protected]; [email protected];
>>>[email protected];
>>>> >[email protected]; [email protected]
>>>> >Subject: Re: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>>> >
>>>> >
>>>> >* Peter Zijlstra <[email protected]> wrote:
>>>> >
>>>> >> On Thu, 2009-06-11 at 07:30 +0100, Metzger, Markus T wrote:
>>>> >> > >-----Original Message-----
>>>> >> > >From: tip-bot for Ingo Molnar [mailto:[email protected]]
>>>> >> > >Sent: Thursday, June 11, 2009 1:37 AM
>>>> >> > >To: [email protected]
>>>> >> > >Cc: [email protected]; [email protected]; [email protected]; Metzger, Markus T;
>>[email protected];
>>>> >> > >[email protected]; [email protected]
>>>> >> > >Subject: [tip:tracing/core] Revert "x86, bts: reenable ptrace branch trace support"
>>>> >> > >
>>>> >> > >Commit-ID: 511b01bdf64ad8a38414096eab283c7784aebfc4
>>>> >> > >Gitweb: http://git.kernel.org/tip/511b01bdf64ad8a38414096eab283c7784aebfc4
>>>> >> > >Author: Ingo Molnar <[email protected]>
>>>> >> > >AuthorDate: Thu, 11 Jun 2009 00:32:00 +0200
>>>> >> > >Committer: Ingo Molnar <[email protected]>
>>>> >> > >CommitDate: Thu, 11 Jun 2009 00:32:00 +0200
>>>> >> > >
>>>> >> > >Revert "x86, bts: reenable ptrace branch trace support"
>>>> >> > >
>>>> >> > >This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
>>>> >> > >
>>>> >> > >A late objection to the ABI has arrived:
>>>> >> > >
>>>> >> > > http://lkml.org/lkml/2009/6/10/253
>>>> >> >
>>>> >> > I thought that this has been resolved. See for example http://lkml.org/lkml/2009/6/10/257.
>>>> >> >
>>>> >> > Peters concerns were that Debug Store details are exposed to user space, which is
>>>> >> > not the case. Debug Store itself is fully in-kernel and the expectation of a
>>>> >> > user-defined buffer can be implemented on top of the Debug Store changes that
>>>> >> > Peter expects are needed to support PEBS.
>>>> >> >
>>>> >> > A user-defined trace buffer size is required to support
>>>> >> > different usage models. Some users only need a small amount of
>>>> >> > trace, whereas others need a big amount. The interface will have
>>>> >> > to reflect that in some way.
>>>> >>
>>>> >> Right, your last email did explain how we could keep per task
>>>> >> in-kernel buffers and fill them from the DS and still have them of
>>>> >> user-specified size.
>>>> >>
>>>> >> That would indeed keep the proposed ABI workable, what I'm still
>>>> >> not liking is that this buffer is in-kernel, but I guess that
>>>> >> might be something for other people to have an opinion on.
>>>> >
>>>> > Hm. Wrt. the ABI, wouldnt it make more sense to expose this PMU
>>>> > feature via perfcounters: a sampling hw-branch-executions
>>>> > counter, with interval=1.
>>>> >
>>>> > That would give the exact existing semantics, plus a lot lot
>>>> > more. Markus?
>>>>
>>>> What more would we get?
>>>
>>>There's numerous direct functionality advantages:
>>>
>>> - We will get all the sampling features of perfcounters such as
>>> timed samples, CPU ID samples. Some will be approximate (timing),
>>> some precise (CPU ID).
>>>
>>> - We will get the advanced workflow isolation features: we could
>>> sample on a per CPU basis (system-wide BTS), and we could sample
>>> child tasks automatically. The current code is limited to a
>>> single task.
>>>
>>> - We will sample other types of information into the same outgoing
>>> event buffer: for example branch-miss events, intermixed with BTS
>>> records. This could help not just the narrow purpose of
>>> debugging, but also the purpose of performance analysis.
>>>
>>> - There's a rich and fast/efficient VFS based APIs to wait for
>>> event overflows: poll(), read(), mmap().
>>>
>>> - Remote sampling via perfcounters is transparent, while ptrace
>>> sampling can be seen by apps.
>>>
>>>There's maintenance advantages as well from the x86 architecture and
>>>scheduler maintenance point of view:
>>>
>>> - We would have a single facility handling the Debug Store, and
>>> we'd have almost all pieces in place for PEBS support in
>>> perfcounters as well so there's good synergy.
>>
>>I'm not exactly sure what you are proposing.
>>
>>There currently is a single facility handling Debug Store which is used
>>by perfmon for PEBS sampling and by BTS for branch tracing. The ptrace
>>interface is a thin layer that allows debuggers to easily access the
>>part that is relevant for them.
>>
>>
>>Are you proposing a single abstraction of sampling and branch tracing events
>>using records of different sizes in one big stream?
>
>Ingo,
>
>I did not hear from you.
>Could you be a bit more specific about what you have in mind regarding this?
>
>regards,
>markus.
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.