Commit graph

246 commits

Author SHA1 Message Date
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
Robert Richter 06552ccc36 x86/oprofile: minor style changes in struct op_x86_model_spec
Some vertical alignments. Variables are now located in the beginning
of the struct.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11 16:09:54 +02:00
Linus Torvalds 57eee9ae7b Merge branch 'oprofile-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'oprofile-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  oprofile: introduce module_param oprofile.cpu_type
  oprofile: add support for Core i7 and Atom
  oprofile: remove undocumented oprofile.p4force option
  oprofile: re-add force_arch_perfmon option
2009-06-10 19:51:10 -07:00
Robert Richter e419294ed3 x86/oprofile: moving arch_perfmon counter setup to op_x86_model_spec.init
The function arch_perfmon_init() in nmi_int.c is model specific. This
patch moves it to op_model_ppro.c by using the init function pointer
in struct op_x86_model_spec.

Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-10 22:09:24 +02:00
Robert Richter 849620fab4 Revert "oprofile: discover counters for op ppro too"
This reverts commit 59512900ba.

arch_perfmon_setup_counters() is actually never called for ppro, so
there is no code that changes the numbers in op_ppro_spec. The patch
as it is has no effect.

Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-10 22:07:35 +02:00
Robert Richter 0886751c5d Merge commit 'v2.6.30' into oprofile/master 2009-06-10 21:47:10 +02:00
Ingo Molnar 23db9f430b Merge branch 'linus' into perfcounters/core
Merge reason: merge almost-rc8 into perfcounters/core, which was -rc6
              based - to pick up the latest upstream fixes.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-01 10:01:39 +02:00
Masami Hiramatsu 7b6c6c7773 x86, 32-bit: fix kernel_trap_sp()
Use &regs->sp instead of regs for getting the top of stack in kernel mode.
(on x86-64, regs->sp always points the top of stack)

[ Impact: Oprofile decodes only stack for backtracing on i386 ]

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
[ v2: rename the API to kernel_stack_pointer(), move variable inside ]
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: systemtap@sources.redhat.com
Cc: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Jan Blunck <jblunck@suse.de>
Cc: Christoph Hellwig <hch@infradead.org>
LKML-Reference: <20090511210300.17332.67549.stgit@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-05-12 00:39:52 +02:00
Robert Richter 7e4e0bd50e oprofile: introduce module_param oprofile.cpu_type
This patch removes module_param oprofile.force_arch_perfmon and
introduces oprofile.cpu_type=archperfmon instead. This new parameter
can be reused for other models and architectures.

Currently only archperfmon is supported.

Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-05-08 11:06:34 +02:00
Andi Kleen 6adf406f0a oprofile: add support for Core i7 and Atom
The registers are about the same as other Family 6 CPUs
so we only need to add detection.

I'm not completely happy with calling Nehalem Core i7 because
there will be undoubtedly other Nehalem based CPUs
in the future with different marketing names, but it's
the best we got for now.

Requires updated oprofile userland for the new event files.

If you don't want to update right now you can also use
oprofile.force_arch_perfmon=1 (added in the next patch) with 0.9.4

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-05-08 11:06:33 +02:00
Andi Kleen 1f3d7b6069 oprofile: remove undocumented oprofile.p4force option
There are no new P4s and the oprofile code knows about all existing
ones, so we don't really need the p4force option anymore.

Remove it.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-05-08 11:06:33 +02:00
Andi Kleen 1dcdb5a9e7 oprofile: re-add force_arch_perfmon option
This re-adds the force_arch_perfmon option that was in the original
arch perfmon patchkit. Originally this was rejected in favour
of a generalized perfmon=name option, but it turned out implementing
the later in a reliable way is hard (and it would have been easy
to crash the kernel if a user gets it wrong)

But now Atom and Core i7 support being readded a user would
need to update their oprofile userland to beyond 0.9.4 to use oprofile again
on Atom or Core i7.

To avoid this problem readd the force_arch_perfmon option.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-05-08 11:06:33 +02:00
Ingo Molnar f541ae326f Merge branch 'linus' into perfcounters/core-v2
Merge reason: we have gathered quite a few conflicts, need to merge upstream

Conflicts:
	arch/powerpc/kernel/Makefile
	arch/x86/ia32/ia32entry.S
	arch/x86/include/asm/hardirq.h
	arch/x86/include/asm/unistd_32.h
	arch/x86/include/asm/unistd_64.h
	arch/x86/kernel/cpu/common.c
	arch/x86/kernel/irq.c
	arch/x86/kernel/syscall_table_32.S
	arch/x86/mm/iomap_32.c
	include/linux/sched.h
	kernel/Makefile

Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-04-06 09:02:57 +02:00
Rusty Russell 7ad728f981 cpumask: x86: convert cpu_sibling_map/cpu_core_map to cpumask_var_t
Impact: reduce per-cpu size for CONFIG_CPUMASK_OFFSTACK=y

In most places it's cleaner to use the accessors cpu_sibling_mask()
and cpu_core_mask() wrappers which already exist.

