From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B8D4ECAAD4 for ; Wed, 31 Aug 2022 12:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiHaMaJ (ORCPT ); Wed, 31 Aug 2022 08:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiHaMaI (ORCPT ); Wed, 31 Aug 2022 08:30:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1BABB1E3; Wed, 31 Aug 2022 05:30:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 63B3C61999; Wed, 31 Aug 2022 12:30:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D51DC433C1; Wed, 31 Aug 2022 12:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661949005; bh=xUAe/8husFmwnBA0zfVEAqWyrCl83ZcMIyiwRkNQ/A0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tq+5F6knMwcUy7jvIG0XcNJ+kcjbinj3aLlcszl+ZsZjV7F6Q6DUccGBrae5H1VJp MP9eanqJzI0BF5vq1V+Cy3z/NfbuCMTG5mzKrQyU9W46S/+vynmLiO5qi6JeTn9w1R aLRS+eCJKey1uCkpwoi+7sCeV9TsyvoGyWHFVF/NrFBcuVj/LwSJES2Mlh3v6duLzN AH7VIXkUuyOF6yMankiGQ2HAb3G+higOdsRRJIYVt9VRwfLnzyKK13mbpeZKqTI2Hs Zg6SkcFPcxGg20jHsiUmHPhnX2lz3oeR5G/01wi3BkDsxBjZF9MOavScLUoNXjLQJV iOkMaD/gWLyrQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 4F3DA404A1; Wed, 31 Aug 2022 09:30:03 -0300 (-03) Date: Wed, 31 Aug 2022 09:30:03 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Kan Liang , Thomas Richter , James Clark , Miaoqian Lin , John Garry , Zhengjun Xing , Florian Fischer , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, perry.taylor@intel.com, caleb.biggers@intel.com, kshipra.bopardikar@intel.com, Stephane Eranian Subject: Re: [PATCH v1 2/8] perf metric: Return early if no CPU PMU table exists Message-ID: References: <20220830164846.401143-1-irogers@google.com> <20220830164846.401143-3-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220830164846.401143-3-irogers@google.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org Em Tue, Aug 30, 2022 at 09:48:40AM -0700, Ian Rogers escreveu: > Previous behavior is to segfault if there is no CPU PMU table and a > metric is sought. To reproduce compile with NO_JEVENTS=1 then request > a metric, for example, "perf stat -M IPC true". > > Fixes: 00facc760903 ("perf jevents: Switch build to use jevents.py") > Signed-off-by: Ian Rogers Before: $ make -k NO_JEVENTS=1 BUILD_BPF_SKEL=1 O=/tmp/build/perf-urgent -C tools/perf install-bin $ perf stat -M IPC true Segmentation fault (core dumped) $ After: $ perf stat -M IPC true Usage: perf stat [] [] -M, --metrics monitor specified metrics or metric groups (separated by ,) $ Better, but perhaps we could provide some better message as to why the metric provided isn't acceptable? Anyway, applied to perf/urgent. Thanks, - Arnaldo > --- > tools/perf/util/metricgroup.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index ad5cacdecd81..18aae040d61d 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -1655,6 +1655,9 @@ int metricgroup__parse_groups(const struct option *opt, > struct evlist *perf_evlist = *(struct evlist **)opt->value; > const struct pmu_events_table *table = pmu_events_table__find(); > > + if (!table) > + return -EINVAL; > + > return parse_groups(perf_evlist, str, metric_no_group, > metric_no_merge, NULL, metric_events, table); > } > -- > 2.37.2.672.g94769d06f0-goog -- - Arnaldo