public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* RE: Proposed systemtap access to perfmon hardware
@ 2006-03-22 23:23 Stone, Joshua I
  0 siblings, 0 replies; 18+ messages in thread
From: Stone, Joshua I @ 2006-03-22 23:23 UTC (permalink / raw)
  To: fche; +Cc: systemtap

fche@redhat.com wrote:
> joshua wrote:
>>  [...]
>>> If they are started by default, where exactly are they running?
>>> Beginning of begin probe? End of begin probe?
>> 
>> I think the perfmon setup needs to happen before all begin probes, so
>> that the handle can be accessed within begin probes.  [...]
> 
> How important would that be?  At this time, we don't provide any
> ordering guarantees amongst begin/end probes.  If a begin probe would
> have to manipulate the handle, why not put that right into the
> perfctr.*.setup probe directly?

Perhaps it isn't that important - I didn't consider putting the work in
the ".setup" probe.  This is fine as long as the setup probe has the
guarantee that the counters haven't started yet (regardless of its
position in the begin stage)

It might be nice to have a similar shutdown/cleanup/whatever probe that
guarantees that the counters have been stopped.  This is superfluous if
we guarantee that the counters will be stopped before running any end
probes, but I haven't seen discussion on that point yet.  We should also
define when the handle be invalidated - this could be at the conclusion
of the cleanup probe, if it exists, or after all end probes have
completed.


Josh

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Proposed systemtap access to perfmon hardware
@ 2006-03-23 17:09 Stone, Joshua I
  0 siblings, 0 replies; 18+ messages in thread
From: Stone, Joshua I @ 2006-03-23 17:09 UTC (permalink / raw)
  To: William Cohen; +Cc: SystemTAP, Maynard Johnson

William Cohen wrote:
> As far as when the performance counters are set up and torn down it
> seems like it would be most reasonable to set them up before the first
> probe begin action and tear them down after the last probe end action.

I agree

> This would mean for sampling would need to have it stop sampling if
> don't want any additional samples while doing the probe end action.

This should be gated for you by using the session_state.  Begin probes
only run during STAP_SESSION_STARTING, normal probes (including permon
sampling) should only run during STAP_SESSION_RUNNING, and end probes
only run during STAP_SESSION_STOPPING.  If a probe is entered during a
state that doesn't match what it expects, it just returns with out
taking any action.


Josh

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Proposed systemtap access to perfmon hardware
@ 2006-03-22 23:46 Stone, Joshua I
  2006-03-23 12:54 ` Maynard Johnson
  0 siblings, 1 reply; 18+ messages in thread
From: Stone, Joshua I @ 2006-03-22 23:46 UTC (permalink / raw)
  To: maynardj, William Cohen; +Cc: SystemTAP

Maynard Johnson wrote:
> William Cohen wrote:
>> The individual start and stop operations would be allowed.
> This is not so good.  Besides the fact that it may be difficult (or
> impossible) to do, I don't see it being all that useful.  But then,
> I'm a tool developer, not a performance analyst, so I could be
> missing the point.

Enabling start & stop lets you narrow the context that you want to
measure.  Perfmon can only give you thread level virtualization of the
counters.  With start & stop I can, for example, start the counters when
I enter sys_open and stop when I return.  Now if I want I can get a
microbenchmark of IPC for the sys_open call (and its callees).

But this also opens up possibilities for more obscure "contexts" -
perhaps I want to start counting when a network packet is received and
stop when it is delivered to the thread.  Any probepoint you can do
today can become a start/stop point for the counters.


Josh

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Proposed systemtap access to perfmon hardware
@ 2006-03-22 19:09 Stone, Joshua I
  2006-03-22 20:04 ` Frank Ch. Eigler
  0 siblings, 1 reply; 18+ messages in thread
From: Stone, Joshua I @ 2006-03-22 19:09 UTC (permalink / raw)
  To: William Cohen; +Cc: SystemTAP

William Cohen wrote:
> It is and open question what the counters default are; do they start
> running by default or have to be explicitly started.

This could be solved with an extension on the probe declaration.  For
example, the sensible default is probably to start the counters, but we
could allow a ".paused" to override that default.

> If they are started by default, where exactly are they running?
> Beginning of begin probe? End of begin probe?

I think the perfmon setup needs to happen before all begin probes, so
that the handle can be accessed within begin probes.  I don't know that
it really matters when you actually start the counters, but I would lean
towards putting that after.

A side note about handles - it might be useful to add a language
semantic to make it easier to capture handles.  There are actions that
would make sense for handles of other probe types besides perfmon,
especially being able to dynamically enable/disable kprobes and timers.


Josh

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Proposed systemtap access to perfmon hardware
@ 2006-03-15 16:24 William Cohen
  2006-03-15 22:34 ` Frank Ch. Eigler
  2006-03-22  3:34 ` Maynard Johnson
  0 siblings, 2 replies; 18+ messages in thread
From: William Cohen @ 2006-03-15 16:24 UTC (permalink / raw)
  To: SystemTAP

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

I have written up material describing how I would think that systemtap 
could use the performance monitoring hardware. It is a work in progress, 
but I would appreciate people's comments on it.

-Will