I couldn't avoid cleaning up the access in oprofile, either.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-03-13 14:49:50 +10:30
Ingo Molnar 8163d88c79 Merge commit 'v2.6.29-rc7' into perfcounters/core
Conflicts:
	arch/x86/mm/iomap_32.c
2009-03-04 11:42:31 +01:00
Tim Blechmann 780eef9492 x86: oprofile: don't set counter width from cpuid on Core2
Impact: fix stuck NMIs and non-working oprofile on certain CPUs

Resetting the counter width of the performance counters on Intel's
Core2 CPUs, breaks the delivery of NMIs, when running in x86_64 mode.

This should fix bug #12395:

  http://bugzilla.kernel.org/show_bug.cgi?id=12395

Signed-off-by: Tim Blechmann <tim@klingt.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
LKML-Reference: <20090303100412.GC10085@erda.amd.com>
Cc: <stable@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-03-03 12:04:22 +01:00
Ingo Molnar 82aa9a1829 perfcounters: fix "perf counters kills oprofile" bug, v2
Impact: fix kernel crash

Both oprofile and perfcounters register an NMI die handler, but only one
can handle the NMI.  Conveniently, oprofile unregisters it's notifier
when not actively in use, so setting it's notifier priority higher than
perfcounter's allows oprofile to borrow the NMI for the duration of it's
run.  Tested/works both as module and built-in.

While testing, I found that if kerneltop was generating NMIs at very
high frequency, the kernel may panic when oprofile registered it's
handler.  This turned out to be because oprofile registers it's handler
before reset_value has been allocated, so if an NMI comes in while it's
still setting up, kabOom.  Rather than try more invasive changes, I
followed the lead of other places in op_model_ppro.c, and simply
returned in that highly unlikely event.  (debug warnings attached)

Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-02-05 15:24:14 +01:00
Mike Galbraith 5b75af0a02 perfcounters: fix "perf counters kill oprofile" bug
With oprofile as a module, and unloaded by profiling script,
both oprofile and kerneltop work fine.. unless you leave kerneltop
running when you start profiling, then you may see badness.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-02-04 17:36:18 +01:00
Ingo Molnar 506c10f26c Merge commit 'v2.6.29-rc1' into perfcounters/core
Conflicts:
	include/linux/kernel_stat.h
2009-01-11 02:42:53 +01:00
Robert Richter d2852b932f Merge branch 'oprofile/ring_buffer' into oprofile/oprofile-for-tip 2009-01-08 14:27:34 +01:00
Robert Richter 14f0ca8eae oprofile: make new cpu buffer functions part of the api
This patch creates the new functions

 oprofile_write_reserve()
 oprofile_add_data()
 oprofile_write_commit()

and makes them part of the oprofile api.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-01-07 22:48:15 +01:00
Robert Richter 1acda878e2 oprofile: use new data sample format for ibs
The new ring buffer implementation allows the storage of samples with
different size. This patch implements the usage of the new sample
format to store ibs samples in the cpu buffer. Until now, writing to
the cpu buffer could lead to incomplete sampling sequences since IBS
samples were transfered in multiple samples. Due to a full buffer,
data could be lost at any time. This can't happen any more since the
complete data is reserved in advance and then stored in a single
sample.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-01-07 22:47:23 +01:00
Robert Richter ae735e9964 oprofile: rework implementation of cpu buffer events
Special events such as task or context switches are marked with an
escape code in the cpu buffer followed by an event code or a task
identifier. There is one escape code per event. To make escape
sequences also available for data samples the internal cpu buffer
format must be changed. The current implementation does not allow the
extension of event codes since this would lead to collisions with the
task identifiers. To avoid this, this patch introduces an event mask
that allows the storage of multiple events with one escape code. Now,
task identifiers are stored in the data section of the sample. The
implementation also allows the usage of custom data in a sample. As a
side effect the new code is much more readable and easier to
understand.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-01-07 22:40:47 +01:00
Robert Richter fc81be8ca2 oprofile: rename variable ibs_allowed to has_ibs in op_model_amd.c
This patch renames ibs_allowed to has_ibs. Varible name fits better
now.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-01-07 22:34:21 +01:00
Robert Richter 83bd924395 x86/oprofile: fix pci_dev use count for AMD northbridge devices
This patch fixes the PCI device use count for AMD northbridge
devices. In case of an IBS LVT initialization failure, the PCI device
is released now by calling pci_dev_put().

If there are no initialization errors, the devices are released in
pci_get_device() while iterating.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-29 15:19:32 +01:00
Ingo Molnar 5c167b8585 x86, perfcounters: rename intel_arch_perfmon.h => perf_counter.h
Impact: rename include file

