Skip to content

Commit 5804b11

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-4.19-20180815' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: kernel: - kallsyms, x86: Export addresses of PTI entry trampolines (Alexander Shishkin) - kallsyms: Simplify update_iter_mod() (Adrian Hunter) - x86: Add entry trampolines to kcore (Adrian Hunter) Hardware tracing: - Fix auxtrace queue resize (Adrian Hunter) Arch specific: - Fix uninitialized ARM SPE record error variable (Kim Phillips) - Fix trace event post-processing in powerpc (Sandipan Das) Build: - Fix check-headers.sh AND list path of execution (Alexander Kapshuk) - Remove -mcet and -fcf-protection when building the python binding with older clang versions (Arnaldo Carvalho de Melo) - Make check-headers.sh check based on kernel dir (Jiri Olsa) - Move syscall_64.tbl check into check-headers.sh (Jiri Olsa) Infrastructure: - Check for null when copying nsinfo. (Benno Evers) Libraries: - Rename libtraceevent prefixes, prep work for making it a shared library generaly available (Tzvetomir Stoyanov (VMware)) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2 parents 13e091b + 6855dc4 commit 5804b11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3003
-1362
lines changed

arch/x86/mm/cpu_entry_area.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <linux/spinlock.h>
44
#include <linux/percpu.h>
5+
#include <linux/kallsyms.h>
6+
#include <linux/kcore.h>
57

68
#include <asm/cpu_entry_area.h>
79
#include <asm/pgtable.h>
@@ -13,6 +15,7 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(struct entry_stack_page, entry_stack_storage)
1315
#ifdef CONFIG_X86_64
1416
static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
1517
[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
18+
static DEFINE_PER_CPU(struct kcore_list, kcore_entry_trampoline);
1619
#endif
1720

1821
struct cpu_entry_area *get_cpu_entry_area(int cpu)
@@ -146,10 +149,40 @@ static void __init setup_cpu_entry_area(int cpu)
146149

147150
cea_set_pte(&get_cpu_entry_area(cpu)->entry_trampoline,
148151
__pa_symbol(_entry_trampoline), PAGE_KERNEL_RX);
152+
/*
153+
* The cpu_entry_area alias addresses are not in the kernel binary
154+
* so they do not show up in /proc/kcore normally. This adds entries
155+
* for them manually.
156+
*/
157+
kclist_add_remap(&per_cpu(kcore_entry_trampoline, cpu),
158+
_entry_trampoline,
159+
&get_cpu_entry_area(cpu)->entry_trampoline, PAGE_SIZE);
149160
#endif
150161
percpu_setup_debug_store(cpu);
151162
}
152163

164+
#ifdef CONFIG_X86_64
165+
int arch_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
166+
char *name)
167+
{
168+
unsigned int cpu, ncpu = 0;
169+
170+
if (symnum >= num_possible_cpus())
171+
return -EINVAL;
172+
173+
for_each_possible_cpu(cpu) {
174+
if (ncpu++ >= symnum)
175+
break;
176+
}
177+
178+
*value = (unsigned long)&get_cpu_entry_area(cpu)->entry_trampoline;
179+
*type = 't';
180+
strlcpy(name, "__entry_SYSCALL_64_trampoline", KSYM_NAME_LEN);
181+
182+
return 0;
183+
}
184+
#endif
185+
153186
static __init void setup_cpu_entry_area_ptes(void)
154187
{
155188
#ifdef CONFIG_X86_32

fs/proc/kcore.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,11 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
383383
phdr->p_type = PT_LOAD;
384384
phdr->p_flags = PF_R|PF_W|PF_X;
385385
phdr->p_offset = kc_vaddr_to_offset(m->addr) + dataoff;
386-
phdr->p_vaddr = (size_t)m->addr;
387-
if (m->type == KCORE_RAM || m->type == KCORE_TEXT)
386+
if (m->type == KCORE_REMAP)
387+
phdr->p_vaddr = (size_t)m->vaddr;
388+
else
389+
phdr->p_vaddr = (size_t)m->addr;
390+
if (m->type == KCORE_RAM || m->type == KCORE_TEXT || m->type == KCORE_REMAP)
388391
phdr->p_paddr = __pa(m->addr);
389392
else
390393
phdr->p_paddr = (elf_addr_t)-1;

include/linux/kcore.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ enum kcore_type {
1212
KCORE_VMEMMAP,
1313
KCORE_USER,
1414
KCORE_OTHER,
15+
KCORE_REMAP,
1516
};
1617

1718
struct kcore_list {
1819
struct list_head list;
1920
unsigned long addr;
21+
unsigned long vaddr;
2022
size_t size;
2123
int type;
2224
};
@@ -36,11 +38,22 @@ struct vmcoredd_node {
3638

3739
#ifdef CONFIG_PROC_KCORE
3840
extern void kclist_add(struct kcore_list *, void *, size_t, int type);
41+
static inline
42+
void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz)
43+
{
44+
m->vaddr = (unsigned long)vaddr;
45+
kclist_add(m, addr, sz, KCORE_REMAP);
46+
}
3947
#else
4048
static inline
4149
void kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
4250
{
4351
}
52+
53+
static inline
54+
void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz)
55+
{
56+
}
4457
#endif
4558

