Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5000105rdb; Tue, 12 Dec 2023 16:14:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRE3vJ+JGGmdJWloWeD2rcTiBb0FfjU3xhFER6nM3J5U+WsVdkTbFAkghw5zBNKA/0QmHY X-Received: by 2002:a05:6a20:1604:b0:18c:b464:eba3 with SMTP id l4-20020a056a20160400b0018cb464eba3mr4499052pzj.7.1702426495883; Tue, 12 Dec 2023 16:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702426495; cv=none; d=google.com; s=arc-20160816; b=eD4CrFwosuqAfSW2IKpFVjRhx9FjsCuOVkAZ+arxjMrl/lEsy/doSquehm5iJxq/O5 9ZEOuNX9LMI4qbUMs1cdHnK4QpTXdMM8kTwTWl9OdIJvarSNHydCuLBEe1X5sSWwL80x rUHOxD+V+4yMVirn3ktKu7mV2J7DLmvDhxs6kW7AvNoxC5Gu3fx2QU2I+HBPOq07Am8O GdsaYhr2aSw+mPoYUH83OfIjkrd54a/14WAZ1M4aDyIbxN0YDLIAv0EfU+GW2x3Zq+4T gxcNlQpakHCxAqposJWQivGczZA8R+0qB+sopS4WU1vQ+IkV5GhjQX2SlgrGv24civDg sItw== 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:sender :dkim-signature; bh=Q4UEMHhiignCwX0EjxC7/0B5MhyjQn86th3on3YHVjY=; fh=7Id7wL2M+oCJXD4imOzx4OKioxBXSOZqypDprm7aO4E=; b=GzTVYINQN53C/sdDgE5szrl5Uzdqs+zWDqWDNZVjimiWslPCqbYcvBBb9bxzRy5wTq 3T9cL5MSU9lKjP0jEhF46aoTkyEUfjIve2VMZz6gIkxnX4DA1euXMk5TqVKLZU2bYdQ4 EuIllq0jn01RtFDnoWh+yRsn5OMnltOUJQqHailyQkAfEn+WPelJHIQUNClBt14IIpMD sYPB0wkD5LzE9e1F63kzEkG6NxLhvBYilNHNXTIB5a/a86c8N9wSVVe0hS/Ad6fGizid XkNE1vdZ00tJArda6ho3afq5lQr20M86EgNxXFsfCBKs/8XK06x/q3RKpyxhVZG3ft2D f5JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YB5Gx0Vh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id nm14-20020a17090b19ce00b002860ab2ad3dsi8585295pjb.57.2023.12.12.16.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YB5Gx0Vh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3371180B284A; Tue, 12 Dec 2023 16:14:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378159AbjLMAO3 (ORCPT + 99 others); Tue, 12 Dec 2023 19:14:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377930AbjLMAOK (ORCPT ); Tue, 12 Dec 2023 19:14:10 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC971BF; Tue, 12 Dec 2023 16:13:51 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d0ccda19eeso39492205ad.1; Tue, 12 Dec 2023 16:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702426429; x=1703031229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Q4UEMHhiignCwX0EjxC7/0B5MhyjQn86th3on3YHVjY=; b=YB5Gx0VhKM5KpNaWf89X3AlRS615oRwOZdVZp8nk2SQAzwyh/cSwYb5KRIF5w27PmP Wz1gtz12XqO8kTP4Wjgcc6Fs2/ZzN8msPZAPtbOrYEM79Bvl7UCw4QrN+R95LXR0fGEj kXX2ez7f7ysEaSv8mM3eUJoUoH6hYutfZYBnscJDT2Mr5vchIX8RtowfB7bnF83JGkj9 MiqlB5ZU9Vz+F7kRpAR6MwFWggR68YgygOY9Ir4X8/OQG5O49N+Bao+eCmAGCXz6e3OG MrZe+0aPQBLKw1GkND4JbwSVaQTxbIoZhknaFNMRJeGqlBIc3qDhE6ZDI4F5elmqXHc7 DZ2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702426429; x=1703031229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Q4UEMHhiignCwX0EjxC7/0B5MhyjQn86th3on3YHVjY=; b=ihe4CqDf45HpVjBcaLrIzI0vbE8o+qnmz82u5Kg8qRawq7WF0Gq2FjibUOjPrqXacO s+rRmhIrHIqLFndwQqmiThxkH5f/8q/5n9ZSvGGGA5zWRkVNz+VbIAXJp2m7NluGTCOc lFapJf59LM5pzQWrQZPZP29Nw6tPcVFyx+RTWKyIdNoB9dykLYJfQKeYyWlwkhej5OSo 7mTIvzXnR0u+XlaMheWtHcji8aslmT4S+zkXiOWUSZkI71Xwr0EIzzTIHBPlBPrWMbjJ dDGJ0ri4wjbmRvKkvOQhhThMsqRTgOkCEU56kBT1gEDZl1myK/PWHonNdHXckenKFgVS JneA== X-Gm-Message-State: AOJu0YwBBgkPk/+VOAUfzOaRV6Ltjy7yuu1x9syHmm/5j1wV7u5HqD2V AKBE/zBJZl04WUgLgo0v+5U= X-Received: by 2002:a17:903:44a:b0:1cc:446c:770c with SMTP id iw10-20020a170903044a00b001cc446c770cmr3763140plb.33.1702426429067; Tue, 12 Dec 2023 16:13:49 -0800 (PST) Received: from bangji.corp.google.com ([2620:15c:2c0:5:8251:f360:4316:214e]) by smtp.gmail.com with ESMTPSA id i11-20020a17090332cb00b001d0ab572458sm9136398plr.121.2023.12.12.16.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:13:48 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra Cc: Ian Rogers , Adrian Hunter , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Linus Torvalds , Stephane Eranian , Masami Hiramatsu , linux-toolchains@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH 13/17] perf report: Add 'symoff' sort key Date: Tue, 12 Dec 2023 16:13:19 -0800 Message-ID: <20231213001323.718046-14-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213001323.718046-1-namhyung@kernel.org> References: <20231213001323.718046-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 12 Dec 2023 16:14:53 -0800 (PST) The symoff sort key is to print symbol and offset of sample. This is useful for data type profiling to show exact instruction in the function which refers the data. $ perf report -s type,sym,typeoff,symoff --hierarchy ... # Overhead Data Type / Symbol / Data Type Offset / Symbol Offset # .............. ..................................................... # 1.23% struct cfs_rq 0.84% update_blocked_averages 0.19% struct cfs_rq +336 (leaf_cfs_rq_list.next) 0.19% [k] update_blocked_averages+0x96 0.19% struct cfs_rq +0 (load.weight) 0.14% [k] update_blocked_averages+0x104 0.04% [k] update_blocked_averages+0x31c 0.17% struct cfs_rq +404 (throttle_count) 0.12% [k] update_blocked_averages+0x9d 0.05% [k] update_blocked_averages+0x1f9 0.08% struct cfs_rq +272 (propagate) 0.07% [k] update_blocked_averages+0x3d3 0.02% [k] update_blocked_averages+0x45b ... Signed-off-by: Namhyung Kim --- tools/perf/Documentation/perf-report.txt | 1 + tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 47 ++++++++++++++++++++++++ tools/perf/util/sort.h | 1 + 4 files changed, 50 insertions(+) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index b57eb51b47aa..38f59ac064f7 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -120,6 +120,7 @@ OPTIONS - simd: Flags describing a SIMD operation. "e" for empty Arm SVE predicate. "p" for partial Arm SVE predicate - type: Data type of sample memory access. - typeoff: Offset in the data type of sample memory access. + - symoff: Offset in the symbol. By default, comm, dso and symbol keys are used. (i.e. --sort comm,dso,symbol) diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 18128a49309e..4a0aea0c9e00 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -84,6 +84,7 @@ enum hist_column { HISTC_SIMD, HISTC_TYPE, HISTC_TYPE_OFFSET, + HISTC_SYMBOL_OFFSET, HISTC_NR_COLS, /* Last entry */ }; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index d78e680d3988..0cbbd5ba8175 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -419,6 +419,52 @@ struct sort_entry sort_sym = { .se_width_idx = HISTC_SYMBOL, }; +/* --sort symoff */ + +static int64_t +sort__symoff_cmp(struct hist_entry *left, struct hist_entry *right) +{ + int64_t ret; + + ret = sort__sym_cmp(left, right); + if (ret) + return ret; + + return left->ip - right->ip; +} + +static int64_t +sort__symoff_sort(struct hist_entry *left, struct hist_entry *right) +{ + int64_t ret; + + ret = sort__sym_sort(left, right); + if (ret) + return ret; + + return left->ip - right->ip; +} + +static int +hist_entry__symoff_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) +{ + struct symbol *sym = he->ms.sym; + + if (sym == NULL) + return repsep_snprintf(bf, size, "[%c] %-#.*llx", he->level, width - 4, he->ip); + + return repsep_snprintf(bf, size, "[%c] %s+0x%llx", he->level, sym->name, he->ip - sym->start); +} + +struct sort_entry sort_sym_offset = { + .se_header = "Symbol Offset", + .se_cmp = sort__symoff_cmp, + .se_sort = sort__symoff_sort, + .se_snprintf = hist_entry__symoff_snprintf, + .se_filter = hist_entry__sym_filter, + .se_width_idx = HISTC_SYMBOL_OFFSET, +}; + /* --sort srcline */ char *hist_entry__srcline(struct hist_entry *he) @@ -2335,6 +2381,7 @@ static struct sort_dimension common_sort_dimensions[] = { DIM(SORT_SIMD, "simd", sort_simd), DIM(SORT_ANNOTATE_DATA_TYPE, "type", sort_type), DIM(SORT_ANNOTATE_DATA_TYPE_OFFSET, "typeoff", sort_type_offset), + DIM(SORT_SYM_OFFSET, "symoff", sort_sym_offset), }; #undef DIM diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index d806adcc1e1e..6f6b4189a389 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -249,6 +249,7 @@ enum sort_type { SORT_SIMD, SORT_ANNOTATE_DATA_TYPE, SORT_ANNOTATE_DATA_TYPE_OFFSET, + SORT_SYM_OFFSET, /* branch stack specific sort keys */ __SORT_BRANCH_STACK, -- 2.43.0.472.g3155946c3a-goog