We'll be providing an asm/perf_counter.h to the generic perfcounter code,
so use the already existing x86 file for this purpose and rename it.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-12-23 12:45:09 +01:00
Robert Richter fe615cbf34 x86/oprofile: cleanup IBS init/exit functions in op_model_amd.c
Implementation of pairwise init/exit funcions for IBS and IBS NMI
setup. There are also some function renames and the removal of forward
function declarations.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-10 14:20:08 +01:00
Robert Richter 9fa6812dba x86/oprofile: reordering IBS code in op_model_amd.c
This is part of the cpu buffer rework.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-10 14:20:07 +01:00
Robert Richter cdc1834d1a oprofile: whitspace changes only
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-10 14:20:05 +01:00
Robert Richter fd13f6c851 oprofile: comment cleanup
This fixes the coding style of some comments.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-10 14:20:01 +01:00
William Cohen 3d337c653c x86/oprofile: fix Intel cpu family 6 detection
Alan Jenkins wrote:
> This is on an EeePC 701, /proc/cpuinfo as attached.
>
> Is this expected?  Will the next release work?
>
> Thanks, Alan
>
> # opcontrol --setup --no-vmlinux
> cpu_type 'unset' is not valid
> you should upgrade oprofile or force the use of timer mode
>
> # opcontrol -v
> opcontrol: oprofile 0.9.4 compiled on Nov 29 2008 22:44:10
>
> # cat /dev/oprofile/cpu_type
> i386/p6
> # uname -r
> 2.6.28-rc6eeepc

Hi Alan,

Looking at the kernel driver code for oprofile it can return the "i386/p6" for
the cpu_type. However, looking at the user-space oprofile code there isn't the
matching entry in libop/op_cpu_type.c or the events/unit_mask files in
events/i386 directory.

The Intel AP-485 says this is a "Intel Pentium M processor model D". Seems like
the oprofile kernel driver should be identifying the processor as "i386/p6_mobile"

The driver identification code doesn't look quite right in nmi_init.c

http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git;a=blob;f=arch/x86/oprofile/nmi_int.c;h=022cd41ea9b4106e5884277096e80e9088a7c7a9;hb=HEAD

has:

409         case 10 ... 13:
410                 *cpu_type = "i386/p6";
411                 break;

Referring to the Intel AP-485:
case 10 and 11 should produce "i386/piii"
case 13 should produce "i386/p6_mobile"

I didn't see anything for case 12.

Something like the attached patch. I don't have a celeron machine to verify that
changes in this area of the kernel fix thing.

-Will

Signed-off-by: William Cohen <wcohen@redhat.com>
Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-03 17:17:17 +01:00
Eric Dumazet 9ea84ad77d oprofile: fix CPU unplug panic in ppro_stop()
If oprofile statically compiled in kernel, a cpu unplug triggers
a panic in ppro_stop(), because a NULL pointer is dereferenced.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-03 15:58:51 +01:00
Eric Dumazet a4a16beade oprofile: fix an overflow in ppro code
reset_value was changed from long to u64 in commit
b991702884 (oprofile: Implement Intel
architectural perfmon support)

But dynamic allocation of this array use a wrong type (long instead of
u64)

Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-11-17 18:47:36 +01:00
Andi Kleen 7c64ade53a oprofile: Fix p6 counter overflow check
Fix the counter overflow check for CPUs with counter width > 32

