mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-26 12:34:41 +08:00
e7ee404757
Before this patch, if a sample is triggered inside a module not in /lib/modules/`uname -r`/, even if the module is in buildid-cache, 'perf report' will still be unable to find the correct symbol. For example: # rm -rf ~/.debug/ # perf buildid-cache -a ./mymodule.ko # perf probe -m ./mymodule.ko -a get_mymodule_val Added new event: probe:get_mymodule_val (on get_mymodule_val in mymodule) You can now use it in all perf tools, such as: perf record -e probe:get_mymodule_val -aR sleep 1 # perf record -e probe:get_mymodule_val cat /proc/mymodule mymodule:3 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ] # perf report --stdio [SNIP] # # Overhead Command Shared Object Symbol # ........ ....... ................ ...................... # 100.00% cat [mymodule] [k] 0x0000000000000001 # perf report -vvvv --stdio dso__load_sym: adjusting symbol: st_value: 0 sh_addr: 0 sh_offset: 0x70 symbol__new: get_mymodule_val 0x70-0x8a [SNIP] This is caused by dso__load() -> dso__load_sym(). In dso__load(), kmod is true only when its file is found in some well know directories. All files loaded from buildid-cache are treated as user programs. Following dso__load_sym() set map->pgoff incorrectly. This patch gives kernel modules in buildid-cache a chance to adjust value of kmod. After dso__load() get the type of symbols, if it is buildid, check the last 3 chars of original filename against '.ko', and adjust the value of kmod if the file is a kernel module. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: Cody P Schafer <dev@codyps.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kirill Smelkov <kirr@nexedi.com> Cc: Li Zefan <lizefan@huawei.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1454680939-24963-3-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
40 lines
1.4 KiB
C
40 lines
1.4 KiB
C
#ifndef PERF_BUILD_ID_H_
|
|
#define PERF_BUILD_ID_H_ 1
|
|
|
|
#define BUILD_ID_SIZE 20
|
|
#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
|
|
|
|
#include "tool.h"
|
|
#include "strlist.h"
|
|
#include <linux/types.h>
|
|
|
|
extern struct perf_tool build_id__mark_dso_hit_ops;
|
|
struct dso;
|
|
|
|
int build_id__sprintf(const u8 *build_id, int len, char *bf);
|
|
int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id);
|
|
int filename__sprintf_build_id(const char *pathname, char *sbuild_id);
|
|
|
|
char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size);
|
|
bool dso__build_id_is_kmod(const struct dso *dso, char *bf, size_t size);
|
|
|
|
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
|
|
struct perf_sample *sample, struct perf_evsel *evsel,
|
|
struct machine *machine);
|
|
|
|
int dsos__hit_all(struct perf_session *session);
|
|
|
|
bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
|
|
int perf_session__write_buildid_table(struct perf_session *session, int fd);
|
|
int perf_session__cache_build_ids(struct perf_session *session);
|
|
|
|
int build_id_cache__list_build_ids(const char *pathname,
|
|
struct strlist **result);
|
|
bool build_id_cache__cached(const char *sbuild_id);
|
|
int build_id_cache__add_s(const char *sbuild_id,
|
|
const char *name, bool is_kallsyms, bool is_vdso);
|
|
int build_id_cache__remove_s(const char *sbuild_id);
|
|
void disable_buildid_cache(void);
|
|
|
|
#endif
|