File oprofile-s390_fix_timer_mode.patch of Package oprofile

From: Tony Jones <tonyj@suse.de>
Subject: Fix S390 timer mode
References: bsc#957426, http://sourceforge.net/p/oprofile/mailman/message/28465469/
Signed-off-by: Tony Jones <tonyj@suse.de>
Upstream: never, opcontrol is deprecated as of v1.0.0

Userspace and kernel are hopelessly inconsistent on S390, the s390 kernel code
now supports 3 modes of operation but the userspace only understands two. It'
s not posisble to force opcontrol into timer mode as other utils (ophelp, 
oprofiled) see the kernel as running in hardware sampling mode.  I don't 
believe this code has ever worked (a testement to the #s390 oprofile users)
but since opcontrol is now deprecated, we'll go with this local workaround. 
Standard modprobe on s390 will create /dev/opcontrol/0 if hardware sampling is
actually supported (even though /dev/oprofile/cpu_type indicates it is) so 
check this and if not present,  reload with cpu_type=timer which will cause
/dev/oprofile/cpu_type to report 'timer'.

--- a/utils/opcontrol	2014-10-09 03:18:43.000000000 +0200
+++ b/utils/opcontrol	2016-01-21 21:57:40.308676703 +0100
@@ -249,7 +249,7 @@
 {
 	grep oprofilefs /proc/filesystems >/dev/null
 	if test "$?" -ne 0; then
-		modprobe oprofile
+		modprobe oprofile "$1"
 		if test "$?" != "0"; then
 			# couldn't load the module
 			return
@@ -279,7 +279,13 @@
 load_module()
 {
 	OPROFILE_AVAILABLE=no
-	load_module_26
+	load_module_26 ""
+	if test "`cut -c1-5 /dev/oprofile/cpu_type`" = "s390/" -a ! -d /dev/oprofile/0; then
+		umount /dev/oprofile
+		rmmod oprofile
+		load_module_26 "cpu_type=timer"
+	fi
+
 	if test "$OPROFILE_AVAILABLE" != "yes"; then
 		echo "Kernel doesn't support oprofile" >&2
 		exit 1
openSUSE Build Service is sponsored by