Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2018351imu; Fri, 14 Dec 2018 04:35:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wb9JvKujkaUTmlFANh3kaJTuwPGnuTs0JzEV/HAb3qs00swSg8pbzcAY9zGZvBKCe5wla7 X-Received: by 2002:a62:e0d8:: with SMTP id d85mr2646114pfm.214.1544790915267; Fri, 14 Dec 2018 04:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790915; cv=none; d=google.com; s=arc-20160816; b=SWue7e01MRoKO55ODDl0TUnUoaKs0NbENvLsQaLwTvXZi5qtnRqBCw78ppPTRfwubS eLB0DTrFTZd/tkF10sFJ9gtfDC4crs97OVKcCF0ZzteZQKWBLlWqlkHjl7Xm5GJwlxJL 1rDowyVDwGFFA9oyVW4/HA4z9hWtYQNnrBSjSMRyWAjzdL1r4OoR0Cd7zNQWhfjqbEOX IlWvQbBvhxfInsAfsl7at+0fah0kxGxsLGaXEV9U1S6PICRULjSA003Ltxls/obZwx+J 2K8oRgsGiK9g+NZ8dfnEytmctEUoveGUBGrZGSebZsDO6YNE2nPhMYJDOqKkK743/SQR Hfuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8dG5b6/Dw8/l/HKBee35Ly1IAW/he3LKZfrIT9DTZSQ=; b=qpHxoVvlEdYQom4/llzfVaKsiV5y66Ks91rsz8K8q3S3jcA4n1vNkvsRY/TYg4J+Ip /WmLHJtQfyDY+sdqAZDZTMTkR225s7tS37Kj0b+7dGksGVsICOab2tRE54ycDU68fqGl EHc0/qIp/J+11nHuiH1QEko6ptoCLM3s0Yz4hF30c25LnfNczixlWeWiiqcunNp/2tfP Vl44LMWwcl2Ri3JTbNLRNGUPdDWUH/lfrYR/z/cnuKpw/8mFpIjEgd3IoOGO2fktTdnH uVBnJ0I+TiiE042LTw6OdV0FPpQgWGM22ZnXgzVloeOLLLDthyq2g091m/kEdyYi/4i0 CdRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J1+r4b1N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n17si3889810pgj.191.2018.12.14.04.34.55; Fri, 14 Dec 2018 04:35:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J1+r4b1N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730936AbeLNMIP (ORCPT + 99 others); Fri, 14 Dec 2018 07:08:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:53624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730706AbeLNMIM (ORCPT ); Fri, 14 Dec 2018 07:08:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 337C721486; Fri, 14 Dec 2018 12:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789291; bh=yhGyDdBi24zOW8Lajk/R4t9Rvl+6Di8/eIbgtm16qwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1+r4b1NQA3M7XuNiZEmVOobdp73dsvUolt83BJJfp3YMIfjHmDNos+nWjaA4rj6/ tZelyPr+k85uceH33GDJ8FzZH02SHLkG5iClRccoeVBD1z7e7l2VuD85kHoGFCygxg Xb0C5yQQTiSqn7WJCt8wwNVzMuHn3dCRzbIPgdmQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Hendrik Brueckner , Martin Schwidefsky , Sasha Levin Subject: [PATCH 4.14 26/89] s390/cpum_cf: Reject request for sampling in event initialization Date: Fri, 14 Dec 2018 12:59:39 +0100 Message-Id: <20181214115730.986387878@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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: 97b1198fece0 (" "s390, perf: Use common PMU interrupt disabled code") Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Signed-off-by: Martin Schwidefsky Signed-off-by: Sasha Levin --- arch/s390/kernel/perf_cpum_cf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c index 61e91fee8467..edf6a61f0a64 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -349,6 +349,8 @@ static int __hw_perf_event_init(struct perf_event *event) break; case PERF_TYPE_HARDWARE: + if (is_sampling_event(event)) /* No sampling support */ + return -ENOENT; ev = attr->config; /* Count user space (problem-state) only */ if (!attr->exclude_user && attr->exclude_kernel) { -- 2.19.1