4659
#endif /* _LINUX_KCORE_H */

kernel/kallsyms.c

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ int sprint_backtrace(char *buffer, unsigned long address)
432432
/* To avoid using get_symbol_offset for every symbol, we carry prefix along. */
433433
struct kallsym_iter {
434434
loff_t pos;
435+
loff_t pos_arch_end;
435436
loff_t pos_mod_end;
436437
loff_t pos_ftrace_mod_end;
437438
unsigned long value;
@@ -443,9 +444,29 @@ struct kallsym_iter {
443444
int show_value;
444445
};
445446

447+
int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
448+
char *type, char *name)
449+
{
450+
return -EINVAL;
451+
}
452+
453+
static int get_ksymbol_arch(struct kallsym_iter *iter)
454+
{
455+
int ret = arch_get_kallsym(iter->pos - kallsyms_num_syms,
456+
&iter->value, &iter->type,
457+
iter->name);
458+
459+
if (ret < 0) {
460+
iter->pos_arch_end = iter->pos;
461+
return 0;
462+
}
463+
464+
return 1;
465+
}
466+
446467
static int get_ksymbol_mod(struct kallsym_iter *iter)
447468
{
448-
int ret = module_get_kallsym(iter->pos - kallsyms_num_syms,
469+
int ret = module_get_kallsym(iter->pos - iter->pos_arch_end,
449470
&iter->value, &iter->type,
450471
iter->name, iter->module_name,
451472
&iter->exported);
@@ -501,32 +522,34 @@ static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
501522
iter->nameoff = get_symbol_offset(new_pos);
502523
iter->pos = new_pos;
503524
if (new_pos == 0) {
525+
iter->pos_arch_end = 0;
504526
iter->pos_mod_end = 0;
505527
iter->pos_ftrace_mod_end = 0;
506528
}
507529
}
508530

531+
/*
532+
* The end position (last + 1) of each additional kallsyms section is recorded
533+
* in iter->pos_..._end as each section is added, and so can be used to
534+
* determine which get_ksymbol_...() function to call next.
535+
*/
509536
static int update_iter_mod(struct kallsym_iter *iter, loff_t pos)
510537
{
511538
iter->pos = pos;
512539

513-
if (iter->pos_ftrace_mod_end > 0 &&
514-
iter->pos_ftrace_mod_end < iter->pos)
515-
return get_ksymbol_bpf(iter);
540+
if ((!iter->pos_arch_end || iter->pos_arch_end > pos) &&
541+
get_ksymbol_arch(iter))
542+
return 1;
516543

517-
if (iter->pos_mod_end > 0 &&
518-
iter->pos_mod_end < iter->pos) {
519-
if (!get_ksymbol_ftrace_mod(iter))
520-
return get_ksymbol_bpf(iter);
544+
if ((!iter->pos_mod_end || iter->pos_mod_end > pos) &&
545+
get_ksymbol_mod(iter))
521546
return 1;
522-
}
523547

524-
if (!get_ksymbol_mod(iter)) {
525-
if (!get_ksymbol_ftrace_mod(iter))
526-
return get_ksymbol_bpf(iter);
527-
}
548+
if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) &&
549+
get_ksymbol_ftrace_mod(iter))
550+
return 1;
528551

529-
return 1;
552+
return get_ksymbol_bpf(iter);
530553
}
531554

532555
/* Returns false if pos at or past end of file. */

tools/lib/lockdep/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ $(OUTPUT)liblockdep.a: $(LIB_IN)
129129
tags: force
130130
$(RM) tags
131131
find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
132-
--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
132+
--regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
133133

134134
TAGS: force
135135
$(RM) TAGS
136136
find . -name '*.[ch]' | xargs etags \
137-
--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
137+
--regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
138138

139139
define do_install
140140
$(print_install) \

tools/lib/traceevent/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ endef
233233
tags: force
234234
$(RM) tags
235235
find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
236-
--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
236+
--regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
237237

238238
TAGS: force
239239
$(RM) TAGS
240240
find . -name '*.[ch]' | xargs etags \
241-
--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
241+
--regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
242242

243243
define do_install_mkdir
244244
if [ ! -d '$(DESTDIR_SQ)$1' ]; then \

0 commit comments

Comments
 (0)