Skip to content

Commit

Permalink
oprofile, s390: Add event interface to the System z hardware sampling…
Browse files Browse the repository at this point in the history
… module

With this patch the OProfile Basic Mode Sampling support for System z
is enhanced with a counter file system.  That way hardware sampling
can be configured using the user space tools with only little
modifications.

With the patch by default new cpu_types (s390/z10, s390/z196) are
returned in order to indicate that we are running a CPU which provides
the hardware sampling facility.  Existing user space tools will
complain about an unknown cpu type. In order to be compatible with
existing user space tools the `cpu_type' module parameter has been
added.  Setting the parameter to `timer' will force the module to
return `timer' as cpu_type.  The module will still try to use hardware
sampling if available and the hwsampling virtual filesystem will be
also be available for configuration.  So this has a different effect
than using the generic oprofile module parameter `timer=1'.

If the basic mode sampling is enabled on the machine and the
cpu_type=timer parameter is not used the kernel module will provide
the following virtual filesystem:

/dev/oprofile/0/enabled
/dev/oprofile/0/event
/dev/oprofile/0/count
/dev/oprofile/0/unit_mask
/dev/oprofile/0/kernel
/dev/oprofile/0/user

In the counter file system only the values of 'enabled', 'count',
'kernel', and 'user' are evaluated by the kernel module. Everything
else must contain fixed values.

The 'event' value only supports a single event - HWSAMPLING with value
0.

The 'count' value specifies the hardware sampling rate as it is passed
to the CPU measurement facility.

The 'kernel' and 'user' flags can now be used to filter for samples
when using hardware sampling.

Additionally also the following file will be created:
/dev/oprofile/timer/enabled

This will always be the inverted value of /dev/oprofile/0/enabled. 0
is not accepted without hardware sampling.

Signed-off-by: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
  • Loading branch information
Andreas Krebbel authored and Robert Richter committed Dec 7, 2011
1 parent f8c8520 commit dd3c467
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 30 deletions.
2 changes: 2 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
timer: [X86] Force use of architectural NMI
timer mode (see also oprofile.timer
for generic hr timer mode)
[s390] Force legacy basic mode sampling
(report cpu_type "timer")

oops=panic Always panic on oopses. Default is to just kill the
process, but there is a small probability of
Expand Down
7 changes: 6 additions & 1 deletion arch/s390/oprofile/hwsampler.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <asm/irq.h>

#include "hwsampler.h"
#include "op_counter.h"

#define MAX_NUM_SDB 511
#define MIN_NUM_SDB 1
Expand Down Expand Up @@ -896,21 +897,25 @@ static void add_samples_to_oprofile(unsigned int cpu, unsigned long *sdbt,
if (sample_data_ptr->P == 1) {
/* userspace sample */
unsigned int pid = sample_data_ptr->prim_asn;
if (!counter_config.user)
goto skip_sample;
rcu_read_lock();
tsk = pid_task(find_vpid(pid), PIDTYPE_PID);
if (tsk)
regs = task_pt_regs(tsk);
rcu_read_unlock();
} else {
/* kernelspace sample */
if (!counter_config.kernel)
goto skip_sample;
regs = task_pt_regs(current);
}

mutex_lock(&hws_sem);
oprofile_add_ext_hw_sample(sample_data_ptr->ia, regs, 0,
!sample_data_ptr->P, tsk);
mutex_unlock(&hws_sem);

skip_sample:
sample_data_ptr++;
}
}
Expand Down
Loading

0 comments on commit dd3c467

Please sign in to comment.