From patchwork Thu Nov 9 23:59:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 163674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp787705vqs; Thu, 9 Nov 2023 16:04:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0KZWWm/VzVyA5OPjrH7OWJkSzh/zCU5cOlCXT2G7j09rm25JwJOdxyP6W1zNLiYxBx4/1 X-Received: by 2002:a05:6830:1058:b0:6be:e447:dbd with SMTP id b24-20020a056830105800b006bee4470dbdmr6494253otp.22.1699574691825; Thu, 09 Nov 2023 16:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699574691; cv=none; d=google.com; s=arc-20160816; b=g3njUtc9m5Ql3ldHcwoeZrnEPQ8z3add5duJGOG5HArlVLoEnxh7G29lmGS8n3qs85 YSjIVU8kZ+Zvr91oRj5QfJqawgv+2c7CkfrwqPb/mmpYDKhEdUlDDESLrkbmMME2MPW4 skiAwlHoLNsS9uU2oriubjtXuLNK5IcglUqc8DsbJF7GOnz3T7b8lO/qbhpKrcd1YwFT DaNoVkvE9dgqVLkvdm4WciSkhPEH4ZGvi8PqY88DCXhe/TD3xamyAzIkAmI7zq6MRuUe 6M52Dci+O+OEP0cNfoOIz/mhKrFOqJ6L5g9SaCHui39kM/R8BqIVsX7qrXD5/cwygWx0 wrZQ== 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=EJFFyw141jUP/xKayMqLdMQ+KiPiQ49S3rXykXIzrtU=; fh=K//si1Hi/RYC7s39rVvmvh0YbZGmBrdWWHQg3cPF7Xc=; b=HiFhINtIWpmIbESwaWkijao753Eup46I2WmwHmBlPKbzMhSHFHjoPZYIIEpsznSb0w VozkOGAXz5Kr/NS2Trvu8t7CmxipD6d2yqbX4jKG44Eyxi2WGL8H5QQGiRx52tNDKvwg LmUrsNiRXNa1wnXAmFSfn70oQqjXBQOkrp9UONppHklpBklbswyBLGOfFkYZouawYmDT S0fhnhDhxeeko5tLKmBsHC0czJM+rAGetfsZdF/jpTAy+MXIPSTgGI+ylDC2hxHOKITZ z4i00179ocNKzeMqbC/7lz3I7wu7+Ke+EozjEDaPqLOiI+CdOYH0+hSZMOapYmgHtjCh syJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hewpSY+M; 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=kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id v1-20020a05683018c100b006bf0a6dd33bsi6490387ote.96.2023.11.09.16.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:04:51 -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=@gmail.com header.s=20230601 header.b=hewpSY+M; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 18797834011E; Thu, 9 Nov 2023 16:04:20 -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 S1345624AbjKJABs (ORCPT + 30 others); Thu, 9 Nov 2023 19:01:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345553AbjKJABS (ORCPT ); Thu, 9 Nov 2023 19:01:18 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B324C12; Thu, 9 Nov 2023 16:00:44 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-27ff7fe7fbcso1299961a91.1; Thu, 09 Nov 2023 16:00:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699574443; x=1700179243; 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=EJFFyw141jUP/xKayMqLdMQ+KiPiQ49S3rXykXIzrtU=; b=hewpSY+M0Ilee/HvRvj+BMRJ5nds7ngzW3sNArweE5dKbyElgMsVFrLa/soTZSiQyC 6yUqPEW8yfUF8u7/+dXfjO+xEPiRRGR0XM/HdVjo9wskXjr4F0fjED5/841J7ubjv2ww GEjCptdXWtePI71qD4eKMTYpPsHo4tpeNBiGZXt/Z6njLp2ZkUub/TbUciq8O+JKutGi S3Yg3Vq8EcNF7Q3h96my8YVd+YZh5gx2VL63p9vGuSOmDVD1VpQxhihjmfyQSO6vaGaG UDd6wwob+jhqMhZWq/cM1MmpfCU3M/9fEBBdxX4Pk0ntlVeGjMW14/r+XmvJH925Zla/ ipgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699574443; x=1700179243; 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=EJFFyw141jUP/xKayMqLdMQ+KiPiQ49S3rXykXIzrtU=; b=OWsh++P4a2uXIIu9n+E8QeC5SHq189/21i33deZWA5fo+3NkRJOshYRkdiRcSDgCbL lBgDeJ79fzoXcnBnTEkJ7TdXkHBtrIfPWBpVJwESMYMCGsXrY2ZCPKfO2eXNlrxY029p Ko5hzWVdV7zitSFcaCnVhUHrjyFcT0VjpoHNA2juEmNYlT5NFxlzFqFVb2Jdr75JCTeb nuaiHofK2zt7J1QedGdEYL2yB83ts1yZmm446tm9DrEkutR+3PhN3diu4JiphSvne5Wy SMhNMJS8NukMegRUgecwdrWYbeIgx3+Gp/beJ/+oO5an/o0Yh474TcJ4/Pnu0CWbqWCa lhBw== X-Gm-Message-State: AOJu0Ywc24/a8V3i93XtUIciJFLZX3gF4ivF2FRRiSZ4ha/MYDnC2vM9 a5i8Ne/2P/SLC3ijW35xKxQ= X-Received: by 2002:a17:90a:ea85:b0:280:2652:d46 with SMTP id h5-20020a17090aea8500b0028026520d46mr3769910pjz.28.1699574443393; Thu, 09 Nov 2023 16:00:43 -0800 (PST) Received: from bangji.corp.google.com ([2620:15c:2c0:5:d45c:ae16:d959:a5f1]) by smtp.gmail.com with ESMTPSA id k32-20020a17090a4ca300b002635db431a0sm371312pjh.45.2023.11.09.16.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:00:43 -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 , Andi Kleen , linux-trace-devel@vger.kernel.org, linux-toolchains@vger.kernel.org Subject: [PATCH 19/52] perf report: Support data type profiling Date: Thu, 9 Nov 2023 15:59:38 -0800 Message-ID: <20231110000012.3538610-20-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231110000012.3538610-1-namhyung@kernel.org> References: <20231110000012.3538610-1-namhyung@kernel.org> 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 16:04:20 -0800 (PST) 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 fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782133231962768710 X-GMAIL-MSGID: 1782133231962768710 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 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 121a2781323c..cd2cefd1ea9a 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); @@ -1622,6 +1632,11 @@ int cmd_report(int argc, const char **argv) sort_order = NULL; } + if (sort_order && strstr(sort_order, "type")) { + report.data_type = true; + report.annotation_opts.annotate_src = false; + } + if (strcmp(input_name, "-") != 0) setup_browser(true); else @@ -1680,7 +1695,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)