Commit Graph

148 Commits

Author SHA1 Message Date
Ingo Molnar cdd6c482c9 perf: Do the big rename: Performance Counters -> Performance Events
Bye-bye Performance Counters, welcome Performance Events!

In the past few months the perfcounters subsystem has grown out its
initial role of counting hardware events, and has become (and is
becoming) a much broader generic event enumeration, reporting, logging,
monitoring, analysis facility.

Naming its core object 'perf_counter' and naming the subsystem
'perfcounters' has become more and more of a misnomer. With pending
code like hw-breakpoints support the 'counter' name is less and
less appropriate.

All in one, we've decided to rename the subsystem to 'performance
events' and to propagate this rename through all fields, variables
and API names. (in an ABI compatible fashion)

The word 'event' is also a bit shorter than 'counter' - which makes
it slightly more convenient to write/handle as well.

Thanks goes to Stephane Eranian who first observed this misnomer and
suggested a rename.

User-space tooling and ABI compatibility is not affected - this patch
should be function-invariant. (Also, defconfigs were not touched to
keep the size down.)

This patch has been generated via the following script:

  FILES=$(find * -type f | grep -vE 'oprofile|[^K]config')

  sed -i \
    -e 's/PERF_EVENT_/PERF_RECORD_/g' \
    -e 's/PERF_COUNTER/PERF_EVENT/g' \
    -e 's/perf_counter/perf_event/g' \
    -e 's/nb_counters/nb_events/g' \
    -e 's/swcounter/swevent/g' \
    -e 's/tpcounter_event/tp_event/g' \
    $FILES

  for N in $(find . -name perf_counter.[ch]); do
    M=$(echo $N | sed 's/perf_counter/perf_event/g')
    mv $N $M
  done

  FILES=$(find . -name perf_event.*)

  sed -i \
    -e 's/COUNTER_MASK/REG_MASK/g' \
    -e 's/COUNTER/EVENT/g' \
    -e 's/\<event\>/event_id/g' \
    -e 's/counter/event/g' \
    -e 's/Counter/Event/g' \
    $FILES

... to keep it as correct as possible. This script can also be
used by anyone who has pending perfcounters patches - it converts
a Linux kernel tree over to the new naming. We tried to time this
change to the point in time where the amount of pending patches
is the smallest: the end of the merge window.

Namespace clashes were fixed up in a preparatory patch - and some
stylistic fallout will be fixed up in a subsequent patch.

( NOTE: 'counters' are still the proper terminology when we deal
  with hardware registers - and these sed scripts are a bit
  over-eager in renaming them. I've undone some of that, but
  in case there's something left where 'counter' would be
  better than 'event' we can undo that on an individual basis
  instead of touching an otherwise nicely automated patch. )

Suggested-by: Stephane Eranian <eranian@google.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <linux-arch@vger.kernel.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-09-21 14:28:04 +02:00
Andrew Morton 4680e64a88 arch/x86/oprofile/op_model_amd.c: fix op_amd_handle_ibs() return type
arch/x86/oprofile/op_model_amd.c: In function 'op_amd_handle_ibs':
arch/x86/oprofile/op_model_amd.c:217: warning: no return statement in function returning non-void

Fix this by making op_amd_handle_ibs() return void.

Cc: Robert Richter <robert.richter@amd.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-08-04 16:02:01 +02:00
Robert Richter 54a0bf3c2c Revert "x86: oprofile/op_model_amd.c set return values for op_amd_handle_ibs()"
This reverts commit 21e7087821.

