From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759338AbdACOZ3 (ORCPT ); Tue, 3 Jan 2017 09:25:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58252 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756406AbdACOY5 (ORCPT ); Tue, 3 Jan 2017 09:24:57 -0500 Date: Tue, 3 Jan 2017 15:24:54 +0100 From: Jiri Olsa To: Peter Zijlstra Cc: Jiri Olsa , lkml , Ingo Molnar , Andi Kleen , Alexander Shishkin , Arnaldo Carvalho de Melo , Vince Weaver Subject: [PATCH] perf/x86: Reject non sampling events with precise_ip Message-ID: <20170103142454.GA26251@krava> References: <1482931866-6018-1-git-send-email-jolsa@kernel.org> <1482931866-6018-3-git-send-email-jolsa@kernel.org> <20170103094059.GC3093@worktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170103094059.GC3093@worktop> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 03 Jan 2017 14:24:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 03, 2017 at 10:40:59AM +0100, Peter Zijlstra wrote: > On Wed, Dec 28, 2016 at 02:31:04PM +0100, Jiri Olsa wrote: > > When in counting mode we setup the counter with the > > longest possible period and read the value with read > > syscall. > > > > We also still setup the PMI to be triggered when such > > counter overflow to reconfigure it. > > > > We also get PEBS interrupt if such counter has precise_ip > > set (which makes no sense, but it's possible). > > I think we should reject non sampling pebs events, as you say they make > no sense what so ever. ook, attached jirka --- As Peter suggested [1] rejecting non sampling PEBS events, because they dont make any sense and could cause issues in NMI handler [2]. [1] http://lkml.kernel.org/r/20170103094059.GC3093@worktop [2] http://lkml.kernel.org/r/1482931866-6018-3-git-send-email-jolsa@kernel.org Signed-off-by: Jiri Olsa --- arch/x86/events/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 64582cfa6976..48b851f0ef89 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -505,6 +505,10 @@ int x86_pmu_hw_config(struct perf_event *event) if (event->attr.precise_ip > precise) return -EOPNOTSUPP; + + /* There's no sense in having PEBS for non sampling events. */ + if (!is_sampling_event(event)) + return -EINVAL; } /* * check that PEBS LBR correction does not conflict with -- 2.9.3