Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp176401rwr; Wed, 19 Apr 2023 20:08:57 -0700 (PDT) X-Google-Smtp-Source: AKy350b0O5SKhyS1YmkMj6kbm2AyXaSzbq4hZ+BjvXUgyfTeNZRhvhaMRKLvuqWv4WdwPIsqmgOn X-Received: by 2002:a05:6870:a688:b0:18b:757:3679 with SMTP id i8-20020a056870a68800b0018b07573679mr129149oam.27.1681960137371; Wed, 19 Apr 2023 20:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681960137; cv=none; d=google.com; s=arc-20160816; b=h+wK7UtlPWDELOEXN2BWpTEOvqTHvR90Lc7tmsKcVeVEqowwuE3GTkZv3iIhrGgzCV mxp/C8zasLJm4a1I1zzNTsY3wJ0vsTkomOjFb7mZJOZX65zFg2y8nI4lmdPF/r8s2Ekb Ro1ahTl0AztwWhR8lJeehyUU/QnnHcax8sppax6b1XRFcUPavBYygEdE+Mk2HWqsu04g q7tK0/XwV4NHhdR0m62OYKI/zeI5jDjBfUWRq966NEihW+SmVzZiS5EwWuFwAc/PMOTq 8Qt2CeqXFAppphxP08BXx2l2+pGzdhUtft0RXpmT/RWdMFDSZBqnkrI06DVcxjRIr7u5 r9Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UekTisYIvPA/j7ZPtvMcrO4RAhE+IXzH03BNicXD274=; b=bZ8o2pAIvHtAsU4AAtEkoo6awUjSLBS973DmLmjowWxYb6XStUe0opsLtPuyi3bxlg 8e/bhsmRVMzeixTMxSTvyMSOyQ/yB6Bi83yn7npHwIwgaHlOdb+C6oKPU2cYAw+jkN8k YBC5A08CLRk2DJGUlnxNrH4vOX1NTZUq1NyaEjWu+hhl9hHuOroT+Y2Dzcg9ni+JpIZ2 IYd1SUNVj5um5LgzDYhj8fuEValnMw1JHOiT0/rJqu+TIY7yypDfA3K/avmIwXcd8IKc LEdoQKkXXQJkR2ILg1LuJaqjN2864t7QVUTog25aJ9mF+AX31sp+V9HNrqaZS1iot2pt uwuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c77-20020a4a4f50000000b0053c3b0372e9si466289oob.92.2023.04.19.20.08.42; Wed, 19 Apr 2023 20:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbjDTCzd (ORCPT + 99 others); Wed, 19 Apr 2023 22:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbjDTCzc (ORCPT ); Wed, 19 Apr 2023 22:55:32 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B83198E; Wed, 19 Apr 2023 19:55:30 -0700 (PDT) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Q22Kw2QpxzsR6g; Thu, 20 Apr 2023 10:53:56 +0800 (CST) Received: from M910t (10.110.54.157) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 20 Apr 2023 10:55:26 +0800 Date: Thu, 20 Apr 2023 10:55:11 +0800 From: Changbin Du To: Adrian Hunter CC: Changbin Du , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , , , Hui Wang , Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH v5 2/3] perf: add helper map__fprintf_dsoname_dsoff Message-ID: <20230420025511.fkd7upvuoxfz2xih@M910t> References: <20230418031825.1262579-1-changbin.du@huawei.com> <20230418031825.1262579-3-changbin.du@huawei.com> <3001bde2-b010-3c00-17de-1c78ef4b589b@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <3001bde2-b010-3c00-17de-1c78ef4b589b@intel.com> X-Originating-IP: [10.110.54.157] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 19, 2023 at 09:58:10PM +0300, Adrian Hunter wrote: > On 18/04/23 06:18, Changbin Du wrote: > > This adds a helper function map__fprintf_dsoname_dsoff() to print dsoname > > with optional dso offset. > > > > Suggested-by: Adrian Hunter > > Signed-off-by: Changbin Du > > --- > > tools/perf/util/map.c | 13 +++++++++++++ > > tools/perf/util/map.h | 1 + > > 2 files changed, 14 insertions(+) > > > > diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c > > index d81b6ca18ee9..7da96b41100f 100644 > > --- a/tools/perf/util/map.c > > +++ b/tools/perf/util/map.c > > @@ -445,6 +445,19 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp) > > return fprintf(fp, "%s", dsoname); > > } > > > > +size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp) > > +{ > > + int printed = 0; > > + > > + printed += fprintf(fp, " ("); > > + printed += map__fprintf_dsoname(map, fp); > > + if (print_off && map && map__dso(map) && !map__dso(map)->kernel) > > That will also block vmlinux offsets not just [kernel.kallsyms] > Is that what was intended? > Not only vmlinux, modules are also blocked. We'd better print offset for vmlinux and modules. $ sudo perf script -k vmlinux -F +dsoff perf-exec 2531039 4120893.685967: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux) perf-exec 2531039 4120893.685970: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux) perf-exec 2531039 4120893.685972: 9 cycles: ffffffff99094ec4 [unknown] (vmlinux) perf-exec 2531039 4120893.685973: 194 cycles: ffffffff99094ec6 [unknown] (vmlinux) perf-exec 2531039 4120893.685974: 4605 cycles: ffffffff99094ec4 [unknown] (vmlinux) perf-exec 2531039 4120893.685976: 108083 cycles: ffffffff9928e8d0 [unknown] (vmlinux) ls 2531039 4120893.686003: 2197682 cycles: ffffffff993c92bc [unknown] (vmlinux) ls 2531039 4120893.686554: 4497190 cycles: ffffffffc159692b strcasestr+0x7b (/lib/modules/5.15.0-60-generic/extra/isac_ipc.ko) ls 2531039 4120893.687700: 4189758 cycles: ffffffffc18a5d66 delete_net_reject_cache+0x76 (/lib/modules/5.15.0-60-generic/extra/isac_networkfilter.ko) ls 2531039 4120893.688786: 3780376 cycles: ffffffffc18a67de delete_net_process_info+0x5e (/lib/modules/5.15.0-60-generic/extra/isac_networkfilter.ko) ls 2531039 4120893.689716: 3416607 cycles: ffffffffc18a67de delete_net_process_info+0x5e (/lib/modules/5.15.0-60-generic/extra/isac_networkfilter.ko) But I found addr returned by map__dso_map_ip() for 'vmlinux' is not a 'dso offset'. $ sudo perf script -k vmlinux -F +dsoff perf-exec 2531039 4120893.685967: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux+0xffffffff99094ec4) perf-exec 2531039 4120893.685970: 1 cycles: ffffffff99094ec4 [unknown] (vmlinux+0xffffffff99094ec4) perf-exec 2531039 4120893.685972: 9 cycles: ffffffff99094ec4 [unknown] (vmlinux+0xffffffff99094ec4) perf-exec 2531039 4120893.685973: 194 cycles: ffffffff99094ec6 [unknown] (vmlinux+0xffffffff99094ec6) Do you have better idea? -- Cheers, Changbin Du