Instead Andrew's patch will be applied he posted at the same time.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-08-04 15:53:36 +02:00
Robert Richter c550091edd x86/oprofile: Small coding style fixes
Some small coding style fixes.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:22 +02:00
Robert Richter 11be1a7b54 x86/oprofile: Add counter reservation check for virtual counters
This patch adds a check for the availability of a counter. A virtual
counter is used only if its physical counter is not reserved.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 61d149d524 x86/oprofile: Implement op_x86_virt_to_phys()
This patch implements a common x86 function to convert virtual counter
numbers to physical.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 1b294f5960 oprofile: Adding switch counter to oprofile statistic variables
This patch moves the multiplexing switch counter from x86 code to
common oprofile statistic variables. Now the value will be available
and usable for all architectures. The initialization and
incrementation also moved to common code.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 4d015f79e9 x86/oprofile: Implement mux_clone()
To setup a counter for all cpus, its structure is cloned from cpu
0. This patch implements mux_clone() to do this part for multiplexing
data.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 5280514471 x86/oprofile: Enable multiplexing only if the model supports it
This patch checks if the model supports multiplexing. Only then
multiplexing will be enabled. The code is added to the common x86
initialization.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 39e97f40c3 x86/oprofile: Add function has_mux() to check multiplexing support
The check is used to prevent running multiplexing code for models not
supporting multiplexing. Before, the code was running but without
effect.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 52471c67ee x86/oprofile: Modify initialization of num_virt_counters
Models that do not yet support counter multiplexing have to setup
num_virt_counters. This patch implements the setup from num_counters
if num_virt_counters is not set. Thus, num_virt_counters must be setup
only for multiplexing support.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:21 +02:00
Robert Richter 2904a52757 x86/oprofile: Remove unused num_virt_controls from struct op_x86_model_spec
The member num_virt_controls of struct op_x86_model_spec is not
used. This patch removes it.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:20 +02:00
Robert Richter 259a83a8ab x86/oprofile: Remove const qualifier from struct op_x86_model_spec
This patch removes the const qualifier from struct
op_x86_model_spec to make model parameters changable.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:20 +02:00
Robert Richter b28d1b923a x86/oprofile: Moving nmi_cpu_switch() in nmi_int.c
This patch moves some code in nmi_int.c to get a single separate
multiplexing code section.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:20 +02:00
Robert Richter d0f585dd20 x86/oprofile: Moving nmi_cpu_save/restore_mpx_registers() in nmi_int.c
This patch moves some code in nmi_int.c to get a single separate
multiplexing code section.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:20 +02:00
Robert Richter 48fb4b4671 x86/oprofile: Moving nmi_setup_cpu_mux() in nmi_int.c
This patch moves some code in nmi_int.c to get a single separate
multiplexing code section.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:20 +02:00
Robert Richter 6ab82f958a x86/oprofile: Implement multiplexing setup/shutdown functions
This patch implements nmi_setup_mux() and nmi_shutdown_mux() functions
to setup/shutdown multiplexing. Multiplexing code in nmi_int.c is now
much more separated.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:20 +02:00
Robert Richter 7e7478c6bc oprofile: Grouping multiplexing code in op_model_amd.c
This patch moves some multiplexing code to the new function
op_mux_fill_in_addresses(). Also, the whole multiplexing code is now
at a single location.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:19 +02:00
Robert Richter d8471ad3ab oprofile: Introduce op_x86_phys_to_virt()
This new function translates physical to virtual counter numbers.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:19 +02:00
Robert Richter 6bfccd099c x86/oprofile: Fix initialization of switch_index
Variable switch_index must be initialized for each cpu. This patch
fixes the initialization by moving it to the per-cpu init function
nmi_cpu_setup().

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:18 +02:00
Robert Richter 82a225283f x86/oprofile: Use per_cpu() instead of __get_cpu_var()
__get_cpu_var() calls smp_processor_id(). When the cpu id is already
known, instead use per_cpu() to avoid generating the id again.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:18 +02:00
Robert Richter 5e766e3e43 x86/oprofile: Fix usage of NUM_CONTROLS/NUM_COUNTERS macros
Use the corresponding macros when iterating over counter and control
registers. Since NUM_CONTROLS and NUM_COUNTERS are equal for AMD cpus
the fix is more a cosmetical change.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:43:18 +02:00
Jason Yeh 4d4036e0e7 oprofile: Implement performance counter multiplexing
The number of hardware counters is limited. The multiplexing feature
enables OProfile to gather more events than counters are provided by
the hardware. This is realized by switching between events at an user
specified time interval.

