From patchwork Mon Dec 4 18:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 173502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2950264vqy; Mon, 4 Dec 2023 10:23:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBDJQ6gA8mlUtIosA1+yLtxt2aG9n7SYM/fb4aXPdXJRGASJwe9jEQAA9QELgfd/4+BB3G X-Received: by 2002:a17:903:264f:b0:1cc:5a74:b1df with SMTP id je15-20020a170903264f00b001cc5a74b1dfmr3881143plb.2.1701714223816; Mon, 04 Dec 2023 10:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701714223; cv=none; d=google.com; s=arc-20160816; b=xDewC7kgSRp7F0fHSJzdlnUkVIQsviF80cyI3N9uawOhZ948ADfTS8itRE0Muo1Q7N m0sWiaf+nDCdgz1Poun0UmndgJLOTO/VWBzNvAE0sBS+/c+YhsQbMbZAcSWgVUdSSOdy /tmhxDu2XrqqoqNj+47y+4MHJQjpj83W8xgDhLo/ZirdbE3plyISBgBOVJDwwOn+dG/T 1hk/vQEIT1bCgxHzfm8mWiBfl1gQUahWU8UkHXium/4nMAIh3iejAOq2MQqJe4khdiKP jnhv2dOdqm0N3xlcEsF7pJ1sVga8NpjSg3Yd6LX8zH+0NffdHGRGgfE1NiSUpXoiwU91 co0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=SZ0pxQHPPtXifBYnQK2oqRhP2CZVwJXTHj6rC9GaE3c=; fh=GdNrbVz4+rD5GDxx28FfX7pstWQA2odnFE24GYz37s4=; b=NH+zmuozxgxp0ha5YjRh8ye2B3n2hPaeaSnSPwSYGtwIh8ybmPHe+y6h8QXg9RPi+g d7ebtXAsOY0XFWwqGSUWrmynKXf1X/23zkhyaWo4l77CAANIj1O24AHCORwiMjotLr+n /UAz/0mMNUGxOdPpA+svxzAN7hBto8jj29EnZl+GphPsgAfgG1wFWjPy4fonOWTMqqMk ydJSTwQ1q7YckRuYtFh5lij3oeRPqGeUhi5TW+/abfOc9A7/khQUJWSAS2/Bm0ICxEhJ L3BsUvwiR2JwMi5V4srbhsbLm55pgZFurzZmkKcXnfv8zSB81cwVTRRd7N3fU1irwLKp zd3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=P9S4QcPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id v16-20020a63f850000000b005be1ee5be76si8352200pgj.373.2023.12.04.10.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:23:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=P9S4QcPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3CB988047560; Mon, 4 Dec 2023 10:23:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232726AbjLDSXa (ORCPT + 99 others); Mon, 4 Dec 2023 13:23:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232775AbjLDSXa (ORCPT ); Mon, 4 Dec 2023 13:23:30 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45414107 for ; Mon, 4 Dec 2023 10:23:36 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-db3ef4c7094so4420408276.1 for ; Mon, 04 Dec 2023 10:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701714215; x=1702319015; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=SZ0pxQHPPtXifBYnQK2oqRhP2CZVwJXTHj6rC9GaE3c=; b=P9S4QcPW5Eh/3vBzx4A6vHvsIbdvrm7Hvr0V0y80HGL8IYg62FJv6KsMWsMFdUaWMO N9qhefubyi1bAbmDVqjYEFrorVqM6RHQCOZNgOG+9i7ZZD4rMWtt+EAikFY7TcK97jNy epM4/byRmFSZyv8abKGyFOSyomlXjYA9AasUlktW06JTychjoMLxbnhTJWLFkxR3HEiI RCxo5XyDefB4n24h4kbjhVVwmuebJhCQl/80WvulztIoHDjVA6P5nvQJLHWzkCJPtHsa tbACaKlXYz6/cCHdQupSqlt0662wrsF7IV0nNneTIdROvdgH2Mf8EglzBeXAAtpiivyO AiWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701714215; x=1702319015; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SZ0pxQHPPtXifBYnQK2oqRhP2CZVwJXTHj6rC9GaE3c=; b=SGm2OLiprvWbTXkT7DOjqlVeMcnLaRsX8q07EuSSGNgXwLtiT89f1sD5etHnXhhP2b tOPJKqOTWiRIFuLvqMnwOykH5RnuIxBiVhbYPt54xhTenwUo96lz2rtI1chAjjVglNJG LtJHBToPYRFlxuSY2sMAM88BpJuMtYrAE4qUg5H/PPfdNyr67a/Ktc9MOqnwkigNDC1H F41Wd5Rub8U3xJBohdt5btW/n1yWfrIGS6AE0QV8RxFQAzWg/0OHxqOaD9DmnsDCt1pr XXvo66EW4q7X8AMDCHuN1F/lQwoMeOb0isC2epTnQGuTiUZO96r0A0af9gZAPKB32Nb7 /yUA== X-Gm-Message-State: AOJu0YwYeKD6icmluLJ2Vb7FHdqRparwX+Q4X56vjhg4tfLyUNgvP9I0 9LR+LG5RbtWYMBZ2mNVjWR6cVUNyAXdj X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b241:d804:967e:c827]) (user=irogers job=sendgmr) by 2002:a25:cace:0:b0:db5:4692:3aae with SMTP id a197-20020a25cace000000b00db546923aaemr331621ybg.4.1701714215509; Mon, 04 Dec 2023 10:23:35 -0800 (PST) Date: Mon, 4 Dec 2023 10:23:29 -0800 Message-Id: <20231204182330.654255-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Subject: [PATCH v1 1/2] perf metrics: Avoid segv if default metricgroup isn't set From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Ilkka Koskinen , Kan Liang , Kajol Jain , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:23:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784376693973485762 X-GMAIL-MSGID: 1784376693973485762 A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in default_metricgroup_cmp and perf_stat__print_shadow_stats_metricgroup that assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "". Fixes: 1c0e47956a8e ("perf metrics: Sort the Default metricgroup") Signed-off-by: Ian Rogers --- tools/perf/util/metricgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 0484736d9fe4..ca3e0404f187 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -225,7 +225,7 @@ static struct metric *metric__new(const struct pmu_metric *pm, m->pmu = pm->pmu ?: "cpu"; m->metric_name = pm->metric_name; - m->default_metricgroup_name = pm->default_metricgroup_name; + m->default_metricgroup_name = pm->default_metricgroup_name ?: ""; m->modifier = NULL; if (modifier) { m->modifier = strdup(modifier);