Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1256707lqj; Mon, 3 Jun 2024 15:45:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXe0U4XmeMwCPXgB5lzdZqZiCtZnRplWWKBM2hX45PZfdS5vyNm9uIGbna7gGF8fM81TkzgDAZsdESsa9ocTroTLabnbg5cAVBr/nAjag== X-Google-Smtp-Source: AGHT+IGMfusICZD4OVzVg3/5mWLo+X/4q4gnAKIfpbaIg44YOiKbFHGzV2JCkTNQs9yPWXgPrI1/ X-Received: by 2002:a17:90b:1012:b0:2bd:92e6:ff1a with SMTP id 98e67ed59e1d1-2c1dc58fa63mr8673380a91.29.1717454710683; Mon, 03 Jun 2024 15:45:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717454710; cv=pass; d=google.com; s=arc-20160816; b=A7oe8/MT0vP8a3mTcacLykCAMvxHT61Opd/+twNQ0KsxdB3+JIHO9SDJwGwGP5JU0t DGnn2JiVvI5s/RBdvvuZFoDos4kR40mhmjfqoHej88XNTmrcQAFXeV1bFgu9ILdcsgYn ndfZEwYKXMIiWQgF71Y+ymcO59DpIS3fqJJNHSg9wvySU/qN09+TsxdafzSOU+szOYBT 3fMd8nwYSPN2/wtxqNJyCRbFQfOT7RrqH/Tcxjq6KFcjqNR52/YupvdQjRDgJauZ4OuG X6GdGifRwz84u3SJREXXY4FXRIG5jhY9h1krsFeZkJpeoSAZFHw2FnD0kbRC2EyWltQV 3PRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GkA/FRuQ2uBEMekp+bXx87GxTlkDPPfT6LywGKvnQS0=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=vQEDMu7qrJxgx49ho6CAVAkStip82ljsGGMIeDwYDu8BdbQI8bpQz0NaHH/MHnnDi1 K2Q3KYJUYI0unkisRJkqV8T78+/y7ns75xre9gTrv34Zacp1fFG0G4T5oS4t//1Xu5Tk SwJNeWqDhd7uC62PMHJfssnw5foMEXKSRRrLxQv6xWSA0f9SVV7ogmpMc5eJ3Jc0ob2A uwZikiqqbCb0kblQKrZJ5MPoFH5CoKDhwVBm3lJMpiMUa349E1vKpNQhWRl9bXHy/xt0 LNxyd8z2jUYsDOs01GmUljNIMko7+ORIxMRlDChgXlDOY1hFacRQ45m66e3OsM9C2ajD VS5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NdsIo1cG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199791-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2534ff60dsi450923a91.61.2024.06.03.15.45.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 15:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199791-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NdsIo1cG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199791-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 63033B2351B for ; Mon, 3 Jun 2024 22:44:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A65513D501; Mon, 3 Jun 2024 22:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NdsIo1cG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46D7B13D27F; Mon, 3 Jun 2024 22:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454656; cv=none; b=tjIpAX/6e7w5H3C7sD3j/C5QiOx5Yxh/i/fQI70GeYB+5k4LF5HbdpNHcmrQjSOnxveGHLQguxyBbO1GvpDfkEosS4oHdaYhhsXPaUqqC7QJ6o67D/x15SQWkjVGuuSThjt6ZhQzuuzhKCmjBLJb9FcggPonXeTw3na5YPoDHY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454656; c=relaxed/simple; bh=jSrJ9iNN+XlHHSV30984S7Q4L1nAEpF0UPaMLYCqwls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OtmeDSt/I+5hqzzhpwaGgoaDPzi9WhL8+zrtR9ZzEm94pvnsAxq3y05zqYlppEDPhoxnRqn7/8hiNcheoRrJF9H5fXjqrG8UTLxLJzaiNURNG1+xlX9L0WDVrBA9dz6pGdd80JKgMvutNuGW/QGRfqjGg8b3rbW1nb9//txksrc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NdsIo1cG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E086C4AF0E; Mon, 3 Jun 2024 22:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717454655; bh=jSrJ9iNN+XlHHSV30984S7Q4L1nAEpF0UPaMLYCqwls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NdsIo1cGRDVOLo7Wc9L5DwpE676YaatVb0A00KZ+q3/e2HFYep7utc/faVMlW4I0p LWLBA9ZrIB1Z/OF1G5k8gnbQ+/zvo8it0anU29XD2gna1w7CuwjdrZ5QhY64MjwK0R A1Epr7I/b5apbN8S4xFhzrDkHGDharrm0xFWQY61WcmHL+/2PL4sNzrTK14lJ+DP1b RrpBcy409IyjYQ0pU/i0jPcXYoV4Zgc8TXXK601HkqSn0HLVQnmXYg7gC9tqRP3Jwx O2HhemQmEJ3iQ0l9KQZ8K8LAfzU7/24CtgyNBsA8yyCt4yDSNde/Y/tEya3ZEkweLm gWjoxLJKieszQ== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 4/4] perf hist: Honor symbol_conf.skip_empty Date: Mon, 3 Jun 2024 15:44:12 -0700 Message-ID: <20240603224412.1910049-5-namhyung@kernel.org> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog In-Reply-To: <20240603224412.1910049-1-namhyung@kernel.org> References: <20240603224412.1910049-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit So that it can skip events with no sample according to the config value. This can omit the dummy event in the output of perf report --group. Signed-off-by: Namhyung Kim --- tools/perf/ui/hist.c | 18 ++++++++++++++++-- tools/perf/util/evsel.c | 13 ++++++++++--- tools/perf/util/python.c | 3 +++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 539978c95cfd..d76062979ab7 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -95,6 +95,10 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, } for (i = 0; i < nr_members; i++) { + if (symbol_conf.skip_empty && + data[i].hists->stats.nr_samples == 0) + continue; + ret += __hpp__fmt_print(hpp, data[i].hists, data[i].val, data[i].samples, fmt, len, print_fn, fmtype); @@ -296,8 +300,18 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt, int len = fmt->user_len ?: fmt->len; struct evsel *evsel = hists_to_evsel(hists); - if (symbol_conf.event_group) - len = max(len, evsel->core.nr_members * fmt->len); + if (symbol_conf.event_group) { + int nr = 0; + struct evsel *pos; + + for_each_group_evsel(pos, evsel) { + if (!symbol_conf.skip_empty || + evsel__hists(pos)->stats.nr_samples) + nr++; + } + + len = max(len, nr * fmt->len); + } if (len < (int)strlen(fmt->name)) len = strlen(fmt->name); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 4f818ab6b662..befb80c272d2 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -53,6 +53,7 @@ #include "../perf-sys.h" #include "util/parse-branch-options.h" #include "util/bpf-filter.h" +#include "util/hist.h" #include #include #include @@ -830,16 +831,22 @@ const char *evsel__group_name(struct evsel *evsel) int evsel__group_desc(struct evsel *evsel, char *buf, size_t size) { int ret = 0; + bool first = true; struct evsel *pos; const char *group_name = evsel__group_name(evsel); if (!evsel->forced_leader) ret = scnprintf(buf, size, "%s { ", group_name); - ret += scnprintf(buf + ret, size - ret, "%s", evsel__name(evsel)); + for_each_group_evsel(pos, evsel) { + if (symbol_conf.skip_empty && + evsel__hists(pos)->stats.nr_samples == 0) + continue; - for_each_group_member(pos, evsel) - ret += scnprintf(buf + ret, size - ret, ", %s", evsel__name(pos)); + ret += scnprintf(buf + ret, size - ret, "%s%s", + first ? "" : ", ", evsel__name(pos)); + first = false; + } if (!evsel->forced_leader) ret += scnprintf(buf + ret, size - ret, " }"); diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 0aeb97c11c03..88f98f2772fb 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -23,6 +23,7 @@ #include "util/env.h" #include "util/pmu.h" #include "util/pmus.h" +#include "util/symbol_conf.h" #include #include "util.h" @@ -50,6 +51,8 @@ #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #endif +struct symbol_conf symbol_conf; + /* * Avoid bringing in event parsing. */ -- 2.45.1.288.g0e0cd299f1-goog