[-- Attachment #2: stapperfmon.txt --]
[-- Type: text/plain, Size: 5928 bytes --]

Systemtap Performance Monitoring Hardware Support Proposal

March 15, 2006

Most modern processors have performance monitoring hardware that can
count event such as processor clock cycles, memory references, cache
misses, branches, and branch mispredictions.  The hardware counts can
be used directly to guage the cost of operations or the counts can be
used to trigger sampling to find out where these operations occur in
code.  SystemTap should have the ability to uses this performance
monitoring hardware to indicate what the underlying causes of the
performance problems are.



SYSTEMTAP PERFORMANCE MONITORING API


perfmon_allocate_counter:long (event_spec:string)

All the perfmon_allocate_counter() calls must be in the probe begin
(removing this restrictions will be considered later). A string as
specified in the EVENT SPECIFICATION section describes the event
performance counter configuration. If the configuration is sucessful a
even_handle in the form of a non-zero 64-bit value will be returned. A
zero value indicates that there was a problem with the counter
allocation. This event_handle will be used by other functions to
uniquely identify the counter being used. The counters are not set up
or running until the perfmon_create_context is performed.


perfmon_free_counter:long (event_handle:long)

All perfmon_free_counter() calls must be in the probe end (removing
this restrictions will be considered later). The function returns the
event_handle for a successful free operation and zero for an
unsuccessful operation.


perfmon_create_context:long ()

The perfmon_create_context command sets up the performance monitoring
hardware for the allocated contexts and starts the counters running.
If successful, the function will return zero. If the operation is
unsuccessful because an error code will be returned. This function
should only be used in probe begin. (FIXME list error code returned.)


perfmon_get_counter:long (event_handle:long)

The event_handle passed in indicates which counter to read. The value
is returned as a 64-bit long of the current counter value; the counter
could be either running or stopped.  The return value is undefined for
an invalid event_handle.


perfmon_start_counter:long (event_handle:long)

The event_handle passed in indicates which counter to start. The value
is returned as a 64-bit long of the current counter value.  The return
value is undefined for an invalid event_handle.


perfmon_stop_counter:long (event_handle:long)

The event_handle passed in indicates which counter to stop. The value
is returned as a 64-bit long of the current counter value.  The return
value is undefined for an invalid event_handle.


perfmon_handle_to_string:string (event_handle:long)

The perfmon_handle_to_string operation returns the string used by the
perfmon_allocate_counter to generate the handle.


probe kernel.perfmon.sample(event_handle:long) {/*body*/}

The kernel.perfmon.sample probe indicates the action to implement when
the counter specified by event_handle overflows. This could be
triggered at anytime, so the context information is limited to the
same data available for an asynchronous timer probe.

The event_handle is a global variable in the instrumentation
script. Multiple probes for a particular global variable is allowed.


EVENT SPECIFICATION

The performance monitoring events are specified in strings. The
information at the very least include the event name being monitored
by the counter.  Additional information would include a event mask to
specify subevents, whether to count in kernel or user space, whether
to keep track of counts on a per thread or per CPU basis, and the
interval for the sampling.

(FIXME more detail on the string compositions)


SYSTEMTAP PERFORMANCE HARDWARE ACCESS IMPLEMENTATION

The SystemTap access performance monitoring hardware is planned to be
built on the perfmon2 kernel support. The perfom2 provides reservation
and access to the performance monitoring hardware on ia64, i386, and
PowerPC processors. The perfmon2 support is not yet in the upstream
kernels, but patches are available.

Outline where things are done.

	In Translator:
	   group all probe kernel.perfmon.sample() together

	In perfmon tapset:
	   perfmon_allocate_counter()
	   perfmon_free_counter()
	   perfmon_create_context()
	   perfmon_get_counter()
	   perfmon_start_counter()
	   perfmon_stop_counter()
	   perfmon_handle_to_string()


	On startup (probe begin):
	   if perfmon.sample used, register perfmon custom buffer mechanism
	   The following steps will need some work done in userspace (libpfm):
	   -translate each of the perfmon_allocate_counter into perfmon config
	   -set up the perfmon contexts (either per processor or per pid)
	   -activate the perfmon contexts

	On shutdown (probe end):
	   The following steps will need some work done in userspace (libpfm):
	   -destroy the perfmon contexts
	   -if perfmon.sample used, unregister perfmon custom buffer mechanism

FIXME more details on the proposed implementation.



SYSTEMTAP PERFMON ISSUES

-There are numerous constraints on event setup. It is possible to
 request a configuration that cannot be set up in the performance
 monitoring hardware.

-This mechanism does not provide access to other related information
 provided by the performance monitoring hardware, e.g. the performance
 monitoring registers storing the data address tha caused a cache miss
 on ia64.

-The perfmon clones the context for new threads that have the perfmon
 context set up, but we probably do not want to attach to each
 existing thread and set up the context on it. That is going to be
 relatively expensive.

-Perfmon can either do global or per thread monitoring, but they
 cannot be mixed.


REFERENCES


Stephane Eranian, The perfmon2 interface specification
HP Laboratories, HPL-2004-200(R.1), February 7, 2005.
http://www.hpl.hp.com/techreports/2004/HPL-2004-200R1.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2006-03-23 17:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-22 23:23 Proposed systemtap access to perfmon hardware Stone, Joshua I
  -- strict thread matches above, loose matches on Subject: below --
2006-03-23 17:09 Stone, Joshua I
2006-03-22 23:46 Stone, Joshua I
2006-03-23 12:54 ` Maynard Johnson
2006-03-23 14:46   ` William Cohen
2006-03-22 19:09 Stone, Joshua I
2006-03-22 20:04 ` Frank Ch. Eigler
2006-03-15 16:24 William Cohen
2006-03-15 22:34 ` Frank Ch. Eigler
2006-03-17 16:20   ` William Cohen
2006-03-17 17:10     ` Bill Rugolsky Jr.
2006-03-17 17:34     ` Frank Ch. Eigler
2006-03-17 20:26       ` William Cohen
2006-03-20 17:27         ` Frank Ch. Eigler
2006-03-22  3:34 ` Maynard Johnson
2006-03-22 18:02   ` William Cohen
2006-03-22 22:16     ` Maynard Johnson
2006-03-22 18:30   ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).