I had a similar change in a different patch that I didn't submit
and I didn't notice the problem earlier because it was always
tested together.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-11-07 17:34:41 +01:00
Robert Richter 0f019cc477 oprofile: fixing whitespaces in arch/x86/oprofile/*
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-16 17:17:46 +02:00
Robert Richter 5a289395bf Merge branch 'oprofile/x86-oprofile-for-tip' into oprofile/oprofile-for-tip
Conflicts:
	arch/x86/oprofile/op_model_ppro.c
2008-10-15 22:19:41 +02:00
Suravee Suthikulpanit 5f87dfb79f x86/oprofile: add the logic for enabling additional IBS bits
This patch adds the logic for enabling additional IBS control bits :
* IBS-Fetch IbsRandEn bit (bit 57)
* IBS-Op IbsOpCntCtl bit (bit 19)

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:56:56 +02:00
Robert Richter 69046d4304 x86/oprofile: reordering functions in nmi_int.c
No functional changes. The intension is to remove static function
declarations.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:56:53 +02:00
Robert Richter 25ad2913ca oprofile: more whitespace fixes
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:55:51 +02:00
Robert Richter c92960fccb oprofile: whitespace fixes
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:47:41 +02:00
Robert Richter ccd755c2d9 OProfile: Rename IBS sysfs dir into "ibs_op"
The new name is now more close to those used in the spec.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:47:38 +02:00
Robert Richter 2d55a47882 OProfile: Rework string handling in setup_ibs_files()
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:47:34 +02:00
Robert Richter e2fee2761a OProfile: Rework oprofile_add_ibs_sample() function
Code looks much more cleaner now.

Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15 20:47:31 +02:00
Andi Kleen 59512900ba oprofile: discover counters for op ppro too
Discover number of counters for all family 6 models even when not
in arch perfmon mode.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-13 19:25:11 +02:00
Andi Kleen b991702884 oprofile: Implement Intel architectural perfmon support
Newer Intel CPUs (Core1+) have support for architectural
events described in CPUID 0xA. See the IA32 SDM Vol3b.18 for details.

The advantage of this is that it can be done without knowing about
the specific CPU, because the CPU describes by itself what
performance events are supported. This is only a fallback
because only a limited set of 6 events are supported.
This allows to do profiling on Nehalem and on Atom systems
(later not tested)

This patch implements support for that in oprofile's Intel
Family 6 profiling module. It also has the advantage of supporting
an arbitary number of events now as reported by the CPU.
Also allow arbitary counter widths >32bit while we're at it.

Requires a patched oprofile userland to support the new
architecture.

v2: update for latest oprofile tree
    remove force_arch_perfmon

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-13 19:25:09 +02:00
Andi Kleen f645f64064 oprofile: Don't report Nehalem as core_2
This essentially reverts Linus' earlier 4b9f12a377
commit. Nehalem is not core_2, so it shouldn't be reported as such.
However with the earlier arch perfmon patch it will fall back to
arch perfmon mode now, so there is no need to fake it as core_2.
The only drawback is that Linus will need to patch the arch perfmon
support into his oprofile binary now, but I think he can do that.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-13 19:25:06 +02:00
Andi Kleen 5d4488027d oprofile: drop const in num counters field
allow to modify it at runtime

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-13 19:25:04 +02:00
Ingo Molnar 0d15504f16 Merge branch 'oprofile-for-tip' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile into oprofile
Conflicts:
	arch/x86/oprofile/nmi_int.c

Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-09-30 12:28:50 +02:00
Ingo Molnar 59293c8ad5 Merge commit 'v2.6.27-rc8' into oprofile
Conflicts:
	arch/x86/oprofile/nmi_int.c

Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-09-30 12:16:26 +02:00
Robert Richter f78e80209c Merge commit 'v2.6.27-rc5' into tip/oprofile
Conflicts:
	arch/x86/oprofile/nmi_int.c
2008-09-24 11:25:31 +02:00
Robert Richter 4c168eaf7e Revert "Oprofile Multiplexing Patch"
Reverting commit 1a960b402a for the main
branch. Multiplexing will be tracked on a separate feature branch.

Conflicts:

    arch/x86/oprofile/nmi_int.c
2008-09-24 11:08:52 +02:00
Andrea Righi 45f197ade7 x86, oprofile: BUG: using smp_processor_id() in preemptible code
Add __raw access before setting per cpu variable switch_index, to avoid
the following BUG:

[  449.166827] BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/6998
[  449.166848] caller is op_nmi_init+0xf0/0x2b0 [oprofile]
[  449.166855] Pid: 6998, comm: modprobe Not tainted 2.6.27-rc5-mm1 #29
[  449.166860] Call Trace:
[  449.166872]  [<ffffffff80362d67>] debug_smp_processor_id+0xd7/0xe0
[  449.166887]  [<ffffffffa00181c0>] op_nmi_init+0xf0/0x2b0 [oprofile]
[  449.166902]  [<ffffffffa0018000>] oprofile_init+0x0/0x60 [oprofile]
[  449.166915]  [<ffffffffa00180a9>] oprofile_arch_init+0x9/0x30 [oprofile]
[  449.166928]  [<ffffffffa001801e>] oprofile_init+0x1e/0x60 [oprofile]
[  449.166937]  [<ffffffff8020903b>] _stext+0x3b/0x160
[  449.166946]  [<ffffffff80477985>] __mutex_unlock_slowpath+0xe5/0x190
[  449.166955]  [<ffffffff80262c1a>] trace_hardirqs_on_caller+0xca/0x140
[  449.166965]  [<ffffffff8026f7fc>] sys_init_module+0xdc/0x210
[  449.166972]  [<ffffffff8020b7cb>] system_call_fastpath+0x16/0x1b

Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
Acked-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-09-22 12:27:47 +02:00
Andrea Righi b61e06f258 x86, oprofile: BUG scheduling while atomic
nmi_shutdown() calls unregister_die_notifier() from an atomic context
after setting preempt_disable() via get_cpu_var():

[ 1049.404154] BUG: scheduling while atomic: oprofiled/7796/0x00000002
[ 1049.404171] INFO: lockdep is turned off.
[ 1049.404176] Modules linked in: oprofile af_packet rfcomm l2cap kvm_intel kvm i915 drm acpi_cpufreq cpufreq_userspace cpufreq_conservative cpufreq_ondemand cpufreq_powersave freq_table container sbs sbshc dm_mod arc4 ecb cryptomgr aead snd_hda_intel crypto_blkcipher snd_pcm_oss crypto_algapi snd_pcm iwlagn iwlcore snd_timer iTCO_wdt led_class btusb iTCO_vendor_support snd psmouse bluetooth mac80211 soundcore cfg80211 snd_page_alloc intel_agp video output button battery ac dcdbas evdev ext3 jbd mbcache sg sd_mod piix ata_piix libata scsi_mod dock tg3 libphy ehci_hcd uhci_hcd usbcore thermal processor fan fuse
[ 1049.404362] Pid: 7796, comm: oprofiled Not tainted 2.6.27-rc5-mm1 #30
[ 1049.404368] Call Trace:
[ 1049.404384]  [<ffffffff804769fd>] thread_return+0x4a0/0x7d3
[ 1049.404396]  [<ffffffff8026ad92>] generic_exec_single+0x52/0xe0
[ 1049.404405]  [<ffffffff8026ae1a>] generic_exec_single+0xda/0xe0
[ 1049.404414]  [<ffffffff8026aee3>] smp_call_function_single+0x73/0x150
[ 1049.404423]  [<ffffffff804770c5>] schedule_timeout+0x95/0xd0
[ 1049.404430]  [<ffffffff80476083>] wait_for_common+0x43/0x180
[ 1049.404438]  [<ffffffff80476154>] wait_for_common+0x114/0x180
[ 1049.404448]  [<ffffffff80236980>] default_wake_function+0x0/0x10
[ 1049.404457]  [<ffffffff8024f810>] synchronize_rcu+0x30/0x40
[ 1049.404463]  [<ffffffff8024f890>] wakeme_after_rcu+0x0/0x10
[ 1049.404472]  [<ffffffff80479ca0>] _spin_unlock_irqrestore+0x40/0x80
[ 1049.404482]  [<ffffffff80256def>] atomic_notifier_chain_unregister+0x3f/0x60
[ 1049.404501]  [<ffffffffa03d8801>] nmi_shutdown+0x51/0x90 [oprofile]
[ 1049.404517]  [<ffffffffa03d6134>] oprofile_shutdown+0x34/0x70 [oprofile]
[ 1049.404532]  [<ffffffffa03d721e>] event_buffer_release+0xe/0x40 [oprofile]
[ 1049.404543]  [<ffffffff802bdcdd>] __fput+0xcd/0x240
[ 1049.404551]  [<ffffffff802baa74>] filp_close+0x54/0x90
[ 1049.404560]  [<ffffffff8023e1d1>] put_files_struct+0xb1/0xd0
[ 1049.404568]  [<ffffffff8023f82f>] do_exit+0x18f/0x930
[ 1049.404576]  [<ffffffff8020be03>] restore_args+0x0/0x30
[ 1049.404584]  [<ffffffff80240006>] do_group_exit+0x36/0xa0
[ 1049.404592]  [<ffffffff8020b7cb>] system_call_fastpath+0x16/0x1b

This can be easily triggered with 'opcontrol --shutdown'.

Simply move get_cpu_var() above unregister_die_notifier().

Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
Acked-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-09-22 11:54:24 +02:00
Andi Kleen 80a8c9fffa x86: fix oprofile + hibernation badness
Vegard Nossum reported oprofile + hibernation problems:

> Now some warnings:
>
> ------------[ cut here ]------------
> WARNING: at /uio/arkimedes/s29/vegardno/git-working/linux-2.6/kernel/smp.c:328 s
> mp_call_function_mask+0x194/0x1a0()

The usual problem: the suspend function when interrupts are
already disabled calls smp_call_function which is not allowed with
interrupt off. But at this point all the other CPUs should be already
down anyways, so it should be enough to just drop that.

This patch should fix that problem at least by fixing cpu hotplug&
suspend support.

[ mingo@elte.hu: fixed 5 coding style errors. ]

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Tested-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-20 16:18:31 +02:00
Ingo Molnar 2879a927bb Merge branch 'x86/oprofile' into oprofile 2008-08-19 03:34:07 +02:00
Paolo Ciarrocchi 20211e4d34 x86: Coding style fixes to arch/x86/oprofile/op_model_p4.c
A coding style patch to arch/x86/oprofile/op_model_p4.c that
removes 87 errors and 4 warnings.

Before:
total: 89 errors, 13 warnings, 722 lines checked

After:
total: 2 errors, 9 warnings, 721 lines checked

Compile tested, binary verified as follow:

paolo@paolo-desktop:~/linux.trees.git$ size /tmp/op_model_p4.o.*
   text    data     bss     dec     hex filename
   2691     968      32    3691     e6b /tmp/op_model_p4.o.after
   2691     968      32    3691     e6b /tmp/op_model_p4.o.before

paolo@paolo-desktop:~/linux.trees.git$ md5sum /tmp/op_model_p4.o.*
8c1c9823bab33333e1f7f76574e62561  /tmp/op_model_p4.o.after
8c1c9823bab33333e1f7f76574e62561  /tmp/op_model_p4.o.before

Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Cc: robert.richter@amd.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-19 03:33:51 +02:00
Robert Richter 7e7b43892b x86/oprofile: fix on_each_cpu build error
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Jason Yeh <jason.yeh@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:17 +02:00
Jason Yeh 1a960b402a Oprofile Multiplexing Patch
This patch introduces multiplexing support for the Oprofile kernel
module. It basically adds a new function pointer in oprofile_operator
allowing each architecture to supply its callback to switch between
different sets of event when the timer expires. Userspace tools can
modify the time slice through /dev/oprofile/time_slice.

It also modifies the number of counters exposed to the userspace through
/dev/oprofile. For example, the number of counters for AMD CPUs are
changed to 32 and multiplexed in the sets of 4.

Signed-off-by: Jason Yeh <jason.yeh@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:16 +02:00
Robert Richter 6852fd9b86 x86/oprofile: reanaming op_model_athlon.c to op_model_amd.c
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:14 +02:00
Robert Richter 852402cc27 x86/oprofile: add CONFIG_OPROFILE_IBS option
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:13 +02:00
Robert Richter 543a157bbd x86/oprofile: op_model_athlon.c: fix counter reset when reenabling IBS OP
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:11 +02:00
Robert Richter 87f0baccc2 x86/oprofile: macro definition cleanup in op_model_athlon.c
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:10 +02:00
Robert Richter a4c408a411 OProfile: fix IBS build error for UP
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:10 +02:00
Robert Richter 270d3e1a10 OProfile: enable IBS for AMD CPUs
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:09 +02:00
Robert Richter fc2bd7345b OProfile: fix setup_ibs_files() function interface
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:09 +02:00
Robert Richter ebb535de26 OProfile: on_each_cpu(): kill unused retry parameter
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:08 +02:00
Robert Richter 90645700ef OProfile: Fix build error in op_model_athlon.c
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:07 +02:00
Robert Richter 7d77f2dcae OProfile: change IBS interrupt initialization
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:07 +02:00
Robert Richter 7939d2bf7e x86/oprofile: separating the IBS handler
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:05 +02:00
Barry Kasindorf 56784f11df x86/oprofile: add IBS support for AMD CPUs, model specific code
This patchset supports the new profiling hardware available in the
latest AMD CPUs in the oProfile driver.

Signed-off-by: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:05 +02:00
Robert Richter 6657fe4f56 x86/oprofile: renaming athlon_*() into op_amd_*()
These functions contain code for all AMD CPUs. The new names fit
better.

Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:02 +02:00
Robert Richter dfa1542897 x86/oprofile: Minor changes in op_model_athlon.c
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Cc: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:01 +02:00
Robert Richter adf5ec0bca x86/oprofile: introduce model specific init/exit functions
This patch implements model specific OProfile init/exit functions for
x86 CPUs. Though there is more rework needed at the initialization
code, this new introduced functions allow it to keep model specific
code in the corresponding op_model_*.c files.

The function interface is the same as for oprofile_arch_init/exit().

Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:01 +02:00
Barry Kasindorf 12f2b2610e oprofile: Add support for AMD Family 11h
This patch add support for AMD Family 11h CPUs.

Signed-off-by: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-26 11:48:00 +02:00
Linus Torvalds 4b9f12a377 x86/oprofile/nmi_int: add Nehalem to list of ppro cores
..otherwise oprofile will fall back on that poor timer interrupt.

Also replace the unreadable chain of if-statements with a "switch()"
statement instead. It generates better code, and is a lot clearer.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-24 17:29:00 -07:00
Ingo Molnar 1a781a777b Merge branch 'generic-ipi' into generic-ipi-for-linus
Conflicts:

	arch/powerpc/Kconfig
	arch/s390/kernel/time.c
	arch/x86/kernel/apic_32.c
	arch/x86/kernel/cpu/perfctr-watchdog.c
	arch/x86/kernel/i8259_64.c
	arch/x86/kernel/ldt.c
	arch/x86/kernel/nmi_64.c
	arch/x86/kernel/smpboot.c
	arch/x86/xen/smp.c
	include/asm-x86/hw_irq_32.h
	include/asm-x86/hw_irq_64.h
	include/asm-x86/mach-default/irq_vectors.h
	include/asm-x86/mach-voyager/irq_vectors.h
	include/asm-x86/smp.h
	kernel/Makefile

Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-15 21:55:59 +02:00
Jens Axboe 15c8b6c1aa on_each_cpu(): kill unused 'retry' parameter
It's not even passed on to smp_call_function() anymore, since that
was removed. So kill it.

Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
2008-06-26 11:24:38 +02:00
Vegard Nossum 93e1ade538 x86/oprofile: disable preemption in nmi_shutdown
fix:

    BUG: using smp_processor_id() in preemptible [00000000] code: oprofiled/27301
    caller is nmi_shutdown+0x11/0x60
    Pid: 27301, comm: oprofiled Not tainted 2.6.26-rc7 #25
     [<c028a90d>] debug_smp_processor_id+0xbd/0xc0
     [<c045fba1>] nmi_shutdown+0x11/0x60
     [<c045dd4a>] oprofile_shutdown+0x2a/0x60

Note that we don't need this for the other functions, since they are all
called with on_each_cpu() (which disables preemption for us anyway).

Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Philippe Elie <phil.el@wanadoo.fr>
Cc: oprofile-list@lists.sf.net
Cc: Johannes Weiner <hannes@saeurebad.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-06-24 13:48:29 +02:00
Mike Travis d18d00f5db x86: oprofile: remove NR_CPUS arrays in arch/x86/oprofile/nmi_int.c
Change the following arrays sized by NR_CPUS to be PERCPU variables:

	static struct op_msrs cpu_msrs[NR_CPUS];
	static unsigned long saved_lvtpc[NR_CPUS];

Also some minor complaints from checkpatch.pl fixed.

Based on:
	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
	git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git

All changes were transparent except for:

 static void nmi_shutdown(void)
 {
+	struct op_msrs *msrs = &__get_cpu_var(cpu_msrs);
 	nmi_enabled = 0;
 	on_each_cpu(nmi_cpu_shutdown, NULL, 0, 1);
 	unregister_die_notifier(&profile_exceptions_nb);
-	model->shutdown(cpu_msrs);
+	model->shutdown(msrs);
 	free_msrs();
 }

The existing code passed a reference to cpu 0's instance of struct op_msrs
to model->shutdown, whilst the other functions are passed a reference to
<this cpu's> instance of a struct op_msrs.  This seemed to be a bug to me
even though as long as cpu 0 and <this cpu> are of the same type it would
have the same effect...?

Cc: Philippe Elie <phil.el@wanadoo.fr>
Signed-off-by: Mike Travis <travis@sgi.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-19 19:44:58 +02:00
Paolo Ciarrocchi 0fb90297dc x86: coding style fixes to arch/x86/oprofile/nmi_timer_int.c
Before:
   total: 3 errors, 0 warnings, 69 lines checked
After:
   total: 0 errors, 0 warnings, 69 lines checked

No code changed:

arch/x86/oprofile/nmi_timer_int.o:

   text	   data	    bss	    dec	    hex	filename
    180	     12	      0	    192	     c0	nmi_timer_int.o.before
    180	     12	      0	    192	     c0	nmi_timer_int.o.after

md5:
   0433c31d758e81da574e01722a8036ea  nmi_timer_int.o.before.asm
   0433c31d758e81da574e01722a8036ea  nmi_timer_int.o.after.asm

Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-17 17:40:50 +02:00
Paolo Ciarrocchi d717ca84c0 x86: coding style fixes to arch/x86/oprofile/init.c
Before:
   total: 5 errors, 4 warnings, 48 lines checked
After:
   total: 0 errors, 4 warnings, 49 lines checked

No code changed:

arch/x86/oprofile/init.o:

   text	   data	    bss	    dec	    hex	filename
     42	      0	      0	     42	     2a	init.o.before
     42	      0	      0	     42	     2a	init.o.after

md5:
   74c94c315cfbf245aeba36eceac57e66  init.o.before.asm
   74c94c315cfbf245aeba36eceac57e66  init.o.after.asm

Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-17 17:40:49 +02:00
Paolo Ciarrocchi d4413732b5 x86: coding style fixes to arch/x86/oprofile/op_model_athlon.c
The patch fixes 33 errors and a few warnings reported by checkpatch.pl

arch/x86/oprofile/op_model_athlon.o:
   text    data     bss     dec     hex filename
   1691       0      32    1723     6bb op_model_athlon.o.before
   1691       0      32    1723     6bb op_model_athlon.o.after
md5:
c354bc2d7140e1e626c03390eddaa0a6  op_model_athlon.o.before.asm
c354bc2d7140e1e626c03390eddaa0a6  op_model_athlon.o.after.asm

Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-17 17:40:48 +02:00
Paolo Ciarrocchi 8b45b72b04 x86: coding style fixes to arch/x86/oprofile/op_model_ppro.c
no code changed:

arch/x86/oprofile/op_model_ppro.o:
   text    data     bss     dec     hex filename
   1765       0      16    1781     6f5 op_model_ppro.o.before
   1765       0      16    1781     6f5 op_model_ppro.o.after
md5:
71c7f68d2197d686e3d1121bc18a6b6e  op_model_ppro.o.before.asm
71c7f68d2197d686e3d1121bc18a6b6e  op_model_ppro.o.after.asm

Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-17 17:40:48 +02:00
Harvey Harrison f6e8e28410 x86: rename stack_pointer to kernel_trap_sp
Choose a less generic name for such a special case.  Add
a comment explaining the odd use in X86_32.

Change the one user of stack_pointer.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:16 +01:00
Arjan van de Ven 5bc27dc2f5 x86: pull bp calculation earlier into the backtrace path
Right now, we take the stack pointer early during the backtrace path, but
only calculate bp several functions deep later, making it hard to reconcile
the stack and bp backtraces (as well as showing several internal backtrace
functions on the stack with bp based backtracing).

This patch moves the bp taking to the same place we take the stack pointer;
sadly this ripples through several layers of the back tracing stack,
but it's not all that bad in the end I hope.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:07 +01:00
Arjan van de Ven bc850d6b37 x86: add the capability to print fuzzy backtraces
For enhancing the 32 bit EBP based backtracer, I need the capability
for the backtracer to tell it's customer that an entry is either
reliable or unreliable, and the backtrace printing code then needs to
print the unreliable ones slightly different.

This patch adds the basic capability, the next patch will add a user
of this capability.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:07 +01:00
Carlos R. Mafra b75f53dba8 x86: fix style errors in nmi_int.c
This patch fixes most errors detected by checkpatch.pl.

                                     errors   lines of code   errors/KLOC
arch/x86/oprofile/nmi_int.c (after)       1             461           2.1
arch/x86/oprofile/nmi_int.c (before)     60             477         125.7

No code changed.

size:
   text    data     bss     dec     hex filename
   2675     264     472    3411     d53 nmi_int.o.after
   2675     264     472    3411     d53 nmi_int.o.before

md5sum:
  847aea0cc68fe1a2b5e7019439f3b4dd  nmi_int.o.after
  847aea0cc68fe1a2b5e7019439f3b4dd  nmi_int.o.before

Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
Reviewed-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:32:33 +01:00
H. Peter Anvin 65ea5b0349 x86: rename the struct pt_regs members for 32/64-bit consistency
We have a lot of code which differs only by the naming of specific
members of structures that contain registers.  In order to enable
additional unifications, this patch drops the e- or r- size prefix
from the register names in struct pt_regs, and drops the x- prefixes
for segment registers on the 32-bit side.

This patch also performs the equivalent renames in some additional
places that might be candidates for unification in the future.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:30:56 +01:00
Kay Sievers af5ca3f4ec Driver core: change sysdev classes to use dynamic kobject names
All kobjects require a dynamically allocated name now. We no longer
need to keep track if the name is statically assigned, we can just
unconditionally free() all kobject names on cleanup.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-01-24 20:40:40 -08:00
Arjan van de Ven e107ebe0e4 x86: add support for the latest Intel processors to Oprofile
The latest Intel processors (the 45nm ones) have a model number of 23
(old ones had 15); they're otherwise compatible on the oprofile side.
This patch adds the new model number to the oprofile code.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-18 22:49:33 +01:00
Barry Kasindorf bd87f1f028 oprofile: op_model_athlon.c support for AMD family 10h barcelona performance counters
This patch is for controlling the upper 32bits of the event ctrl msrs.
This includes the upper 4 bits of the event select and the Guest Only and
Host Only bits

This patch is necessary to make Event Based Profiling work reliably on a
Family 10h processor

[akpm@linux-foundation.org: checkpatch.pl fixes]

Signed-off-by: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2007-12-18 18:05:58 +01:00
Adrian Bunk ea5806559f x86: add instrumentation menu
It seems commit 09cadedbdc was incomplete 
due to a clash with the x86 architecture merge.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2007-10-23 22:37:22 +02:00
Linus Torvalds c00046c279 Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial
* git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial: (74 commits)
  fix do_sys_open() prototype
  sysfs: trivial: fix sysfs_create_file kerneldoc spelling mistake
  Documentation: Fix typo in SubmitChecklist.
  Typo: depricated -> deprecated
  Add missing profile=kvm option to Documentation/kernel-parameters.txt
  fix typo about TBI in e1000 comment
  proc.txt: Add /proc/stat field
  small documentation fixes
  Fix compiler warning in smount example program from sharedsubtree.txt
  docs/sysfs: add missing word to sysfs attribute explanation
  documentation/ext3: grammar fixes
  Documentation/java.txt: typo and grammar fixes
  Documentation/filesystems/vfs.txt: typo fix
  include/asm-*/system.h: remove unused set_rmb(), set_wmb() macros
  trivial copy_data_pages() tidy up
  Fix typo in arch/x86/kernel/tsc_32.c
  file link fix for Pegasus USB net driver help
  remove unused return within void return function
  Typo fixes retrun -> return
  x86 hpet.h: remove broken links
  ...
