aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/oprofile/op_model_amd.c
AgeCommit message (Collapse)Author
2010-03-01perf, x86: rename macro in ARCH_PERFMON_EVENTSEL_ENABLERobert Richter
For consistency reasons this patch renames ARCH_PERFMON_EVENTSEL0_ENABLE to ARCH_PERFMON_EVENTSEL_ENABLE. The following is performed: $ sed -i -e s/ARCH_PERFMON_EVENTSEL0_ENABLE/ARCH_PERFMON_EVENTSEL_ENABLE/g \ arch/x86/include/asm/perf_event.h arch/x86/kernel/cpu/perf_event.c \ arch/x86/kernel/cpu/perf_event_p6.c \ arch/x86/kernel/cpu/perfctr-watchdog.c \ arch/x86/oprofile/op_model_amd.c arch/x86/oprofile/op_model_ppro.c Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-03-01perf, x86: add some IBS macros to perf_event.hRobert Richter
Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-03-01perf, x86: make IBS macros available in perf_event.hRobert Richter
This patch moves code from oprofile to perf_event.h to make it also available for usage by perf. Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: fix msr access to reserved countersRobert Richter
During switching virtual counters there is access to perfctr msrs. If the counter is not available this fails due to an invalid address. This patch fixes this. Cc: stable@kernel.org Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: use kzalloc() instead of kmalloc()Robert Richter
Cc: stable@kernel.org Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: fix perfctr nmi reservation for mulitplexingRobert Richter
Multiple virtual counters share one physical counter. The reservation of virtual counters fails due to duplicate allocation of the same counter. The counters are already reserved. Thus, virtual counter reservation may removed at all. This also makes the code easier. Cc: stable@kernel.org Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: warn user if a counter is already activeRobert Richter
This patch generates a warning if a counter is already active. Implemented for AMD and P6 models. P4 is not supported. Cc: Naga Chumbalkar <nagananda.chumbalkar@hp.com> Cc: Shashi Belur <shashi-kiran.belur@hp.com> Cc: Tony Jones <tonyj@suse.de> Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: implement randomization for IBS periodic op counterRobert Richter
IBS selects an op (execution operation) for sampling by counting either cycles or dispatched ops. Better statistical samples can be produced by adding a software generated random offset to the periodic op counter value with each sample. This patch adds software randomization to the IBS periodic op counter. The lower 12 bits of the 20 bit counter are randomized. IbsOpCurCnt is initialized with a 12 bit random value. There is a work around if the hw can not write to IbsOpCurCnt. Then the lower 8 bits of the 16 bit IbsOpMaxCnt [15:0] value are randomized in the range of -128 to +127 by adding/subtracting an offset to the maximum count (IbsOpMaxCnt). The linear feedback shift register (LFSR) algorithm is used for pseudo-random number generation to have low impact to the memory system. Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: implement lsfr pseudo-random number generator for IBSSuravee Suthikulpanit
This patch implements a linear feedback shift register (LFSR) for pseudo-random number generation for IBS. For IBS measurements it would be good to minimize memory traffic in the interrupt handler since every access pollutes the data caches. Computing a maximal period LFSR just needs shifts and ORs. The LFSR method is good enough to randomize the ops at low overhead. 16 pseudo-random bits are enough for the implementation and it doesn't matter that the pattern repeats with a fairly short cycle. It only needs to break up (hard) periodic sampling behavior. The logic was designed by Paul Drongowski. Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: implement IBS cpuid feature detectionRobert Richter
This patch adds IBS feature detection using cpuid flags. An IBS capability mask is introduced to test for certain IBS features. The bit mask is the same as for IBS cpuid feature flags (Fn8000_001B_EAX), but bit 0 is used to indicate the existence of IBS. The patch also changes the handling of the IbsOpCntCtl bit (periodic op counter count control). The oprofilefs file for this feature (ibs_op/dispatched_ops) will be only exposed if the feature is available, also the default for the bit is set to count clock cycles. In general, the userland can detect the availability of a feature by checking for the corresponding file in oprofilefs. If it exists, the feature also exists. This may lead to a dynamic file layout depending on the cpu type with that the userland has to deal with. Current opcontrol is compatible. Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: remove node check in AMD IBS initializationRobert Richter
Standard AMD systems have the same number of nodes as there are northbridge devices. However, there may kernel configurations (especially for 32 bit) or system setups exist, where the node number is different or it can not be detected properly. Thus the check is not reliable and may fail though IBS setup was fine. For this reason it is better to remove the check. Cc: stable <stable@kernel.org> Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-02-26oprofile/x86: remove OPROFILE_IBS config optionRobert Richter
OProfile support for IBS is now for several versions in the kernel. The feature is stable now and the code can be activated permanently. As a side effect IBS now works also on nosmp configs. Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-08-04arch/x86/oprofile/op_model_amd.c: fix op_amd_handle_ibs() return typeAndrew Morton
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-04Revert "x86: oprofile/op_model_amd.c set return values for op_amd_handle_ibs()"Robert Richter
This reverts commit 21e70878215f620fe99ea7d7c74bc641aeec932f. Instead Andrew's patch will be applied he posted at the same time. Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20x86/oprofile: Small coding style fixesRobert Richter
Some small coding style fixes. Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20x86/oprofile: Implement op_x86_virt_to_phys()Robert Richter
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-20x86/oprofile: Remove unused num_virt_controls from struct op_x86_model_specRobert Richter
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-20x86/oprofile: Remove const qualifier from struct op_x86_model_specRobert Richter
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-20oprofile: Grouping multiplexing code in op_model_amd.cRobert Richter
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-20oprofile: Introduce op_x86_phys_to_virt()Robert Richter
This new function translates physical to virtual counter numbers. Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-07-20x86/oprofile: Fix usage of NUM_CONTROLS/NUM_COUNTERS macrosRobert Richter
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-20oprofile: Implement performance counter multiplexingJason Yeh
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-14x86/oprofile: Whitespaces changes onlyRobert Richter
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-14x86/oprofile: Fix cast of counter valueRobert Richter
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-06-18x86: oprofile/op_model_amd.c set return values for op_amd_handle_ibs()Jaswinder Singh Rajput
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-11x86/oprofile: introduce oprofile_add_data64()Robert Richter
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-11x86/oprofile: use 64 bit values in IBS functionsRobert Richter
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-11x86/oprofile: use 64 bit wrmsr functionsRobert Richter
This patch replaces some wrmsr() functions with wrmsrl(). Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11x86/oprofile: replace CTR*_IS_RESERVED macrosRobert Richter
The patch replaces all CTR*_IS_RESERVED macros. Signed-off-by: Robert Richter <robert.richter@amd.com>
2009-06-11x86/oprofile: replace CTRL_SET_*ACTIVE macrosRobert Richter
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-11x86/oprofile: replace CTR_OVERFLOWED macrosRobert Richter
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-11x86/oprofile: replace macros to calculate control registerRobert Richter
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-11x86/oprofile: pass the model to setup_ctrs() functionsRobert Richter
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-11x86/oprofile: remove unused macros for AMD virtualization profilingRobert Richter
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-11x86/oprofile: remove MSR macros for AMD cpusRobert Richter
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-11x86/oprofile: move common macros to op_x86_model.hRobert Richter
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-11x86/oprofile: remove #ifdefs in ibs functionsRobert Richter
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-01-07oprofile: make new cpu buffer functions part of the apiRobert Richter
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-07oprofile: use new data sample format for ibsRobert Richter
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-07oprofile: rework implementation of cpu buffer eventsRobert Richter
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-07oprofile: rename variable ibs_allowed to has_ibs in op_model_amd.cRobert Richter
This patch renames ibs_allowed to has_ibs. Varible name fits better now. Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-29x86/oprofile: fix pci_dev use count for AMD northbridge devicesRobert Richter
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-10x86/oprofile: cleanup IBS init/exit functions in op_model_amd.cRobert Richter
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-10x86/oprofile: reordering IBS code in op_model_amd.cRobert Richter
This is part of the cpu buffer rework. Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-10oprofile: whitspace changes onlyRobert Richter
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-12-10oprofile: comment cleanupRobert Richter
This fixes the coding style of some comments. Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15x86/oprofile: add the logic for enabling additional IBS bitsSuravee Suthikulpanit
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-15oprofile: more whitespace fixesRobert Richter
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15oprofile: whitespace fixesRobert Richter
Signed-off-by: Robert Richter <robert.richter@amd.com>
2008-10-15OProfile: Rename IBS sysfs dir into "ibs_op"Robert Richter
The new name is now more close to those used in the spec. Signed-off-by: Robert Richter <robert.richter@amd.com>