Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6856217imu; Thu, 31 Jan 2019 00:28:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN4K3KGncGo5PKBiPRuXbHuD0Tz/nwF9hwGYTISfPQNaj+SgdYkYbBKMSug80PtPATY57qpX X-Received: by 2002:a17:902:1008:: with SMTP id b8mr32651238pla.252.1548923297483; Thu, 31 Jan 2019 00:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548923297; cv=none; d=google.com; s=arc-20160816; b=YbwP8AwADiHjtImJDy1TEXkRK5kGrbGiYBrnlNXJdl2HxBMaPXPOxcGomDXLjrjq5H eaiQrcLAvSUvvoXcUSXuJtJm4WoQvqOT64obEyHY/Ws0fs2ZXn1blDsqc02ddvzpCdtb iyLYF4eBoXF8jn5Gf7adLejuH0/ZEPsWhX5q5cWrn1FFIL8JrnatccBd5XG+hbcGn/4+ JD2eLnZ4mXwRcEtIyhWsLNyLUbeSF5hOeZrnM8fxfejCKua4ZMYKb4uJzdoRCJ90CBi+ 9voIhCjLW4l3kCZrY76GCiIU31VUMUjfjBuH9SJyfeSl3pAorBUxpdevvqWnnFo2uZol P3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=poEfA7rwjOBxznYstfTmLB59oK1wkNcqU3byAe0V2B4=; b=efQ25ysvSvgr9S2Micl7B968Z2juaRCBFWGm6D87NKBrwaqHjx34uCmn0vIHCTHMr4 RPDL4v8YkDwyfEFCOAW263QTSSMPyO2xG7rqjtRxkEP9AO9VErZcKRhv0vYmj39kqbdo ZcQ4IPjqQF5wai+LLr54j30b0vOaL9b916dCOvEURM5uSZ1Wc2efwaz5d0blsQ5VH2fs m6F1EdHFrdUiVXvjpsuK5Yq0kuiq+doO3A3VZaBJovZ1PebN6VBiIYhQQnSlbHfQalQw 2OEJkyA3B2VqdThvgH0ILNNd67DOwCEzPu+G1qiY3mY8s5AuOiZjEFXa3D5Z3cskVdM8 QkAA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si4185687plm.393.2019.01.31.00.28.02; Thu, 31 Jan 2019 00:28:17 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731625AbfAaI1P (ORCPT + 99 others); Thu, 31 Jan 2019 03:27:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50496 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfAaI1P (ORCPT ); Thu, 31 Jan 2019 03:27:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB55E804EC; Thu, 31 Jan 2019 08:27:14 +0000 (UTC) Received: from krava (ovpn-204-189.brq.redhat.com [10.40.204.189]) by smtp.corp.redhat.com (Postfix) with SMTP id 1EFFB5C207; Thu, 31 Jan 2019 08:27:11 +0000 (UTC) Date: Thu, 31 Jan 2019 09:27:11 +0100 From: Jiri Olsa To: Ravi Bangoria Cc: lkml , Peter Zijlstra , linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Andi Kleen , eranian@google.com, vincent.weaver@maine.edu, "Naveen N. Rao" Subject: Re: System crash with perf_fuzzer (kernel: 5.0.0-rc3) Message-ID: <20190131082711.GC24233@krava> References: <7c7ec3d9-9af6-8a1d-515d-64dcf8e89b78@linux.ibm.com> <20190130183648.GA24233@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190130183648.GA24233@krava> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 31 Jan 2019 08:27:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 07:36:48PM +0100, Jiri Olsa wrote: SNIP > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 280a72b3a553..22ec63a0782e 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -4969,6 +4969,26 @@ static void __perf_event_period(struct perf_event *event, > } > } > > +static int check_period(struct perf_event *event, u64 value) > +{ > + u64 sample_period_attr = event->attr.sample_period; > + u64 sample_period_hw = event->hw.sample_period; > + int ret; > + > + if (event->attr.freq) { > + event->attr.sample_freq = value; > + } else { > + event->attr.sample_period = value; > + event->hw.sample_period = value; > + } hm, I think we need to check the period without changing the event, because we don't disable pmu, so it might get picked up by bts code will check jirka > + > + ret = event->pmu->check_period(event); > + > + event->attr.sample_period = sample_period_attr; > + event->hw.sample_period = sample_period_hw; > + return ret; > +} > + > static int perf_event_period(struct perf_event *event, u64 __user *arg) > { > u64 value; > @@ -4985,6 +5005,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg) > if (event->attr.freq && value > sysctl_perf_event_sample_rate) > return -EINVAL; > > + if (check_period(event, value)) > + return -EINVAL; > + > event_function_call(event, __perf_event_period, &value); > > return 0; > @@ -9601,6 +9624,11 @@ static int perf_pmu_nop_int(struct pmu *pmu) > return 0; > } > > +static int perf_event_nop_int(struct perf_event *event) > +{ > + return 0; > +} > + > static DEFINE_PER_CPU(unsigned int, nop_txn_flags); > > static void perf_pmu_start_txn(struct pmu *pmu, unsigned int flags) > @@ -9901,6 +9929,9 @@ int perf_pmu_register(struct pmu *pmu, const char *name, int type) > pmu->pmu_disable = perf_pmu_nop_void; > } > > + if (!pmu->check_period) > + pmu->check_period = perf_event_nop_int; > + > if (!pmu->event_idx) > pmu->event_idx = perf_event_idx_default; > > -- > 2.17.2 >