linux/include
Paul Mackerras 3b6f9e5cb2 perf_counter: Add support for pinned and exclusive counter groups
Impact: New perf_counter features

A pinned counter group is one that the user wants to have on the CPU
whenever possible, i.e. whenever the associated task is running, for
a per-task group, or always for a per-cpu group.  If the system
cannot satisfy that, it puts the group into an error state where
it is not scheduled any more and reads from it return EOF (i.e. 0
bytes read).  The group can be released from error state and made
readable again using prctl(PR_TASK_PERF_COUNTERS_ENABLE).  When we
have finer-grained enable/disable controls on counters we'll be able
to reset the error state on individual groups.

An exclusive group is one that the user wants to be the only group
using the CPU performance monitor hardware whenever it is on.  The
counter group scheduler will not schedule an exclusive group if there
are already other groups on the CPU and will not schedule other groups
onto the CPU if there is an exclusive group scheduled (that statement
does not apply to groups containing only software counters, which can
always go on and which do not prevent an exclusive group from going on).
With an exclusive group, we will be able to let users program PMU
registers at a low level without the concern that those settings will
perturb other measurements.

Along the way this reorganizes things a little:
- is_software_counter() is moved to perf_counter.h.
- cpuctx->active_oncpu now records the number of hardware counters on
  the CPU, i.e. it now excludes software counters.  Nothing was reading
  cpuctx->active_oncpu before, so this change is harmless.
- A new cpuctx->exclusive field records whether we currently have an
  exclusive group on the CPU.
- counter_sched_out moves higher up in perf_counter.c and gets called
  from __perf_counter_remove_from_context and __perf_counter_exit_task,
  where we used to have essentially the same code.
- __perf_counter_sched_in now goes through the counter list twice, doing
  the pinned counters in the first loop and the non-pinned counters in
  the second loop, in order to give the pinned counters the best chance
  to be scheduled in.

Note that only a group leader can be exclusive or pinned, and that
attribute applies to the whole group.  This avoids some awkwardness in
some corner cases (e.g. where a group leader is closed and the other
group members get added to the context list).  If we want to relax that
restriction later, we can, and it is easier to relax a restriction than
to apply a new one.

This doesn't yet handle the case where a pinned counter is inherited
and goes into error state in the child - the error state is not
propagated up to the parent when the child exits, and arguably it
should.

Signed-off-by: Paul Mackerras <paulus@samba.org>
2009-01-14 21:00:30 +11:00
..
acpi Merge branch 'simplify_PRT' into release 2009-01-09 03:41:08 -05:00
asm-arm
asm-frv NOMMU: Make VMAs per MM as for MMU-mode linux 2009-01-08 12:04:47 +00:00
asm-generic remove linux/hardirq.h from asm-generic/local.h 2009-01-06 15:59:13 -08:00
asm-h8300
asm-m32r NOMMU: Make VMAs per MM as for MMU-mode linux 2009-01-08 12:04:47 +00:00
asm-m68k m68k: introduce asm/swab.h 2009-01-06 18:10:27 -08:00
asm-mn10300 mn10300: introduce asm/swab.h 2009-01-06 18:10:29 -08:00
crypto
drm
keys
linux perf_counter: Add support for pinned and exclusive counter groups 2009-01-14 21:00:30 +11:00
math-emu
media
mtd trivial: fix then -> than typos in comments and documentation 2009-01-06 11:28:06 +01:00
net Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx 2009-01-09 11:52:14 -08:00
pcmcia
rdma
rxrpc
scsi [SCSI] fc transport: restore missing dev_loss_tmo callback to LLDD 2009-01-06 09:43:33 -06:00
sound Merge branch 'topic/asoc' into for-linus 2009-01-06 09:48:51 +01:00
trace
video
xen xen: add xenfs to allow usermode <-> Xen interaction 2009-01-08 08:30:59 -08:00
Kbuild