[PATCH] Fix 'Invalid argument' error with 'opcontrol --start' in Timer mode
Maynard Johnson <maynardj <at> us.ibm.com>
2013-06-18 14:10:12 GMT
Fix 'Invalid argument' error with 'opcontrol --start' in Timer mode
When a processor type does not support oprofile event-based profiling,
the oprofile kernel driver writes "timer" to the /dev/oprofile/cpu_type
file. Usually (perhaps "always"), the architecture-specific oprofile
kernel driver does not set up the standard oprofile function pointers
that are defined in 'struct oprofile_operations oprofile_ops'. One of
those function pointers is 'oprofile_ops.backtrace'. When opcontrol
"--start" option is being executed, one of the actions taken is to write
the CALLGRAPH value from the daemonrc file to /dev/oprofile/backtrace_depth.
The kernel driver's filesystem function defined to respond to writes to this
file is drivers/oprofile/oprofile_files.c:depth_write(). In that function,
if 'oprofile_ops.backtrace' is not set, it returns -EINVAL, resulting in
the following opcontrol error:
opcontrol: line 1172: echo: write error: Invalid argument
This patch detects when the system is in timer mode and handles this error
appropriately -- if simply writing '0' to backtrace_depth, the error is
ignored; otherwise, print a message that call graph is not supported on
this system in TIMER mode.
Signed-off-by: Maynard Johnson <maynardj <at> us.ibm.com>
---
utils/opcontrol | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/utils/opcontrol b/utils/opcontrol
index 038e0db..20c6c6a 100644
--- a/utils/opcontrol
+++ b/utils/opcontrol
(Continue reading)