Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1228259rdh; Mon, 25 Sep 2023 06:57:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfVGQCejL90EcZJs4CTPOWiHHaU+5tQ4RGJdGtKfloHdFO7NZopIjAQ73nyt2gMo6JWSaB X-Received: by 2002:a17:903:2289:b0:1c1:f15c:976f with SMTP id b9-20020a170903228900b001c1f15c976fmr5300808plh.26.1695650258380; Mon, 25 Sep 2023 06:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695650258; cv=none; d=google.com; s=arc-20160816; b=zP1Fla8tlQdRXbVFrVLK9q29vGCbnvnPp6LJNWHHxyZK7zalMNx4z1zQ41eBLAExv4 Zx60ezb/hmTw/yV8tXS93esd+lpeO9U2JMJckF0bHDVO+VLuQ4qz8FHMJm+D8iB5LCxB EH8Zu3UxKeEYyJMwf4tnXc/IHRZomYJR05DCo84OElMSkdKEn0OoQ6At/sxHgSZyoYoQ ZKFNTgph3GJ84m8Uy15YWZIRnQ+DjnvNgFnotyeJtL/LnXFrS2x5nMFEJ8PGEBoN4Ooz rNsE/FAjCfnqTROrbqEYEO74d0iDyMc8mKPWV8ZfCxnifexeLy283llBAH+/6RG/pgSc ZQ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q2IrkQn/sGcXh4TgHYxzMtqboxi2ZTb0Piqie6JfnLg=; fh=aicQXd2sVDKynU70/92qv+8AnsPgYK5pq7fTzS41MP4=; b=X8+pLBSgDJhydz586pzIhA2hNwHPgbEJ6lUeawAe8wiXZtB6V9uFs65HBYTBLPq6Kl eqsGzV5gdtimNnshPb0GPEw6tYSPi6u9rkIc4hojt5QTEsS9q7g2k52ixqYQRXBvAnAw uiW+Zup0srOZPxE10EJlB4AU2iNd8xxTRYgXcoFurpKWsJxbjg/uazevZyQ1Ceep+mId qCTDldNB9UxVDVomQYCWx6dEHsEi2y3ZmrOcji232K6NmnQY11rr2/+Ro8RCcSvJ2mQ7 rweNIhveYDBGrqE+k9H9aOUhLbDlluOdMDCWA4bofwb0wMXoo1/BofgGd6Bcu4Rn7KEt TjOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ato+KAhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t16-20020a170902e85000b001c33cde7b3asi11248659plg.410.2023.09.25.06.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:57:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ato+KAhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2EA0D805A799; Sun, 24 Sep 2023 23:21:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232118AbjIYGV2 (ORCPT + 99 others); Mon, 25 Sep 2023 02:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232202AbjIYGUR (ORCPT ); Mon, 25 Sep 2023 02:20:17 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98AD5126; Sun, 24 Sep 2023 23:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695622810; x=1727158810; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9UMN3WZoocsNCZA/WkP90QJko5sdpEGQyaq/bysRWVc=; b=ato+KAheI19ZkAGjBsjq2msM6kandZnColS+jjD5WSUNwlOEirb0nkJ5 8DEhx15n6spgkM/VQUcei469WcYKGWWQq7ZFHHRSU6zVavkOrMi9RQ2Ya MkgLH9Hg1K8gLpsh7+vTFkBK/O1hbi6ynNUeCPU7TfZAX1NUUfzlgjvUb nm7Tcsj7YGWxNeHO5t6vL4nzFABhcvm/CqmsASVD5OVVz5rNGKjWYtX0D cELZJ/3ZTNFJR+3BR0JBdPGs5ih9nKcO1D0XQYU9ekl2FebyDdPZWuADT 1ZjXXq1qiSAbLZqu9PsUt1UbVd2dZkLADG4HL24dBrBVqAHANZ0+VHLx6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="445279564" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="445279564" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 23:19:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="818494453" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="818494453" Received: from b49691a75598.jf.intel.com ([10.54.34.22]) by fmsmga004.fm.intel.com with ESMTP; 24 Sep 2023 23:19:25 -0700 From: weilin.wang@intel.com To: weilin.wang@intel.com, Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers , Mark Rutland Subject: [RFC PATCH 24/25] perf stat: Add check to ensure correctness in platform that does not support hardware-grouping Date: Sun, 24 Sep 2023 23:18:23 -0700 Message-Id: <20230925061824.3818631-25-weilin.wang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230925061824.3818631-1-weilin.wang@intel.com> References: <20230925061824.3818631-1-weilin.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 24 Sep 2023 23:21:33 -0700 (PDT) From: Weilin Wang Add check and return with -EINVAL when event json files do not support hardware aware grouping so that the program could successfully fall back to normal grouping without segfault. Signed-off-by: Weilin Wang --- tools/perf/util/metricgroup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 6a4404226..1c89c9371 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -1684,6 +1684,8 @@ static int metricgroup__add_metric_event_callback(const struct pmu_event *pe, struct metricgroup__add_metric_event_data *d = data; if (!strcasecmp(pe->name, d->event_name)) { + if (!pe->counter) + return -EINVAL; event = event_info__new(d->event_id, pe->pmu, pe->counter, pe->taken_alone, /*free_counter=*/false); if (!event) -- 2.39.3