Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1284046lqt; Fri, 7 Jun 2024 13:30:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzOjJ+b+fsASdBmY5aX+8eXRlyrmYk7oJMk/qImHS33dxeggGJN9J2RZusF0/YNg+mZ31xT1+pOKMR8t74EjMAT8KetC4fJ1L/IM7d2w== X-Google-Smtp-Source: AGHT+IFnSsQpKUoWeuItLAD6ZhLRzu7pQvjCMcxDe3k5KXyRYYoJj09usKw2o/GQRvrWUXnJFGSh X-Received: by 2002:ae9:e713:0:b0:794:7776:d078 with SMTP id af79cd13be357-7953c5f87d6mr357563485a.73.1717792235226; Fri, 07 Jun 2024 13:30:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717792235; cv=pass; d=google.com; s=arc-20160816; b=0E3NrX8xkq2d3K1BVzBd4T5KeUNcR2XTvnfyg/kmzQBGH6Zr/oPTy0qXD55DauvVtV oawZTyEV9zxZ+Y99lVtTU70jL60KMMIFgpeuV1/wYQTmOmYHEcISiAw7xgGdDn9kFoLr n9S0jdyUJJfu0b9mImmGY7mYjuEl1f7J+ZIFN1TZA66Te0QDMFJ0X46Sbj0PhRpZz/X9 0vJJq457n7+FnZkyhOnJ9CSRUVfzHWIUYPQhgalYgAW69pKkNgL8BjjkWGqOlR8EuOPS R1+f9vLYpbmxUkLpqnxnEYtoLBvWpNx85E5xbY8VAzJ61LQyJxw1Ul6TvD5AStlJ9KGS 90aA== 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=5iGvggoXa7G6Yl1takJjyNnRIO1WUcQ4sJmamZrsTyo=; fh=VvmxeZa3Qe1p4ODl48ZXIELSHJLsywFHVgxPDK6aBdM=; b=yixWNkqhapLxr7wZQai/mDmLKu+W0pQHbpEd15NykdDMNQbcnDKc1d+osB4+9L2KWg 5UpYZHzQAKbegICwC4O28oH8ovllJVqXjkT6wpMQ1I66YLykXnlFZvlu4/Ccnj6KD+85 U76pkAMgpw/yVcy5oT/eB+maotiyEPgFB3IGICIDJwng51MsXvBQmtO0pf+PVm3Xo16Y F0CX8RE4mim+f0rPtVlqNWZI/JGjS2WGeH6fyEtid/K2mVOwmwuFBfSHzou2zzsFVHfF CBL6++pyKe4Fp9G2RX15hToFSB0bkqEPBXxxIHE2Yq+ngiXCGCM4mscr5csP2pt1zJj1 qTQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ky9ue0y+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44038b82069si50080291cf.759.2024.06.07.13.30.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 13:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ky9ue0y+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206708-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E1F311C21809 for ; Fri, 7 Jun 2024 20:30:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7743E15572E; Fri, 7 Jun 2024 20:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ky9ue0y+" 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 2BAA21552EF; Fri, 7 Jun 2024 20:29:21 +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=1717792162; cv=none; b=A3D7mIjjpzBX785rYPBZslvvtWSGdpZEwNkY4REZVmsoxDyQyFUZx51wYhJ+bwLPLMpUfSp7kfBQr5ylhxYdZyp2qYChAOoYCTvPJC+zLLtNuBMjJ9t8FI6kmgwhnWNhoCgWuVwNZSC++J20nHUwJFNEAJArPMBlxT0HEQLO1Wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792162; c=relaxed/simple; bh=Bdv1T3V+QVoamQb/wjWYwDu3U6qdpHhyUU9S4KSBk3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TDf61lMMVPsDBIHRuXBE+KC9g4uedh+76QV+2ndnJqzKdnG1Q458ooxMc7E07/nlRUtYbvlzLEU81HBYqfzFscEKA+m8K6Sg0HCx1KrZXqvHr82egLTlj0Qm8BrvX5hnoo3clXw0px1I30RpiSddtTQLOy9EfZQRHrcrPMbj3OY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ky9ue0y+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60982C4AF0F; Fri, 7 Jun 2024 20:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717792161; bh=Bdv1T3V+QVoamQb/wjWYwDu3U6qdpHhyUU9S4KSBk3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ky9ue0y+/xNybgFOEj5pGu0kOmr7vYGQrZQBMDpDR5oWSotHdAojnDD9Nfu1TzIUa WLbq0nlyvnSpZY7NXuwXiMtNnAg926Dm7Ge3wgd1/cB/Ie8885mkgVPrhA3HmZrT6s 4NS4tAIlzCepbJtzqLhpczQwr3kEreT8R6wM+/YsDQ5QF8gdMT+hMBx5/dYykDOErZ 3MMpO7Vaw0uM3/g4n9egvEEHkf9JOj2ZLpU58uCp461qsvEx4kOeuHuNgzxy/7aIKp nK4yR5Nl+BXMJog7sY6NFEO3Qr3I6jyucwbNHFQfD3mPExW8ClVSlWmEM9HReuuZHP sbz9Hml6g18og== 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, Arnaldo Carvalho de Melo Subject: [PATCH 4/4] perf hist: Honor symbol_conf.skip_empty Date: Fri, 7 Jun 2024 13:29:18 -0700 Message-ID: <20240607202918.2357459-5-namhyung@kernel.org> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240607202918.2357459-1-namhyung@kernel.org> References: <20240607202918.2357459-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. An example output: $ sudo perf mem record -a sleep 1 $ sudo perf report --group Before) # # Samples: 232 of events 'cpu/mem-loads,ldlat=30/P, cpu/mem-stores/P, dummy:u' # Event count (approx.): 3089861 # # Overhead Command Shared Object Symbol # ........................ ........... ................. ..................................... # 9.29% 0.00% 0.00% swapper [kernel.kallsyms] [k] update_blocked_averages 5.26% 0.15% 0.00% swapper [kernel.kallsyms] [k] __update_load_avg_se 4.15% 0.00% 0.00% perf-exec [kernel.kallsyms] [k] slab_update_freelist.isra.0 3.87% 0.00% 0.00% perf-exec [kernel.kallsyms] [k] memcg_slab_post_alloc_hook 3.79% 0.17% 0.00% swapper [kernel.kallsyms] [k] enqueue_task_fair 3.63% 0.00% 0.00% sleep [kernel.kallsyms] [k] next_uptodate_page 2.86% 0.00% 0.00% swapper [kernel.kallsyms] [k] __update_load_avg_cfs_rq 2.78% 0.00% 0.00% swapper [kernel.kallsyms] [k] __schedule 2.34% 0.00% 0.00% swapper [kernel.kallsyms] [k] intel_idle 2.32% 0.97% 0.00% swapper [kernel.kallsyms] [k] psi_group_change After) # # Samples: 232 of events 'cpu/mem-loads,ldlat=30/P, cpu/mem-stores/P' # Event count (approx.): 3089861 # # Overhead Command Shared Object Symbol # ................ ........... ................. ..................................... # 9.29% 0.00% swapper [kernel.kallsyms] [k] update_blocked_averages 5.26% 0.15% swapper [kernel.kallsyms] [k] __update_load_avg_se 4.15% 0.00% perf-exec [kernel.kallsyms] [k] slab_update_freelist.isra.0 3.87% 0.00% perf-exec [kernel.kallsyms] [k] memcg_slab_post_alloc_hook 3.79% 0.17% swapper [kernel.kallsyms] [k] enqueue_task_fair 3.63% 0.00% sleep [kernel.kallsyms] [k] next_uptodate_page 2.86% 0.00% swapper [kernel.kallsyms] [k] __update_load_avg_cfs_rq 2.78% 0.00% swapper [kernel.kallsyms] [k] __schedule 2.34% 0.00% swapper [kernel.kallsyms] [k] intel_idle 2.32% 0.97% swapper [kernel.kallsyms] [k] psi_group_change Now it doesn't have a column for the dummy event. Tested-by: Arnaldo Carvalho de Melo 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 7e863cd92781..5d1f04f66a5a 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 && + values[i].hists->stats.nr_samples == 0) + continue; + ret += __hpp__fmt_print(hpp, values[i].hists, values[i].val, values[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.2.505.gda0bf45e8d-goog