Skip to content

Commit d207ea8

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Thomas Gleixner: "Kernel: - Improve kallsyms coverage - Add x86 entry trampolines to kcore - Fix ARM SPE handling - Correct PPC event post processing Tools: - Make the build system more robust - Small fixes and enhancements all over the place - Update kernel ABI header copies - Preparatory work for converting libtraceevnt to a shared library - License cleanups" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (100 commits) tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy' tools arch x86: Update tools's copy of cpufeatures.h perf python: Fix pyrf_evlist__read_on_cpu() interface perf mmap: Store real cpu number in 'struct perf_mmap' perf tools: Remove ext from struct kmod_path perf tools: Add gzip_is_compressed function perf tools: Add lzma_is_compressed function perf tools: Add is_compressed callback to compressions array perf tools: Move the temp file processing into decompress_kmodule perf tools: Use compression id in decompress_kmodule() perf tools: Store compression id into struct dso perf tools: Add compression id into 'struct kmod_path' perf tools: Make is_supported_compression() static perf tools: Make decompress_to_file() function static perf tools: Get rid of dso__needs_decompress() call in __open_dso() perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble() perf tools: Get rid of dso__needs_decompress() call in read_object_code() tools lib traceevent: Change to SPDX License format perf llvm: Allow passing options to llc in addition to clang perf parser: Improve error message for PMU address filters ...
2 parents 2a8a2b7 + 66e5db4 commit d207ea8

Some content is hidden

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

93 files changed

+3259
-1628
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
@@ -359,8 +359,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
359359
phdr->p_type = PT_LOAD;
360360
phdr->p_flags = PF_R | PF_W | PF_X;
361361
phdr->p_offset = kc_vaddr_to_offset(m->addr) + data_offset;
362-
phdr->p_vaddr = (size_t)m->addr;
363-
if (m->type == KCORE_RAM)
362+
if (m->type == KCORE_REMAP)
363+
phdr->p_vaddr = (size_t)m->vaddr;
364+
else
365+
phdr->p_vaddr = (size_t)m->addr;
366+
if (m->type == KCORE_RAM || m->type == KCORE_REMAP)
364367
phdr->p_paddr = __pa(m->addr);
365368
else if (m->type == KCORE_TEXT)
366369
phdr->p_paddr = __pa_symbol(m->addr);

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
void __init 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/arch/x86/include/asm/cpufeatures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
221221
#define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */
222222
#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
223+
#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
223224

224225
/* Virtualization flags: Linux defined, word 8 */
225226
#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@@ -230,7 +231,7 @@
230231

231232
#define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */
232233
#define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */
233-
234+
#define X86_FEATURE_EPT_AD ( 8*32+17) /* Intel Extended Page Table access-dirty bit */
234235

235236
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
236237
#define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/

tools/arch/x86/lib/memcpy_64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ ENTRY(__memcpy_mcsafe)
256256

257257
/* Copy successful. Return zero */
258258
.L_done_memcpy_trap:
259-
xorq %rax, %rax
259+
xorl %eax, %eax
260260
ret
261261
ENDPROC(__memcpy_mcsafe)
262262
EXPORT_SYMBOL_GPL(__memcpy_mcsafe)

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)