From patchwork Thu Oct 12 03:50:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 151697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp964752vqb; Wed, 11 Oct 2023 20:53:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfR6RPCODtGPdhWf4g28m7do90SAEnksuvfhRi2Sgkscv1H33YMF2TkEwHZU3rUDzm74Tg X-Received: by 2002:a05:6e02:60a:b0:34f:7ba2:50e8 with SMTP id t10-20020a056e02060a00b0034f7ba250e8mr22720365ils.2.1697082786533; Wed, 11 Oct 2023 20:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697082786; cv=none; d=google.com; s=arc-20160816; b=mp7vN0sRMvQQn3qnPvvYijV0STLBT9Rk/unusYJMHIsevpS2QKdUN0GAm+y9yuapla vfFaomwMM4SuDnh5S4kmrkE5rK8rYUdQZYpCBVvvt0eeK+Tln0HceUNEAXwyB9mEQySI jC7PZCnFSxThZChpX3+OqsrxjfbLFnTeqi6DIAJwSlK7Amsbh27dh4y03cIPN5stMDBa /KKw2CkqAidJnOXVzufzLkRsbahc7N9cZzVSZm7fqxRoS3Fu9wA2VhSd69NH/v3TcNc5 hc2t7IqDCB63MuBBCsR+2P62Mdr5x0Mogd9vNpobSBRBaLGsgGK7hHZyNIgb/vYeJRaH WYiQ== 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=ZII5vF3dprwXJP49CiS8ixHpGtBs+wAGFWOW7yk/k14=; fh=7Id7wL2M+oCJXD4imOzx4OKioxBXSOZqypDprm7aO4E=; b=d6/kAUQXcksDWYmygK3F+U8JmCuXo2nMnU2PTbj5nYX1BcBvFx7oDaSIfOWTvvS3bN 7GXx/YrYalbfla88ory2eLxfTnmIuC3tqt7UjIR7jIqpWpebQTrhfZkkNYkynXI75jWI KmqTMVmZmicxcx/dB4VppKo3loLoxfwAazvD8NB7Z/KrxZMgsmeuBZs0E/IpPlt7q39F +6GtO2reSUX7aich64L7ufDGpWysB6M0/JTj33kF2JarWeXd9IjqEJleNirN9u3neFEC WKq4yMEdggE5ZveQKQBWJmnedaiB7DBXd+9KVux8sbmF3GVVN28vVepUIE8q6l/ZfW7Y u1cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kKTQafDw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n5-20020a63f805000000b0058986c61bb6si1163244pgh.706.2023.10.11.20.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 20:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kKTQafDw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 7BA698043AE8; Wed, 11 Oct 2023 20:53:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377424AbjJLDw4 (ORCPT + 18 others); Wed, 11 Oct 2023 23:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377097AbjJLDwV (ORCPT ); Wed, 11 Oct 2023 23:52:21 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F32138; Wed, 11 Oct 2023 20:51:38 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bdf4752c3cso4012275ad.2; Wed, 11 Oct 2023 20:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697082696; x=1697687496; 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=ZII5vF3dprwXJP49CiS8ixHpGtBs+wAGFWOW7yk/k14=; b=kKTQafDwBS3LnqLJJl/sGP0kPj0dFyOBIdszVkK/c2O2NsyGGINKG2UTmdGs5LyK0q DbrAzKI97ANciQ9bHroC3HygOoGshLomfSW6ohN3RIj2iQn24zWWBmiehttQ1HkWg24Z wR2xqRRF46EOmQ2FeklYlhbmWIVXuAH4wsfUQuf7UfzF8WZ4FC5nkOtV5KcEP3Fs3u5z vy0T369S9P++g3ZvqQuF0dbgjn/njnmSuBGsplqFcLANPntNA3mchl+8B0InJ0CMF4Os /Bt0RODOFS06ypD4T3hxCSQ3LoszGLIX2yvAgZ827FhrVARijcvvTz+VGxyMEfA5I60m BCng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697082696; x=1697687496; 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=ZII5vF3dprwXJP49CiS8ixHpGtBs+wAGFWOW7yk/k14=; b=C4JwWdn4wVVKkSHJMuRHfY7MuX/Op71+9xPubXesNCeizBGlVnFPiH2GDEyG+cX1ed G97ceBTOzws+e3UYGrpXswelTycUG4BauNw8CjCdiZvUd2MHAoFsP+DC8efxBdG/BejH sNLK/XuwLJSmFMClTQ269Jpq1hzfz8AmZ+sCZGhr8LJQ1H4M9U0+Yk6vHppdz0qWrGtX umsAnXet5JHil0KS7airM/yAFVmManFDrAAzXAKhwO9fDRmq12HP5Y2c1dFxplQ4YtA8 gPTp0r9Irg1OGtiIQYDl/ydpe1HYRU3JNKdlk51JwU870uu3Yz6Rg1/qUe7bHPrH9G/m uEtg== X-Gm-Message-State: AOJu0YyCY1a3LgClmb59AeKdEjPFZiBMLg+RgKj2h6seVMl9aQVbxyOS 13GEA1RURYU7aSuFz+3s+EE= X-Received: by 2002:a17:902:6bc5:b0:1c9:bef4:e11 with SMTP id m5-20020a1709026bc500b001c9bef40e11mr5717841plt.46.1697082695866; Wed, 11 Oct 2023 20:51:35 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6780:42e0:b1b9:d490:2f5e:be06]) by smtp.gmail.com with ESMTPSA id w8-20020a170902d70800b001bc18e579aesm711374ply.101.2023.10.11.20.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 20:51:35 -0700 (PDT) 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 16/48] perf report: Support data type profiling Date: Wed, 11 Oct 2023 20:50:39 -0700 Message-ID: <20231012035111.676789-17-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog In-Reply-To: <20231012035111.676789-1-namhyung@kernel.org> References: <20231012035111.676789-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 20:53:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779520280092104945 X-GMAIL-MSGID: 1779520280092104945 Enable type annotation when the 'type' sort key is used. It shows type of variables the samples access at the moment. Users can see which types are accessed frequently. $ perf report -s dso,type --stdio ... # Overhead Shared Object Data Type # ........ ................. ......... # 35.47% [kernel.kallsyms] (unknown) 1.62% [kernel.kallsyms] struct sched_entry 1.23% [kernel.kallsyms] struct cfs_rq 0.83% [kernel.kallsyms] struct task_struct 0.34% [kernel.kallsyms] struct list_head 0.30% [kernel.kallsyms] struct mem_cgroup ... Signed-off-by: Namhyung Kim --- tools/perf/builtin-report.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index dcedfe00f04d..e60c6bb32d92 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -96,6 +96,7 @@ struct report { bool stitch_lbr; bool disable_order; bool skip_empty; + bool data_type; int max_stack; struct perf_read_values show_threads_values; struct annotation_options annotation_opts; @@ -171,7 +172,7 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter, struct mem_info *mi; struct branch_info *bi; - if (!ui__has_annotation() && !rep->symbol_ipc) + if (!ui__has_annotation() && !rep->symbol_ipc && !rep->data_type) return 0; if (sort__mode == SORT_MODE__BRANCH) { @@ -323,10 +324,19 @@ static int process_sample_event(struct perf_tool *tool, if (al.map != NULL) map__dso(al.map)->hit = 1; - if (ui__has_annotation() || rep->symbol_ipc || rep->total_cycles_mode) { + if (ui__has_annotation() || rep->symbol_ipc || rep->total_cycles_mode || + rep->data_type) { hist__account_cycles(sample->branch_stack, &al, sample, rep->nonany_branch_mode, &rep->total_cycles); + if (rep->data_type) { + struct symbol *sym = al.sym; + struct annotation *notes = sym ? symbol__annotation(sym) : NULL; + + /* XXX: Save annotate options here */ + if (notes) + notes->options = &rep->annotation_opts; + } } ret = hist_entry_iter__add(&iter, &al, rep->max_stack, rep); @@ -1600,6 +1610,9 @@ int cmd_report(int argc, const char **argv) sort_order = NULL; } + if (sort_order && strstr(sort_order, "type")) + report.data_type = true; + if (strcmp(input_name, "-") != 0) setup_browser(true); else @@ -1658,7 +1671,7 @@ int cmd_report(int argc, const char **argv) * so don't allocate extra space that won't be used in the stdio * implementation. */ - if (ui__has_annotation() || report.symbol_ipc || + if (ui__has_annotation() || report.symbol_ipc || report.data_type || report.total_cycles_mode) { ret = symbol__annotation_init(); if (ret < 0)