A new file (/dev/oprofile/time_slice) is added for the user to specify
the timer interval in ms. If the number of events to profile is higher
than the number of hardware counters available, the patch will
schedule a work queue that switches the event counter and re-writes
the different sets of values into it. The switching mechanism needs to
be implemented for each architecture to support multiplexing. This
patch only implements AMD CPU support, but multiplexing can be easily
extended for other models and architectures.

There are follow-on patches that rework parts of this patch.

Signed-off-by: Jason Yeh <jason.yeh@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20 16:33:53 +02:00
Robert Richter 6e63ea4b0b x86/oprofile: Whitespaces changes only
This patch fixes whitespace changes of code that will be touched in
follow-on patches.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-14 16:44:51 +02:00
Robert Richter 44ab9a6b0e x86/oprofile: Rework and simplify nmi_cpu_setup()
This patch removes the function nmi_save_registers(). Per-cpu code is
now executed only in the function nmi_cpu_setup().  Also, it renames
the per-cpu function nmi_restore_registers() to
nmi_cpu_restore_registers().

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-14 16:44:51 +02:00
Robert Richter 8045a4c293 x86/oprofile: Fix cast of counter value
When casting the counter value to a 64 bit value in 32 bit mode, sign
extension may lead to broken counter values. This patch fixes this by
casting to (u64) instead of (s64).

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-14 15:30:03 +02:00
Robert Richter debc6a6927 Merge commit 'v2.6.31-rc3'; commit 'tip/oprofile' into oprofile/core
Conflicts:
	drivers/oprofile/oprofile_stats.c
	drivers/usb/otg/Kconfig
	drivers/usb/otg/Makefile

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-14 15:20:44 +02:00
Robert Richter 8d7ff4f2a0 x86/oprofile: rename kernel parameter for architectural perfmon to arch_perfmon
The short name of the achitecture is 'arch_perfmon'. This patch
changes the kernel parameter to use this name.

Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-07-10 05:22:50 +02:00
Jaswinder Singh Rajput 21e7087821 x86: oprofile/op_model_amd.c set return values for op_amd_handle_ibs()
op_amd_handle_ibs() should return 0 when IBS is not present or not defined.

Fix compilation warning:
 CC [M]  arch/x86/oprofile/op_model_amd.o
 arch/x86/oprofile/op_model_amd.c: In function ‘op_amd_handle_ibs’:
 arch/x86/oprofile/op_model_amd.c:217: warning: no return statement in function returning non-void

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-18 16:44:38 +02:00
Robert Richter 802070f547 x86/oprofile: fix initialization of arch_perfmon for core_i7
Commit:

 e419294 x86/oprofile: moving arch_perfmon counter setup to op_x86_model_spec.init

introduced a bug in the initialization of core_i7 leading to the
incorrect model setup to &op_ppro_spec. This patch fixes this.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-12 18:43:51 +02:00
Robert Richter 1241eb8f13 Merge commit 'tip/perfcounters-for-linus' into oprofile/master
Conflicts:
	arch/x86/oprofile/op_model_ppro.c

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-12 17:58:48 +02:00
Robert Richter 51563a0e56 x86/oprofile: introduce oprofile_add_data64()
The IBS implemention writes 64 bit register values to the cpu buffer
by writing two 32 values using oprofile_add_data(). This patch
introduces oprofile_add_data64() to write a single 64 bit value to the
buffer.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 20:16:00 +02:00
Robert Richter c572ae4efd x86/oprofile: use 64 bit values in IBS functions
The IBS code internally uses 32 bit values (a low and a high value) to
represent a 64 bit value. This patch changes this and now 64 bit
values are used instead. 64 bit MSR functions can be used now.

