From patchwork Thu Nov 9 16:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 163520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp566188vqs; Thu, 9 Nov 2023 08:52:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGS1MvDcRNu/AKVrOSl1lmgDWUKO4XOvpLX8wSeZUUv+s1HuJG8enDqrckhR+13j/7pqrUq X-Received: by 2002:a05:6808:ec2:b0:3a7:2598:ab2c with SMTP id q2-20020a0568080ec200b003a72598ab2cmr2476414oiv.7.1699548750290; Thu, 09 Nov 2023 08:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699548750; cv=none; d=google.com; s=arc-20160816; b=qGVGUE3pMAJ+oAtQLvXGcPQwxvcwNFlUIrvpvd4NAPx+H0Wzx0enEBsY4BJRGUmKmE SLbyb9xXy2aa/2/THJk2FTXx3879gKSATVpLaSrDh+R6MamkbLmOz5iTxjqP4uh6I8gL 5eQ7mYy/3s2dEH/+x0OL4+FpxMKtFXbZ711XsVx4PUryadcVvzD+iF7Y93h/WKNpa5br 5lfRPtYrO5XF8UEmNxlfWZ0C96pPs3+pwKiIWE+MMIa8pqoSXneE3gX21+beyCOf+FUf 9VE8U2qUoOoiCRStRTVsVrb6JmN+akZk8/+5n/SWgOZqf69m6ZSK2rEWkxRJtUIC2gb6 mPVw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZOWJH7Y7PGAH4rL6YZen3J1HhaI/3jjvXLYYYwJ+Rv0=; fh=D+kl9R+jTJEwAwqiAxEC2cJTZTxuNVFMR/Q334V6DjY=; b=BxRgyauLTtoqxv8hV66JFKAgrK4YI6i/Af5P4m565yKfmGDaJogl/kzQtoDLH+LOs2 soM4zlxlO82F/9TtmdskdoLtnWn0ZB7byv/EDYWsz1ybcEXkWijxy9mblx44FFT5sJCu ZpPkB3BIxZJbsHdzirFD2g2iY4RJ4h69to4XCvncAVn6j8xFLKh6+HXq7M6f/CVyRJLG tc50V1PdhVm/10Zp72Wo0tDJ14B2fww7Wm8s+nyCiwIZFfRVGA0VY9FExLn7Iyi+l7z/ ahHdvGCsdNSNmjjqsA8zvtuAgCcp/EUEjiRdm+XWCnZsVUAJ5tjWKXmcc36rgBJ887Jk C/lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="kk/oULXC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k190-20020a636fc7000000b005b7d9aace9dsi7343255pgc.46.2023.11.09.08.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:52:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="kk/oULXC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id A9D1383805EA; Thu, 9 Nov 2023 08:52:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343808AbjKIQwN (ORCPT + 31 others); Thu, 9 Nov 2023 11:52:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235113AbjKIQwC (ORCPT ); Thu, 9 Nov 2023 11:52:02 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C488F6F9B; Thu, 9 Nov 2023 08:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699548073; x=1731084073; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=KzH3foBT6935svPDaKLGpoAT5Z4PddTwZ1RPNXFCxow=; b=kk/oULXCCUHAByIHMC3ioK0C4IA09eVIH2jeDnm142TA7fQAeYV5gKKy 40Bki5PjtNRP6NypT1hNClLQbwy+3+60aGXMUA0e+yqr0rI+G48rLHhXu 062wNfIdYOtvo0cjkPayzTEyD+Hb16A4AY7s+aWAF7UMEAIYyDrl3+6NT 6mv+Jy8yEwh5ceaEo5idXBj67ReMRQIJis4YQuNhZHxxLLc0Kc6FLxtXl rMlfEudU88DOeYSX8kQe6InD6oO6xgV0Qv8cQ1nKlV82uh71NU2EY7ypS WeS6PwmgET7IH9ass3DvSnoNYyPkUro/tJUgG9u7YolYcO85/e1/yn3kK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10889"; a="388879751" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="388879751" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 08:41:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10889"; a="763462743" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="763462743" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga002.jf.intel.com with ESMTP; 09 Nov 2023 08:41:04 -0800 From: kan.liang@linux.intel.com To: acme@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, tinghao.zhang@intel.com, Kan Liang , Arnaldo Carvalho de Melo Subject: [PATCH] perf evsel: Ignore the non-group case for branch counters Date: Thu, 9 Nov 2023 08:40:07 -0800 Message-Id: <20231109164007.2037721-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 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 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:52:25 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782106030366570208 X-GMAIL-MSGID: 1782106030366570208 From: Kan Liang The perf test 27: Sample parsing fails with the branch counters support introduced. The branch counters feature requires all the events to belong to a group. There is no problem with the normal perf usage which usually initializes an evlist even for a single evsel. But the perf test is special, which may not initialize an evlist. The Sample parsing test case is one of the examples. The existing code crashes with the !evsel->evlist. Non-group means the evsel doesn't have branch counters support. Reported-by: Arnaldo Carvalho de Melo Closes: https://lore.kernel.org/lkml/ZUv+G+w5EvJgQS45@kernel.org/ Signed-off-by: Kan Liang --- tools/perf/util/evsel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 58a9b8c82790..7a6a2d1f96db 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2355,6 +2355,10 @@ static inline bool evsel__has_branch_counters(const struct evsel *evsel) { struct evsel *cur, *leader = evsel__leader(evsel); + /* The branch counters feature only supports group */ + if (!leader || !evsel->evlist) + return false; + evlist__for_each_entry(evsel->evlist, cur) { if ((leader == evsel__leader(cur)) && (cur->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS))