From: Maynard J. <may...@us...> - 2013-06-18 14:10:44
|
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 <may...@us...> --- 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 @@ -1173,7 +1173,18 @@ do_setup() set_param() { if test "$KERNEL_SUPPORT" = "yes"; then - echo $2 >$MOUNT/$1 + if test "$IS_TIMER" = 1 -a "$1" = "backtrace_depth"; then + echo "Writing $2 to $MOUNT/$1" + echo $2 >$MOUNT/$1 > /dev/null + if test "$2" -ne 0; then + result=`cat $MOUNT/$1` + if test "$result" -ne "$2"; then + echo "Callgraph profiling not supported on this system in Timer mode" + fi + fi + else + echo $2 >$MOUNT/$1 + fi else $SYSCTL -w dev.oprofile.$1=$2 fi -- 1.7.1 |