Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3323525yba; Tue, 16 Apr 2019 09:04:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbjn1BcxU8jtayzDotbo17oc+1vpAZcZEK3cIBmeirhO/mlPL+44YXmZdQyNhueR/Zigos X-Received: by 2002:a17:902:2f84:: with SMTP id t4mr61556483plb.6.1555430640832; Tue, 16 Apr 2019 09:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555430640; cv=none; d=google.com; s=arc-20160816; b=g49MjL2PIbF7PzVYmPGGw6EiUnjVFSRZnWdsxa3bDMiNTwfZsnKi0vEoTacxw4vCkR fItLfgCzfxjczc3pC6TRqYXOIj1rKsX5/br8oVfrZnLYGK2XysOD1IGrZO9dZ7oFXuet WxcxbOgCOoPirO9L4zDYzVsTHUOytRCdDnaid1JqmP+SCGQjq9hZiFEiKGLDYTxUHfCr nI1tzZsLRygxY9FXRZL2HPavw4Ds4ePbD6Yb9o7GJWN/aTGqkAsCVCAcSAoFFKx3Mr1v 6/Xkx9lJONCVKmRy+aUMAYjXtZQN4GVO6HAQRSmAPD6vV7QD53i70THFMzSQ/i+eaHa8 Rb2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Ws9cubLK+Kg81mGa12i8UpVBR7tEPbtNRSQZ90eEYbY=; b=OQoLHfTQOBjUrA/IbW4oO8ZyFTmGFlqdxattRRwcg8Pv7Eh66B55bPCK2I88bhQEqU /bMcYJFgVgDVFgG3zdoi06MicpcIichMtkD3ArvjXsvClHHXsxvZUeyj3CEu0bS1bt0W sUdmC/WRk6ZPHuDdNnft834gfTb8cGgL/Ug+h5jCdF9jVTX27Ief1386xGSbysDjAgPP 8tfbfGsc0tJYq/iVWij5csXS2wNIUS9Wjdr8cWcSa1ItEwWLvNR9wBj+gekiRICFS6Dm mTzUyEqftq6P6Dq5gocmkgGRavyhV8yDiioo6gqJgs18tjth9URe4rPdQOyV0Qu1WW9e YgaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si42281969pgv.297.2019.04.16.09.03.43; Tue, 16 Apr 2019 09:04:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730020AbfDPQB7 (ORCPT + 99 others); Tue, 16 Apr 2019 12:01:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57816 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbfDPQB6 (ORCPT ); Tue, 16 Apr 2019 12:01:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E204D309E979; Tue, 16 Apr 2019 16:01:57 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D47B05D71D; Tue, 16 Apr 2019 16:01:52 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Adrian Hunter , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Namhyung Kim , Peter Zijlstra , Song Liu , Yonghong Song , Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Alexander Shishkin , Peter Zijlstra , Andi Kleen Subject: [PATCH 07/12] perf tools: Check maps for bpf programs Date: Tue, 16 Apr 2019 18:01:22 +0200 Message-Id: <20190416160127.30203-8-jolsa@kernel.org> In-Reply-To: <20190416160127.30203-1-jolsa@kernel.org> References: <20190416160127.30203-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 16 Apr 2019 16:01:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Song Liu As reported by Jiri Olsa in: "[BUG] perf: intel_pt won't display kernel function" https://lore.kernel.org/lkml/20190403143738.GB32001@krava Recent changes to support PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT broke --kallsyms option. This is because it broke test __map__is_kmodule. This patch fixes this by adding check for bpf program, so that these maps are not mistaken as kernel modules. Reported-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Daniel Borkmann Cc: Martin KaFai Lau Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Yonghong Song Cc: Arnaldo Carvalho de Melo Fixes: 76193a94522f ("perf, bpf: Introduce PERF_RECORD_KSYMBOL") Link: https://lore.kernel.org/lkml/20190403145353.GE32553@kernel.org Signed-off-by: Song Liu Link: http://lkml.kernel.org/n/tip-gnffkcoc4nauqcpgvsmwka2w@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/map.c | 16 ++++++++++++++++ tools/perf/util/map.h | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index e32628cd20a7..28d484ef74ae 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -261,6 +261,22 @@ bool __map__is_extra_kernel_map(const struct map *map) return kmap && kmap->name[0]; } +bool __map__is_bpf_prog(const struct map *map) +{ + const char *name; + + if (map->dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO) + return true; + + /* + * If PERF_RECORD_BPF_EVENT is not included, the dso will not have + * type of DSO_BINARY_TYPE__BPF_PROG_INFO. In such cases, we can + * guess the type based on name. + */ + name = map->dso->short_name; + return name && (strstr(name, "bpf_prog_") == name); +} + bool map__has_symbols(const struct map *map) { return dso__has_symbols(map->dso); diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 0e20749f2c55..dc93787c74f0 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h @@ -159,10 +159,12 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, bool __map__is_kernel(const struct map *map); bool __map__is_extra_kernel_map(const struct map *map); +bool __map__is_bpf_prog(const struct map *map); static inline bool __map__is_kmodule(const struct map *map) { - return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map); + return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) && + !__map__is_bpf_prog(map); } bool map__has_symbols(const struct map *map); -- 2.17.2