android_kernel_oneplus_msm8998/arch/s390/kernel
Thomas Richter 9ba7a303ff s390/cpum_cf: Reject request for sampling in event initialization
[ Upstream commit 613a41b0d16e617f46776a93b975a1eeea96417c ]

On s390 command perf top fails
[root@s35lp76 perf] # ./perf top -F100000  --stdio
   Error:
   cycles: PMU Hardware doesn't support sampling/overflow-interrupts.
   	Try 'perf stat'
[root@s35lp76 perf] #

Using event -e rb0000 works as designed.  Event rb0000 is the event
number of the sampling facility for basic sampling.

During system start up the following PMUs are installed in the kernel's
PMU list (from head to tail):
   cpum_cf --> s390 PMU counter facility device driver
   cpum_sf --> s390 PMU sampling facility device driver
   uprobe
   kprobe
   tracepoint
   task_clock
   cpu_clock

Perf top executes following functions and calls perf_event_open(2) system
call with different parameters many times:

cmd_top
--> __cmd_top
    --> perf_evlist__add_default
        --> __perf_evlist__add_default
            --> perf_evlist__new_cycles (creates event type:0 (HW)
			    		config 0 (CPU_CYCLES)
	        --> perf_event_attr__set_max_precise_ip
		    Uses perf_event_open(2) to detect correct
		    precise_ip level. Fails 3 times on s390 which is ok.

Then functions cmd_top
--> __cmd_top
    --> perf_top__start_counters
        -->perf_evlist__config
	   --> perf_can_comm_exec
               --> perf_probe_api
	           This functions test support for the following events:
		   "cycles:u", "instructions:u", "cpu-clock:u" using
		   --> perf_do_probe_api
		       --> perf_event_open_cloexec
		           Test the close on exec flag support with
			   perf_event_open(2).
	               perf_do_probe_api returns true if the event is
		       supported.
		       The function returns true because event cpu-clock is
		       supported by the PMU cpu_clock.
	               This is achieved by many calls to perf_event_open(2).

Function perf_top__start_counters now calls perf_evsel__open() for every
event, which is the default event cpu_cycles (config:0) and type HARDWARE
(type:0) which a predfined frequence of 4000.

Given the above order of the PMU list, the PMU cpum_cf gets called first
and returns 0, which indicates support for this sampling. The event is
fully allocated in the function perf_event_open (file kernel/event/core.c
near line 10521 and the following check fails:

        event = perf_event_alloc(&attr, cpu, task, group_leader, NULL,
		                 NULL, NULL, cgroup_fd);
	if (IS_ERR(event)) {
		err = PTR_ERR(event);
		goto err_cred;
	}

        if (is_sampling_event(event)) {
		if (event->pmu->capabilities & PERF_PMU_CAP_NO_INTERRUPT) {
			err = -EOPNOTSUPP;
			goto err_alloc;
		}
	}

The check for the interrupt capabilities fails and the system call
perf_event_open() returns -EOPNOTSUPP (-95).

Add a check to return -ENODEV when sampling is requested in PMU cpum_cf.
This allows common kernel code in the perf_event_open() system call to
test the next PMU in above list.

Fixes: 97b1198fec (" "s390, perf: Use common PMU interrupt disabled code")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-17 21:55:09 +01:00
..
vdso32 s390/vdso: add missing FORCE to build targets 2018-11-27 16:08:00 +01:00
vdso64 s390/vdso: add missing FORCE to build targets 2018-11-27 16:08:00 +01:00
.gitignore
alternative.c s390: add automatic detection of the spectre defense 2018-04-29 07:50:04 +02:00
asm-offsets.c s390/ftrace: use expoline for indirect branches 2018-05-30 07:49:17 +02:00
audit.c
audit.h
base.S s390/kernel: use expoline for indirect branches 2018-05-26 08:48:59 +02:00
cache.c s390/cachinfo: add missing facility check to init_cache_level() 2015-07-28 08:54:42 +02:00
compat_audit.c
compat_linux.c s390: fix handling of -1 in set{,fs}[gu]id16 syscalls 2018-02-22 15:44:58 +01:00
compat_linux.h
compat_ptrace.h
compat_signal.c s390/compat: correct restore of high gprs on signal return 2016-03-03 15:07:12 -08:00
compat_wrapper.c s390: wire up mlock2 system call 2015-11-16 12:51:07 +01:00
cpcmd.c s390/diag: add a statistic for diagnose calls 2015-10-14 14:32:06 +02:00
crash_dump.c s390/kdump: Add final note 2017-05-25 14:30:09 +02:00
debug.c s390: time: Provide read_boot_clock64() and read_persistent_clock64() 2015-05-22 10:36:29 -07:00
diag.c s390/diag: add a s390 prefix to the diagnose trace point 2015-11-09 09:10:47 +01:00
dis.c s390/disassembler: increase show_code buffer size 2017-11-30 08:37:18 +00:00
dumpstack.c
early.c s390: add options to change branch prediction behaviour for the kernel 2018-04-29 07:50:03 +02:00
ebcdic.c
entry.h s390/udelay: make udelay have busy loop semantics 2015-10-14 14:32:13 +02:00
entry.S s390: Correct register corruption in critical section cleanup 2018-07-11 16:03:48 +02:00
ftrace.c
head.S s390: remove SALIPL loader 2015-11-16 12:51:11 +01:00
head64.S s390/cpumf: Fix lpp detection 2016-04-12 09:08:31 -07:00
head_kdump.S
idle.c
ipl.c s390: add options to change branch prediction behaviour for the kernel 2018-04-29 07:50:03 +02:00
irq.c s390: remove indirect branch from do_softirq_own_stack 2018-05-26 08:48:56 +02:00
jump_label.c Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
kprobes.c
lgr.c
machine_kexec.c
Makefile s390: move spectre sysfs attribute code 2018-05-26 08:48:59 +02:00
mcount.S s390/ftrace: use expoline for indirect branches 2018-05-30 07:49:17 +02:00
module.c s390: correct module section names for expoline code revert 2018-04-29 07:50:04 +02:00
nmi.c s390/nmi: reduce size of percpu variable 2015-10-27 09:33:57 +01:00
nospec-branch.c s390: extend expoline to BC instructions 2018-05-26 08:48:59 +02:00
nospec-sysfs.c s390: move spectre sysfs attribute code 2018-05-26 08:48:59 +02:00
os_info.c
perf_cpum_cf.c s390/cpum_cf: Reject request for sampling in event initialization 2018-12-17 21:55:09 +01:00
perf_cpum_cf_events.c
perf_cpum_sf.c s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero 2018-05-26 08:48:55 +02:00
perf_event.c
pgm_check.S
process.c s390/runtime instrumentation: simplify task exit handling 2017-12-09 18:42:38 +01:00
processor.c s390: run user space and KVM guests with modified branch prediction 2018-04-29 07:50:03 +02:00
ptrace.c s390/ptrace: Preserve previous registers for short regset write 2017-02-01 08:30:52 +01:00
reipl.S s390/kernel: use expoline for indirect branches 2018-05-26 08:48:59 +02:00
relocate_kernel.S
runtime_instr.c s390/runtime instrumentation: simplify task exit handling 2017-12-09 18:42:38 +01:00
s390_ksyms.c s390/fpu: split fpu-internal.h into fpu internals, api, and type headers 2015-10-16 09:41:12 +02:00
sclp.c s390/sclp: _sclp_wait_int(): retain full PSW mask 2015-11-12 13:08:00 +01:00
setup.c s390: correct nospec auto detection init order 2018-04-29 07:50:04 +02:00
signal.c s390/fpu: always enable the vector facility if it is available 2015-10-14 14:32:08 +02:00
smp.c s390: introduce execute-trampolines for branches 2018-04-29 07:50:03 +02:00
stacktrace.c
suspend.c PCI: Include <linux/pci.h>, not <asm/pci.h> 2015-06-08 07:55:03 -05:00
swsusp.S s390/kernel: use expoline for indirect branches 2018-05-26 08:48:59 +02:00
sys_s390.c
syscalls.S s390: fix compat system call table 2017-12-16 10:33:49 +01:00
sysinfo.c
time.c s390/etr,stp: fix possible deadlock on machine check 2015-10-14 14:32:18 +02:00
topology.c s390/topology: reduce per_cpu() invocations 2015-10-27 09:34:39 +01:00
trace.c s390/diag: add a s390 prefix to the diagnose trace point 2015-11-09 09:10:47 +01:00
traps.c s390/fpu: split fpu-internal.h into fpu internals, api, and type headers 2015-10-16 09:41:12 +02:00
uprobes.c s390/uprobes: implement arch_uretprobe_is_alive() 2018-04-29 07:50:07 +02:00
vdso.c s390/vdso: use correct memory barrier 2015-10-14 14:32:01 +02:00
vmlinux.lds.S s390: introduce execute-trampolines for branches 2018-04-29 07:50:03 +02:00
vtime.c s390/vtime: correct scaled cputime of partially idle CPUs 2015-09-30 16:22:38 +02:00