2007-10-19 20:36:17 -07:00
Simon Arlott 27b46d7661 spelling fixes: arch/i386/
Spelling fixes in arch/i386/.

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
2007-10-20 01:13:56 +02:00
Jan Blunck f1df280f53 x86: introduce frame_pointer() and stack_pointer()
This patch defines frame_pointer() and stack_pointer() similar to the
already defined instruction_pointer(). Thus the oprofile code can be
written in a more readable fashion.

[ tglx: arch/x86 adaptation ]

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2007-10-19 20:35:04 +02:00
Jan Blunck 574a60421c i386: make callgraph use dump_trace() on i386/x86_64
This patch improves oprofile callgraphs for i386/x86_64. The old
backtracing code was unable to produce kernel backtraces if the
kernel wasn't compiled with framepointers. The code now uses
dump_trace().

[ tglx: arch/x86 adaptation ]

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2007-10-19 20:35:03 +02:00
Stephane Eranian 0f8e45a288 i386: make Oprofile call shutdown() only once per session
Oprofile: call model->shutdown() only once to avoid calling release_ev*()
multiple times

[ tglx: arch/x86 adaptation ]

Signed-off-by: Stephane Eranian <eranian@hpl.hp.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2007-10-17 20:15:14 +02:00
Mike Travis d5a7430ddc Convert cpu_sibling_map to be a per cpu variable
Convert cpu_sibling_map from a static array sized by NR_CPUS to a per_cpu
variable.  This saves sizeof(cpumask_t) * NR unused cpus.  Access is mostly
from startup and CPU HOTPLUG functions.

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-16 09:42:50 -07:00
Thomas Gleixner ff4395654d i386: move oprofile
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2007-10-11 11:16:55 +02:00