lkml.org 
[lkml]   [2018]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[tip:perf/core] perf kcore_copy: Keep phdr data in a list
Commit-ID:  f6838209484d5cfb368ca5c61d150cc4054eef59
Gitweb: https://git.kernel.org/tip/f6838209484d5cfb368ca5c61d150cc4054eef59
Author: Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 22 May 2018 13:54:38 +0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 23 May 2018 10:26:40 -0300

perf kcore_copy: Keep phdr data in a list

Currently, kcore_copy makes 2 program headers, one for the kernel text
(namely kernel_map) and one for the modules (namely modules_map). Now
more program headers are needed, but treating each program header as a
special case results in much more code.

Instead, in preparation to add more program headers, change to keep
program header data (phdr_data) in a list.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/1526986485-6562-11-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol-elf.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 48943b834f11..b13873a6f368 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1388,6 +1388,7 @@ struct phdr_data {
off_t offset;
u64 addr;
u64 len;
+ struct list_head node;
};

struct kcore_copy_info {
@@ -1399,6 +1400,7 @@ struct kcore_copy_info {
u64 last_module_symbol;
struct phdr_data kernel_map;
struct phdr_data modules_map;
+ struct list_head phdrs;
};

static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
@@ -1510,6 +1512,11 @@ static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
if (elf_read_maps(elf, true, kcore_copy__read_map, kci) < 0)
return -1;

+ if (kci->kernel_map.len)
+ list_add_tail(&kci->kernel_map.node, &kci->phdrs);
+ if (kci->modules_map.len)
+ list_add_tail(&kci->modules_map.node, &kci->phdrs);
+
return 0;
}

@@ -1678,6 +1685,8 @@ int kcore_copy(const char *from_dir, const char *to_dir)
char kcore_filename[PATH_MAX];
char extract_filename[PATH_MAX];

+ INIT_LIST_HEAD(&kci.phdrs);
+
if (kcore_copy__copy_file(from_dir, to_dir, "kallsyms"))
return -1;

\
 
 \ /
  Last update: 2018-05-24 07:42    [W:0.214 / U:6.700 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site