No functional changes.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 20:16:00 +02:00
Robert Richter 1a245c4534 x86/oprofile: remove some local variables in MSR save/restore functions
The patch removes some local variables in these functions.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 20:15:28 +02:00
Robert Richter 95e74e62c1 x86/oprofile: use 64 bit values to save MSR states
This patch removes struct op_saved_msr and replaces it by an u64
variable. This makes code easier and it is possible to use 64 bit MSR
functions.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 20:12:57 +02:00
Robert Richter bbc5986d2d x86/oprofile: use 64 bit wrmsr functions
This patch replaces some wrmsr() functions with wrmsrl().

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:17 +02:00
Robert Richter 217d3cfb95 x86/oprofile: replace CTR*_IS_RESERVED macros
The patch replaces all CTR*_IS_RESERVED macros.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:16 +02:00
Robert Richter dea3766ca0 x86/oprofile: replace CTRL_SET_*ACTIVE macros
The patch replaces all CTRL_SET_*ACTIVE macros. 64 bit MSR functions
and 64 bit counter values are used now. The code uses bit masks from
<asm/intel_arch_perfmon.h>.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:15 +02:00
Robert Richter 42399adb23 x86/oprofile: replace CTR_OVERFLOWED macros
The patch replaces all CTR_OVERFLOWED macros. 64 bit MSR functions and
64 bit counter values are used now. Thus, it will be easier to later
extend the models to use more than 32 bit width counters.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:15 +02:00
Robert Richter 3370d35856 x86/oprofile: replace macros to calculate control register
This patch introduces op_x86_get_ctrl() to calculate the value of the
performance control register. This is generic code usable for all
models. The event and reserved masks are model specific and stored in
struct op_x86_model_spec. 64 bit MSR functions are used now. The patch
removes many hard to read macros used for ctrl calculation.

The function op_x86_get_ctrl() is common code and the first step to
further merge performance counter implementations for x86 models.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:14 +02:00
Robert Richter ef8828ddf8 x86/oprofile: pass the model to setup_ctrs() functions
In follow-on patches the setup_ctrs() functions will need data that
describes the model. This patch extends the function argument list to
pass a pointer of the model to these function.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:14 +02:00
Robert Richter 9c59354b48 x86/oprofile: remove unused macros for AMD virtualization profiling
The use of the macros has no effect. The oprofilefs has to be extended
first to support these features.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:13 +02:00
Robert Richter ec064c093e x86/oprofile: fix and cleanup CTRL_SET_* macros
This patch fixes missing braces around macro parameters. Macro
definitions from intel_arch_perfmon.h are used where possible.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:13 +02:00
Robert Richter 1131a47824 x86/oprofile: remove MSR macros for p4 cpus
The macros CTRL_READ() and CTRL_WRITE() make the code hard to read and
maintain. This patch replaces them by rdmsr()/wrmsr() functions and
simplifies the code.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:12 +02:00
Robert Richter 74c9a5c341 x86/oprofile: remove MSR macros for ppro cpus
The macros CTRL_READ() and CTRL_WRITE() make the code hard to read and
maintain. This patch replaces them by rdmsr()/wrmsr() functions and
simplifies the code.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:11 +02:00
Robert Richter d2731a4387 x86/oprofile: remove MSR macros for AMD cpus
The macros CTRL_READ() and CTRL_WRITE() make the code hard to read and
maintain. This patch replaces them by rdmsr()/wrmsr() functions and
simplifies the code.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:11 +02:00
Robert Richter ff9faa8b67 x86/oprofile: move common macros to op_x86_model.h
There are duplicate macro implementations in model specific code. This
patch moves all common macros to op_x86_model.h.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:42:10 +02:00
Robert Richter d20f24c660 x86/oprofile: simplify AMD cpu init code
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 19:41:50 +02:00
Ingo Molnar 940010c5a3 Merge branch 'linus' into perfcounters/core
Conflicts:
	arch/x86/kernel/irqinit.c
	arch/x86/kernel/irqinit_64.c
	arch/x86/kernel/traps.c
	arch/x86/mm/fault.c
	include/linux/sched.h
	kernel/exit.c
2009-06-11 17:55:42 +02:00
Robert Richter 9063759540 x86/oprofile: remove #ifdefs in ibs functions
IBS code is moved to separate functions. This allows the removal
of #ifdefs in functions.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 16:10:13 +02:00