From af8b3cd3934ec60f4c2a420d19a9d416554f140b Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Tue, 14 Feb 2017 00:11:02 -0800 Subject: x86/process: Optimize TIF checks in __switch_to_xtra() Help the compiler to avoid reevaluating the thread flags for each checked bit by reordering the bit checks and providing an explicit xor for evaluation. With default defconfigs for each arch, x86_64: arch/x86/kernel/process.o text data bss dec hex 3056 8577 16 11649 2d81 Before 3024 8577 16 11617 2d61 After i386: arch/x86/kernel/process.o text data bss dec hex 2957 8673 8 11638 2d76 Before 2925 8673 8 11606 2d56 After Originally-by: Thomas Gleixner Signed-off-by: Kyle Huey Cc: Peter Zijlstra Cc: Andy Lutomirski Link: http://lkml.kernel.org/r/20170214081104.9244-2-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/kernel/process.c | 65 ++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index f67591561711..ea9ea2582dab 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -182,54 +182,61 @@ int set_tsc_mode(unsigned int val) return 0; } +static inline void switch_to_bitmap(struct tss_struct *tss, + struct thread_struct *prev, + struct thread_struct *next, + unsigned long tifp, unsigned long tifn) +{ + if (tifn & _TIF_IO_BITMAP) { + /* + * Copy the relevant range of the IO bitmap. + * Normally this is 128 bytes or less: + */ + memcpy(tss->io_bitmap, next->io_bitmap_ptr, + max(prev->io_bitmap_max, next->io_bitmap_max)); + /* + * Make sure that the TSS limit is correct for the CPU + * to notice the IO bitmap. + */ + refresh_tss_limit(); + } else if (tifp & _TIF_IO_BITMAP) { + /* + * Clear any possible leftover bits: + */ + memset(tss->io_bitmap, 0xff, prev->io_bitmap_max); + } +} + void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, struct tss_struct *tss) { struct thread_struct *prev, *next; + unsigned long tifp, tifn; prev = &prev_p->thread; next = &next_p->thread; - if (test_tsk_thread_flag(prev_p, TIF_BLOCKSTEP) ^ - test_tsk_thread_flag(next_p, TIF_BLOCKSTEP)) { + tifn = READ_ONCE(task_thread_info(next_p)->flags); + tifp = READ_ONCE(task_thread_info(prev_p)->flags); + switch_to_bitmap(tss, prev, next, tifp, tifn); + + propagate_user_return_notify(prev_p, next_p); + + if ((tifp ^ tifn) & _TIF_BLOCKSTEP) { unsigned long debugctl = get_debugctlmsr(); debugctl &= ~DEBUGCTLMSR_BTF; - if (test_tsk_thread_flag(next_p, TIF_BLOCKSTEP)) + if (tifn & _TIF_BLOCKSTEP) debugctl |= DEBUGCTLMSR_BTF; - update_debugctlmsr(debugctl); } - if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^ - test_tsk_thread_flag(next_p, TIF_NOTSC)) { - /* prev and next are different */ - if (test_tsk_thread_flag(next_p, TIF_NOTSC)) + if ((tifp ^ tifn) & _TIF_NOTSC) { + if (tifn & _TIF_NOTSC) hard_disable_TSC(); else hard_enable_TSC(); } - - if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) { - /* - * Copy the relevant range of the IO bitmap. - * Normally this is 128 bytes or less: - */ - memcpy(tss->io_bitmap, next->io_bitmap_ptr, - max(prev->io_bitmap_max, next->io_bitmap_max)); - - /* - * Make sure that the TSS limit is correct for the CPU - * to notice the IO bitmap. - */ - refresh_tss_limit(); - } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) { - /* - * Clear any possible leftover bits: - */ - memset(tss->io_bitmap, 0xff, prev->io_bitmap_max); - } - propagate_user_return_notify(prev_p, next_p); } /* -- cgit v1.2.3-55-g7522 From b9894a2f5bd18b1691cb6872c9afe32b148d0132 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Tue, 14 Feb 2017 00:11:03 -0800 Subject: x86/process: Correct and optimize TIF_BLOCKSTEP switch The debug control MSR is "highly magical" as the blockstep bit can be cleared by hardware under not well documented circumstances. So a task switch relying on the bit set by the previous task (according to the previous tasks thread flags) can trip over this and not update the flag for the next task. To fix this its required to handle DEBUGCTLMSR_BTF when either the previous or the next or both tasks have the TIF_BLOCKSTEP flag set. While at it avoid branching within the TIF_BLOCKSTEP case and evaluating boot_cpu_data twice in kernels without CONFIG_X86_DEBUGCTLMSR. x86_64: arch/x86/kernel/process.o text data bss dec hex 3024 8577 16 11617 2d61 Before 3008 8577 16 11601 2d51 After i386: No change [ tglx: Made the shift value explicit, use a local variable to make the code readable and massaged changelog] Originally-by: Thomas Gleixner Signed-off-by: Kyle Huey Cc: Peter Zijlstra Cc: Andy Lutomirski Link: http://lkml.kernel.org/r/20170214081104.9244-3-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/process.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index d8b5f8ab8ef9..4c928f332f8f 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -127,6 +127,7 @@ /* DEBUGCTLMSR bits (others vary by model): */ #define DEBUGCTLMSR_LBR (1UL << 0) /* last branch recording */ +#define DEBUGCTLMSR_BTF_SHIFT 1 #define DEBUGCTLMSR_BTF (1UL << 1) /* single-step on branches */ #define DEBUGCTLMSR_TR (1UL << 6) #define DEBUGCTLMSR_BTS (1UL << 7) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index ea9ea2582dab..83fa3cb4f8f0 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -222,13 +222,15 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, propagate_user_return_notify(prev_p, next_p); - if ((tifp ^ tifn) & _TIF_BLOCKSTEP) { - unsigned long debugctl = get_debugctlmsr(); + if ((tifp & _TIF_BLOCKSTEP || tifn & _TIF_BLOCKSTEP) && + arch_has_block_step()) { + unsigned long debugctl, msk; + rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl); debugctl &= ~DEBUGCTLMSR_BTF; - if (tifn & _TIF_BLOCKSTEP) - debugctl |= DEBUGCTLMSR_BTF; - update_debugctlmsr(debugctl); + msk = tifn & _TIF_BLOCKSTEP; + debugctl |= (msk >> TIF_BLOCKSTEP) << DEBUGCTLMSR_BTF_SHIFT; + wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl); } if ((tifp ^ tifn) & _TIF_NOTSC) { -- cgit v1.2.3-55-g7522 From 5a920155e388ec22a22e0532fb695b9215c9b34d Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Tue, 14 Feb 2017 00:11:04 -0800 Subject: x86/process: Optimize TIF_NOTSC switch Provide and use a toggle helper instead of doing it with a branch. x86_64: arch/x86/kernel/process.o text data bss dec hex 3008 8577 16 11601 2d51 Before 2976 8577 16 11569 2d31 After i386: arch/x86/kernel/process.o text data bss dec hex 2925 8673 8 11606 2d56 Before 2893 8673 8 11574 2d36 After Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra Cc: Andy Lutomirski Link: http://lkml.kernel.org/r/20170214081104.9244-4-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/tlbflush.h | 10 ++++++++++ arch/x86/kernel/process.c | 22 ++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 6fa85944af83..ff4923a19f79 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -110,6 +110,16 @@ static inline void cr4_clear_bits(unsigned long mask) } } +static inline void cr4_toggle_bits(unsigned long mask) +{ + unsigned long cr4; + + cr4 = this_cpu_read(cpu_tlbstate.cr4); + cr4 ^= mask; + this_cpu_write(cpu_tlbstate.cr4, cr4); + __write_cr4(cr4); +} + /* Read the CR4 shadow. */ static inline unsigned long cr4_read_shadow(void) { diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 83fa3cb4f8f0..366db7782fc6 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -124,11 +124,6 @@ void flush_thread(void) fpu__clear(&tsk->thread.fpu); } -static void hard_disable_TSC(void) -{ - cr4_set_bits(X86_CR4_TSD); -} - void disable_TSC(void) { preempt_disable(); @@ -137,15 +132,10 @@ void disable_TSC(void) * Must flip the CPU state synchronously with * TIF_NOTSC in the current running context. */ - hard_disable_TSC(); + cr4_set_bits(X86_CR4_TSD); preempt_enable(); } -static void hard_enable_TSC(void) -{ - cr4_clear_bits(X86_CR4_TSD); -} - static void enable_TSC(void) { preempt_disable(); @@ -154,7 +144,7 @@ static void enable_TSC(void) * Must flip the CPU state synchronously with * TIF_NOTSC in the current running context. */ - hard_enable_TSC(); + cr4_clear_bits(X86_CR4_TSD); preempt_enable(); } @@ -233,12 +223,8 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl); } - if ((tifp ^ tifn) & _TIF_NOTSC) { - if (tifn & _TIF_NOTSC) - hard_disable_TSC(); - else - hard_enable_TSC(); - } + if ((tifp ^ tifn) & _TIF_NOTSC) + cr4_toggle_bits(X86_CR4_TSD); } /* -- cgit v1.2.3-55-g7522 From ab6d9468631a6e56e4c071c6ce6710956485fe08 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:19 -0700 Subject: x86/msr: Rename MISC_FEATURE_ENABLES to MISC_FEATURES_ENABLES This matches the only public Intel documentation of this MSR, in the "Virtualization Technology FlexMigration Application Note" (preserved at https://bugzilla.kernel.org/attachment.cgi?id=243991) Signed-off-by: Kyle Huey Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-2-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/msr-index.h | 6 +++--- arch/x86/kernel/cpu/intel.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 4c928f332f8f..f429b70ebaef 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -553,10 +553,10 @@ #define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT 39 #define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT) -/* MISC_FEATURE_ENABLES non-architectural features */ -#define MSR_MISC_FEATURE_ENABLES 0x00000140 +/* MISC_FEATURES_ENABLES non-architectural features */ +#define MSR_MISC_FEATURES_ENABLES 0x00000140 -#define MSR_MISC_FEATURE_ENABLES_RING3MWAIT_BIT 1 +#define MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT 1 #define MSR_IA32_TSC_DEADLINE 0x000006E0 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 063197771b8d..e229318d7230 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -91,13 +91,13 @@ static void probe_xeon_phi_r3mwait(struct cpuinfo_x86 *c) } if (ring3mwait_disabled) { - msr_clear_bit(MSR_MISC_FEATURE_ENABLES, - MSR_MISC_FEATURE_ENABLES_RING3MWAIT_BIT); + msr_clear_bit(MSR_MISC_FEATURES_ENABLES, + MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT); return; } - msr_set_bit(MSR_MISC_FEATURE_ENABLES, - MSR_MISC_FEATURE_ENABLES_RING3MWAIT_BIT); + msr_set_bit(MSR_MISC_FEATURES_ENABLES, + MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT); set_cpu_cap(c, X86_FEATURE_RING3MWAIT); -- cgit v1.2.3-55-g7522 From dd93938a92dc067aba70c401bdf2e50ed58083db Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:20 -0700 Subject: x86/arch_prctl: Rename 'code' argument to 'option' The x86 specific arch_prctl() arbitrarily changed prctl's 'option' to 'code'. Before adding new options, rename it. Signed-off-by: Kyle Huey Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-3-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/um/include/shared/os.h | 4 ++-- arch/x86/include/asm/proto.h | 2 +- arch/x86/kernel/process_64.c | 8 ++++---- arch/x86/um/asm/ptrace.h | 2 +- arch/x86/um/os-Linux/prctl.c | 4 ++-- arch/x86/um/syscalls_64.c | 13 +++++++------ 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index de5d572225f3..32e41c4ef6d3 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -302,8 +302,8 @@ extern int ignore_sigio_fd(int fd); extern void maybe_sigio_broken(int fd, int read); extern void sigio_broken(int fd, int read); -/* sys-x86_64/prctl.c */ -extern int os_arch_prctl(int pid, int code, unsigned long *addr); +/* prctl.c */ +extern int os_arch_prctl(int pid, int option, unsigned long *addr); /* tty.c */ extern int get_pty(void); diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h index 9b9b30b19441..91675a960391 100644 --- a/arch/x86/include/asm/proto.h +++ b/arch/x86/include/asm/proto.h @@ -30,6 +30,6 @@ void x86_report_nx(void); extern int reboot_force; -long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); +long do_arch_prctl(struct task_struct *task, int option, unsigned long addr); #endif /* _ASM_X86_PROTO_H */ diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index d6b784a5520d..4377cfe8e449 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -547,13 +547,13 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr) } #endif -long do_arch_prctl(struct task_struct *task, int code, unsigned long addr) +long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) { int ret = 0; int doit = task == current; int cpu; - switch (code) { + switch (option) { case ARCH_SET_GS: if (addr >= TASK_SIZE_MAX) return -EPERM; @@ -621,9 +621,9 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr) return ret; } -long sys_arch_prctl(int code, unsigned long addr) +long sys_arch_prctl(int option, unsigned long addr) { - return do_arch_prctl(current, code, addr); + return do_arch_prctl(current, option, addr); } unsigned long KSTK_ESP(struct task_struct *task) diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h index e59eef20647b..b291ca5cf66b 100644 --- a/arch/x86/um/asm/ptrace.h +++ b/arch/x86/um/asm/ptrace.h @@ -78,7 +78,7 @@ static inline int ptrace_set_thread_area(struct task_struct *child, int idx, return -ENOSYS; } -extern long arch_prctl(struct task_struct *task, int code, +extern long arch_prctl(struct task_struct *task, int option, unsigned long __user *addr); #endif diff --git a/arch/x86/um/os-Linux/prctl.c b/arch/x86/um/os-Linux/prctl.c index 96eb2bd28832..0a6e16a35b77 100644 --- a/arch/x86/um/os-Linux/prctl.c +++ b/arch/x86/um/os-Linux/prctl.c @@ -6,7 +6,7 @@ #include #include -int os_arch_prctl(int pid, int code, unsigned long *addr) +int os_arch_prctl(int pid, int option, unsigned long *addr) { - return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, code); + return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, option); } diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c index 10d907098c26..3c2dd8768992 100644 --- a/arch/x86/um/syscalls_64.c +++ b/arch/x86/um/syscalls_64.c @@ -11,7 +11,8 @@ #include /* XXX This should get the constants from libc */ #include -long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) +long arch_prctl(struct task_struct *task, int option + unsigned long __user *addr) { unsigned long *ptr = addr, tmp; long ret; @@ -30,7 +31,7 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) * arch_prctl is run on the host, then the registers are read * back. */ - switch (code) { + switch (option) { case ARCH_SET_FS: case ARCH_SET_GS: ret = restore_registers(pid, ¤t->thread.regs.regs); @@ -50,11 +51,11 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) ptr = &tmp; } - ret = os_arch_prctl(pid, code, ptr); + ret = os_arch_prctl(pid, option, ptr); if (ret) return ret; - switch (code) { + switch (option) { case ARCH_SET_FS: current->thread.arch.fs = (unsigned long) ptr; ret = save_registers(pid, ¤t->thread.regs.regs); @@ -73,9 +74,9 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) return ret; } -long sys_arch_prctl(int code, unsigned long addr) +long sys_arch_prctl(int option, unsigned long addr) { - return arch_prctl(current, code, (unsigned long __user *) addr); + return arch_prctl(current, option, (unsigned long __user *) addr); } void arch_switch_to(struct task_struct *to) -- cgit v1.2.3-55-g7522 From ff3f097eef30151f5ee250859e0fe8a0ec02c160 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:21 -0700 Subject: x86/arch_prctl/64: Use SYSCALL_DEFINE2 to define sys_arch_prctl() Use the SYSCALL_DEFINE2 macro instead of manually defining it. Signed-off-by: Kyle Huey Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-4-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/kernel/process_64.c | 3 ++- arch/x86/um/syscalls_64.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 4377cfe8e449..bf9d7b6c0223 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -621,7 +622,7 @@ long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) return ret; } -long sys_arch_prctl(int option, unsigned long addr) +SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, addr) { return do_arch_prctl(current, option, addr); } diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c index 3c2dd8768992..42369fa5421f 100644 --- a/arch/x86/um/syscalls_64.c +++ b/arch/x86/um/syscalls_64.c @@ -7,6 +7,7 @@ #include #include +#include #include #include /* XXX This should get the constants from libc */ #include @@ -74,7 +75,7 @@ long arch_prctl(struct task_struct *task, int option return ret; } -long sys_arch_prctl(int option, unsigned long addr) +SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, addr) { return arch_prctl(current, option, (unsigned long __user *) addr); } -- cgit v1.2.3-55-g7522 From 17a6e1b8e8e8539f89156643f8c3073f09ec446a Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:22 -0700 Subject: x86/arch_prctl/64: Rename do_arch_prctl() to do_arch_prctl_64() In order to introduce new arch_prctls that are not 64 bit only, rename the existing 64 bit implementation to do_arch_prctl_64(). Also rename the second argument of that function from 'addr' to 'arg2', because it will no longer always be an address. Signed-off-by: Kyle Huey Reviewed-by: Andy Lutomirski Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-5-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/um/include/shared/os.h | 2 +- arch/x86/include/asm/proto.h | 3 +-- arch/x86/kernel/process_64.c | 32 +++++++++++++++++--------------- arch/x86/kernel/ptrace.c | 8 ++++---- arch/x86/um/os-Linux/prctl.c | 4 ++-- arch/x86/um/syscalls_64.c | 14 +++++++------- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 32e41c4ef6d3..cd1fa97776c3 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -303,7 +303,7 @@ extern void maybe_sigio_broken(int fd, int read); extern void sigio_broken(int fd, int read); /* prctl.c */ -extern int os_arch_prctl(int pid, int option, unsigned long *addr); +extern int os_arch_prctl(int pid, int option, unsigned long *arg2); /* tty.c */ extern int get_pty(void); diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h index 91675a960391..4e276f6cb1c1 100644 --- a/arch/x86/include/asm/proto.h +++ b/arch/x86/include/asm/proto.h @@ -9,6 +9,7 @@ void syscall_init(void); #ifdef CONFIG_X86_64 void entry_SYSCALL_64(void); +long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2); #endif #ifdef CONFIG_X86_32 @@ -30,6 +31,4 @@ void x86_report_nx(void); extern int reboot_force; -long do_arch_prctl(struct task_struct *task, int option, unsigned long addr); - #endif /* _ASM_X86_PROTO_H */ diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index bf9d7b6c0223..e37f764c11cc 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -205,7 +205,7 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp, (struct user_desc __user *)tls, 0); else #endif - err = do_arch_prctl(p, ARCH_SET_FS, tls); + err = do_arch_prctl_64(p, ARCH_SET_FS, tls); if (err) goto out; } @@ -548,7 +548,7 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr) } #endif -long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) +long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2) { int ret = 0; int doit = task == current; @@ -556,62 +556,64 @@ long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) switch (option) { case ARCH_SET_GS: - if (addr >= TASK_SIZE_MAX) + if (arg2 >= TASK_SIZE_MAX) return -EPERM; cpu = get_cpu(); task->thread.gsindex = 0; - task->thread.gsbase = addr; + task->thread.gsbase = arg2; if (doit) { load_gs_index(0); - ret = wrmsrl_safe(MSR_KERNEL_GS_BASE, addr); + ret = wrmsrl_safe(MSR_KERNEL_GS_BASE, arg2); } put_cpu(); break; case ARCH_SET_FS: /* Not strictly needed for fs, but do it for symmetry with gs */ - if (addr >= TASK_SIZE_MAX) + if (arg2 >= TASK_SIZE_MAX) return -EPERM; cpu = get_cpu(); task->thread.fsindex = 0; - task->thread.fsbase = addr; + task->thread.fsbase = arg2; if (doit) { /* set the selector to 0 to not confuse __switch_to */ loadsegment(fs, 0); - ret = wrmsrl_safe(MSR_FS_BASE, addr); + ret = wrmsrl_safe(MSR_FS_BASE, arg2); } put_cpu(); break; case ARCH_GET_FS: { unsigned long base; + if (doit) rdmsrl(MSR_FS_BASE, base); else base = task->thread.fsbase; - ret = put_user(base, (unsigned long __user *)addr); + ret = put_user(base, (unsigned long __user *)arg2); break; } case ARCH_GET_GS: { unsigned long base; + if (doit) rdmsrl(MSR_KERNEL_GS_BASE, base); else base = task->thread.gsbase; - ret = put_user(base, (unsigned long __user *)addr); + ret = put_user(base, (unsigned long __user *)arg2); break; } #ifdef CONFIG_CHECKPOINT_RESTORE # ifdef CONFIG_X86_X32_ABI case ARCH_MAP_VDSO_X32: - return prctl_map_vdso(&vdso_image_x32, addr); + return prctl_map_vdso(&vdso_image_x32, arg2); # endif # if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION case ARCH_MAP_VDSO_32: - return prctl_map_vdso(&vdso_image_32, addr); + return prctl_map_vdso(&vdso_image_32, arg2); # endif case ARCH_MAP_VDSO_64: - return prctl_map_vdso(&vdso_image_64, addr); + return prctl_map_vdso(&vdso_image_64, arg2); #endif default: @@ -622,9 +624,9 @@ long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) return ret; } -SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, addr) +SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) { - return do_arch_prctl(current, option, addr); + return do_arch_prctl_64(current, option, arg2); } unsigned long KSTK_ESP(struct task_struct *task) diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 2364b23ea3e5..f37d18124648 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -396,12 +396,12 @@ static int putreg(struct task_struct *child, if (value >= TASK_SIZE_MAX) return -EIO; /* - * When changing the segment base, use do_arch_prctl + * When changing the segment base, use do_arch_prctl_64 * to set either thread.fs or thread.fsindex and the * corresponding GDT slot. */ if (child->thread.fsbase != value) - return do_arch_prctl(child, ARCH_SET_FS, value); + return do_arch_prctl_64(child, ARCH_SET_FS, value); return 0; case offsetof(struct user_regs_struct,gs_base): /* @@ -410,7 +410,7 @@ static int putreg(struct task_struct *child, if (value >= TASK_SIZE_MAX) return -EIO; if (child->thread.gsbase != value) - return do_arch_prctl(child, ARCH_SET_GS, value); + return do_arch_prctl_64(child, ARCH_SET_GS, value); return 0; #endif } @@ -869,7 +869,7 @@ long arch_ptrace(struct task_struct *child, long request, Works just like arch_prctl, except that the arguments are reversed. */ case PTRACE_ARCH_PRCTL: - ret = do_arch_prctl(child, data, addr); + ret = do_arch_prctl_64(child, data, addr); break; #endif diff --git a/arch/x86/um/os-Linux/prctl.c b/arch/x86/um/os-Linux/prctl.c index 0a6e16a35b77..8431e87ac333 100644 --- a/arch/x86/um/os-Linux/prctl.c +++ b/arch/x86/um/os-Linux/prctl.c @@ -6,7 +6,7 @@ #include #include -int os_arch_prctl(int pid, int option, unsigned long *addr) +int os_arch_prctl(int pid, int option, unsigned long *arg2) { - return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, option); + return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) arg2, option); } diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c index 42369fa5421f..81b9fe100f7c 100644 --- a/arch/x86/um/syscalls_64.c +++ b/arch/x86/um/syscalls_64.c @@ -12,10 +12,10 @@ #include /* XXX This should get the constants from libc */ #include -long arch_prctl(struct task_struct *task, int option - unsigned long __user *addr) +long arch_prctl(struct task_struct *task, int option) + unsigned long __user *arg2) { - unsigned long *ptr = addr, tmp; + unsigned long *ptr = arg2, tmp; long ret; int pid = task->mm->context.id.u.pid; @@ -65,19 +65,19 @@ long arch_prctl(struct task_struct *task, int option ret = save_registers(pid, ¤t->thread.regs.regs); break; case ARCH_GET_FS: - ret = put_user(tmp, addr); + ret = put_user(tmp, arg2); break; case ARCH_GET_GS: - ret = put_user(tmp, addr); + ret = put_user(tmp, arg2); break; } return ret; } -SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, addr) +SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) { - return arch_prctl(current, option, (unsigned long __user *) addr); + return arch_prctl(current, option, (unsigned long __user *) arg2); } void arch_switch_to(struct task_struct *to) -- cgit v1.2.3-55-g7522 From b0b9b014016d16ca7a192da986aa8ebae21bb995 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:23 -0700 Subject: x86/arch_prctl: Add do_arch_prctl_common() Add do_arch_prctl_common() to handle arch_prctls that are not specific to 64 bit mode. Call it from the syscall entry point, but not any of the other callsites in the kernel, which all want one of the existing 64 bit only arch_prctls. Signed-off-by: Kyle Huey Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-6-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/proto.h | 3 +++ arch/x86/kernel/process.c | 6 ++++++ arch/x86/kernel/process_64.c | 8 +++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h index 4e276f6cb1c1..8d3964fc5f91 100644 --- a/arch/x86/include/asm/proto.h +++ b/arch/x86/include/asm/proto.h @@ -31,4 +31,7 @@ void x86_report_nx(void); extern int reboot_force; +long do_arch_prctl_common(struct task_struct *task, int option, + unsigned long cpuid_enabled); + #endif /* _ASM_X86_PROTO_H */ diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 366db7782fc6..b12e95eceb83 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -545,3 +545,9 @@ out: put_task_stack(p); return ret; } + +long do_arch_prctl_common(struct task_struct *task, int option, + unsigned long cpuid_enabled) +{ + return -EINVAL; +} diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index e37f764c11cc..d81b0a60a45c 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -626,7 +626,13 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2) SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) { - return do_arch_prctl_64(current, option, arg2); + long ret; + + ret = do_arch_prctl_64(current, option, arg2); + if (ret == -EINVAL) + ret = do_arch_prctl_common(current, option, arg2); + + return ret; } unsigned long KSTK_ESP(struct task_struct *task) -- cgit v1.2.3-55-g7522 From 79170fda313ed5be2394f87aa2a00d597f8ed4a1 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:24 -0700 Subject: x86/syscalls/32: Wire up arch_prctl on x86-32 Hook up arch_prctl to call do_arch_prctl() on x86-32, and in 32 bit compat mode on x86-64. This allows to have arch_prctls that are not specific to 64 bits. On UML, simply stub out this syscall. Signed-off-by: Kyle Huey Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-7-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/kernel/process_32.c | 7 +++++++ arch/x86/kernel/process_64.c | 7 +++++++ arch/x86/um/Makefile | 2 +- arch/x86/um/syscalls_32.c | 7 +++++++ include/linux/compat.h | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 arch/x86/um/syscalls_32.c diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 9ba050fe47f3..0af59fa789ea 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -390,3 +390,4 @@ 381 i386 pkey_alloc sys_pkey_alloc 382 i386 pkey_free sys_pkey_free 383 i386 statx sys_statx +384 i386 arch_prctl sys_arch_prctl compat_sys_arch_prctl diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 4c818f8bc135..ff40e74c9181 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,7 @@ #include #include #include +#include void __show_regs(struct pt_regs *regs, int all) { @@ -304,3 +306,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) return prev_p; } + +SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) +{ + return do_arch_prctl_common(current, option, arg2); +} diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index d81b0a60a45c..ea1a6180bf39 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -635,6 +635,13 @@ SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) return ret; } +#ifdef CONFIG_IA32_EMULATION +COMPAT_SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) +{ + return do_arch_prctl_common(current, option, arg2); +} +#endif + unsigned long KSTK_ESP(struct task_struct *task) { return task_pt_regs(task)->sp; diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile index e7e7055a8658..69f0827d5f53 100644 --- a/arch/x86/um/Makefile +++ b/arch/x86/um/Makefile @@ -16,7 +16,7 @@ obj-y = bug.o bugs_$(BITS).o delay.o fault.o ldt.o \ ifeq ($(CONFIG_X86_32),y) -obj-y += checksum_32.o +obj-y += checksum_32.o syscalls_32.o obj-$(CONFIG_ELF_CORE) += elfcore.o subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o diff --git a/arch/x86/um/syscalls_32.c b/arch/x86/um/syscalls_32.c new file mode 100644 index 000000000000..627d68836b16 --- /dev/null +++ b/arch/x86/um/syscalls_32.c @@ -0,0 +1,7 @@ +#include +#include + +SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) +{ + return -EINVAL; +} diff --git a/include/linux/compat.h b/include/linux/compat.h index aef47be2a5c1..af9dbc44fd92 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -723,6 +723,8 @@ asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, int, const char __user *); +asmlinkage long compat_sys_arch_prctl(int option, unsigned long arg2); + /* * For most but not all architectures, "am I in a compat syscall?" and * "am I a compat task?" are the same question. For architectures on which -- cgit v1.2.3-55-g7522 From 90218ac77d0582eaf2d0872d8d900cbd5bf1f205 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:25 -0700 Subject: x86/cpufeature: Detect CPUID faulting support Intel supports faulting on the CPUID instruction beginning with Ivy Bridge. When enabled, the processor will fault on attempts to execute the CPUID instruction with CPL>0. This will allow a ptracer to emulate the CPUID instruction. Bit 31 of MSR_PLATFORM_INFO advertises support for this feature. It is documented in detail in Section 2.3.2 of https://bugzilla.kernel.org/attachment.cgi?id=243991 Detect support for this feature and expose it as X86_FEATURE_CPUID_FAULT. Signed-off-by: Kyle Huey Reviewed-by: Borislav Petkov Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-8-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/intel.c | 24 +++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index b04bb6dfed7f..0fe00446f9ca 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -187,6 +187,7 @@ * Reuse free bits when adding new feature flags! */ #define X86_FEATURE_RING3MWAIT ( 7*32+ 0) /* Ring 3 MONITOR/MWAIT */ +#define X86_FEATURE_CPUID_FAULT ( 7*32+ 1) /* Intel CPUID faulting */ #define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ #define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ #define X86_FEATURE_CAT_L3 ( 7*32+ 4) /* Cache Allocation Technology L3 */ diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index f429b70ebaef..b1f75daca34b 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -45,6 +45,8 @@ #define MSR_IA32_PERFCTR1 0x000000c2 #define MSR_FSB_FREQ 0x000000cd #define MSR_PLATFORM_INFO 0x000000ce +#define MSR_PLATFORM_INFO_CPUID_FAULT_BIT 31 +#define MSR_PLATFORM_INFO_CPUID_FAULT BIT_ULL(MSR_PLATFORM_INFO_CPUID_FAULT_BIT) #define MSR_PKG_CST_CONFIG_CONTROL 0x000000e2 #define NHM_C3_AUTO_DEMOTE (1UL << 25) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index e229318d7230..a07f8295c9ed 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -488,6 +488,28 @@ static void intel_bsp_resume(struct cpuinfo_x86 *c) init_intel_energy_perf(c); } +static void init_cpuid_fault(struct cpuinfo_x86 *c) +{ + u64 msr; + + if (!rdmsrl_safe(MSR_PLATFORM_INFO, &msr)) { + if (msr & MSR_PLATFORM_INFO_CPUID_FAULT) + set_cpu_cap(c, X86_FEATURE_CPUID_FAULT); + } +} + +static void init_intel_misc_features(struct cpuinfo_x86 *c) +{ + u64 msr; + + if (rdmsrl_safe(MSR_MISC_FEATURES_ENABLES, &msr)) + return; + + /* Check features and update capabilities */ + init_cpuid_fault(c); + probe_xeon_phi_r3mwait(c); +} + static void init_intel(struct cpuinfo_x86 *c) { unsigned int l2 = 0; @@ -602,7 +624,7 @@ static void init_intel(struct cpuinfo_x86 *c) init_intel_energy_perf(c); - probe_xeon_phi_r3mwait(c); + init_intel_misc_features(c); } #ifdef CONFIG_X86_32 -- cgit v1.2.3-55-g7522 From e9ea1e7f53b852147cbd568b0568c7ad97ec21a3 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 20 Mar 2017 01:16:26 -0700 Subject: x86/arch_prctl: Add ARCH_[GET|SET]_CPUID Intel supports faulting on the CPUID instruction beginning with Ivy Bridge. When enabled, the processor will fault on attempts to execute the CPUID instruction with CPL>0. Exposing this feature to userspace will allow a ptracer to trap and emulate the CPUID instruction. When supported, this feature is controlled by toggling bit 0 of MSR_MISC_FEATURES_ENABLES. It is documented in detail in Section 2.3.2 of https://bugzilla.kernel.org/attachment.cgi?id=243991 Implement a new pair of arch_prctls, available on both x86-32 and x86-64. ARCH_GET_CPUID: Returns the current CPUID state, either 0 if CPUID faulting is enabled (and thus the CPUID instruction is not available) or 1 if CPUID faulting is not enabled. ARCH_SET_CPUID: Set the CPUID state to the second argument. If cpuid_enabled is 0 CPUID faulting will be activated, otherwise it will be deactivated. Returns ENODEV if CPUID faulting is not supported on this system. The state of the CPUID faulting flag is propagated across forks, but reset upon exec. Signed-off-by: Kyle Huey Cc: Grzegorz Andrejczuk Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Peter Zijlstra Cc: Dave Hansen Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: Nadav Amit Cc: Robert O'Callahan Cc: Richard Weinberger Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Len Brown Cc: Shuah Khan Cc: user-mode-linux-devel@lists.sourceforge.net Cc: Jeff Dike Cc: Alexander Viro Cc: user-mode-linux-user@lists.sourceforge.net Cc: David Matlack Cc: Boris Ostrovsky Cc: Dmitry Safonov Cc: linux-fsdevel@vger.kernel.org Cc: Paolo Bonzini Link: http://lkml.kernel.org/r/20170320081628.18952-9-khuey@kylehuey.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/msr-index.h | 2 + arch/x86/include/asm/processor.h | 2 + arch/x86/include/asm/thread_info.h | 6 ++- arch/x86/include/uapi/asm/prctl.h | 11 ++++-- arch/x86/kernel/cpu/intel.c | 18 +++++---- arch/x86/kernel/process.c | 78 ++++++++++++++++++++++++++++++++++++++ fs/exec.c | 1 + include/linux/thread_info.h | 4 ++ 8 files changed, 109 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index b1f75daca34b..673f9ac50f6d 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -558,6 +558,8 @@ /* MISC_FEATURES_ENABLES non-architectural features */ #define MSR_MISC_FEATURES_ENABLES 0x00000140 +#define MSR_MISC_FEATURES_ENABLES_CPUID_FAULT_BIT 0 +#define MSR_MISC_FEATURES_ENABLES_CPUID_FAULT BIT_ULL(MSR_MISC_FEATURES_ENABLES_CPUID_FAULT_BIT) #define MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT 1 #define MSR_IA32_TSC_DEADLINE 0x000006E0 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index f385eca5407a..a80c1b3997ed 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -884,6 +884,8 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip, extern int get_tsc_mode(unsigned long adr); extern int set_tsc_mode(unsigned int val); +DECLARE_PER_CPU(u64, msr_misc_features_shadow); + /* Register/unregister a process' MPX related resource */ #define MPX_ENABLE_MANAGEMENT() mpx_enable_management() #define MPX_DISABLE_MANAGEMENT() mpx_disable_management() diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index ad6f5eb07a95..9fc44b95f7cb 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -87,6 +87,7 @@ struct thread_info { #define TIF_SECCOMP 8 /* secure computing */ #define TIF_USER_RETURN_NOTIFY 11 /* notify kernel of userspace return */ #define TIF_UPROBE 12 /* breakpointed or singlestepping */ +#define TIF_NOCPUID 15 /* CPUID is not accessible in userland */ #define TIF_NOTSC 16 /* TSC is not accessible in userland */ #define TIF_IA32 17 /* IA32 compatibility process */ #define TIF_NOHZ 19 /* in adaptive nohz mode */ @@ -110,6 +111,7 @@ struct thread_info { #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY) #define _TIF_UPROBE (1 << TIF_UPROBE) +#define _TIF_NOCPUID (1 << TIF_NOCPUID) #define _TIF_NOTSC (1 << TIF_NOTSC) #define _TIF_IA32 (1 << TIF_IA32) #define _TIF_NOHZ (1 << TIF_NOHZ) @@ -138,7 +140,7 @@ struct thread_info { /* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW \ - (_TIF_IO_BITMAP|_TIF_NOTSC|_TIF_BLOCKSTEP) + (_TIF_IO_BITMAP|_TIF_NOCPUID|_TIF_NOTSC|_TIF_BLOCKSTEP) #define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY) #define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW) @@ -239,6 +241,8 @@ static inline int arch_within_stack_frames(const void * const stack, extern void arch_task_cache_init(void); extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); extern void arch_release_task_struct(struct task_struct *tsk); +extern void arch_setup_new_exec(void); +#define arch_setup_new_exec arch_setup_new_exec #endif /* !__ASSEMBLY__ */ #endif /* _ASM_X86_THREAD_INFO_H */ diff --git a/arch/x86/include/uapi/asm/prctl.h b/arch/x86/include/uapi/asm/prctl.h index 835aa51c7f6e..c45765517092 100644 --- a/arch/x86/include/uapi/asm/prctl.h +++ b/arch/x86/include/uapi/asm/prctl.h @@ -1,10 +1,13 @@ #ifndef _ASM_X86_PRCTL_H #define _ASM_X86_PRCTL_H -#define ARCH_SET_GS 0x1001 -#define ARCH_SET_FS 0x1002 -#define ARCH_GET_FS 0x1003 -#define ARCH_GET_GS 0x1004 +#define ARCH_SET_GS 0x1001 +#define ARCH_SET_FS 0x1002 +#define ARCH_GET_FS 0x1003 +#define ARCH_GET_GS 0x1004 + +#define ARCH_GET_CPUID 0x1011 +#define ARCH_SET_CPUID 0x1012 #define ARCH_MAP_VDSO_X32 0x2001 #define ARCH_MAP_VDSO_32 0x2002 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index a07f8295c9ed..dfa90a3a5145 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -90,16 +90,12 @@ static void probe_xeon_phi_r3mwait(struct cpuinfo_x86 *c) return; } - if (ring3mwait_disabled) { - msr_clear_bit(MSR_MISC_FEATURES_ENABLES, - MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT); + if (ring3mwait_disabled) return; - } - - msr_set_bit(MSR_MISC_FEATURES_ENABLES, - MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT); set_cpu_cap(c, X86_FEATURE_RING3MWAIT); + this_cpu_or(msr_misc_features_shadow, + 1UL << MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT); if (c == &boot_cpu_data) ELF_HWCAP2 |= HWCAP2_RING3MWAIT; @@ -505,9 +501,15 @@ static void init_intel_misc_features(struct cpuinfo_x86 *c) if (rdmsrl_safe(MSR_MISC_FEATURES_ENABLES, &msr)) return; - /* Check features and update capabilities */ + /* Clear all MISC features */ + this_cpu_write(msr_misc_features_shadow, 0); + + /* Check features and update capabilities and shadow control bits */ init_cpuid_fault(c); probe_xeon_phi_r3mwait(c); + + msr = this_cpu_read(msr_misc_features_shadow); + wrmsrl(MSR_MISC_FEATURES_ENABLES, msr); } static void init_intel(struct cpuinfo_x86 *c) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index b12e95eceb83..0bb88428cbf2 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -37,6 +37,7 @@ #include #include #include +#include /* * per-CPU TSS segments. Threads are completely 'soft' on Linux, @@ -172,6 +173,73 @@ int set_tsc_mode(unsigned int val) return 0; } +DEFINE_PER_CPU(u64, msr_misc_features_shadow); + +static void set_cpuid_faulting(bool on) +{ + u64 msrval; + + msrval = this_cpu_read(msr_misc_features_shadow); + msrval &= ~MSR_MISC_FEATURES_ENABLES_CPUID_FAULT; + msrval |= (on << MSR_MISC_FEATURES_ENABLES_CPUID_FAULT_BIT); + this_cpu_write(msr_misc_features_shadow, msrval); + wrmsrl(MSR_MISC_FEATURES_ENABLES, msrval); +} + +static void disable_cpuid(void) +{ + preempt_disable(); + if (!test_and_set_thread_flag(TIF_NOCPUID)) { + /* + * Must flip the CPU state synchronously with + * TIF_NOCPUID in the current running context. + */ + set_cpuid_faulting(true); + } + preempt_enable(); +} + +static void enable_cpuid(void) +{ + preempt_disable(); + if (test_and_clear_thread_flag(TIF_NOCPUID)) { + /* + * Must flip the CPU state synchronously with + * TIF_NOCPUID in the current running context. + */ + set_cpuid_faulting(false); + } + preempt_enable(); +} + +static int get_cpuid_mode(void) +{ + return !test_thread_flag(TIF_NOCPUID); +} + +static int set_cpuid_mode(struct task_struct *task, unsigned long cpuid_enabled) +{ + if (!static_cpu_has(X86_FEATURE_CPUID_FAULT)) + return -ENODEV; + + if (cpuid_enabled) + enable_cpuid(); + else + disable_cpuid(); + + return 0; +} + +/* + * Called immediately after a successful exec. + */ +void arch_setup_new_exec(void) +{ + /* If cpuid was previously disabled for this task, re-enable it. */ + if (test_thread_flag(TIF_NOCPUID)) + enable_cpuid(); +} + static inline void switch_to_bitmap(struct tss_struct *tss, struct thread_struct *prev, struct thread_struct *next, @@ -225,6 +293,9 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, if ((tifp ^ tifn) & _TIF_NOTSC) cr4_toggle_bits(X86_CR4_TSD); + + if ((tifp ^ tifn) & _TIF_NOCPUID) + set_cpuid_faulting(!!(tifn & _TIF_NOCPUID)); } /* @@ -549,5 +620,12 @@ out: long do_arch_prctl_common(struct task_struct *task, int option, unsigned long cpuid_enabled) { + switch (option) { + case ARCH_GET_CPUID: + return get_cpuid_mode(); + case ARCH_SET_CPUID: + return set_cpuid_mode(task, cpuid_enabled); + } + return -EINVAL; } diff --git a/fs/exec.c b/fs/exec.c index 65145a3df065..72934df68471 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1320,6 +1320,7 @@ void setup_new_exec(struct linux_binprm * bprm) else set_dumpable(current->mm, suid_dumpable); + arch_setup_new_exec(); perf_event_exec(); __set_task_comm(current, kbasename(bprm->filename), true); diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index 58373875e8ee..55125d674338 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -101,6 +101,10 @@ static inline void check_object_size(const void *ptr, unsigned long n, { } #endif /* CONFIG_HARDENED_USERCOPY */ +#ifndef arch_setup_new_exec +static inline void arch_setup_new_exec(void) { } +#endif + #endif /* __KERNEL__ */ #endif /* _LINUX_THREAD_INFO_H */ -- cgit v1.2.3-55-g7522 From 4c38c8f5d2c8c48dcf502cd039f30cb1f82fe63c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 12:49:58 -0300 Subject: perf unwind arm64: Add missing errno.h header Since it uses EINVAL unconditionally, it needs to also unconditionally include errno.h. Detected when recent changes made errno.h not be included by chance when tools/perf/arch/arm64/util/unwind-libunwind.c gets included by tools/perf/util/libunwind/arm64.c. Putting this changeset just before that change so that we don't lose bisectability on arm64. Cc: Adrian Hunter Cc: David Ahern Cc: Jean Pihet Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Fixes: 8ab596afb97b ("perf tools ARM64: Wire up perf_regs and unwind support") Link: http://lkml.kernel.org/n/tip-60zjev2o1locp5ivod38epa2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm64/util/unwind-libunwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/arch/arm64/util/unwind-libunwind.c b/tools/perf/arch/arm64/util/unwind-libunwind.c index c116b713f7f7..b415dfdbccca 100644 --- a/tools/perf/arch/arm64/util/unwind-libunwind.c +++ b/tools/perf/arch/arm64/util/unwind-libunwind.c @@ -1,6 +1,6 @@ +#include #ifndef REMOTE_UNWIND_LIBUNWIND -#include #include #include "perf_regs.h" #include "../../util/unwind.h" -- cgit v1.2.3-55-g7522 From 7909675daf55e8222b40e5e162bbc9d633bd5bac Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 11:08:20 -0300 Subject: perf tools: Remove FLEX_ARRAY definition We rely on symbol->name[0] since the beginning of tools/perf/, never having received any complaint about it, also all the containers build perf just fine, so remove this git codebase remnant. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-jsjpgojut8e22o2gtz83augk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-help.c | 4 ++-- tools/perf/util/util.h | 22 ---------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 1eec96a0fa67..9730fd409f3b 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -15,13 +15,13 @@ static struct man_viewer_list { struct man_viewer_list *next; - char name[FLEX_ARRAY]; + char name[0]; } *man_viewer_list; static struct man_viewer_info_list { struct man_viewer_info_list *next; const char *info; - char name[FLEX_ARRAY]; + char name[0]; } *man_viewer_info_list; enum help_format { diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 7cf5752b38fd..df13658377e4 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -1,28 +1,6 @@ #ifndef GIT_COMPAT_UTIL_H #define GIT_COMPAT_UTIL_H -#ifndef FLEX_ARRAY -/* - * See if our compiler is known to support flexible array members. - */ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define FLEX_ARRAY /* empty */ -#elif defined(__GNUC__) -# if (__GNUC__ >= 3) -# define FLEX_ARRAY /* empty */ -# else -# define FLEX_ARRAY 0 /* older GNU extension */ -# endif -#endif - -/* - * Otherwise, default to safer but a bit wasteful traditional style - */ -#ifndef FLEX_ARRAY -# define FLEX_ARRAY 1 -#endif -#endif - #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #ifdef __GNUC__ -- cgit v1.2.3-55-g7522 From 379d61b1c7d42512cded04d372f15a7e725db9e1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 11:23:41 -0300 Subject: tools include: Introduce linux/bug.h, from the kernel sources With just what we will need in the upcoming changesets, the BUILD_BUG_ON_ZERO() definition. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-lw8zg7x6ttwcvqhp90mwe3vo@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/bug.h | 10 ++++++++++ tools/perf/MANIFEST | 1 + 2 files changed, 11 insertions(+) create mode 100644 tools/include/linux/bug.h diff --git a/tools/include/linux/bug.h b/tools/include/linux/bug.h new file mode 100644 index 000000000000..8e4a4f49135d --- /dev/null +++ b/tools/include/linux/bug.h @@ -0,0 +1,10 @@ +#ifndef _TOOLS_PERF_LINUX_BUG_H +#define _TOOLS_PERF_LINUX_BUG_H + +/* Force a compilation error if condition is true, but also produce a + result (of value 0 and type size_t), so the expression can be used + e.g. in a structure initializer (or where-ever else comma expressions + aren't permitted). */ +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) + +#endif /* _TOOLS_PERF_LINUX_BUG_H */ diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 89018c7311a4..a29da46d180f 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST @@ -64,6 +64,7 @@ tools/include/linux/bitops.h tools/include/linux/compiler.h tools/include/linux/compiler-gcc.h tools/include/linux/coresight-pmu.h +tools/include/linux/bug.h tools/include/linux/filter.h tools/include/linux/hash.h tools/include/linux/kernel.h -- cgit v1.2.3-55-g7522 From f6441aff8946f7fd6ab730d7eb9eba18a9ebeba4 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 11:25:00 -0300 Subject: tools include: Adopt __same_type() and __must_be_array() from the kernel Will be used to adopt the more stringent version of ARRAY_SIZE(), the one in the kernel sources. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-d85dpvay1hoqscpezlntyd8x@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/compiler-gcc.h | 3 +++ tools/include/linux/compiler.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h index 616935f1ff56..825d44f89a29 100644 --- a/tools/include/linux/compiler-gcc.h +++ b/tools/include/linux/compiler-gcc.h @@ -16,3 +16,6 @@ #if GCC_VERSION >= 40300 # define __compiletime_error(message) __attribute__((error(message))) #endif /* GCC_VERSION >= 40300 */ + +/* &a[0] degrades to a pointer: a different type from an array */ +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index c9e65e8faacd..23299d7e7160 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h @@ -17,6 +17,11 @@ # define __always_inline inline __attribute__((always_inline)) #endif +/* Are two types/vars the same type (ignoring qualifiers)? */ +#ifndef __same_type +# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + #ifdef __ANDROID__ /* * FIXME: Big hammer to get rid of tons of: -- cgit v1.2.3-55-g7522 From 8607c1ee734d12f62c6a46abef13a510e25a1839 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 11:29:26 -0300 Subject: tools include: Move ARRAY_SIZE() to linux/kernel.h To match the kernel, then look for places redefining it to make it use this version, which checks that its parameter is an array at build time. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-txlcf1im83bcbj6kh0wxmyy8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/kernel.h | 3 +++ tools/perf/util/util.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index adb4d0147755..73ccc48126bb 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifndef UINT_MAX #define UINT_MAX (~0U) @@ -76,6 +77,8 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); int scnprintf(char * buf, size_t size, const char * fmt, ...); +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + /* * This looks more complex than it should be. But we need to * get the type for the ~ right in round_down (it needs to be diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index df13658377e4..3eccd6f21d17 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -1,8 +1,6 @@ #ifndef GIT_COMPAT_UTIL_H #define GIT_COMPAT_UTIL_H -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - #ifdef __GNUC__ #define TYPEOF(x) (__typeof__(x)) #else -- cgit v1.2.3-55-g7522 From 877a7a11050ee4d465364c57f8fbf78f6b1a2559 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 11:39:06 -0300 Subject: perf tools: Add include where ARRAY_SIZE() is used To pave the way for further cleanups where linux/kernel.h may stop being included in some header. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-qqxan6tfsl6qx3l0v3nwgjvk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/bench/numa.c | 1 + tools/perf/builtin-help.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-lock.c | 1 + tools/perf/builtin-sched.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 1 + tools/perf/tests/bpf.c | 1 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/clang.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/dso-data.c | 1 + tools/perf/tests/evsel-roundtrip-name.c | 1 + tools/perf/tests/hists_common.c | 1 + tools/perf/tests/hists_cumulate.c | 1 + tools/perf/tests/hists_filter.c | 1 + tools/perf/tests/hists_link.c | 1 + tools/perf/tests/hists_output.c | 1 + tools/perf/tests/is_printable_array.c | 1 + tools/perf/tests/mmap-basic.c | 1 + tools/perf/tests/parse-events.c | 2 +- tools/perf/tests/parse-no-sample-id-all.c | 1 + tools/perf/tests/pmu.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/tui/setup.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/bpf-loader.c | 1 + tools/perf/util/data-convert-bt.c | 1 + tools/perf/util/dso.c | 1 + tools/perf/util/dwarf-regs.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/evlist.h | 1 + tools/perf/util/mem-events.c | 1 + tools/perf/util/perf-hooks.c | 1 + tools/perf/util/session.h | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/symbol.c | 1 + tools/perf/util/thread.c | 1 + 42 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index 1fe43bd5a012..27ebd50ee619 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 9730fd409f3b..1f18385907f5 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -12,6 +12,7 @@ #include #include #include "util/debug.h" +#include static struct man_viewer_list { struct man_viewer_list *next; diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 515587825af4..8f0b94563936 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -20,6 +20,7 @@ #include "util/debug.h" +#include #include #include #include diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 38b409173693..a7d7f4c6052e 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -24,6 +24,7 @@ #include #endif +#include #include #include #include diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index b686fb6759da..f74dd869f88b 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -26,6 +26,7 @@ #include #include +#include static struct perf_session *session; diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 79833e226789..5cd60882c8d9 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -22,6 +22,7 @@ #include "util/debug.h" +#include #include #include #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 2dab70fba2ba..36b076653d16 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -24,6 +24,7 @@ #include "util/thread-stack.h" #include "util/time-utils.h" #include +#include #include #include #include "asm/bug.h" diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index fafdb44b8bcb..822c8d39ca1d 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -23,6 +23,7 @@ #include "util/cache.h" #include "util/evlist.h" #include "util/evsel.h" +#include #include #include #include "util/symbol.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index fce278d5fada..2792ed1fae43 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 9dc346f2b255..07ee1352f4ed 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -22,6 +22,7 @@ #include #include #include +#include const char perf_usage_string[] = "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 1a04fe77487d..67fe5eeff021 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include "tests.h" diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index e6d7876c94c2..f029737ad255 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -13,6 +13,7 @@ #include "color.h" #include #include "symbol.h" +#include static bool dont_fork; diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c index f853e242a86c..c5bb2203f5a9 100644 --- a/tools/perf/tests/clang.c +++ b/tools/perf/tests/clang.c @@ -2,6 +2,7 @@ #include "debug.h" #include "util.h" #include "c++/clang-c.h" +#include static struct { int (*func)(void); diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index d1f693041324..99dbd5ae294a 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 13725e09ba22..46ea2e061b86 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c index 60926a1f6fd7..9221d2732cc4 100644 --- a/tools/perf/tests/evsel-roundtrip-name.c +++ b/tools/perf/tests/evsel-roundtrip-name.c @@ -3,6 +3,7 @@ #include "parse-events.h" #include "tests.h" #include "debug.h" +#include static int perf_evsel__roundtrip_cache_name_test(void) { diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index 6b21746d6eec..f6c580e3ed84 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c @@ -7,6 +7,7 @@ #include "util/machine.h" #include "util/thread.h" #include "tests/hists_common.h" +#include static struct { u32 pid; diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 9fd54b79a788..70918b986568 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -9,6 +9,7 @@ #include "util/parse-events.h" #include "tests/tests.h" #include "tests/hists_common.h" +#include struct sample { u32 pid; diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 62efb14f3a5a..f171b2da4899 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -9,6 +9,7 @@ #include "util/parse-events.h" #include "tests/tests.h" #include "tests/hists_common.h" +#include struct sample { u32 pid; diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index eddc7407ff8a..1bd26d23c2fc 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -9,6 +9,7 @@ #include "thread.h" #include "parse-events.h" #include "hists_common.h" +#include struct sample { u32 pid; diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index 63c5efaba1b5..cdf0dde5fe97 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -9,6 +9,7 @@ #include "util/parse-events.h" #include "tests/tests.h" #include "tests/hists_common.h" +#include struct sample { u32 cpu; diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c index 42e13393e502..a008e5c2d980 100644 --- a/tools/perf/tests/is_printable_array.c +++ b/tools/perf/tests/is_printable_array.c @@ -1,4 +1,5 @@ #include +#include #include "tests.h" #include "debug.h" #include "util.h" diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 634bce9caebd..a7cb80805993 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -7,6 +7,7 @@ #include "cpumap.h" #include "tests.h" #include +#include /* * This test will generate random numbers of calls to some getpid syscalls, diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 1dc838014422..05621748aead 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1,4 +1,3 @@ - #include "parse-events.h" #include "evsel.h" #include "evlist.h" @@ -6,6 +5,7 @@ #include "tests.h" #include "debug.h" #include "util.h" +#include #include #include diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c index 65dcf48a92fb..c6207db09f12 100644 --- a/tools/perf/tests/parse-no-sample-id-all.c +++ b/tools/perf/tests/parse-no-sample-id-all.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c index 1e2ba2602930..de6498dc4cbb 100644 --- a/tools/perf/tests/pmu.c +++ b/tools/perf/tests/pmu.c @@ -2,6 +2,7 @@ #include "pmu.h" #include "util.h" #include "tests.h" +#include /* Simulated format definitions. */ static struct test_format { diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 5f23710b9fee..73b5e47ef20b 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -1,4 +1,5 @@ #include +#include #include #include "util.h" diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index ba36aac340bc..9adce112d255 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -10,6 +10,7 @@ #include "../../util/evsel.h" #include "../../util/config.h" #include +#include struct disasm_line_samples { double percent; diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index 4ea2ba861fc2..d9350a1da48b 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c @@ -1,6 +1,7 @@ #include #include #include +#include #ifdef HAVE_BACKTRACE_SUPPORT #include #endif diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 30498a2d4a6f..45df4a38811a 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -22,6 +22,7 @@ #include #include #include +#include #include const char *disassembler_style; diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index bc6bc7062eb4..27af9d62d899 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "perf.h" #include "debug.h" diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 89ece2445713..b7917519f6cc 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 42db00d78573..385c82e12473 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "symbol.h" diff --git a/tools/perf/util/dwarf-regs.c b/tools/perf/util/dwarf-regs.c index 62bc4a86a970..c708395b3cb6 100644 --- a/tools/perf/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs.c @@ -8,6 +8,7 @@ #include #include #include +#include #ifndef EM_AARCH64 #define EM_AARCH64 183 /* ARM 64 bit */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 4d7e65fa9d86..a0f59f69f46a 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1,3 +1,4 @@ +#include #include #include /* To get things like MAP_HUGETLB even on older libc headers */ #include diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 39942995f537..3fed4fb2e866 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -1,6 +1,7 @@ #ifndef __PERF_EVLIST_H #define __PERF_EVLIST_H 1 +#include #include #include #include diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 1d4ab53c60ca..c56d52f90b54 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "mem-events.h" #include "debug.h" #include "symbol.h" diff --git a/tools/perf/util/perf-hooks.c b/tools/perf/util/perf-hooks.c index cb368306b12b..d55092964da2 100644 --- a/tools/perf/util/perf-hooks.c +++ b/tools/perf/util/perf-hooks.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "util/util.h" #include "util/debug.h" #include "util/perf-hooks.h" diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4bd758553450..1ffae42f76a1 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -9,6 +9,7 @@ #include "thread.h" #include "data.h" #include "ordered-events.h" +#include #include #include diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 73f3ec1cf2a0..13b9af1d1b45 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -7,6 +7,7 @@ #include "evlist.h" #include #include "mem-events.h" +#include regex_t parent_regex; const char default_parent_pattern[] = "^sys_|^do_page_fault"; diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 9b4d8ba22fed..619e3eb44c50 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index dcdb87a5d0a1..e8ce6abc5321 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "session.h" #include "thread.h" #include "thread-stack.h" -- cgit v1.2.3-55-g7522 From 0061459744cb985ef31a484bcd9b2fc3cfd01c1b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 11:58:55 -0300 Subject: objtool: Drop ARRAY_SIZE() definition, tools/include/linux/kernel.h has it now And with the goodies present in the kernel.h counterpart, i.e. checking that the parameter is an array at build time. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Josh Poimboeuf Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-roiwxwgwgld4kygn65if60wa@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/objtool/builtin-check.c | 3 +-- tools/objtool/objtool.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 066086dd59a8..282a60368b14 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -36,8 +36,7 @@ #include "warn.h" #include - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#include #define STATE_FP_SAVED 0x1 #define STATE_FP_SETUP 0x2 diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c index 46c326db4f46..ecc5b1b5d15d 100644 --- a/tools/objtool/objtool.c +++ b/tools/objtool/objtool.c @@ -31,11 +31,10 @@ #include #include #include +#include #include "builtin.h" -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - struct cmd_struct { const char *name; int (*fn)(int, const char **); -- cgit v1.2.3-55-g7522 From 68289cbd83eaa20faef7cc818121bc8e769065de Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 12:01:36 -0300 Subject: tools include: Drop ARRAY_SIZE() definition from linux/hashtable.h As tools/include/linux/kernel.h has it now, with the goodies present in the kernel.h counterpart, i.e. checking that the parameter is an array at build time. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Josh Poimboeuf Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-v0b41ivu6z6dyugbq9ffa9ez@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/hashtable.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/include/linux/hashtable.h b/tools/include/linux/hashtable.h index c65cc0aa2659..251eabf2a05e 100644 --- a/tools/include/linux/hashtable.h +++ b/tools/include/linux/hashtable.h @@ -13,10 +13,6 @@ #include #include -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - #define DEFINE_HASHTABLE(name, bits) \ struct hlist_head name[1 << (bits)] = \ { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } -- cgit v1.2.3-55-g7522 From b640985fe40c7446fa5db467e747fbac5c081c86 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 12:13:25 -0300 Subject: perf tools: Remove unused macros from util.h TYPEOF(), for instance, was only used by MSB() that wasn't used at all, besides typeof() is used in many places, should be the preferred way. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-golox8oa2w1oq28snki14z6s@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 3eccd6f21d17..2abd4f783ffd 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -1,18 +1,6 @@ #ifndef GIT_COMPAT_UTIL_H #define GIT_COMPAT_UTIL_H -#ifdef __GNUC__ -#define TYPEOF(x) (__typeof__(x)) -#else -#define TYPEOF(x) -#endif - -#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits)))) -#define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */ - -/* Approximation of the length of the decimal representation of this type. */ -#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) - #define _ALL_SOURCE 1 #define _BSD_SOURCE 1 /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ -- cgit v1.2.3-55-g7522 From fd20e8111cc0e51ce12fb8ee17c863088fe95065 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 15:23:08 -0300 Subject: perf tools: Including missing inttypes.h header Needed to use the PRI[xu](32,64) formatting macros. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-wkbho8kaw24q67dd11q0j39f@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 + tools/perf/bench/numa.c | 1 + tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-diff.c | 1 + tools/perf/builtin-kallsyms.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-lock.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/builtin-sched.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/tests/attr.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/dwarf-unwind.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/tests/hists_common.c | 1 + tools/perf/tests/mmap-basic.c | 1 + tools/perf/tests/mmap-thread-lookup.c | 1 + tools/perf/tests/openat-syscall-all-cpus.c | 1 + tools/perf/tests/openat-syscall.c | 1 + tools/perf/tests/perf-record.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/tests/sw-clock.c | 1 + tools/perf/tests/unit_number__scnprintf.c | 1 + tools/perf/tests/vmlinux-kallsyms.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/gtk/annotate.c | 2 +- tools/perf/ui/hist.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/auxtrace.c | 1 + tools/perf/util/callchain.c | 1 + tools/perf/util/data-convert-bt.c | 1 + tools/perf/util/debug.c | 1 + tools/perf/util/dwarf-aux.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/evsel_fprintf.c | 1 + tools/perf/util/header.c | 1 + tools/perf/util/intel-bts.c | 1 + tools/perf/util/intel-pt.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/ordered-events.c | 1 + tools/perf/util/probe-event.c | 1 + tools/perf/util/probe-finder.c | 1 + tools/perf/util/scripting-engines/trace-event-perl.c | 1 + tools/perf/util/scripting-engines/trace-event-python.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/srcline.c | 1 + tools/perf/util/stat.c | 1 + tools/perf/util/unwind-libunwind-local.c | 1 + tools/perf/util/util.c | 1 + 59 files changed, 59 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 5c76cc83186a..a8e37f3148c2 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index 27ebd50ee619..27de0c8c5c19 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c @@ -4,6 +4,7 @@ * numa: Simulate NUMA-sensitive workload and measure their NUMA performance */ +#include /* For the CLR_() macros */ #include diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 70c2c773a2b8..cc8156a969ac 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -9,6 +9,7 @@ * Dick Fowles * Joe Mario */ +#include #include #include #include diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index cd2605d86984..09be77b13788 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -19,6 +19,7 @@ #include "util/data.h" #include "util/config.h" +#include #include #include diff --git a/tools/perf/builtin-kallsyms.c b/tools/perf/builtin-kallsyms.c index 8ff38c4eb2c0..bcfb363112d3 100644 --- a/tools/perf/builtin-kallsyms.c +++ b/tools/perf/builtin-kallsyms.c @@ -7,6 +7,7 @@ * * Released under the GPL v2. (and only v2, not any later version) */ +#include #include "builtin.h" #include #include diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 8f0b94563936..fa6bf1c39b65 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index a7d7f4c6052e..e82a6979327f 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index f74dd869f88b..6f93a6f0e268 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1,3 +1,4 @@ +#include #include "builtin.h" #include "perf.h" diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 643f4faac0d0..1ebc67390898 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -1,3 +1,4 @@ +#include #include "builtin.h" #include "perf.h" diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3191ab063852..65429d1b29c8 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -40,6 +40,7 @@ #include "util/perf-hooks.h" #include "asm/bug.h" +#include #include #include #include diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c18158b83eb1..66a2f44518de 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -40,6 +40,7 @@ #include "util/auxtrace.h" #include +#include #include #include diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 5cd60882c8d9..d4677fb7f7f5 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 36b076653d16..c4e36b4743f4 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -30,6 +30,7 @@ #include "asm/bug.h" #include "util/mem-events.h" #include "util/dump-insn.h" +#include static char const *script_name; static char const *generate_script_lang; diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 610225b6326e..b7199f029073 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 822c8d39ca1d..a24b229a785f 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -12,6 +12,7 @@ * of the License. */ +#include #include #include "builtin.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 2792ed1fae43..aba5fac41529 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -39,6 +39,7 @@ #include "syscalltbl.h" #include "rb_resort.h" +#include #include /* FIXME: Still needed for audit_errno_to_name */ #include #include diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 88dc51f4c27b..bb2bc487f703 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -18,6 +18,7 @@ * permissions. All the event text files are stored there. */ +#include #include #include #include diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 99dbd5ae294a..6effcfb7e0c1 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c index 1046491de4b2..dfe5c89e2049 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "tests.h" #include "debug.h" diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 19ef77bd6eb4..8d376e155697 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -1,4 +1,5 @@ #include +#include #include #include "tests.h" #include "evlist.h" diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index f6c580e3ed84..00b8dc50f3db 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c @@ -1,3 +1,4 @@ +#include #include "perf.h" #include "util/debug.h" #include "util/symbol.h" diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index a7cb80805993..aba40eb4c56f 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -1,3 +1,4 @@ +#include /* For the CLR_() macros */ #include diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c index 0c5ce44f723f..a5ffb754f8c6 100644 --- a/tools/perf/tests/mmap-thread-lookup.c +++ b/tools/perf/tests/mmap-thread-lookup.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index c8d9592eb142..eb7b1a6d507e 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -1,3 +1,4 @@ +#include /* For the CPU_* macros */ #include diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index d7414128d7fe..5964938d4b85 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -1,3 +1,4 @@ +#include #include #include #include "thread_map.h" diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 87893f3ba5f1..a8b6fdaf8df1 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -1,3 +1,4 @@ +#include /* For the CLR_() macros */ #include diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 73b5e47ef20b..bac5c3885b3b 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 4c9fd046d57b..29f11c4b3e60 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c index 623c2aa53c4a..f84cb70ee5e5 100644 --- a/tools/perf/tests/unit_number__scnprintf.c +++ b/tools/perf/tests/unit_number__scnprintf.c @@ -1,3 +1,4 @@ +#include #include #include #include "tests.h" diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index 862b043e5924..8456175fc234 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "map.h" #include "symbol.h" diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 9adce112d255..2ed64124276f 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -9,6 +9,7 @@ #include "../../util/symbol.h" #include "../../util/evsel.h" #include "../../util/config.h" +#include #include #include diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index da24072bb76e..a2ea1fa15ae6 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 8c9308ac30b7..71359b898b67 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c @@ -3,7 +3,7 @@ #include "util/annotate.h" #include "util/evsel.h" #include "ui/helpline.h" - +#include enum { ANN_COL__PERCENT, diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 5d632dca672a..59addd52d9cd 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 45df4a38811a..4d4faf99d52d 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -7,6 +7,7 @@ * Released under the GPL v2. (and only v2, not any later version) */ +#include #include "util.h" #include "ui/ui.h" #include "sort.h" diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 78bd632f144d..a81a402a7459 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 2e5eff5abef0..0096d45a06b3 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -9,6 +9,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index b7917519f6cc..ef80221e0d9c 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -7,6 +7,7 @@ * Released under the GPL v2. (and only v2, not any later version) */ +#include #include #include #include diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 03eb81f30d0d..4d5df25f155a 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -2,6 +2,7 @@ #include "../perf.h" +#include #include #include #include diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 41e068e94349..5fb186d142f6 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -17,6 +17,7 @@ * */ +#include #include #include "util.h" #include "debug.h" diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index a0f59f69f46a..b761b0eb60af 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1,3 +1,4 @@ +#include #include #include #include /* To get things like MAP_HUGETLB even on older libc headers */ diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 50420cd35446..cf27039df100 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -8,6 +8,7 @@ */ #include "util.h" #include +#include #include #include "cpumap.h" #include "thread_map.h" diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3779b9f3f134..99a13a63ff1f 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c index 4ef5184819a0..8000f62d5d53 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 2ccc7f06db79..0371f3483ede 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1,3 +1,4 @@ +#include #include "util.h" #include #include diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 6c2eb5da4afc..471ed8b26a1c 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index da20cd5612e9..bdd4a28c6cee 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index dfc600446586..15b2a17cf76e 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1,3 +1,4 @@ +#include #include "callchain.h" #include "debug.h" #include "event.h" diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index e70e935b1841..df05be69cc9e 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index e4b889444447..e61b4b34a929 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 57cd268d4275..9ddd7dad2e6e 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index dff043a29589..2b12bdb3ce33 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 783326cfbaa6..dd61213e7a3c 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -21,6 +21,7 @@ #include +#include #include #include #include diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7b740a73e595..0695e08d2252 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 13b9af1d1b45..63ad5374f364 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1,3 +1,4 @@ +#include #include #include "sort.h" #include "hist.h" diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 778ccb5d99d1..ef192802edc9 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 0d51334a9b46..bbf30b2d1614 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -1,3 +1,4 @@ +#include #include #include "stat.h" #include "evlist.h" diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index bfb9b7987692..788f4d3c76f5 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 6097d87429e2..524bd3b9d98d 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -7,6 +7,7 @@ #ifdef HAVE_BACKTRACE_SUPPORT #include #endif +#include #include #include #include -- cgit v1.2.3-55-g7522 From c3dca1a1c0ec51f384515f7e6f3b4e289a1dea2f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 15:25:00 -0300 Subject: perf tools: Remove PRI[xu] macros from perf.h We get them from inttypes.h. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-qla4e4mwbf1oewafp1ee2etd@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 2abd4f783ffd..593a24192924 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -50,25 +49,6 @@ extern const char *spaces; extern const char *dots; extern char buildid_dir[]; -/* On most systems would have given us this, but - * not on some systems (e.g. GNU/Hurd). - */ -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -#ifndef PRIuMAX -#define PRIuMAX "llu" -#endif - -#ifndef PRIu32 -#define PRIu32 "u" -#endif - -#ifndef PRIx32 -#define PRIx32 "x" -#endif - #ifndef PATH_SEP #define PATH_SEP ':' #endif -- cgit v1.2.3-55-g7522 From aa8cc2f6b5faae3511ea229846d8e54bd8df40d1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 15:36:40 -0300 Subject: perf tools: Replace STR() calls with __stringify() Both do the same thing, the later is the one we get from linux/stringify.h, i.e. we now use the same function name/practice as the kernel sources. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-w2sxa5o4bfx7fjrd5mu4zmke@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/dwarf-regs.c | 4 ++-- tools/perf/arch/arm64/util/dwarf-regs.c | 3 ++- tools/perf/arch/powerpc/util/dwarf-regs.c | 5 +++-- tools/perf/util/cgroup.c | 5 +++-- tools/perf/util/jitdump.c | 3 ++- tools/perf/util/util.h | 3 --- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/perf/arch/arm/util/dwarf-regs.c b/tools/perf/arch/arm/util/dwarf-regs.c index 33ec5b339da8..8bb176a37990 100644 --- a/tools/perf/arch/arm/util/dwarf-regs.c +++ b/tools/perf/arch/arm/util/dwarf-regs.c @@ -9,6 +9,7 @@ */ #include +#include #include struct pt_regs_dwarfnum { @@ -16,10 +17,9 @@ struct pt_regs_dwarfnum { unsigned int dwarfnum; }; -#define STR(s) #s #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} #define GPR_DWARFNUM_NAME(num) \ - {.name = STR(%r##num), .dwarfnum = num} + {.name = __stringify(%r##num), .dwarfnum = num} #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} /* diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c index 068b6189157b..aea610c292e6 100644 --- a/tools/perf/arch/arm64/util/dwarf-regs.c +++ b/tools/perf/arch/arm64/util/dwarf-regs.c @@ -11,6 +11,7 @@ #include #include #include /* for struct user_pt_regs */ +#include #include "util.h" struct pt_regs_dwarfnum { @@ -20,7 +21,7 @@ struct pt_regs_dwarfnum { #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} #define GPR_DWARFNUM_NAME(num) \ - {.name = STR(%x##num), .dwarfnum = num} + {.name = __stringify(%x##num), .dwarfnum = num} #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} #define DWARFNUM2OFFSET(index) \ (index * sizeof((struct user_pt_regs *)0)->regs[0]) diff --git a/tools/perf/arch/powerpc/util/dwarf-regs.c b/tools/perf/arch/powerpc/util/dwarf-regs.c index 41bdf9530d82..98ac87052a74 100644 --- a/tools/perf/arch/powerpc/util/dwarf-regs.c +++ b/tools/perf/arch/powerpc/util/dwarf-regs.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "util.h" struct pt_regs_dwarfnum { @@ -24,10 +25,10 @@ struct pt_regs_dwarfnum { }; #define REG_DWARFNUM_NAME(r, num) \ - {.name = STR(%)STR(r), .dwarfnum = num, \ + {.name = __stringify(%)__stringify(r), .dwarfnum = num, \ .ptregs_offset = offsetof(struct pt_regs, r)} #define GPR_DWARFNUM_NAME(num) \ - {.name = STR(%gpr##num), .dwarfnum = num, \ + {.name = __stringify(%gpr##num), .dwarfnum = num, \ .ptregs_offset = offsetof(struct pt_regs, gpr[num])} #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0, .ptregs_offset = 0} diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 86399eda3684..03347748f3fa 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -4,6 +4,7 @@ #include "evsel.h" #include "cgroup.h" #include "evlist.h" +#include int nr_cgroups; @@ -27,8 +28,8 @@ cgroupfs_find_mountpoint(char *buf, size_t maxlen) path_v1[0] = '\0'; path_v2[0] = '\0'; - while (fscanf(fp, "%*s %"STR(PATH_MAX)"s %"STR(PATH_MAX)"s %" - STR(PATH_MAX)"s %*d %*d\n", + while (fscanf(fp, "%*s %"__stringify(PATH_MAX)"s %"__stringify(PATH_MAX)"s %" + __stringify(PATH_MAX)"s %*d %*d\n", mountpoint, type, tokens) == 3) { if (!path_v1[0] && !strcmp(type, "cgroup")) { diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index c9a941ef0f6d..da6262dbe9e3 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "util.h" #include "event.h" @@ -181,7 +182,7 @@ jit_open(struct jit_buf_desc *jd, const char *name) jd->use_arch_timestamp); if (header.version > JITHEADER_VERSION) { - pr_err("wrong jitdump version %u, expected " STR(JITHEADER_VERSION), + pr_err("wrong jitdump version %u, expected " __stringify(JITHEADER_VERSION), header.version); goto error; } diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 593a24192924..aa35509464b5 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -180,9 +180,6 @@ struct perf_event_attr; void event_attr_init(struct perf_event_attr *attr); -#define _STR(x) #x -#define STR(x) _STR(x) - size_t hex_width(u64 v); int hex2u64(const char *ptr, u64 *val); -- cgit v1.2.3-55-g7522 From 28a9bb9621d9f8b4328048297cd306e09fbbf175 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 15:39:06 -0300 Subject: perf tools: Ditch unused PATH_SEP, STRIP_EXTENSION Should make sense for windows, where git is supported. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-lzxlhmqrizk72d0zcsreggy8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/perf.c | 10 ---------- tools/perf/util/util.h | 16 ---------------- 2 files changed, 26 deletions(-) diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 07ee1352f4ed..94e9418aecb1 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -328,16 +328,6 @@ static void handle_internal_command(int argc, const char **argv) { const char *cmd = argv[0]; unsigned int i; - static const char ext[] = STRIP_EXTENSION; - - if (sizeof(ext) > 1) { - i = strlen(argv[0]) - strlen(ext); - if (i > 0 && !strcmp(argv[0] + i, ext)) { - char *argv0 = strdup(argv[0]); - argv[0] = cmd = argv0; - argv0[i] = '\0'; - } - } /* Turn "perf cmd --help" into "perf help cmd" */ if (argc > 1 && !strcmp(argv[1], "--help")) { diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index aa35509464b5..f26666d77677 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -49,22 +49,6 @@ extern const char *spaces; extern const char *dots; extern char buildid_dir[]; -#ifndef PATH_SEP -#define PATH_SEP ':' -#endif - -#ifndef STRIP_EXTENSION -#define STRIP_EXTENSION "" -#endif - -#ifndef has_dos_drive_prefix -#define has_dos_drive_prefix(path) 0 -#endif - -#ifndef is_dir_sep -#define is_dir_sep(c) ((c) == '/') -#endif - #ifdef __GNUC__ #define NORETURN __attribute__((__noreturn__)) #else -- cgit v1.2.3-55-g7522 From 3d689ed6099a1a11c38bb78aff7498e78e287e0b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 16:10:49 -0300 Subject: perf tools: Move sane ctype stuff from util.h to sane_ctype.h More stuff that came from git, out of the hodge-podge that is util.h Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-e3lana4gctz3ub4hn4y29hkw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/symbol/kallsyms.c | 1 + tools/perf/arch/common.c | 2 ++ tools/perf/builtin-kmem.c | 2 ++ tools/perf/builtin-sched.c | 2 ++ tools/perf/builtin-script.c | 2 ++ tools/perf/builtin-stat.c | 2 ++ tools/perf/builtin-top.c | 2 ++ tools/perf/builtin-trace.c | 2 ++ tools/perf/tests/code-reading.c | 3 ++- tools/perf/ui/browser.c | 1 + tools/perf/ui/browsers/hists.c | 2 ++ tools/perf/ui/browsers/map.c | 2 ++ tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/annotate.c | 2 ++ tools/perf/util/auxtrace.c | 5 ++-- tools/perf/util/build-id.c | 1 + tools/perf/util/config.c | 2 ++ tools/perf/util/cpumap.c | 2 ++ tools/perf/util/ctype.c | 2 +- tools/perf/util/data-convert-bt.c | 1 + tools/perf/util/debug.c | 2 ++ tools/perf/util/demangle-java.c | 2 ++ tools/perf/util/event.c | 1 + tools/perf/util/evsel.c | 2 ++ tools/perf/util/header.c | 2 ++ tools/perf/util/jitdump.c | 2 ++ tools/perf/util/machine.c | 4 ++- tools/perf/util/probe-event.c | 2 ++ tools/perf/util/probe-finder.h | 2 +- tools/perf/util/sane_ctype.h | 51 +++++++++++++++++++++++++++++++++++++ tools/perf/util/strfilter.c | 2 ++ tools/perf/util/string.c | 2 ++ tools/perf/util/symbol-elf.c | 3 ++- tools/perf/util/symbol.c | 1 + tools/perf/util/trace-event-parse.c | 3 ++- tools/perf/util/util.c | 2 ++ tools/perf/util/util.h | 46 --------------------------------- 37 files changed, 114 insertions(+), 55 deletions(-) create mode 100644 tools/perf/util/sane_ctype.h diff --git a/tools/lib/symbol/kallsyms.c b/tools/lib/symbol/kallsyms.c index 5e431077fcd6..d270ac00613d 100644 --- a/tools/lib/symbol/kallsyms.c +++ b/tools/lib/symbol/kallsyms.c @@ -1,3 +1,4 @@ +#include #include "symbol/kallsyms.h" #include #include diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 886dd2aaff0d..837067f48a4c 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c @@ -4,6 +4,8 @@ #include "../util/util.h" #include "../util/debug.h" +#include "sane_ctype.h" + const char *const arm_triplets[] = { "arm-eabi-", "arm-linux-androideabi-", diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index fa6bf1c39b65..15754a492cad 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -27,6 +27,8 @@ #include #include +#include "sane_ctype.h" + static int kmem_slab; static int kmem_page; diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index d4677fb7f7f5..aefab93d7d2f 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -34,6 +34,8 @@ #include #include +#include "sane_ctype.h" + #define PR_SET_NAME 15 /* Set process name */ #define MAX_CPUS 4096 #define COMM_LEN 20 diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index c4e36b4743f4..5afd9a62360a 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -32,6 +32,8 @@ #include "util/dump-insn.h" #include +#include "sane_ctype.h" + static char const *script_name; static char const *generate_script_lang; static bool debug_mode; diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b7199f029073..5abef25f9983 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -74,6 +74,8 @@ #include #include +#include "sane_ctype.h" + #define DEFAULT_SEPARATOR " " #define CNTR_NOT_SUPPORTED "" #define CNTR_NOT_COUNTED "" diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a0c97c70ec81..ec3247db4826 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -72,6 +72,8 @@ #include #include +#include "sane_ctype.h" + static volatile int done; #define HEADER_LINE_NR 5 diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index aba5fac41529..0b00d8ac5226 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -51,6 +51,8 @@ #include #include +#include "sane_ctype.h" + #ifndef O_CLOEXEC # define O_CLOEXEC 02000000 #endif diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 6effcfb7e0c1..fe6aac82d54e 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "parse-events.h" @@ -18,6 +17,8 @@ #include "tests.h" +#include "sane_ctype.h" + #define BUFSZ 1024 #define READLEN 128 diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 9e47ccbe07f1..73bdd07321c4 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -13,6 +13,7 @@ #include "helpline.h" #include "keysyms.h" #include "../color.h" +#include "sane_ctype.h" static int ui_browser__percent_color(struct ui_browser *browser, double percent, bool current) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a2ea1fa15ae6..56f5c038689e 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -20,6 +20,8 @@ #include "map.h" #include "annotate.h" +#include "sane_ctype.h" + extern void hist_browser__init_hpp(void); static int perf_evsel_browser_title(struct hist_browser *browser, diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c index 9ce142de536d..ffa5addf631d 100644 --- a/tools/perf/ui/browsers/map.c +++ b/tools/perf/ui/browsers/map.c @@ -11,6 +11,8 @@ #include "../keysyms.h" #include "map.h" +#include "sane_ctype.h" + struct map_browser { struct ui_browser b; struct map *map; diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index d52d5f64ea89..297a79c69b71 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -4,7 +4,7 @@ #include "../../util/hist.h" #include "../../util/sort.h" #include "../../util/evsel.h" - +#include "../../util/sane_ctype.h" static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) { diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4d4faf99d52d..d69fdafba274 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -26,6 +26,8 @@ #include #include +#include "sane_ctype.h" + const char *disassembler_style; const char *objdump_path; static regex_t file_lineno; diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index a81a402a7459..0daf63b9ee3e 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -47,7 +46,6 @@ #include "cpumap.h" #include "thread_map.h" #include "asm/bug.h" -#include "symbol/kallsyms.h" #include "auxtrace.h" #include @@ -60,6 +58,9 @@ #include "intel-pt.h" #include "intel-bts.h" +#include "sane_ctype.h" +#include "symbol/kallsyms.h" + int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, struct auxtrace_mmap_params *mp, void *userpg, int fd) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 33af67530d30..3c0755563969 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -19,6 +19,7 @@ #include "vdso.h" #include "probe-file.h" +#include "sane_ctype.h" static bool no_buildid_cache; diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 7b01d59076d3..88783aa3dfc9 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -15,6 +15,8 @@ #include "util/llvm-utils.h" /* perf_llvm_config */ #include "config.h" +#include "sane_ctype.h" + #define MAXNAME (256) #define DEBUG_CACHE_DIR ".debug" diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 061018b42393..9d9ecb2430cc 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -8,6 +8,8 @@ #include #include "asm/bug.h" +#include "sane_ctype.h" + static int max_cpu_num; static int max_present_cpu_num; static int max_node_num; diff --git a/tools/perf/util/ctype.c b/tools/perf/util/ctype.c index d4a5a21c2a7e..4b261c2ec0f1 100644 --- a/tools/perf/util/ctype.c +++ b/tools/perf/util/ctype.c @@ -3,7 +3,7 @@ * * No surprises, and works with signed and unsigned chars. */ -#include "util.h" +#include "sane_ctype.h" enum { S = GIT_SPACE, diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index ef80221e0d9c..c3277b32e917 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -29,6 +29,7 @@ #include "evsel.h" #include "machine.h" #include "config.h" +#include "sane_ctype.h" #define pr_N(n, fmt, ...) \ eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 4d5df25f155a..41aa7c63e037 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -16,6 +16,8 @@ #include "util.h" #include "target.h" +#include "sane_ctype.h" + int verbose; bool dump_trace = false, quiet = false; int debug_ordered_events; diff --git a/tools/perf/util/demangle-java.c b/tools/perf/util/demangle-java.c index 3e6062ab2cdd..cb66d334f532 100644 --- a/tools/perf/util/demangle-java.c +++ b/tools/perf/util/demangle-java.c @@ -7,6 +7,8 @@ #include "demangle-java.h" +#include "sane_ctype.h" + enum { MODE_PREFIX = 0, MODE_CLASS = 1, diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index b761b0eb60af..f8a706ba72f2 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -12,6 +12,7 @@ #include "strlist.h" #include "thread.h" #include "thread_map.h" +#include "sane_ctype.h" #include "symbol/kallsyms.h" #include "asm/bug.h" #include "stat.h" diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 99a13a63ff1f..757f73c4fa95 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -31,6 +31,8 @@ #include "stat.h" #include "util/parse-branch-options.h" +#include "sane_ctype.h" + static struct { bool sample_id_all; bool exclude_guest; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 0371f3483ede..faf046fc398f 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -27,6 +27,8 @@ #include #include "asm/bug.h" +#include "sane_ctype.h" + /* * magic2 = "PERFILE2" * must be a numerical value to let the endianness diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index da6262dbe9e3..d6d25327bc92 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -26,6 +26,8 @@ #include "genelf.h" #include "../builtin.h" +#include "sane_ctype.h" + struct jit_buf_desc { struct perf_data_file *output; struct perf_session *session; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 15b2a17cf76e..f13f46a99b36 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -11,11 +11,13 @@ #include "thread.h" #include "vdso.h" #include -#include #include "unwind.h" #include "linux/hash.h" #include "asm/bug.h" +#include "sane_ctype.h" +#include + static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); static void dsos__init(struct dsos *dsos) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index e61b4b34a929..7caba7003734 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -48,6 +48,8 @@ #include "probe-file.h" #include "session.h" +#include "sane_ctype.h" + #define PERFPROBE_GROUP "probe" bool probe_event_dry_run; /* Dry run flag */ diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index 2956c5198652..27f061551012 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h @@ -2,9 +2,9 @@ #define _PROBE_FINDER_H #include -#include "util.h" #include "intlist.h" #include "probe-event.h" +#include "sane_ctype.h" #define MAX_PROBE_BUFFER 1024 #define MAX_PROBES 128 diff --git a/tools/perf/util/sane_ctype.h b/tools/perf/util/sane_ctype.h new file mode 100644 index 000000000000..4308c22c22ad --- /dev/null +++ b/tools/perf/util/sane_ctype.h @@ -0,0 +1,51 @@ +#ifndef _PERF_SANE_CTYPE_H +#define _PERF_SANE_CTYPE_H + +extern const char *graph_line; +extern const char *graph_dotted_line; +extern const char *spaces; +extern const char *dots; + +/* Sane ctype - no locale, and works with signed chars */ +#undef isascii +#undef isspace +#undef isdigit +#undef isxdigit +#undef isalpha +#undef isprint +#undef isalnum +#undef islower +#undef isupper +#undef tolower +#undef toupper + +extern unsigned char sane_ctype[256]; +#define GIT_SPACE 0x01 +#define GIT_DIGIT 0x02 +#define GIT_ALPHA 0x04 +#define GIT_GLOB_SPECIAL 0x08 +#define GIT_REGEX_SPECIAL 0x10 +#define GIT_PRINT_EXTRA 0x20 +#define GIT_PRINT 0x3E +#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) +#define isascii(x) (((x) & ~0x7f) == 0) +#define isspace(x) sane_istest(x,GIT_SPACE) +#define isdigit(x) sane_istest(x,GIT_DIGIT) +#define isxdigit(x) \ + (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G') +#define isalpha(x) sane_istest(x,GIT_ALPHA) +#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) +#define isprint(x) sane_istest(x,GIT_PRINT) +#define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20)) +#define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20)) +#define tolower(x) sane_case((unsigned char)(x), 0x20) +#define toupper(x) sane_case((unsigned char)(x), 0) + +static inline int sane_case(int x, int high) +{ + if (sane_istest(x, GIT_ALPHA)) + x = (x & ~0x20) | high; + return x; +} + +#endif /* _PERF_SANE_CTYPE_H */ diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c index efb53772e0ec..c663c9153245 100644 --- a/tools/perf/util/strfilter.c +++ b/tools/perf/util/strfilter.c @@ -2,6 +2,8 @@ #include "string.h" #include "strfilter.h" +#include "sane_ctype.h" + /* Operators */ static const char *OP_and = "&"; /* Logical AND */ static const char *OP_or = "|"; /* Logical OR */ diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index e8feb142c9c9..e716a6e5bb19 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -1,6 +1,8 @@ #include "util.h" #include "linux/string.h" +#include "sane_ctype.h" + #define K 1024LL /* * perf_atoll() diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index d1a40bb642ff..e7ee47f7377a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -10,8 +10,9 @@ #include "demangle-rust.h" #include "machine.h" #include "vdso.h" -#include #include "debug.h" +#include "sane_ctype.h" +#include #ifndef EM_AARCH64 #define EM_AARCH64 183 /* ARM 64 bit */ diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 619e3eb44c50..68f14d770083 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -19,6 +19,7 @@ #include "strlist.h" #include "intlist.h" #include "header.h" +#include "sane_ctype.h" #include #include diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index de0078e21408..746bbee645d9 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -21,13 +21,14 @@ #include #include #include -#include #include #include "../perf.h" #include "util.h" #include "trace-event.h" +#include "sane_ctype.h" + static int get_common_field(struct scripting_context *context, int *offset, int *size, const char *type) { diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 524bd3b9d98d..717541e72999 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -21,6 +21,8 @@ #include "callchain.h" #include "strlist.h" +#include "sane_ctype.h" + #define CALLCHAIN_PARAM_DEFAULT \ .mode = CHAIN_GRAPH_ABS, \ .min_percent = 0.5, \ diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index f26666d77677..f7e1ead50f47 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -43,10 +43,6 @@ #include #include "strlist.h" -extern const char *graph_line; -extern const char *graph_dotted_line; -extern const char *spaces; -extern const char *dots; extern char buildid_dir[]; #ifdef __GNUC__ @@ -94,48 +90,6 @@ static inline void *zalloc(size_t size) #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) -/* Sane ctype - no locale, and works with signed chars */ -#undef isascii -#undef isspace -#undef isdigit -#undef isxdigit -#undef isalpha -#undef isprint -#undef isalnum -#undef islower -#undef isupper -#undef tolower -#undef toupper - -extern unsigned char sane_ctype[256]; -#define GIT_SPACE 0x01 -#define GIT_DIGIT 0x02 -#define GIT_ALPHA 0x04 -#define GIT_GLOB_SPECIAL 0x08 -#define GIT_REGEX_SPECIAL 0x10 -#define GIT_PRINT_EXTRA 0x20 -#define GIT_PRINT 0x3E -#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) -#define isascii(x) (((x) & ~0x7f) == 0) -#define isspace(x) sane_istest(x,GIT_SPACE) -#define isdigit(x) sane_istest(x,GIT_DIGIT) -#define isxdigit(x) \ - (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G') -#define isalpha(x) sane_istest(x,GIT_ALPHA) -#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) -#define isprint(x) sane_istest(x,GIT_PRINT) -#define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20)) -#define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20)) -#define tolower(x) sane_case((unsigned char)(x), 0x20) -#define toupper(x) sane_case((unsigned char)(x), 0) - -static inline int sane_case(int x, int high) -{ - if (sane_istest(x, GIT_ALPHA)) - x = (x & ~0x20) | high; - return x; -} - int mkdir_p(char *path, mode_t mode); int rm_rf(const char *path); struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *)); -- cgit v1.2.3-55-g7522 From a12a4e023a55f058178afea1ada3ce7bf4db94c3 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 16:22:30 -0300 Subject: tools include: Include missing headers for fls() and types in linux/log2.h Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-7wj865zidu5ylf87i6i7v6z7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/log2.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h index d5677d39c1e4..0325cefc2220 100644 --- a/tools/include/linux/log2.h +++ b/tools/include/linux/log2.h @@ -12,6 +12,9 @@ #ifndef _TOOLS_LINUX_LOG2_H #define _TOOLS_LINUX_LOG2_H +#include +#include + /* * non-constant log of base 2 calculators * - the arch may override these in asm/bitops.h if they can be implemented -- cgit v1.2.3-55-g7522 From fea013928cdcf81fbe0bfbf9e2eed1c7da2d62c2 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 16:23:22 -0300 Subject: perf tools: Move print_binary definitions to separate files Continuing the split of util.[ch] into more manageable bits. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-5eu367rwcwnvvn7fz09l7xpb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/tests/is_printable_array.c | 2 +- tools/perf/util/Build | 1 + tools/perf/util/debug.c | 1 + tools/perf/util/print_binary.c | 55 ++++++++++++++++++++++ tools/perf/util/print_binary.h | 28 +++++++++++ tools/perf/util/python-ext-sources | 1 + tools/perf/util/python.c | 1 + .../util/scripting-engines/trace-event-python.c | 1 + tools/perf/util/util.c | 54 --------------------- tools/perf/util/util.h | 23 --------- 12 files changed, 91 insertions(+), 78 deletions(-) create mode 100644 tools/perf/util/print_binary.c create mode 100644 tools/perf/util/print_binary.h diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 5afd9a62360a..5f4e36a4c444 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -23,6 +23,7 @@ #include "util/stat.h" #include "util/thread-stack.h" #include "util/time-utils.h" +#include "print_binary.h" #include #include #include diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 0b00d8ac5226..9a8b9e6f47f7 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -36,6 +36,7 @@ #include "util/parse-events.h" #include "util/bpf-loader.h" #include "callchain.h" +#include "print_binary.h" #include "syscalltbl.h" #include "rb_resort.h" diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c index a008e5c2d980..a5192f6a20d7 100644 --- a/tools/perf/tests/is_printable_array.c +++ b/tools/perf/tests/is_printable_array.c @@ -2,7 +2,7 @@ #include #include "tests.h" #include "debug.h" -#include "util.h" +#include "print_binary.h" int test__is_printable_array(int subtest __maybe_unused) { diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 5c0ea11a8f0a..f0b9e5d0e2fc 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -16,6 +16,7 @@ libperf-y += llvm-utils.o libperf-y += parse-events.o libperf-y += perf_regs.o libperf-y += path.o +libperf-y += print_binary.o libperf-y += rbtree.o libperf-y += libstring.o libperf-y += bitmap.o diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 41aa7c63e037..6e1d7e159649 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -13,6 +13,7 @@ #include "color.h" #include "event.h" #include "debug.h" +#include "print_binary.h" #include "util.h" #include "target.h" diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c new file mode 100644 index 000000000000..e908177b9976 --- /dev/null +++ b/tools/perf/util/print_binary.c @@ -0,0 +1,55 @@ +#include "print_binary.h" +#include +#include "sane_ctype.h" + +void print_binary(unsigned char *data, size_t len, + size_t bytes_per_line, print_binary_t printer, + void *extra) +{ + size_t i, j, mask; + + if (!printer) + return; + + bytes_per_line = roundup_pow_of_two(bytes_per_line); + mask = bytes_per_line - 1; + + printer(BINARY_PRINT_DATA_BEGIN, 0, extra); + for (i = 0; i < len; i++) { + if ((i & mask) == 0) { + printer(BINARY_PRINT_LINE_BEGIN, -1, extra); + printer(BINARY_PRINT_ADDR, i, extra); + } + + printer(BINARY_PRINT_NUM_DATA, data[i], extra); + + if (((i & mask) == mask) || i == len - 1) { + for (j = 0; j < mask-(i & mask); j++) + printer(BINARY_PRINT_NUM_PAD, -1, extra); + + printer(BINARY_PRINT_SEP, i, extra); + for (j = i & ~mask; j <= i; j++) + printer(BINARY_PRINT_CHAR_DATA, data[j], extra); + for (j = 0; j < mask-(i & mask); j++) + printer(BINARY_PRINT_CHAR_PAD, i, extra); + printer(BINARY_PRINT_LINE_END, -1, extra); + } + } + printer(BINARY_PRINT_DATA_END, -1, extra); +} + +int is_printable_array(char *p, unsigned int len) +{ + unsigned int i; + + if (!p || !len || p[len - 1] != 0) + return 0; + + len--; + + for (i = 0; i < len; i++) { + if (!isprint(p[i]) && !isspace(p[i])) + return 0; + } + return 1; +} diff --git a/tools/perf/util/print_binary.h b/tools/perf/util/print_binary.h new file mode 100644 index 000000000000..da0427263d2d --- /dev/null +++ b/tools/perf/util/print_binary.h @@ -0,0 +1,28 @@ +#ifndef PERF_PRINT_BINARY_H +#define PERF_PRINT_BINARY_H + +#include + +enum binary_printer_ops { + BINARY_PRINT_DATA_BEGIN, + BINARY_PRINT_LINE_BEGIN, + BINARY_PRINT_ADDR, + BINARY_PRINT_NUM_DATA, + BINARY_PRINT_NUM_PAD, + BINARY_PRINT_SEP, + BINARY_PRINT_CHAR_DATA, + BINARY_PRINT_CHAR_PAD, + BINARY_PRINT_LINE_END, + BINARY_PRINT_DATA_END, +}; + +typedef void (*print_binary_t)(enum binary_printer_ops op, + unsigned int val, void *extra); + +void print_binary(unsigned char *data, size_t len, + size_t bytes_per_line, print_binary_t printer, + void *extra); + +int is_printable_array(char *p, unsigned int len); + +#endif /* PERF_PRINT_BINARY_H */ diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index 0546a4304347..7d3927447fba 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources @@ -21,6 +21,7 @@ util/cgroup.c util/parse-branch-options.c util/rblist.c util/counts.c +util/print_binary.c util/strlist.c util/trace-event.c ../lib/rbtree.c diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index a5fbc012e3df..0533711af44d 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -7,6 +7,7 @@ #include "evsel.h" #include "event.h" #include "cpumap.h" +#include "print_binary.h" #include "thread_map.h" /* diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index dd61213e7a3c..9d92af7d0718 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -46,6 +46,7 @@ #include "../call-path.h" #include "thread_map.h" #include "cpumap.h" +#include "print_binary.h" #include "stat.h" PyMODINIT_FUNC initperf_trace_context(void); diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 717541e72999..4fb8ee552a31 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -21,8 +21,6 @@ #include "callchain.h" #include "strlist.h" -#include "sane_ctype.h" - #define CALLCHAIN_PARAM_DEFAULT \ .mode = CHAIN_GRAPH_ABS, \ .min_percent = 0.5, \ @@ -742,58 +740,6 @@ int fetch_current_timestamp(char *buf, size_t sz) return 0; } -void print_binary(unsigned char *data, size_t len, - size_t bytes_per_line, print_binary_t printer, - void *extra) -{ - size_t i, j, mask; - - if (!printer) - return; - - bytes_per_line = roundup_pow_of_two(bytes_per_line); - mask = bytes_per_line - 1; - - printer(BINARY_PRINT_DATA_BEGIN, 0, extra); - for (i = 0; i < len; i++) { - if ((i & mask) == 0) { - printer(BINARY_PRINT_LINE_BEGIN, -1, extra); - printer(BINARY_PRINT_ADDR, i, extra); - } - - printer(BINARY_PRINT_NUM_DATA, data[i], extra); - - if (((i & mask) == mask) || i == len - 1) { - for (j = 0; j < mask-(i & mask); j++) - printer(BINARY_PRINT_NUM_PAD, -1, extra); - - printer(BINARY_PRINT_SEP, i, extra); - for (j = i & ~mask; j <= i; j++) - printer(BINARY_PRINT_CHAR_DATA, data[j], extra); - for (j = 0; j < mask-(i & mask); j++) - printer(BINARY_PRINT_CHAR_PAD, i, extra); - printer(BINARY_PRINT_LINE_END, -1, extra); - } - } - printer(BINARY_PRINT_DATA_END, -1, extra); -} - -int is_printable_array(char *p, unsigned int len) -{ - unsigned int i; - - if (!p || !len || p[len - 1] != 0) - return 0; - - len--; - - for (i = 0; i < len; i++) { - if (!isprint(p[i]) && !isspace(p[i])) - return 0; - } - return 1; -} - int unit_number__scnprintf(char *buf, size_t size, u64 n) { char unit[4] = "BKMG"; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index f7e1ead50f47..4d9069ab569a 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -213,33 +213,10 @@ const char *perf_tip(const char *dirpath); bool is_regular_file(const char *file); int fetch_current_timestamp(char *buf, size_t sz); -enum binary_printer_ops { - BINARY_PRINT_DATA_BEGIN, - BINARY_PRINT_LINE_BEGIN, - BINARY_PRINT_ADDR, - BINARY_PRINT_NUM_DATA, - BINARY_PRINT_NUM_PAD, - BINARY_PRINT_SEP, - BINARY_PRINT_CHAR_DATA, - BINARY_PRINT_CHAR_PAD, - BINARY_PRINT_LINE_END, - BINARY_PRINT_DATA_END, -}; - -typedef void (*print_binary_t)(enum binary_printer_ops, - unsigned int val, - void *extra); - -void print_binary(unsigned char *data, size_t len, - size_t bytes_per_line, print_binary_t printer, - void *extra); - #ifndef HAVE_SCHED_GETCPU_SUPPORT int sched_getcpu(void); #endif -int is_printable_array(char *p, unsigned int len); - int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); int unit_number__scnprintf(char *buf, size_t size, u64 n); -- cgit v1.2.3-55-g7522 From 632a5cabea21eb079b788d2bb4a9318bd6fff5e1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 16:30:49 -0300 Subject: perf tools: Move srcline definitions to separate header Out of util.h into a new file, srcline.h Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-ludnlm4djqcdjziekzr4s3u9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/map.c | 1 + tools/perf/util/sort.h | 1 + tools/perf/util/srcline.c | 1 + tools/perf/util/srcline.h | 34 ++++++++++++++++++++++++++++++++++ tools/perf/util/util.h | 27 --------------------------- 8 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 tools/perf/util/srcline.h diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 56f5c038689e..ac7f6a3e4a86 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -19,6 +19,7 @@ #include "../ui.h" #include "map.h" #include "annotate.h" +#include "srcline.h" #include "sane_ctype.h" diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 297a79c69b71..66aa4eb369f1 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -4,6 +4,7 @@ #include "../../util/hist.h" #include "../../util/sort.h" #include "../../util/evsel.h" +#include "../../util/srcline.h" #include "../../util/sane_ctype.h" static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 61bf304206fd..af3bd5d31d99 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -8,6 +8,7 @@ #include "evlist.h" #include "evsel.h" #include "annotate.h" +#include "srcline.h" #include "ui/progress.h" #include diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index c1870ac365a3..9059d20c3b8a 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -16,6 +16,7 @@ #include "debug.h" #include "machine.h" #include +#include "srcline.h" #include "unwind.h" static void __maps__insert(struct maps *maps, struct map *map); diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index e35fb186d048..535903297cee 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -21,6 +21,7 @@ #include #include "parse-events.h" #include "hist.h" +#include "srcline.h" #include "thread.h" extern regex_t parent_regex; diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index ef192802edc9..df051a52393c 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -9,6 +9,7 @@ #include "util/util.h" #include "util/debug.h" #include "util/callchain.h" +#include "srcline.h" #include "symbol.h" diff --git a/tools/perf/util/srcline.h b/tools/perf/util/srcline.h new file mode 100644 index 000000000000..7b52ba88676e --- /dev/null +++ b/tools/perf/util/srcline.h @@ -0,0 +1,34 @@ +#ifndef PERF_SRCLINE_H +#define PERF_SRCLINE_H + +#include +#include + +struct dso; +struct symbol; + +extern bool srcline_full_filename; +char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, + bool show_sym, bool show_addr); +char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym, + bool show_sym, bool show_addr, bool unwind_inlines); +void free_srcline(char *srcline); + +#define SRCLINE_UNKNOWN ((char *) "??:0") + +struct inline_list { + char *filename; + char *funcname; + unsigned int line_nr; + struct list_head list; +}; + +struct inline_node { + u64 addr; + struct list_head val; +}; + +struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr); +void inline_node__delete(struct inline_node *node); + +#endif /* PERF_SRCLINE_H */ diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 4d9069ab569a..46cfdccc32bc 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -144,8 +144,6 @@ struct parse_tag { unsigned long parse_tag_value(const char *str, struct parse_tag *tags); -#define SRCLINE_UNKNOWN ((char *) "??:0") - static inline int path__join(char *bf, size_t size, const char *path1, const char *path2) { @@ -161,16 +159,6 @@ static inline int path__join3(char *bf, size_t size, path2, path2[0] ? "/" : "", path3); } -struct dso; -struct symbol; - -extern bool srcline_full_filename; -char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, - bool show_sym, bool show_addr); -char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym, - bool show_sym, bool show_addr, bool unwind_inlines); -void free_srcline(char *srcline); - int perf_event_paranoid(void); void mem_bswap_64(void *src, int byte_size); @@ -221,19 +209,4 @@ int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); int unit_number__scnprintf(char *buf, size_t size, u64 n); -struct inline_list { - char *filename; - char *funcname; - unsigned int line_nr; - struct list_head list; -}; - -struct inline_node { - u64 addr; - struct list_head val; -}; - -struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr); -void inline_node__delete(struct inline_node *node); - #endif /* GIT_COMPAT_UTIL_H */ -- cgit v1.2.3-55-g7522 From a067558e2fa72445e8f6e6b2dd372a82afae6e49 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 17 Apr 2017 16:51:59 -0300 Subject: perf tools: Move extra string util functions to util/string2.h Moving them from util.h, where they don't belong. Since libc already have string.h, name it slightly differently, as string2.h. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-eh3vz5sqxsrdd8lodoro4jrw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/bench/mem-functions.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/ui/browser.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/dso.c | 1 + tools/perf/util/dwarf-aux.c | 1 + tools/perf/util/event.c | 2 +- tools/perf/util/header.c | 1 + tools/perf/util/parse-events.c | 2 +- tools/perf/util/pmu.c | 1 + tools/perf/util/probe-event.c | 1 + tools/perf/util/probe-file.c | 1 + tools/perf/util/probe-finder.c | 1 + tools/perf/util/strfilter.c | 2 +- tools/perf/util/string.c | 16 +++++++++------ tools/perf/util/string2.h | 42 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/thread_map.c | 1 + tools/perf/util/util.h | 32 ------------------------------ 23 files changed, 72 insertions(+), 41 deletions(-) create mode 100644 tools/perf/util/string2.h diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c index d1dea33dcfcf..fbd732b54047 100644 --- a/tools/perf/bench/mem-functions.c +++ b/tools/perf/bench/mem-functions.c @@ -12,6 +12,7 @@ #include #include "../util/header.h" #include "../util/cloexec.h" +#include "../util/string2.h" #include "bench.h" #include "mem-memcpy-arch.h" #include "mem-memset-arch.h" diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 5f4e36a4c444..a710f6867954 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -21,6 +21,7 @@ #include "util/cpumap.h" #include "util/thread_map.h" #include "util/stat.h" +#include "util/string2.h" #include "util/thread-stack.h" #include "util/time-utils.h" #include "print_binary.h" diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 5abef25f9983..1da86e6708c0 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -64,6 +64,7 @@ #include "util/session.h" #include "util/tool.h" #include "util/group.h" +#include "util/string2.h" #include "asm/bug.h" #include diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 9a8b9e6f47f7..4160d946a34d 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -37,6 +37,7 @@ #include "util/bpf-loader.h" #include "callchain.h" #include "print_binary.h" +#include "string2.h" #include "syscalltbl.h" #include "rb_resort.h" diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 73bdd07321c4..a4d3762cd825 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -1,4 +1,5 @@ #include "../util.h" +#include "../string2.h" #include "../config.h" #include "../../perf.h" #include "libslang.h" diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index ac7f6a3e4a86..bc397bbbc3a7 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -20,6 +20,7 @@ #include "map.h" #include "annotate.h" #include "srcline.h" +#include "string2.h" #include "sane_ctype.h" diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index a4f02de7c1b5..c42de4dcc055 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -4,6 +4,7 @@ #include "../sort.h" #include "../hist.h" #include "../helpline.h" +#include "../string2.h" #include "gtk.h" #define MAX_COLUMNS 32 diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 66aa4eb369f1..5565105c9688 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -5,6 +5,7 @@ #include "../../util/sort.h" #include "../../util/evsel.h" #include "../../util/srcline.h" +#include "../../util/string2.h" #include "../../util/sane_ctype.h" static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d69fdafba274..297bf5c66609 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -19,6 +19,7 @@ #include "annotate.h" #include "evsel.h" #include "block-range.h" +#include "string2.h" #include "arch/common.h" #include #include diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 385c82e12473..6ad57730a0ed 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -8,6 +8,7 @@ #include "auxtrace.h" #include "util.h" #include "debug.h" +#include "string2.h" #include "vdso.h" static const char * const debuglink_paths[] = { diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 5fb186d142f6..780ee4629bd0 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -22,6 +22,7 @@ #include "util.h" #include "debug.h" #include "dwarf-aux.h" +#include "string2.h" /** * cu_find_realpath - Find the realpath of the target file diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f8a706ba72f2..53b81b2283c1 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -8,7 +8,7 @@ #include "hist.h" #include "machine.h" #include "sort.h" -#include "string.h" +#include "string2.h" #include "strlist.h" #include "thread.h" #include "thread_map.h" diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index faf046fc398f..51865b8cb9f3 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1,5 +1,6 @@ #include #include "util.h" +#include "string2.h" #include #include #include diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 6b498aea9fde..535c7cbb2bfb 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -7,7 +7,7 @@ #include #include "parse-events.h" #include -#include "string.h" +#include "string2.h" #include "symbol.h" #include "cache.h" #include "header.h" diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 11c752561c55..7503fa170249 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -15,6 +15,7 @@ #include "header.h" #include "pmu-events/pmu-events.h" #include "cache.h" +#include "string2.h" struct perf_pmu_format { char *name; diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 7caba7003734..8f1374071cfc 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -47,6 +47,7 @@ #include "probe-finder.h" #include "probe-file.h" #include "session.h" +#include "string2.h" #include "sane_ctype.h" diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 88714dec8912..7942ea5c7e81 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -28,6 +28,7 @@ #include "probe-file.h" #include "session.h" #include "perf_regs.h" +#include "string2.h" /* 4096 - 2 ('\n' + '\0') */ #define MAX_CMDLEN 4094 diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 9ddd7dad2e6e..3f3cd11d3b7c 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -41,6 +41,7 @@ #include "symbol.h" #include "probe-finder.h" #include "probe-file.h" +#include "string2.h" /* Kprobe tracer basic type is up to u64 */ #define MAX_BASIC_TYPE_BITS 64 diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c index c663c9153245..3b068e0e2d59 100644 --- a/tools/perf/util/strfilter.c +++ b/tools/perf/util/strfilter.c @@ -1,5 +1,5 @@ #include "util.h" -#include "string.h" +#include "string2.h" #include "strfilter.h" #include "sane_ctype.h" diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index e716a6e5bb19..cca53b693a48 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -1,5 +1,7 @@ -#include "util.h" -#include "linux/string.h" +#include "string2.h" +#include +#include +#include #include "sane_ctype.h" @@ -101,8 +103,10 @@ static int count_argc(const char *str) void argv_free(char **argv) { char **p; - for (p = argv; *p; p++) - zfree(p); + for (p = argv; *p; p++) { + free(*p); + *p = NULL; + } free(argv); } @@ -122,7 +126,7 @@ void argv_free(char **argv) char **argv_split(const char *str, int *argcp) { int argc = count_argc(str); - char **argv = zalloc(sizeof(*argv) * (argc+1)); + char **argv = calloc(argc + 1, sizeof(*argv)); char **argvp; if (argv == NULL) @@ -379,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints goto out_err_overflow; if (i > 0) - printed += snprintf(e + printed, size - printed, " %s ", or_and); + printed += scnprintf(e + printed, size - printed, " %s ", or_and); printed += scnprintf(e + printed, size - printed, "%s %s %d", var, eq_neq, ints[i]); } diff --git a/tools/perf/util/string2.h b/tools/perf/util/string2.h new file mode 100644 index 000000000000..2f619681bd6a --- /dev/null +++ b/tools/perf/util/string2.h @@ -0,0 +1,42 @@ +#ifndef PERF_STRING_H +#define PERF_STRING_H + +#include +#include +#include + +s64 perf_atoll(const char *str); +char **argv_split(const char *str, int *argcp); +void argv_free(char **argv); +bool strglobmatch(const char *str, const char *pat); +bool strglobmatch_nocase(const char *str, const char *pat); +bool strlazymatch(const char *str, const char *pat); +static inline bool strisglob(const char *str) +{ + return strpbrk(str, "*?[") != NULL; +} +int strtailcmp(const char *s1, const char *s2); +char *strxfrchar(char *s, char from, char to); + +char *ltrim(char *s); +char *rtrim(char *s); + +static inline char *trim(char *s) +{ + return ltrim(rtrim(s)); +} + +char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); + +static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) +{ + return asprintf_expr_inout_ints(var, true, nints, ints); +} + +static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) +{ + return asprintf_expr_inout_ints(var, false, nints, ints); +} + + +#endif /* PERF_STRING_H */ diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index 9026408ea55b..ef86bf517e01 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c @@ -6,6 +6,7 @@ #include #include #include +#include "string2.h" #include "strlist.h" #include #include diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 46cfdccc32bc..850ca54d17a5 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -98,18 +98,6 @@ int copyfile(const char *from, const char *to); int copyfile_mode(const char *from, const char *to, mode_t mode); int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); -s64 perf_atoll(const char *str); -char **argv_split(const char *str, int *argcp); -void argv_free(char **argv); -bool strglobmatch(const char *str, const char *pat); -bool strglobmatch_nocase(const char *str, const char *pat); -bool strlazymatch(const char *str, const char *pat); -static inline bool strisglob(const char *str) -{ - return strpbrk(str, "*?[") != NULL; -} -int strtailcmp(const char *s1, const char *s2); -char *strxfrchar(char *s, char from, char to); unsigned long convert_unit(unsigned long value, char *unit); ssize_t readn(int fd, void *buf, size_t n); ssize_t writen(int fd, void *buf, size_t n); @@ -121,14 +109,6 @@ void event_attr_init(struct perf_event_attr *attr); size_t hex_width(u64 v); int hex2u64(const char *ptr, u64 *val); -char *ltrim(char *s); -char *rtrim(char *s); - -static inline char *trim(char *s) -{ - return ltrim(rtrim(s)); -} - void dump_stack(void); void sighandler_dump_stack(int sig); @@ -175,18 +155,6 @@ int gzip_decompress_to_file(const char *input, int output_fd); int lzma_decompress_to_file(const char *input, int output_fd); #endif -char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); - -static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) -{ - return asprintf_expr_inout_ints(var, true, nints, ints); -} - -static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) -{ - return asprintf_expr_inout_ints(var, false, nints, ints); -} - int get_stack_size(const char *str, unsigned long *_size); int fetch_kernel_version(unsigned int *puint, -- cgit v1.2.3-55-g7522 From a43783aeec5fac8ef372ff8c0a5bbb3056fc0604 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 10:46:11 -0300 Subject: perf tools: Include errno.h where needed Removing it from util.h, part of an effort to disentangle the includes hell, that makes changes to util.h or something included by it to cause a complete rebuild of the tools. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-ztrjy52q1rqcchuy3rubfgt2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm64/util/dwarf-regs.c | 1 + tools/perf/arch/powerpc/util/kvm-stat.c | 1 + tools/perf/arch/powerpc/util/perf_regs.c | 1 + tools/perf/arch/s390/util/kvm-stat.c | 1 + tools/perf/arch/x86/tests/intel-cqm.c | 1 + tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 + tools/perf/arch/x86/util/auxtrace.c | 1 + tools/perf/arch/x86/util/intel-bts.c | 1 + tools/perf/arch/x86/util/intel-pt.c | 1 + tools/perf/arch/x86/util/kvm-stat.c | 1 + tools/perf/arch/x86/util/perf_regs.c | 1 + tools/perf/builtin-annotate.c | 1 + tools/perf/builtin-buildid-cache.c | 1 + tools/perf/builtin-buildid-list.c | 1 + tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-diff.c | 1 + tools/perf/builtin-ftrace.c | 1 + tools/perf/builtin-help.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-lock.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/builtin-sched.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 1 + tools/perf/tests/attr.c | 1 + tools/perf/tests/backward-ring-buffer.c | 1 + tools/perf/tests/bpf.c | 1 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/tests/evsel-roundtrip-name.c | 1 + tools/perf/tests/hists_link.c | 1 + tools/perf/tests/mmap-basic.c | 1 + tools/perf/tests/openat-syscall-all-cpus.c | 1 + tools/perf/tests/openat-syscall-tp-fields.c | 1 + tools/perf/tests/openat-syscall.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/tests/perf-record.c | 1 + tools/perf/tests/pmu.c | 1 + tools/perf/tests/sdt.c | 1 + tools/perf/tests/sw-clock.c | 1 + tools/perf/tests/switch-tracking.c | 1 + tools/perf/tests/task-exit.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/bpf-loader.c | 1 + tools/perf/util/bpf-loader.h | 2 ++ tools/perf/util/bpf-prologue.c | 1 + tools/perf/util/bpf-prologue.h | 2 ++ tools/perf/util/build-id.c | 1 + tools/perf/util/c++/clang-c.h | 1 + tools/perf/util/cloexec.c | 1 + tools/perf/util/comm.c | 1 + tools/perf/util/config.c | 1 + tools/perf/util/counts.c | 1 + tools/perf/util/data-convert-bt.c | 1 + tools/perf/util/data.c | 1 + tools/perf/util/drv_configs.c | 1 + tools/perf/util/dso.c | 1 + tools/perf/util/dwarf-aux.c | 1 + tools/perf/util/env.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/header.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/intel-bts.c | 1 + tools/perf/util/jitdump.c | 1 + tools/perf/util/lzma.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/ordered-events.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/pmu.c | 1 + tools/perf/util/probe-file.c | 1 + tools/perf/util/quote.c | 1 + tools/perf/util/record.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/stat.c | 1 + tools/perf/util/strbuf.c | 1 + tools/perf/util/strfilter.c | 1 + tools/perf/util/symbol-minimal.c | 1 + tools/perf/util/thread-stack.c | 1 + tools/perf/util/thread.c | 1 + tools/perf/util/thread_map.c | 1 + tools/perf/util/unwind-libunwind-local.c | 1 + tools/perf/util/util.h | 1 - tools/perf/util/vdso.c | 2 +- 95 files changed, 96 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c index aea610c292e6..f268720ff021 100644 --- a/tools/perf/arch/arm64/util/dwarf-regs.c +++ b/tools/perf/arch/arm64/util/dwarf-regs.c @@ -8,6 +8,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include /* for struct user_pt_regs */ diff --git a/tools/perf/arch/powerpc/util/kvm-stat.c b/tools/perf/arch/powerpc/util/kvm-stat.c index 74eee30398f8..249723f0e6a9 100644 --- a/tools/perf/arch/powerpc/util/kvm-stat.c +++ b/tools/perf/arch/powerpc/util/kvm-stat.c @@ -1,3 +1,4 @@ +#include #include "util/kvm-stat.h" #include "util/parse-events.h" #include "util/debug.h" diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c index 4268f7762e25..f860dc411f69 100644 --- a/tools/perf/arch/powerpc/util/perf_regs.c +++ b/tools/perf/arch/powerpc/util/perf_regs.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/tools/perf/arch/s390/util/kvm-stat.c b/tools/perf/arch/s390/util/kvm-stat.c index ed57df2e6d68..d233e2eb9592 100644 --- a/tools/perf/arch/s390/util/kvm-stat.c +++ b/tools/perf/arch/s390/util/kvm-stat.c @@ -9,6 +9,7 @@ * as published by the Free Software Foundation. */ +#include #include "../../util/kvm-stat.h" #include diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c index 7f064eb37158..03c62eb0106b 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c @@ -7,6 +7,7 @@ #include "arch-tests.h" #include +#include #include static pid_t spawn(void) diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index a8e37f3148c2..e3ae9cff2b67 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/arch/x86/util/auxtrace.c b/tools/perf/arch/x86/util/auxtrace.c index cc1d865e31f1..6aa3f2a38321 100644 --- a/tools/perf/arch/x86/util/auxtrace.c +++ b/tools/perf/arch/x86/util/auxtrace.c @@ -13,6 +13,7 @@ * */ +#include #include #include "../../util/header.h" diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 5132775a044f..af2bce7a2cd6 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index 90fa2286edcf..f630de0206a1 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c index b63d4be655a2..bf817beca0a8 100644 --- a/tools/perf/arch/x86/util/kvm-stat.c +++ b/tools/perf/arch/x86/util/kvm-stat.c @@ -1,3 +1,4 @@ +#include #include "../../util/kvm-stat.h" #include #include diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index 3bf3548c5e2d..f95edebfb716 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b2b2722f6bb7..7a5dc7e5c577 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -33,6 +33,7 @@ #include "util/block-range.h" #include +#include #include struct perf_annotate { diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 94b55eee0d9b..034c3d4a7b27 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "builtin.h" #include "perf.h" diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 26f4e608207f..fdaca16e0c74 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -16,6 +16,7 @@ #include "util/session.h" #include "util/symbol.h" #include "util/data.h" +#include static int sysfs__fprintf_build_id(FILE *fp) { diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index cc8156a969ac..a90c1260f49e 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -9,6 +9,7 @@ * Dick Fowles * Joe Mario */ +#include #include #include #include diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 09be77b13788..eec5df80f5a3 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -19,6 +19,7 @@ #include "util/data.h" #include "util/config.h" +#include #include #include #include diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index f80fb60b00b0..67d14037c03e 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -9,6 +9,7 @@ #include "builtin.h" #include "perf.h" +#include #include #include #include diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 1f18385907f5..7bde2f59dac2 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -13,6 +13,7 @@ #include #include "util/debug.h" #include +#include static struct man_viewer_list { struct man_viewer_list *next; diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 65e1c026a2f0..b102ee702aa1 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -22,6 +22,7 @@ #include #include +#include struct perf_inject { struct perf_tool tool; diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 15754a492cad..9409c9464667 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index e82a6979327f..40660428fa72 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 6f93a6f0e268..ff98652484a7 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1,3 +1,4 @@ +#include #include #include "builtin.h" #include "perf.h" diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 65429d1b29c8..70340ff2008d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -40,6 +40,7 @@ #include "util/perf-hooks.h" #include "asm/bug.h" +#include #include #include #include diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 66a2f44518de..2941d8df4d40 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -40,6 +40,7 @@ #include "util/auxtrace.h" #include +#include #include #include #include diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index aefab93d7d2f..39996c53995a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index a710f6867954..853651a0f720 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -32,6 +32,7 @@ #include "asm/bug.h" #include "util/mem-events.h" #include "util/dump-insn.h" +#include #include #include "sane_ctype.h" diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 1da86e6708c0..be2cd537c537 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -69,6 +69,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index a24b229a785f..e2576c8f6d4e 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -12,6 +12,7 @@ * of the License. */ +#include #include #include diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 4160d946a34d..e065c4a12f58 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -41,6 +41,7 @@ #include "syscalltbl.h" #include "rb_resort.h" +#include #include #include /* FIXME: Still needed for audit_errno_to_name */ #include diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 94e9418aecb1..9ccccb0fbd8f 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -19,6 +19,7 @@ #include "util/debug.h" #include #include +#include #include #include #include diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index bb2bc487f703..ba87cd529bfc 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -18,6 +18,7 @@ * permissions. All the event text files are stored there. */ +#include #include #include #include diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 42e892b1e979..50f6d7afee58 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c @@ -8,6 +8,7 @@ #include #include "tests.h" #include "debug.h" +#include #define NR_ITERS 111 diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 67fe5eeff021..b78fbd611a7c 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index f029737ad255..552fd9aca08d 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -3,6 +3,7 @@ * * Builtin regression testing command: ever growing number of sanity tests */ +#include #include #include #include "builtin.h" diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index fe6aac82d54e..3a8bf1565493 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 8d376e155697..4683514751d6 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "tests.h" diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c index 9221d2732cc4..d2bea6f780f8 100644 --- a/tools/perf/tests/evsel-roundtrip-name.c +++ b/tools/perf/tests/evsel-roundtrip-name.c @@ -3,6 +3,7 @@ #include "parse-events.h" #include "tests.h" #include "debug.h" +#include #include static int perf_evsel__roundtrip_cache_name_test(void) diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 1bd26d23c2fc..a26cbb79e988 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -9,6 +9,7 @@ #include "thread.h" #include "parse-events.h" #include "hists_common.h" +#include #include struct sample { diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index aba40eb4c56f..15c770856aac 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -1,3 +1,4 @@ +#include #include /* For the CLR_() macros */ #include diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index eb7b1a6d507e..b7dece0de42c 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -1,3 +1,4 @@ +#include #include /* For the CPU_* macros */ #include diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c index f52239fed361..9788fac91095 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c @@ -5,6 +5,7 @@ #include "thread_map.h" #include "tests.h" #include "debug.h" +#include #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index 5964938d4b85..5f0c700b4693 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 05621748aead..66ecc3f5f618 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -5,6 +5,7 @@ #include "tests.h" #include "debug.h" #include "util.h" +#include #include #include #include diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index a8b6fdaf8df1..d37cd9588cc0 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -1,3 +1,4 @@ +#include #include /* For the CLR_() macros */ #include diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c index de6498dc4cbb..a6d7aef30030 100644 --- a/tools/perf/tests/pmu.c +++ b/tools/perf/tests/pmu.c @@ -2,6 +2,7 @@ #include "pmu.h" #include "util.h" #include "tests.h" +#include #include /* Simulated format definitions. */ diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c index 26e5b7a0b839..f73b3c5e125d 100644 --- a/tools/perf/tests/sdt.c +++ b/tools/perf/tests/sdt.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 29f11c4b3e60..828494db4a19 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index 7ddbe267d0ac..65474fd80da7 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 01a5ba2788c6..32873ec91a4e 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -4,6 +4,7 @@ #include "cpumap.h" #include "tests.h" +#include #include static int exited; diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index bc397bbbc3a7..0916575c6694 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 297bf5c66609..683f8340460c 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -7,6 +7,7 @@ * Released under the GPL v2. (and only v2, not any later version) */ +#include #include #include "util.h" #include "ui/ui.h" diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 26fb1ee5746a..9f0de72d58e2 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -17,6 +17,7 @@ #define __PERF_AUXTRACE_H #include +#include #include #include #include diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 27af9d62d899..bf21c1ca9771 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "perf.h" #include "debug.h" #include "bpf-loader.h" diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index f2b737b225f2..48863867878b 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -85,6 +85,8 @@ int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, char *buf, size_t size); #else +#include + static inline struct bpf_object * bpf__prepare_load(const char *filename __maybe_unused, bool source __maybe_unused) diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c index 6cdbee119ceb..1356220a9f1b 100644 --- a/tools/perf/util/bpf-prologue.c +++ b/tools/perf/util/bpf-prologue.c @@ -12,6 +12,7 @@ #include "bpf-loader.h" #include "bpf-prologue.h" #include "probe-finder.h" +#include #include #include diff --git a/tools/perf/util/bpf-prologue.h b/tools/perf/util/bpf-prologue.h index d94cbea12899..ba564838375f 100644 --- a/tools/perf/util/bpf-prologue.h +++ b/tools/perf/util/bpf-prologue.h @@ -18,6 +18,8 @@ int bpf__gen_prologue(struct probe_trace_arg *args, int nargs, struct bpf_insn *new_prog, size_t *new_cnt, size_t cnt_space); #else +#include + static inline int bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused, int nargs __maybe_unused, diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 3c0755563969..8d8ef1d31b1e 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -7,6 +7,7 @@ * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo */ #include "util.h" +#include #include #include "build-id.h" #include "event.h" diff --git a/tools/perf/util/c++/clang-c.h b/tools/perf/util/c++/clang-c.h index 0eadd792ab1f..ccafcf72b37a 100644 --- a/tools/perf/util/c++/clang-c.h +++ b/tools/perf/util/c++/clang-c.h @@ -20,6 +20,7 @@ extern int perf_clang__compile_bpf(const char *filename, size_t *p_obj_buf_sz); #else +#include static inline void perf_clang__init(void) { } static inline void perf_clang__cleanup(void) { } diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c index f0dcd0ee0afa..4b4f00df58a8 100644 --- a/tools/perf/util/cloexec.c +++ b/tools/perf/util/cloexec.c @@ -1,3 +1,4 @@ +#include #include #include "util.h" #include "../perf.h" diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c index 32837b6f7879..530a62a7b51e 100644 --- a/tools/perf/util/comm.c +++ b/tools/perf/util/comm.c @@ -1,5 +1,6 @@ #include "comm.h" #include "util.h" +#include #include #include #include diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 88783aa3dfc9..f5604039cbe4 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -8,6 +8,7 @@ * Copyright (C) Johannes Schindelin, 2005 * */ +#include #include "util.h" #include "cache.h" #include diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c index e3fde313deb2..83fedd0d22a1 100644 --- a/tools/perf/util/counts.c +++ b/tools/perf/util/counts.c @@ -1,3 +1,4 @@ +#include #include #include "evsel.h" #include "counts.h" diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index c3277b32e917..89d50318833d 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -7,6 +7,7 @@ * Released under the GPL v2. (and only v2, not any later version) */ +#include #include #include #include diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 60bfc9ca1e22..e84bbc8ec058 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/util/drv_configs.c b/tools/perf/util/drv_configs.c index 1647f285c629..eec754243f4d 100644 --- a/tools/perf/util/drv_configs.c +++ b/tools/perf/util/drv_configs.c @@ -17,6 +17,7 @@ #include "evlist.h" #include "evsel.h" #include "pmu.h" +#include static int perf_evsel__apply_drv_configs(struct perf_evsel *evsel, diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 6ad57730a0ed..cd061dc1de70 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "symbol.h" #include "dso.h" #include "machine.h" diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 780ee4629bd0..f5acda13dcfa 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -17,6 +17,7 @@ * */ +#include #include #include #include "util.h" diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 075fc77286bf..9e21538c42ae 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -1,6 +1,7 @@ #include "cpumap.h" #include "env.h" #include "util.h" +#include struct perf_env perf_env; diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 53b81b2283c1..1fc1217a0c2c 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index cf27039df100..f74ea2e55fde 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -8,6 +8,7 @@ */ #include "util.h" #include +#include #include #include #include "cpumap.h" diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 757f73c4fa95..44a7aef3911b 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 51865b8cb9f3..28a3acb7b313 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1,3 +1,4 @@ +#include #include #include "util.h" #include "string2.h" diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index af3bd5d31d99..65d42758aadd 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -10,6 +10,7 @@ #include "annotate.h" #include "srcline.h" #include "ui/progress.h" +#include #include static bool hists__filter_entry_by_dso(struct hists *hists, diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 471ed8b26a1c..b2834ac7b1f5 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index d6d25327bc92..388078d84eed 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index 9ddea5cecd94..5b73b268c169 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f13f46a99b36..cdbfe3e32e5a 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1,3 +1,4 @@ +#include #include #include "callchain.h" #include "debug.h" diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index df05be69cc9e..4de398cfb577 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 535c7cbb2bfb..d4877c8438e5 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1,5 +1,6 @@ #include #include +#include #include "util.h" #include "../perf.h" #include "evlist.h" diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 7503fa170249..bca1844594d0 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 7942ea5c7e81..1ccaefdc05c4 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -14,6 +14,7 @@ * GNU General Public License for more details. * */ +#include #include #include "util.h" #include "event.h" diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c index 293534c1a474..1ba8920151d8 100644 --- a/tools/perf/util/quote.c +++ b/tools/perf/util/quote.c @@ -1,3 +1,4 @@ +#include #include #include "strbuf.h" #include "quote.h" diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 98bf584853ea..d91bdf5a1aa4 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -2,6 +2,7 @@ #include "evsel.h" #include "cpumap.h" #include "parse-events.h" +#include #include #include "util.h" #include "cloexec.h" diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 0695e08d2252..19d993f2a305 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 63ad5374f364..9aa058e167e8 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1,3 +1,4 @@ +#include #include #include #include "sort.h" diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index bbf30b2d1614..c58174443dc1 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -1,3 +1,4 @@ +#include #include #include #include "stat.h" diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index 817593908d47..e91b5e86f027 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c @@ -1,6 +1,7 @@ #include "debug.h" #include "util.h" #include +#include int prefixcmp(const char *str, const char *prefix) { diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c index 3b068e0e2d59..4dc0af669a30 100644 --- a/tools/perf/util/strfilter.c +++ b/tools/perf/util/strfilter.c @@ -2,6 +2,7 @@ #include "string2.h" #include "strfilter.h" +#include #include "sane_ctype.h" /* Operators */ diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index 870ef0f0659c..40bf5d4c0bfd 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c @@ -1,6 +1,7 @@ #include "symbol.h" #include "util.h" +#include #include #include #include diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index d3301529f6a7..dd17d6a38d3a 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c @@ -15,6 +15,7 @@ #include #include +#include #include "thread.h" #include "event.h" #include "machine.h" diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index e8ce6abc5321..378c418ca0c1 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -1,4 +1,5 @@ #include "../perf.h" +#include #include #include #include diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index ef86bf517e01..63ead7b06324 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index 788f4d3c76f5..f8455bed6e65 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 850ca54d17a5..6fd9963be1c8 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 7bdcad484225..d3c39eec89a8 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c @@ -1,4 +1,4 @@ - +#include #include #include #include -- cgit v1.2.3-55-g7522 From 8ec20b176c4be72d067fa18e33a4f156d1da9bc8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 10:57:25 -0300 Subject: perf str{filter,list}: Disentangle headers There are places where we just need a forward declaration, and others were we need to include strlist.h and/or strfilter.h, reducing the impact of changes in headers on the build time, do it. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-zab42gbiki88y9k0csorxekb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-report.c | 1 - tools/perf/builtin-timechart.c | 1 - tools/perf/util/bpf-loader.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/build-id.h | 4 +++- tools/perf/util/evsel_fprintf.c | 1 + tools/perf/util/jitdump.c | 1 - tools/perf/util/map.c | 1 - tools/perf/util/parse-events.c | 1 + tools/perf/util/probe-event.c | 1 + tools/perf/util/probe-event.h | 7 +++++-- tools/perf/util/probe-file.c | 1 + tools/perf/util/probe-file.h | 6 ++++-- tools/perf/util/probe-finder.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 1 - tools/perf/util/util.h | 3 ++- 17 files changed, 22 insertions(+), 11 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2941d8df4d40..f50738e0006e 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -16,7 +16,6 @@ #include #include "util/symbol.h" #include "util/callchain.h" -#include "util/strlist.h" #include "util/values.h" #include "perf.h" diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index e2576c8f6d4e..38e2c437b7b3 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -30,7 +30,6 @@ #include #include "util/symbol.h" #include "util/callchain.h" -#include "util/strlist.h" #include "perf.h" #include "util/header.h" diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index bf21c1ca9771..4bd2d1d882af 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -19,6 +19,7 @@ #include "probe-event.h" #include "probe-finder.h" // for MAX_PROBES #include "parse-events.h" +#include "strfilter.h" #include "llvm-utils.h" #include "c++/clang-c.h" diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 8d8ef1d31b1e..f9ccd053cdf6 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -19,6 +19,7 @@ #include "header.h" #include "vdso.h" #include "probe-file.h" +#include "strlist.h" #include "sane_ctype.h" diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index d27990610f9f..a96081121179 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -5,7 +5,6 @@ #define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) #include "tool.h" -#include "strlist.h" #include extern struct perf_tool build_id__mark_dso_hit_ops; @@ -34,6 +33,9 @@ char *build_id_cache__origname(const char *sbuild_id); char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size); char *build_id_cache__cachedir(const char *sbuild_id, const char *name, bool is_kallsyms, bool is_vdso); + +struct strlist; + struct strlist *build_id_cache__list_all(bool validonly); char *build_id_cache__complement(const char *incomplete_sbuild_id); int build_id_cache__list_build_ids(const char *pathname, diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c index 8000f62d5d53..e415aee6a245 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c @@ -5,6 +5,7 @@ #include "evsel.h" #include "callchain.h" #include "map.h" +#include "strlist.h" #include "symbol.h" static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...) diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 388078d84eed..9084930e1757 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -17,7 +17,6 @@ #include "debug.h" #include "evlist.h" #include "symbol.h" -#include "strlist.h" #include #include "tsc.h" diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 9059d20c3b8a..ebfa5d92358a 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -9,7 +9,6 @@ #include /* To get things like MAP_HUGETLB even on older libc headers */ #include "map.h" #include "thread.h" -#include "strlist.h" #include "vdso.h" #include "build-id.h" #include "util.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d4877c8438e5..580f0e17ad38 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -9,6 +9,7 @@ #include "parse-events.h" #include #include "string2.h" +#include "strlist.h" #include "symbol.h" #include "cache.h" #include "header.h" diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 8f1374071cfc..84e7e698411e 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -36,6 +36,7 @@ #include "util.h" #include "event.h" #include "strlist.h" +#include "strfilter.h" #include "debug.h" #include "cache.h" #include "color.h" diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 5d4e94061402..373842656fb6 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h @@ -3,8 +3,6 @@ #include #include "intlist.h" -#include "strlist.h" -#include "strfilter.h" /* Probe related configurations */ struct probe_conf { @@ -107,6 +105,8 @@ struct line_range { struct intlist *line_list; /* Visible lines */ }; +struct strlist; + /* List of variables */ struct variable_list { struct probe_trace_point point; /* Actual probepoint */ @@ -153,6 +153,9 @@ int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs); int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); int show_probe_trace_events(struct perf_probe_event *pevs, int npevs); void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); + +struct strfilter; + int del_perf_probe_events(struct strfilter *filter); int show_perf_probe_event(const char *group, const char *event, diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 1ccaefdc05c4..685653f2bc32 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -19,6 +19,7 @@ #include "util.h" #include "event.h" #include "strlist.h" +#include "strfilter.h" #include "debug.h" #include "cache.h" #include "color.h" diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h index dbf95a00864a..5ecc9d3925db 100644 --- a/tools/perf/util/probe-file.h +++ b/tools/perf/util/probe-file.h @@ -1,10 +1,11 @@ #ifndef __PROBE_FILE_H #define __PROBE_FILE_H -#include "strlist.h" -#include "strfilter.h" #include "probe-event.h" +struct strlist; +struct strfilter; + /* Cache of probe definitions */ struct probe_cache_entry { struct list_head node; @@ -41,6 +42,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag); struct strlist *probe_file__get_namelist(int fd); struct strlist *probe_file__get_rawlist(int fd); int probe_file__add_event(int fd, struct probe_trace_event *tev); + int probe_file__del_events(int fd, struct strfilter *filter); int probe_file__get_events(int fd, struct strfilter *filter, struct strlist *plist); diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 3f3cd11d3b7c..a5731de0e5eb 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -38,6 +38,7 @@ #include "debug.h" #include "intlist.h" #include "util.h" +#include "strlist.h" #include "symbol.h" #include "probe-finder.h" #include "probe-file.h" diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 9aa058e167e8..4df228ab4db1 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -7,6 +7,7 @@ #include "symbol.h" #include "evsel.h" #include "evlist.h" +#include "strlist.h" #include #include "mem-events.h" #include diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 535903297cee..421232a27e7b 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -11,7 +11,6 @@ #include "symbol.h" #include "string.h" #include "callchain.h" -#include "strlist.h" #include "values.h" #include "../perf.h" diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 6fd9963be1c8..397676c25232 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -40,7 +40,6 @@ #include #include #include -#include "strlist.h" extern char buildid_dir[]; @@ -89,6 +88,8 @@ static inline void *zalloc(size_t size) #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) +struct strlist; + int mkdir_p(char *path, mode_t mode); int rm_rf(const char *path); struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *)); -- cgit v1.2.3-55-g7522 From b0742e90f5ab904aa835350c28bcec48e9109379 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 11:08:10 -0300 Subject: perf tools: Don't include terminal handling headers in util.h Continuing the disentanglement, mostly the TUI needs CTRL(c), that is in sys/ttydefaults.h and term.c needs the termios headers. And term.h needs to be added to a few places too. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-il19zna7qj9ytavdbwlipc7t@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/header.c | 2 ++ tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/parse-events.c | 2 +- tools/perf/util/term.c | 6 +++++- tools/perf/util/util.h | 4 ---- 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 40660428fa72..4002277475cf 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -3,6 +3,7 @@ #include "util/evsel.h" #include "util/evlist.h" +#include "util/term.h" #include "util/util.h" #include "util/cache.h" #include "util/symbol.h" diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index ec3247db4826..47984a838b73 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -40,6 +40,7 @@ #include "util/cpumap.h" #include "util/xyarray.h" #include "util/sort.h" +#include "util/term.h" #include "util/intlist.h" #include "util/parse-branch-options.h" #include "arch/common.h" diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 2ed64124276f..d990ad08a3c6 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -12,6 +12,7 @@ #include #include #include +#include struct disasm_line_samples { double percent; diff --git a/tools/perf/ui/browsers/header.c b/tools/perf/ui/browsers/header.c index edbeaaf31ace..e2c9390ff4c5 100644 --- a/tools/perf/ui/browsers/header.c +++ b/tools/perf/ui/browsers/header.c @@ -8,6 +8,8 @@ #include "util/header.h" #include "util/session.h" +#include + static void ui_browser__argv_write(struct ui_browser *browser, void *entry, int row) { diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 0916575c6694..a271b48ad0d3 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "../../util/evsel.h" #include "../../util/evlist.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 580f0e17ad38..f3dd1aa59a25 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1,7 +1,7 @@ #include #include #include -#include "util.h" +#include "term.h" #include "../perf.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/util/term.c b/tools/perf/util/term.c index 90b47d8aa19c..8f254a74d97d 100644 --- a/tools/perf/util/term.c +++ b/tools/perf/util/term.c @@ -1,4 +1,8 @@ -#include "util.h" +#include "term.h" +#include +#include +#include +#include void get_term_dimensions(struct winsize *ws) { diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 397676c25232..fa8c2e59a0bc 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -35,11 +34,8 @@ #include #include #include -#include #include -#include #include -#include extern char buildid_dir[]; -- cgit v1.2.3-55-g7522 From 9a3993d408bc61b839de1a2c6c783477a04860bb Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 11:33:48 -0300 Subject: perf tools: Move path related functions to util/path.h Disentangling util.h header mess a bit more. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-aj6je8ly377i4upedmjzdsq6@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 1 + tools/perf/tests/mmap-thread-lookup.c | 1 + tools/perf/tests/openat-syscall-all-cpus.c | 4 ++++ tools/perf/tests/openat-syscall.c | 3 +++ tools/perf/ui/setup.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/counts.c | 1 + tools/perf/util/dso.c | 1 + tools/perf/util/path.c | 28 +++++++++++++++++++++++++++- tools/perf/util/path.h | 9 +++++++++ tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 2 +- tools/perf/util/unwind-libdw.c | 1 + tools/perf/util/util.c | 10 ---------- tools/perf/util/util.h | 16 ---------------- 15 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 tools/perf/util/path.h diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e065c4a12f58..d1c8cdc6788b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -24,6 +24,7 @@ #include "util/evlist.h" #include #include "util/machine.h" +#include "util/path.h" #include "util/session.h" #include "util/thread.h" #include diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c index a5ffb754f8c6..6ea4d8a5d26b 100644 --- a/tools/perf/tests/mmap-thread-lookup.c +++ b/tools/perf/tests/mmap-thread-lookup.c @@ -12,6 +12,7 @@ #include "thread_map.h" #include "symbol.h" #include "thread.h" +#include "util.h" #define THREADS 4 diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index b7dece0de42c..1a74dd9fd067 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -3,8 +3,12 @@ /* For the CPU_* macros */ #include +#include +#include +#include #include #include +#include #include "evsel.h" #include "tests.h" #include "thread_map.h" diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index 5f0c700b4693..e44506e21ee7 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -2,6 +2,9 @@ #include #include #include +#include +#include +#include #include "thread_map.h" #include "evsel.h" #include "debug.h" diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 50d13e58210f..5ea0b40c4fc2 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c @@ -4,6 +4,7 @@ #include "../util/cache.h" #include "../util/debug.h" #include "../util/hist.h" +#include "../util/util.h" pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; void *perf_gtk_handle; diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index f9ccd053cdf6..b5c4892c2e18 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -18,6 +18,7 @@ #include "tool.h" #include "header.h" #include "vdso.h" +#include "path.h" #include "probe-file.h" #include "strlist.h" diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c index 83fedd0d22a1..c4af82ab7808 100644 --- a/tools/perf/util/counts.c +++ b/tools/perf/util/counts.c @@ -2,6 +2,7 @@ #include #include "evsel.h" #include "counts.h" +#include "util.h" struct perf_counts *perf_counts__new(int ncpus, int nthreads) { diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index cd061dc1de70..cbfe17f5168a 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -3,6 +3,7 @@ #include #include #include +#include "path.h" #include "symbol.h" #include "dso.h" #include "machine.h" diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index 7c7630be5a89..50ec3bc87a60 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c @@ -11,8 +11,13 @@ * which is what it's designed for. */ #include "cache.h" -#include "util.h" +#include "path.h" +#include #include +#include +#include +#include +#include static char bad_path[] = "/bad-path/"; /* @@ -50,3 +55,24 @@ char *mkpath(const char *fmt, ...) return bad_path; return cleanup_path(pathname); } + +int path__join(char *bf, size_t size, const char *path1, const char *path2) +{ + return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2); +} + +int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3) +{ + return scnprintf(bf, size, "%s%s%s%s%s", path1, path1[0] ? "/" : "", + path2, path2[0] ? "/" : "", path3); +} + +bool is_regular_file(const char *file) +{ + struct stat st; + + if (stat(file, &st)) + return false; + + return S_ISREG(st.st_mode); +} diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h new file mode 100644 index 000000000000..9a276a58e3c2 --- /dev/null +++ b/tools/perf/util/path.h @@ -0,0 +1,9 @@ +#ifndef _PERF_PATH_H +#define _PERF_PATH_H + +int path__join(char *bf, size_t size, const char *path1, const char *path2); +int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3); + +bool is_regular_file(const char *file); + +#endif /* _PERF_PATH_H */ diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 68f14d770083..2cb7665e9973 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -19,6 +19,7 @@ #include "strlist.h" #include "intlist.h" #include "header.h" +#include "path.h" #include "sane_ctype.h" #include diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 5245d2fb1a0a..7acd70fce68e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -13,7 +13,7 @@ #include #include "build-id.h" #include "event.h" -#include "util.h" +#include "path.h" #ifdef HAVE_LIBELF_SUPPORT #include diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 783a53fb7a4e..f90e11a555b2 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -12,6 +12,7 @@ #include "event.h" #include "perf_regs.h" #include "callchain.h" +#include "util.h" static char *debuginfo_path; diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 4fb8ee552a31..64877c6d09b2 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -713,16 +713,6 @@ out: return tip; } -bool is_regular_file(const char *file) -{ - struct stat st; - - if (stat(file, &st)) - return false; - - return S_ISREG(st.st_mode); -} - int fetch_current_timestamp(char *buf, size_t sz) { struct timeval tv; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index fa8c2e59a0bc..617965644ff4 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -120,21 +120,6 @@ struct parse_tag { unsigned long parse_tag_value(const char *str, struct parse_tag *tags); -static inline int path__join(char *bf, size_t size, - const char *path1, const char *path2) -{ - return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2); -} - -static inline int path__join3(char *bf, size_t size, - const char *path1, const char *path2, - const char *path3) -{ - return scnprintf(bf, size, "%s%s%s%s%s", - path1, path1[0] ? "/" : "", - path2, path2[0] ? "/" : "", path3); -} - int perf_event_paranoid(void); void mem_bswap_64(void *src, int byte_size); @@ -162,7 +147,6 @@ int fetch_kernel_version(unsigned int *puint, #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) const char *perf_tip(const char *dirpath); -bool is_regular_file(const char *file); int fetch_current_timestamp(char *buf, size_t sz); #ifndef HAVE_SCHED_GETCPU_SUPPORT -- cgit v1.2.3-55-g7522 From 6dcca6df4b73d409628c7b4464c63d4eb9d4d13a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 11:42:23 -0300 Subject: perf tools: No need to include bitops.h in util.h When we switched to the kernel's roundup_pow_of_two we forgot to remove this include from util.h, do it now. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Fixes: 91529834d1de ("perf evlist: Use roundup_pow_of_two") Link: http://lkml.kernel.org/n/tip-kfye5rxivib6155cltx0bw4h@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 617965644ff4..423ed7f8bcc0 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -35,7 +35,6 @@ #include #include #include -#include extern char buildid_dir[]; -- cgit v1.2.3-55-g7522 From 20a9ed280dde6292c529dfdaaf9ce743ef71bb1f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 11:44:58 -0300 Subject: perf tools: Use api/fs/tracing_path.h where needed Instead of getting it out of luck from util.h, where it isn't needed at all. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-0bqugg5lc5ksla1v4m0dnmc1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-ftrace.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/util/util.h | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 67d14037c03e..0f34ab7a9ec1 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -16,6 +16,7 @@ #include "debug.h" #include +#include #include "evlist.h" #include "target.h" #include "cpumap.h" diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 66ecc3f5f618..f5b77f5c3192 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -9,6 +9,7 @@ #include #include #include +#include #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 423ed7f8bcc0..d4910e490f20 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -34,7 +34,6 @@ #include #include #include -#include extern char buildid_dir[]; -- cgit v1.2.3-55-g7522 From 767fe71b2d576762c77873021abd95c0a18538e3 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 12:20:19 -0300 Subject: perf tools: Remove misplaced __maybe_unused in some functions Those args _are_ being used. Link: http://lkml.kernel.org/n/tip-yi9s00ki1i1tcc704v042957@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/build-id.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index b5c4892c2e18..9815a3b6667a 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -451,14 +451,14 @@ void disable_buildid_cache(void) } static bool lsdir_bid_head_filter(const char *name __maybe_unused, - struct dirent *d __maybe_unused) + struct dirent *d) { return (strlen(d->d_name) == 2) && isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]); } static bool lsdir_bid_tail_filter(const char *name __maybe_unused, - struct dirent *d __maybe_unused) + struct dirent *d) { int i = 0; while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) -- cgit v1.2.3-55-g7522 From 76b31a29ddaf2fa5f0a70458c214bed02a4a70e9 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 12:26:44 -0300 Subject: perf tools: Remove include dirent.h from util.h The files using the dirent.h routines should instead include it, reducing the includes hell that lead to longer build times. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-42g2f4z6nfg7mdb2ae97n7tj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 1 + tools/perf/tests/dso-data.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/cpumap.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/util.h | 2 +- 11 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 853651a0f720..fe1dcd4f2c6d 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -32,6 +32,7 @@ #include "asm/bug.h" #include "util/mem-events.h" #include "util/dump-insn.h" +#include #include #include diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 46ea2e061b86..8f08df5861cb 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index f5b77f5c3192..981d2bf9914f 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -5,6 +5,7 @@ #include "tests.h" #include "debug.h" #include "util.h" +#include #include #include #include diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a271b48ad0d3..f0b5b2b0e521 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 9815a3b6667a..923ea290bb6e 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -7,6 +7,7 @@ * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo */ #include "util.h" +#include #include #include #include "build-id.h" diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 9d9ecb2430cc..37b3bb79ee08 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -3,6 +3,7 @@ #include "../perf.h" #include "cpumap.h" #include +#include #include #include #include diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1fc1217a0c2c..cf457ef534da 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index cdbfe3e32e5a..46411742d03c 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1,3 +1,4 @@ +#include #include #include #include "callchain.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index f3dd1aa59a25..7d84338b19ee 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "term.h" #include "../perf.h" diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 64877c6d09b2..b9716bc6e8fd 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -7,6 +7,7 @@ #ifdef HAVE_BACKTRACE_SUPPORT #include #endif +#include #include #include #include diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index d4910e490f20..c0574e2763b7 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -82,6 +81,7 @@ static inline void *zalloc(size_t size) #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) +struct dirent; struct strlist; int mkdir_p(char *path, mode_t mode); -- cgit v1.2.3-55-g7522 From 1eae20c1d40acf7676aa799b48f747d9b28bf352 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 12:33:30 -0300 Subject: perf tools: Remove regex.h and fnmatch.h from util.h The users of regex and fnmatch functions should include those headers instead. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-ixzm5kuamsq1ixbkuv6kmwzj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-report.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 2 +- tools/perf/util/util.h | 2 -- 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index f50738e0006e..5bbd4b2ef6d2 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 46411742d03c..988e84ce6f88 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "callchain.h" #include "debug.h" #include "event.h" diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 4df228ab4db1..fe4fd7b5f8e0 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "sort.h" #include "hist.h" diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 421232a27e7b..8bcec05ee578 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -2,7 +2,7 @@ #define __PERF_SORT_H #include "../builtin.h" -#include "util.h" +#include #include "color.h" #include diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index c0574e2763b7..d79f3c23dd02 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -23,9 +23,7 @@ #include #include #include -#include #include -#include #include #include #include -- cgit v1.2.3-55-g7522 From 1b5ad16c7aa7177512ce141e345ff36b9f1a6136 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 18 Apr 2017 15:39:45 -0300 Subject: perf tools: Ditch unused strchrnul() reimplementation Remnants from the git codebase. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-kwaez3uxo1w9f8v5r7etl0w6@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index d79f3c23dd02..2a1166f8bb37 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -56,22 +56,6 @@ void set_warning_routine(void (*routine)(const char *err, va_list params)); int prefixcmp(const char *str, const char *prefix); void set_buildid_dir(const char *dir); -#ifdef __GLIBC_PREREQ -#if __GLIBC_PREREQ(2, 1) -#define HAVE_STRCHRNUL -#endif -#endif - -#ifndef HAVE_STRCHRNUL -#define strchrnul gitstrchrnul -static inline char *gitstrchrnul(const char *s, int c) -{ - while (*s && *s != c) - s++; - return (char *)s; -} -#endif - static inline void *zalloc(size_t size) { return calloc(1, size); -- cgit v1.2.3-55-g7522 From 3dfed9102694227aa763b9984c50d72de796d39b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 13:28:30 -0300 Subject: perf unwind: Provide only forward declarations for pointer types No need to drag the headers, helps in untangling them and reducing build time. Link: http://lkml.kernel.org/n/tip-l8soqph92duyw5jdha0fij8b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/unwind.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h index 61fb1e90ff51..bfbdcc6198c9 100644 --- a/tools/perf/util/unwind.h +++ b/tools/perf/util/unwind.h @@ -1,10 +1,13 @@ #ifndef __UNWIND_H #define __UNWIND_H +#include #include -#include "event.h" -#include "symbol.h" -#include "thread.h" + +struct map; +struct perf_sample; +struct symbol; +struct thread; struct unwind_entry { struct map *map; -- cgit v1.2.3-55-g7522 From 9607ad3a63871b074a57ce1facd04a230c38725c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 15:49:18 -0300 Subject: perf tools: Add signal.h to places using its definitions And remove it from util.h, disentangling it a bit more. Link: http://lkml.kernel.org/n/tip-2zg9s5nx90yde64j3g4z2uhk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/tests/intel-cqm.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 1 + tools/perf/trace/beauty/signum.c | 1 + tools/perf/ui/gtk/annotate.c | 1 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/evlist.h | 1 + tools/perf/util/util.c | 1 + tools/perf/util/util.h | 1 - 17 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c index 03c62eb0106b..befde6708c33 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c @@ -6,6 +6,7 @@ #include "evsel.h" #include "arch-tests.h" +#include #include #include #include diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index b102ee702aa1..8bd791cca008 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -23,6 +23,7 @@ #include #include +#include struct perf_inject { struct perf_tool tool; diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 4002277475cf..2b1732cfc0be 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 70340ff2008d..e1b937f23894 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 5bbd4b2ef6d2..b8f2dd322496 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index fe1dcd4f2c6d..76a88bdeebe4 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "sane_ctype.h" diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index be2cd537c537..e3837febb4ff 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 47984a838b73..7ab42b8311a1 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index d1c8cdc6788b..ef3613f2fe6a 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -45,6 +45,7 @@ #include #include #include /* FIXME: Still needed for audit_errno_to_name */ +#include #include #include #include diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 9ccccb0fbd8f..356588982d08 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/trace/beauty/signum.c b/tools/perf/trace/beauty/signum.c index d3b0b1fab077..fde8f2fc6558 100644 --- a/tools/perf/trace/beauty/signum.c +++ b/tools/perf/trace/beauty/signum.c @@ -1,3 +1,4 @@ +#include static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) { diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 71359b898b67..e99ba86158d2 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c @@ -4,6 +4,7 @@ #include "util/evsel.h" #include "ui/helpline.h" #include +#include enum { ANN_COL__PERCENT, diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index c42de4dcc055..e24f83957705 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -6,6 +6,7 @@ #include "../helpline.h" #include "../string2.h" #include "gtk.h" +#include #define MAX_COLUMNS 32 diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f74ea2e55fde..8d36cf345375 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -18,6 +18,7 @@ #include "evsel.h" #include "debug.h" #include "asm/bug.h" +#include #include #include "parse-events.h" diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 3fed4fb2e866..94cea4398a13 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -11,6 +11,7 @@ #include "evsel.h" #include "util.h" #include "auxtrace.h" +#include #include struct pollfd; diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index b9716bc6e8fd..bc42c459f586 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -9,6 +9,7 @@ #endif #include #include +#include #include #include #include diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 2a1166f8bb37..6bf141647403 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3-55-g7522 From 58db1d6e7d5d24afa2d32e916fd6f6b6d240ba93 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 16:05:56 -0300 Subject: perf tools: Move units conversion/formatting routines to separate object Out of util.h, to disentangle it a bit more. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-vpksyj3w5fk9t8s6mxmkajyr@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/tests/unit_number__scnprintf.c | 2 +- tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/python-ext-sources | 1 + tools/perf/util/units.c | 39 +++++++++++++++++++++++++++++++ tools/perf/util/units.h | 10 ++++++++ tools/perf/util/util.c | 35 --------------------------- tools/perf/util/util.h | 3 --- 11 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 tools/perf/util/units.c create mode 100644 tools/perf/util/units.h diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e1b937f23894..99156b4363a5 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -38,6 +38,7 @@ #include "util/bpf-loader.h" #include "util/trigger.h" #include "util/perf-hooks.h" +#include "util/units.h" #include "asm/bug.h" #include diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index b8f2dd322496..3f89e0eaf0d4 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -37,6 +37,7 @@ #include "arch/common.h" #include "util/time-utils.h" #include "util/auxtrace.h" +#include "util/units.h" #include #include diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c index f84cb70ee5e5..44589de084b8 100644 --- a/tools/perf/tests/unit_number__scnprintf.c +++ b/tools/perf/tests/unit_number__scnprintf.c @@ -2,7 +2,7 @@ #include #include #include "tests.h" -#include "util.h" +#include "units.h" #include "debug.h" int test__unit_number__scnprint(int subtest __maybe_unused) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index f0b5b2b0e521..1b12a69740b3 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -24,6 +24,7 @@ #include "annotate.h" #include "srcline.h" #include "string2.h" +#include "units.h" #include "sane_ctype.h" diff --git a/tools/perf/util/Build b/tools/perf/util/Build index f0b9e5d0e2fc..069583bdc670 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -89,6 +89,7 @@ libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o libperf-y += drv_configs.o +libperf-y += units.o libperf-y += time-utils.o libperf-y += expr-bison.o diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 8d36cf345375..5eb638fd003f 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -17,6 +17,7 @@ #include "evlist.h" #include "evsel.h" #include "debug.h" +#include "units.h" #include "asm/bug.h" #include #include diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index 7d3927447fba..9f3b0d9754a8 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources @@ -27,3 +27,4 @@ util/trace-event.c ../lib/rbtree.c util/string.c util/symbol_fprintf.c +util/units.c diff --git a/tools/perf/util/units.c b/tools/perf/util/units.c new file mode 100644 index 000000000000..f6a2a3d117d5 --- /dev/null +++ b/tools/perf/util/units.c @@ -0,0 +1,39 @@ +#include "units.h" +#include +#include +#include + +unsigned long convert_unit(unsigned long value, char *unit) +{ + *unit = ' '; + + if (value > 1000) { + value /= 1000; + *unit = 'K'; + } + + if (value > 1000) { + value /= 1000; + *unit = 'M'; + } + + if (value > 1000) { + value /= 1000; + *unit = 'G'; + } + + return value; +} + +int unit_number__scnprintf(char *buf, size_t size, u64 n) +{ + char unit[4] = "BKMG"; + int i = 0; + + while (((n / 1024) > 1) && (i < 3)) { + n /= 1024; + i++; + } + + return scnprintf(buf, size, "%" PRIu64 "%c", n, unit[i]); +} diff --git a/tools/perf/util/units.h b/tools/perf/util/units.h new file mode 100644 index 000000000000..3ed7774afaa9 --- /dev/null +++ b/tools/perf/util/units.h @@ -0,0 +1,10 @@ +#ifndef PERF_UNIT_H +#define PERF_UNIT_H + +#include +#include + +unsigned long convert_unit(unsigned long value, char *unit); +int unit_number__scnprintf(char *buf, size_t size, u64 n); + +#endif /* PERF_UNIT_H */ diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index bc42c459f586..7741d5f6022b 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -272,28 +272,6 @@ int copyfile(const char *from, const char *to) return copyfile_mode(from, to, 0755); } -unsigned long convert_unit(unsigned long value, char *unit) -{ - *unit = ' '; - - if (value > 1000) { - value /= 1000; - *unit = 'K'; - } - - if (value > 1000) { - value /= 1000; - *unit = 'M'; - } - - if (value > 1000) { - value /= 1000; - *unit = 'G'; - } - - return value; -} - static ssize_t ion(bool is_read, int fd, void *buf, size_t n) { void *buf_start = buf; @@ -731,16 +709,3 @@ int fetch_current_timestamp(char *buf, size_t sz) return 0; } - -int unit_number__scnprintf(char *buf, size_t size, u64 n) -{ - char unit[4] = "BKMG"; - int i = 0; - - while (((n / 1024) > 1) && (i < 3)) { - n /= 1024; - i++; - } - - return scnprintf(buf, size, "%" PRIu64 "%c", n, unit[i]); -} diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 6bf141647403..add9e77369a2 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -73,7 +73,6 @@ int copyfile(const char *from, const char *to); int copyfile_mode(const char *from, const char *to, mode_t mode); int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); -unsigned long convert_unit(unsigned long value, char *unit); ssize_t readn(int fd, void *buf, size_t n); ssize_t writen(int fd, void *buf, size_t n); @@ -134,6 +133,4 @@ int sched_getcpu(void); int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); -int unit_number__scnprintf(char *buf, size_t size, u64 n); - #endif /* GIT_COMPAT_UTIL_H */ -- cgit v1.2.3-55-g7522 From c5e4027e056c3027f682f0d69fe9fd75083b65f8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 16:12:39 -0300 Subject: perf tools: Move timestamp routines from util.h to time-utils.h We already have a header for time utilities, so use it. Link: http://lkml.kernel.org/n/tip-sijzpbvutlg0c3oxn49hy9ca@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-buildid-cache.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/util/time-utils.c | 25 +++++++++++++++++++++++++ tools/perf/util/time-utils.h | 7 +++++++ tools/perf/util/util.c | 25 ------------------------- tools/perf/util/util.h | 6 ------ 7 files changed, 35 insertions(+), 31 deletions(-) diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 034c3d4a7b27..64b44e81c771 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -22,6 +22,7 @@ #include "util/build-id.h" #include "util/session.h" #include "util/symbol.h" +#include "util/time-utils.h" static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) { diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 2b1732cfc0be..d86ac0ac2c99 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -24,6 +24,7 @@ #ifdef HAVE_TIMERFD_SUPPORT #include #endif +#include #include #include diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 99156b4363a5..32a9a68d38a2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -38,6 +38,7 @@ #include "util/bpf-loader.h" #include "util/trigger.h" #include "util/perf-hooks.h" +#include "util/time-utils.h" #include "util/units.h" #include "asm/bug.h" diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c index d1b21c72206d..5b5d0214debd 100644 --- a/tools/perf/util/time-utils.c +++ b/tools/perf/util/time-utils.c @@ -117,3 +117,28 @@ bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp) return false; } + +int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz) +{ + u64 sec = timestamp / NSEC_PER_SEC; + u64 usec = (timestamp % NSEC_PER_SEC) / NSEC_PER_USEC; + + return scnprintf(buf, sz, "%"PRIu64".%06"PRIu64, sec, usec); +} + +int fetch_current_timestamp(char *buf, size_t sz) +{ + struct timeval tv; + struct tm tm; + char dt[32]; + + if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm)) + return -1; + + if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm)) + return -1; + + scnprintf(buf, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000); + + return 0; +} diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h index c1f197c4af6c..8656be08513b 100644 --- a/tools/perf/util/time-utils.h +++ b/tools/perf/util/time-utils.h @@ -1,6 +1,9 @@ #ifndef _TIME_UTILS_H_ #define _TIME_UTILS_H_ +#include +#include + struct perf_time_interval { u64 start, end; }; @@ -11,4 +14,8 @@ int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr); bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp); +int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); + +int fetch_current_timestamp(char *buf, size_t sz); + #endif diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 7741d5f6022b..e86dba2f791a 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -381,14 +381,6 @@ void sighandler_dump_stack(int sig) raise(sig); } -int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz) -{ - u64 sec = timestamp / NSEC_PER_SEC; - u64 usec = (timestamp % NSEC_PER_SEC) / NSEC_PER_USEC; - - return scnprintf(buf, sz, "%"PRIu64".%06"PRIu64, sec, usec); -} - unsigned long parse_tag_value(const char *str, struct parse_tag *tags) { struct parse_tag *i = tags; @@ -692,20 +684,3 @@ out: return tip; } - -int fetch_current_timestamp(char *buf, size_t sz) -{ - struct timeval tv; - struct tm tm; - char dt[32]; - - if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm)) - return -1; - - if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm)) - return -1; - - scnprintf(buf, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000); - - return 0; -} diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index add9e77369a2..dc8eb942f92b 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -20,10 +20,7 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -125,12 +122,9 @@ int fetch_kernel_version(unsigned int *puint, #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) const char *perf_tip(const char *dirpath); -int fetch_current_timestamp(char *buf, size_t sz); #ifndef HAVE_SCHED_GETCPU_SUPPORT int sched_getcpu(void); #endif -int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); - #endif /* GIT_COMPAT_UTIL_H */ -- cgit v1.2.3-55-g7522 From bb8c16db43e48f2012c3ae8c7d682f834c5986d9 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 16:15:13 -0300 Subject: perf kvm: Make function only used by 'perf kvm' static No need to have this polluting util.h, it was polluted enough already. Link: http://lkml.kernel.org/n/tip-wfdidqlwbvi5y0s61kv6z2gn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kvm.c | 14 ++++++++++++++ tools/perf/util/util.c | 14 -------------- tools/perf/util/util.h | 1 - 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index d86ac0ac2c99..129af3e9c728 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -36,6 +36,20 @@ #include #include +static const char *get_filename_for_perf_kvm(void) +{ + const char *filename; + + if (perf_host && !perf_guest) + filename = strdup("perf.data.host"); + else if (!perf_host && perf_guest) + filename = strdup("perf.data.guest"); + else + filename = strdup("perf.data.kvm"); + + return filename; +} + #ifdef HAVE_KVM_STAT_SUPPORT #include "util/kvm-stat.h" diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index e86dba2f791a..eb49330c77d4 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -496,20 +496,6 @@ int parse_callchain_record(const char *arg, struct callchain_param *param) return ret; } -const char *get_filename_for_perf_kvm(void) -{ - const char *filename; - - if (perf_host && !perf_guest) - filename = strdup("perf.data.host"); - else if (!perf_host && perf_guest) - filename = strdup("perf.data.guest"); - else - filename = strdup("perf.data.kvm"); - - return filename; -} - int perf_event_paranoid(void) { int value; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index dc8eb942f92b..c3f6d0de69c5 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -100,7 +100,6 @@ int perf_event_paranoid(void); void mem_bswap_64(void *src, int byte_size); void mem_bswap_32(void *src, int byte_size); -const char *get_filename_for_perf_kvm(void); bool find_process(const char *name); #ifdef HAVE_ZLIB_SUPPORT -- cgit v1.2.3-55-g7522 From 8c2b7cac78e17886e8089389a570a290c9b5ca67 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 16:21:59 -0300 Subject: perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h Two more out of util.h. Link: http://lkml.kernel.org/n/tip-polkuxm1cpr06lbgue5pyqum@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/debug.c | 32 +++++++++++++++++++++++++++++++- tools/perf/util/debug.h | 3 +++ tools/perf/util/util.c | 31 ------------------------------- tools/perf/util/util.h | 3 --- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 6e1d7e159649..9eaf86f4003b 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -8,7 +8,9 @@ #include #include #include - +#ifdef HAVE_BACKTRACE_SUPPORT +#include +#endif #include "cache.h" #include "color.h" #include "event.h" @@ -248,3 +250,31 @@ void perf_debug_setup(void) { libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper); } + +/* Obtain a backtrace and print it to stdout. */ +#ifdef HAVE_BACKTRACE_SUPPORT +void dump_stack(void) +{ + void *array[16]; + size_t size = backtrace(array, ARRAY_SIZE(array)); + char **strings = backtrace_symbols(array, size); + size_t i; + + printf("Obtained %zd stack frames.\n", size); + + for (i = 0; i < size; i++) + printf("%s\n", strings[i]); + + free(strings); +} +#else +void dump_stack(void) {} +#endif + +void sighandler_dump_stack(int sig) +{ + psignal(sig, "perf"); + dump_stack(); + signal(sig, SIG_DFL); + raise(sig); +} diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 98832f5531d3..8a23ea1a71c7 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -56,4 +56,7 @@ int perf_debug_option(const char *str); void perf_debug_setup(void); int perf_quiet_option(void); +void dump_stack(void); +void sighandler_dump_stack(int sig); + #endif /* __PERF_DEBUG_H */ diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index eb49330c77d4..ae8036f06329 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -4,9 +4,6 @@ #include #include #include -#ifdef HAVE_BACKTRACE_SUPPORT -#include -#endif #include #include #include @@ -353,34 +350,6 @@ int hex2u64(const char *ptr, u64 *long_val) return p - ptr; } -/* Obtain a backtrace and print it to stdout. */ -#ifdef HAVE_BACKTRACE_SUPPORT -void dump_stack(void) -{ - void *array[16]; - size_t size = backtrace(array, ARRAY_SIZE(array)); - char **strings = backtrace_symbols(array, size); - size_t i; - - printf("Obtained %zd stack frames.\n", size); - - for (i = 0; i < size; i++) - printf("%s\n", strings[i]); - - free(strings); -} -#else -void dump_stack(void) {} -#endif - -void sighandler_dump_stack(int sig) -{ - psignal(sig, "perf"); - dump_stack(); - signal(sig, SIG_DFL); - raise(sig); -} - unsigned long parse_tag_value(const char *str, struct parse_tag *tags) { struct parse_tag *i = tags; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index c3f6d0de69c5..07c4293742e7 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -80,9 +80,6 @@ void event_attr_init(struct perf_event_attr *attr); size_t hex_width(u64 v); int hex2u64(const char *ptr, u64 *val); -void dump_stack(void); -void sighandler_dump_stack(int sig); - extern unsigned int page_size; extern int cacheline_size; extern int sysctl_perf_event_max_stack; -- cgit v1.2.3-55-g7522 From 166ebdd2442660e7f942d657fc5e629000e58ec3 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Wed, 19 Apr 2017 10:49:40 -0700 Subject: perf mem: Fix display of data source snoop indication 'perf mem report' doesn't display the data source snoop indication correctly. In the kernel API the definition is: #define PERF_MEM_SNOOP_NONE 0x02 /* no snoop */ #define PERF_MEM_SNOOP_HIT 0x04 /* snoop hit */ #define PERF_MEM_SNOOP_MISS 0x08 /* snoop miss */ but the table used by the perf tools exchanged "Hit" and "Miss": "None", "Miss", "Hit", Fix the table in perf. Signed-off-by: Andi Kleen Cc: Jiri Olsa Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20170419174940.13641-1-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/mem-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index c56d52f90b54..06f5a3a4295c 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -206,8 +206,8 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) static const char * const snoop_access[] = { "N/A", "None", - "Miss", "Hit", + "Miss", "HitM", }; -- cgit v1.2.3-55-g7522 From 611f0afee0e87eb6d184e7f58aa20d18d291d169 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 16:29:38 -0300 Subject: perf tools: Add compress.h for the *_decompress_to_file() headers Out of util.h, the implementations were already in separate files, that are built conditionally. Link: http://lkml.kernel.org/n/tip-0ur7szxsb59f8758kfe63prb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/compress.h | 12 ++++++++++++ tools/perf/util/dso.c | 1 + tools/perf/util/lzma.c | 1 + tools/perf/util/util.h | 8 -------- tools/perf/util/zlib.c | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 tools/perf/util/compress.h diff --git a/tools/perf/util/compress.h b/tools/perf/util/compress.h new file mode 100644 index 000000000000..67fd1bb7c2b7 --- /dev/null +++ b/tools/perf/util/compress.h @@ -0,0 +1,12 @@ +#ifndef PERF_COMPRESS_H +#define PERF_COMPRESS_H + +#ifdef HAVE_ZLIB_SUPPORT +int gzip_decompress_to_file(const char *input, int output_fd); +#endif + +#ifdef HAVE_LZMA_SUPPORT +int lzma_decompress_to_file(const char *input, int output_fd); +#endif + +#endif /* PERF_COMPRESS_H */ diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index cbfe17f5168a..3339ab7cabc5 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -3,6 +3,7 @@ #include #include #include +#include "compress.h" #include "path.h" #include "symbol.h" #include "dso.h" diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index 5b73b268c169..4ca7c5c6cdcd 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c @@ -2,6 +2,7 @@ #include #include #include +#include "compress.h" #include "util.h" #include "debug.h" diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 07c4293742e7..5dea8a96cf84 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -99,14 +99,6 @@ void mem_bswap_32(void *src, int byte_size); bool find_process(const char *name); -#ifdef HAVE_ZLIB_SUPPORT -int gzip_decompress_to_file(const char *input, int output_fd); -#endif - -#ifdef HAVE_LZMA_SUPPORT -int lzma_decompress_to_file(const char *input, int output_fd); -#endif - int get_stack_size(const char *str, unsigned long *_size); int fetch_kernel_version(unsigned int *puint, diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c index 495a449fc25c..1329d843eb7b 100644 --- a/tools/perf/util/zlib.c +++ b/tools/perf/util/zlib.c @@ -4,6 +4,7 @@ #include #include +#include "util/compress.h" #include "util/util.h" #include "util/debug.h" -- cgit v1.2.3-55-g7522 From 56e2e05644a9494e8ba3165182dcdf43d40cc6a2 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 18:38:33 -0300 Subject: perf callchain: Move callchain specific routines from util.[ch] Where they belong, no point in leaving those in the generic "util" files. Link: http://lkml.kernel.org/n/tip-ljx3iiip1hlfa7a7apjem7ph@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 103 +++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/python.c | 13 ++++++ tools/perf/util/util.c | 104 -------------------------------------------- tools/perf/util/util.h | 4 -- 4 files changed, 116 insertions(+), 108 deletions(-) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 0096d45a06b3..81fc29ac798f 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -24,6 +24,21 @@ #include "machine.h" #include "callchain.h" +#define CALLCHAIN_PARAM_DEFAULT \ + .mode = CHAIN_GRAPH_ABS, \ + .min_percent = 0.5, \ + .order = ORDER_CALLEE, \ + .key = CCKEY_FUNCTION, \ + .value = CCVAL_PERCENT, \ + +struct callchain_param callchain_param = { + CALLCHAIN_PARAM_DEFAULT +}; + +struct callchain_param callchain_param_default = { + CALLCHAIN_PARAM_DEFAULT +}; + __thread struct callchain_cursor callchain_cursor; int parse_callchain_record_opt(const char *arg, struct callchain_param *param) @@ -113,6 +128,32 @@ static int parse_callchain_value(const char *value) return -1; } +static int get_stack_size(const char *str, unsigned long *_size) +{ + char *endptr; + unsigned long size; + unsigned long max_size = round_down(USHRT_MAX, sizeof(u64)); + + size = strtoul(str, &endptr, 0); + + do { + if (*endptr) + break; + + size = round_up(size, sizeof(u64)); + if (!size || size > max_size) + break; + + *_size = size; + return 0; + + } while (0); + + pr_err("callchain: Incorrect stack dump size (max %ld): %s\n", + max_size, str); + return -1; +} + static int __parse_callchain_report_opt(const char *arg, bool allow_record_opt) { @@ -196,6 +237,68 @@ int parse_callchain_top_opt(const char *arg) return __parse_callchain_report_opt(arg, true); } +int parse_callchain_record(const char *arg, struct callchain_param *param) +{ + char *tok, *name, *saveptr = NULL; + char *buf; + int ret = -1; + + /* We need buffer that we know we can write to. */ + buf = malloc(strlen(arg) + 1); + if (!buf) + return -ENOMEM; + + strcpy(buf, arg); + + tok = strtok_r((char *)buf, ",", &saveptr); + name = tok ? : (char *)buf; + + do { + /* Framepointer style */ + if (!strncmp(name, "fp", sizeof("fp"))) { + if (!strtok_r(NULL, ",", &saveptr)) { + param->record_mode = CALLCHAIN_FP; + ret = 0; + } else + pr_err("callchain: No more arguments " + "needed for --call-graph fp\n"); + break; + + /* Dwarf style */ + } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { + const unsigned long default_stack_dump_size = 8192; + + ret = 0; + param->record_mode = CALLCHAIN_DWARF; + param->dump_size = default_stack_dump_size; + + tok = strtok_r(NULL, ",", &saveptr); + if (tok) { + unsigned long size = 0; + + ret = get_stack_size(tok, &size); + param->dump_size = size; + } + } else if (!strncmp(name, "lbr", sizeof("lbr"))) { + if (!strtok_r(NULL, ",", &saveptr)) { + param->record_mode = CALLCHAIN_LBR; + ret = 0; + } else + pr_err("callchain: No more arguments " + "needed for --call-graph lbr\n"); + break; + } else { + pr_err("callchain: Unknown --call-graph option " + "value: %s\n", arg); + break; + } + + } while (0); + + free(buf); + return ret; +} + int perf_callchain_config(const char *var, const char *value) { char *endptr; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 0533711af44d..c129e99114ae 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -4,12 +4,25 @@ #include #include #include "evlist.h" +#include "callchain.h" #include "evsel.h" #include "event.h" #include "cpumap.h" #include "print_binary.h" #include "thread_map.h" +/* + * Provide these two so that we don't have to link against callchain.c and + * start dragging hist.c, etc. + */ +struct callchain_param callchain_param; + +int parse_callchain_record(const char *arg __maybe_unused, + struct callchain_param *param __maybe_unused) +{ + return 0; +} + /* * Support debug printing even though util/debug.c is not linked. That means * implementing 'verbose' and 'eprintf'. diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index ae8036f06329..131d21a659fb 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -17,24 +17,8 @@ #include #include #include -#include "callchain.h" #include "strlist.h" -#define CALLCHAIN_PARAM_DEFAULT \ - .mode = CHAIN_GRAPH_ABS, \ - .min_percent = 0.5, \ - .order = ORDER_CALLEE, \ - .key = CCKEY_FUNCTION, \ - .value = CCVAL_PERCENT, \ - -struct callchain_param callchain_param = { - CALLCHAIN_PARAM_DEFAULT -}; - -struct callchain_param callchain_param_default = { - CALLCHAIN_PARAM_DEFAULT -}; - /* * XXX We need to find a better place for these things... */ @@ -377,94 +361,6 @@ unsigned long parse_tag_value(const char *str, struct parse_tag *tags) return (unsigned long) -1; } -int get_stack_size(const char *str, unsigned long *_size) -{ - char *endptr; - unsigned long size; - unsigned long max_size = round_down(USHRT_MAX, sizeof(u64)); - - size = strtoul(str, &endptr, 0); - - do { - if (*endptr) - break; - - size = round_up(size, sizeof(u64)); - if (!size || size > max_size) - break; - - *_size = size; - return 0; - - } while (0); - - pr_err("callchain: Incorrect stack dump size (max %ld): %s\n", - max_size, str); - return -1; -} - -int parse_callchain_record(const char *arg, struct callchain_param *param) -{ - char *tok, *name, *saveptr = NULL; - char *buf; - int ret = -1; - - /* We need buffer that we know we can write to. */ - buf = malloc(strlen(arg) + 1); - if (!buf) - return -ENOMEM; - - strcpy(buf, arg); - - tok = strtok_r((char *)buf, ",", &saveptr); - name = tok ? : (char *)buf; - - do { - /* Framepointer style */ - if (!strncmp(name, "fp", sizeof("fp"))) { - if (!strtok_r(NULL, ",", &saveptr)) { - param->record_mode = CALLCHAIN_FP; - ret = 0; - } else - pr_err("callchain: No more arguments " - "needed for --call-graph fp\n"); - break; - - /* Dwarf style */ - } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { - const unsigned long default_stack_dump_size = 8192; - - ret = 0; - param->record_mode = CALLCHAIN_DWARF; - param->dump_size = default_stack_dump_size; - - tok = strtok_r(NULL, ",", &saveptr); - if (tok) { - unsigned long size = 0; - - ret = get_stack_size(tok, &size); - param->dump_size = size; - } - } else if (!strncmp(name, "lbr", sizeof("lbr"))) { - if (!strtok_r(NULL, ",", &saveptr)) { - param->record_mode = CALLCHAIN_LBR; - ret = 0; - } else - pr_err("callchain: No more arguments " - "needed for --call-graph lbr\n"); - break; - } else { - pr_err("callchain: Unknown --call-graph option " - "value: %s\n", arg); - break; - } - - } while (0); - - free(buf); - return ret; -} - int perf_event_paranoid(void) { int value; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 5dea8a96cf84..fcad17ce5c19 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -25,7 +24,6 @@ #include #include #include -#include #include extern char buildid_dir[]; @@ -99,8 +97,6 @@ void mem_bswap_32(void *src, int byte_size); bool find_process(const char *name); -int get_stack_size(const char *str, unsigned long *_size); - int fetch_kernel_version(unsigned int *puint, char *str, size_t str_sz); #define KVER_VERSION(x) (((x) >> 16) & 0xff) -- cgit v1.2.3-55-g7522 From 391e42060098a743a87380ed02bf4c8126742b04 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 18:51:14 -0300 Subject: perf tools: Include sys/param.h where needed As it is going away from util.h, where it is not needed. This is mostly for things like MAXPATHLEN, MAX() and MIN(), these later two probably should go away in favor of its kernel sources replacements. Link: http://lkml.kernel.org/n/tip-z1666f3fl3fqobxvjr5o2r39@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/tests/attr.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/util/config.c | 1 + tools/perf/util/header.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/util.h | 1 - 9 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index a90c1260f49e..a14be1cd3d70 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "util.h" #include "debug.h" #include "builtin.h" diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 76a88bdeebe4..b093a3c21e40 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "sane_ctype.h" diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index ba87cd529bfc..c19e0da54337 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "../perf.h" #include "util.h" #include diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 3a8bf1565493..1f14e7612cbb 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "parse-events.h" #include "evlist.h" diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index f5604039cbe4..07d87d2dbee7 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -9,6 +9,7 @@ * */ #include +#include #include "util.h" #include "cache.h" #include diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 28a3acb7b313..915bc4f39482 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2,6 +2,7 @@ #include #include "util.h" #include "string2.h" +#include #include #include #include diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 65d42758aadd..2944458b9edf 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -12,6 +12,7 @@ #include "ui/progress.h" #include #include +#include static bool hists__filter_entry_by_dso(struct hists *hists, struct hist_entry *he); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 7d84338b19ee..4f7e42e18f8a 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "term.h" #include "../perf.h" #include "evlist.h" diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index fcad17ce5c19..4e2afd6427cd 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3-55-g7522 From bf6733432dd8d92ffd687d6ce014a37923ba8105 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 18:58:26 -0300 Subject: perf tools: Remove a few more needless includes from util.h Link: http://lkml.kernel.org/n/tip-sb2zu21d6h42e5qnsrtl6wuu@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 4e2afd6427cd..0df20a3973da 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -10,18 +10,14 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include #include #include -#include #include #include -- cgit v1.2.3-55-g7522 From 86a5e0c2028899465a129d87f60fe4018c5ae839 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 19:03:14 -0300 Subject: perf tools: Remove sys/ioctl.h from util.h Not needed in this header, added to the places that need 'struct winsize' and the ioctl defines. Link: http://lkml.kernel.org/n/tip-2pznlli3146y4242otlcm70m@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/top.h | 2 +- tools/perf/util/util.h | 1 - 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 5eb638fd003f..46c0faf6c502 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -25,6 +25,7 @@ #include "parse-events.h" #include +#include #include #include diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 44a7aef3911b..0e879097adfb 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "asm/bug.h" #include "callchain.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 4f7e42e18f8a..01e779b91c8e 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "term.h" #include "../perf.h" diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index b2940c88734a..9bdfb78a9a35 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include struct perf_evlist; struct perf_evsel; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 0df20a3973da..c014b2fc22b3 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -18,7 +18,6 @@ #include #include #include -#include #include extern char buildid_dir[]; -- cgit v1.2.3-55-g7522 From 72f7c4d22ccf7c7e78aa80ea3285e77404b31913 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 19:06:30 -0300 Subject: perf tools: Remove string.h from util.h Not needed in this header, added to the places that need strdup, strcmp and a few other prototypes. Link: http://lkml.kernel.org/n/tip-t24yy85xnlv55kyosrum2ubs@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/comm.c | 1 + tools/perf/util/namespaces.c | 1 + tools/perf/util/util.h | 1 - tools/perf/util/xyarray.c | 2 ++ 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c index 530a62a7b51e..7bc981b6bf29 100644 --- a/tools/perf/util/comm.c +++ b/tools/perf/util/comm.c @@ -3,6 +3,7 @@ #include #include #include +#include #include struct comm_str { diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c index 2de8da64d90c..67dcbcc73c7d 100644 --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c @@ -11,6 +11,7 @@ #include "event.h" #include #include +#include struct namespaces *namespaces__new(struct namespaces_event *event) { diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index c014b2fc22b3..b8dfbe1d9670 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c index c10ba41ef3f6..7251fdbabced 100644 --- a/tools/perf/util/xyarray.c +++ b/tools/perf/util/xyarray.c @@ -1,5 +1,7 @@ #include "xyarray.h" #include "util.h" +#include +#include struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) { -- cgit v1.2.3-55-g7522 From a3b70b3bb34296a63b43614f13991111eccbb44a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 20:46:41 -0300 Subject: perf tools: Remove stale prototypes from builtin.h Some, like prune_packed_objects() are clearly git specific, others don't have implementations and some are used in just one place, make them static. Link: http://lkml.kernel.org/n/tip-faj3c5dnttf3hurv4pujut8n@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin.h | 4 ---- tools/perf/perf.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h index 26669bf9129c..d4d19fe3d050 100644 --- a/tools/perf/builtin.h +++ b/tools/perf/builtin.h @@ -2,16 +2,12 @@ #define BUILTIN_H #include "util/util.h" -#include "util/strbuf.h" extern const char perf_usage_string[]; extern const char perf_more_info_string[]; void list_common_cmds_help(void); const char *help_unknown_cmd(const char *cmd); -void prune_packed_objects(int); -int read_line_with_nul(char *buf, int size, FILE *file); -int check_pager_config(const char *cmd); int cmd_annotate(int argc, const char **argv); int cmd_bench(int argc, const char **argv); diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 356588982d08..0b2cad0fb3f9 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -91,7 +91,7 @@ static int pager_command_config(const char *var, const char *value, void *data) } /* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */ -int check_pager_config(const char *cmd) +static int check_pager_config(const char *cmd) { int err; struct pager_config c; -- cgit v1.2.3-55-g7522 From 7a8ef4c4b5fd5c578da4dadbcb1c5da650426c74 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 20:57:47 -0300 Subject: perf tools: Remove string.h, unistd.h and sys/stat.h from util.h Not needed in this header, added to the places that need FILE, putchar(), access() and a few other prototypes. Link: http://lkml.kernel.org/n/tip-xxtdsl6nsna82j7puwbdjqhs@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/subcmd/help.h | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/arm64/util/dwarf-regs.c | 1 + tools/perf/builtin-help.c | 4 ++++ tools/perf/builtin-mem.c | 3 +++ tools/perf/builtin-report.c | 3 +++ tools/perf/builtin-script.c | 3 +++ tools/perf/builtin-stat.c | 3 +++ tools/perf/builtin-version.c | 3 ++- tools/perf/perf.c | 3 +++ tools/perf/tests/attr.c | 3 +++ tools/perf/tests/bpf.c | 2 ++ tools/perf/tests/parse-events.c | 3 +++ tools/perf/util/build-id.c | 2 ++ tools/perf/util/color.h | 2 ++ tools/perf/util/config.c | 3 +++ tools/perf/util/dso.c | 3 +++ tools/perf/util/event.c | 3 +++ tools/perf/util/header.c | 3 +++ tools/perf/util/machine.c | 3 +++ tools/perf/util/pmu.c | 1 + tools/perf/util/probe-file.c | 3 +++ tools/perf/util/strlist.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/util.h | 3 --- 25 files changed, 57 insertions(+), 4 deletions(-) diff --git a/tools/lib/subcmd/help.h b/tools/lib/subcmd/help.h index e145a020780c..9bd4223dc722 100644 --- a/tools/lib/subcmd/help.h +++ b/tools/lib/subcmd/help.h @@ -2,6 +2,7 @@ #define __SUBCMD_HELP_H #include +#include struct cmdnames { size_t alloc; diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index dfea6b635525..29361d9b635a 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -33,6 +33,7 @@ #include "../../util/cs-etm.h" #include +#include #define ENABLE_SINK_MAX 128 #define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c index f268720ff021..cd764a9fd098 100644 --- a/tools/perf/arch/arm64/util/dwarf-regs.c +++ b/tools/perf/arch/arm64/util/dwarf-regs.c @@ -10,6 +10,7 @@ #include #include +#include #include #include /* for struct user_pt_regs */ #include diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 7bde2f59dac2..492f8e14ab09 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -14,6 +14,10 @@ #include "util/debug.h" #include #include +#include +#include +#include +#include static struct man_viewer_list { struct man_viewer_list *next; diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 1ebc67390898..2e5be1d63af6 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -1,4 +1,7 @@ #include +#include +#include +#include #include "builtin.h" #include "perf.h" diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 3f89e0eaf0d4..22478ff2b706 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -46,6 +46,9 @@ #include #include #include +#include +#include +#include struct report { struct perf_tool tool; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index b093a3c21e40..d05aec491cff 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -37,6 +37,9 @@ #include #include #include +#include +#include +#include #include "sane_ctype.h" diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index e3837febb4ff..eb3cc0b9a9e4 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -76,6 +76,9 @@ #include #include #include +#include +#include +#include #include "sane_ctype.h" diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c index b9a095b1db99..d25149456a2f 100644 --- a/tools/perf/builtin-version.c +++ b/tools/perf/builtin-version.c @@ -1,6 +1,7 @@ -#include "util/util.h" #include "builtin.h" #include "perf.h" +#include +#include int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused) { diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 0b2cad0fb3f9..4cc6960f6226 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -24,6 +24,9 @@ #include #include #include +#include +#include +#include #include const char perf_usage_string[] = diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index c19e0da54337..0dd77494bb58 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include "../perf.h" #include "util.h" #include diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index b78fbd611a7c..5876da126b58 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 981d2bf9914f..7fad885491c5 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -7,6 +7,9 @@ #include "util.h" #include #include +#include +#include +#include #include #include #include diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 923ea290bb6e..687b5add4bde 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include "build-id.h" #include "event.h" #include "symbol.h" diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index a93997f16dec..52122bcc3170 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -1,6 +1,8 @@ #ifndef __PERF_COLOR_H #define __PERF_COLOR_H +#include + /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ #define COLOR_MAXLEN 24 diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 07d87d2dbee7..8d724f0fa5a8 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -16,6 +16,9 @@ #include "util/hist.h" /* perf_hist_config */ #include "util/llvm-utils.h" /* perf_llvm_config */ #include "config.h" +#include +#include +#include #include "sane_ctype.h" diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 3339ab7cabc5..a96a99d2369f 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -2,6 +2,9 @@ #include #include #include +#include +#include +#include #include #include "compress.h" #include "path.h" diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index cf457ef534da..2e829ac0f615 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -3,6 +3,9 @@ #include #include #include +#include +#include +#include #include /* To get things like MAP_HUGETLB even on older libc headers */ #include #include "event.h" diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 915bc4f39482..948b2c5efb65 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -11,7 +11,10 @@ #include #include #include +#include +#include #include +#include #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 988e84ce6f88..7a47f52ccfcc 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -14,6 +14,9 @@ #include "thread.h" #include "vdso.h" #include +#include +#include +#include #include "unwind.h" #include "linux/hash.h" #include "asm/bug.h" diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index bca1844594d0..ac16a9db1fb5 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 685653f2bc32..d679389e627c 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -15,7 +15,10 @@ * */ #include +#include +#include #include +#include #include "util.h" #include "event.h" #include "strlist.h" diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c index 0d3dfcb919b4..9de5434bb49e 100644 --- a/tools/perf/util/strlist.c +++ b/tools/perf/util/strlist.c @@ -10,6 +10,7 @@ #include #include #include +#include static struct rb_node *strlist__node_new(struct rblist *rblist, const void *entry) diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 131d21a659fb..6450c75a6f5b 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -3,6 +3,7 @@ #include "debug.h" #include #include +#include #include #include #include diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index b8dfbe1d9670..bd883f25b76e 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -7,9 +7,6 @@ #define _DEFAULT_SOURCE 1 #define HAS_BOOL -#include -#include -#include #include #include #include -- cgit v1.2.3-55-g7522 From 4208735d8de58f1cbc2e0009d87514ce06681e5a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 19:06:30 -0300 Subject: perf tools: Remove poll.h and wait.h from util.h Not needed in this header, added to the places that need poll(), wait() and a few other prototypes. Link: http://lkml.kernel.org/n/tip-i39c7b6xmo1vwd9wxp6fmkl0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/tests/intel-cqm.c | 1 + tools/perf/builtin-ftrace.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-record.c | 2 ++ tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/util/debug.c | 1 + tools/perf/util/help-unknown-cmd.c | 1 + tools/perf/util/llvm-utils.c | 1 + tools/perf/util/util.h | 2 -- 12 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c index befde6708c33..f9713a71d77e 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 0f34ab7a9ec1..9e0b35cd0eea 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "debug.h" #include diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 129af3e9c728..f309c3773522 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 32a9a68d38a2..ee7d0a82ccd0 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -44,10 +44,12 @@ #include #include +#include #include #include #include #include +#include #include #include diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index eb3cc0b9a9e4..a935b5023732 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -78,6 +78,7 @@ #include #include #include +#include #include #include "sane_ctype.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index ef3613f2fe6a..eaa66fb57347 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -45,6 +45,7 @@ #include #include #include /* FIXME: Still needed for audit_errno_to_name */ +#include #include #include #include diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 552fd9aca08d..9e08d297f1a9 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "builtin.h" #include "hist.h" #include "intlist.h" diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 4683514751d6..634f20c631d8 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "tests.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 9eaf86f4003b..a5b3777ffee6 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #ifdef HAVE_BACKTRACE_SUPPORT diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c index 34201440ac03..1c88ad6425b8 100644 --- a/tools/perf/util/help-unknown-cmd.c +++ b/tools/perf/util/help-unknown-cmd.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include #include #include #include "../builtin.h" diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c index 824356488ce6..c6a15f204c03 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c @@ -12,6 +12,7 @@ #include "llvm-utils.h" #include "config.h" #include "util.h" +#include #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index bd883f25b76e..3852b6d3270a 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include extern char buildid_dir[]; -- cgit v1.2.3-55-g7522 From e8b3ae40151e94e30a82c2cf8efa5ab4f99c8abf Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 21:33:07 -0300 Subject: perf tools: Add the right header to obtain PERF_ALIGN() The util/event.h header needs PERF_ALIGN(), but wasn't including linux/kernel.h, where it is defined, instead it was getting it by luck by including map.h, which it doesn't need at all. Fix it by including the right header. Link: http://lkml.kernel.org/n/tip-nf3t9blzm5ncoxsczi8oy9mx@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index eb7a7b200737..db2de6413518 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -3,9 +3,9 @@ #include #include +#include #include "../perf.h" -#include "map.h" #include "build-id.h" #include "perf_regs.h" -- cgit v1.2.3-55-g7522 From e7ff8920e62f0188e77b1dc5dc5d9a7322c342d7 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 19 Apr 2017 21:34:35 -0300 Subject: perf tools: Use just forward declarations for struct thread where possible Removing various instances of unnecessary includes, reducing the maze of header dependencies. Link: http://lkml.kernel.org/n/tip-hwu6eyuok9pc57alookyzmsf@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/unwind-libdw.c | 1 + tools/perf/arch/x86/util/unwind-libdw.c | 1 + tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/session.h | 3 +-- tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 3 ++- tools/perf/util/unwind-libdw.h | 6 ++++-- 15 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/perf/arch/arm/util/unwind-libdw.c b/tools/perf/arch/arm/util/unwind-libdw.c index b4176c60117a..bacfa00fca39 100644 --- a/tools/perf/arch/arm/util/unwind-libdw.c +++ b/tools/perf/arch/arm/util/unwind-libdw.c @@ -1,6 +1,7 @@ #include #include "../../util/unwind-libdw.h" #include "../../util/perf_regs.h" +#include "../../util/event.h" bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) { diff --git a/tools/perf/arch/x86/util/unwind-libdw.c b/tools/perf/arch/x86/util/unwind-libdw.c index c4b72176ca83..38dc9bb2a7c9 100644 --- a/tools/perf/arch/x86/util/unwind-libdw.c +++ b/tools/perf/arch/x86/util/unwind-libdw.c @@ -1,6 +1,7 @@ #include #include "../../util/unwind-libdw.h" #include "../../util/perf_regs.h" +#include "../../util/event.h" bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) { diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index a14be1cd3d70..e33b4acece90 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -32,6 +32,7 @@ #include #include "ui/browsers/hists.h" #include "evlist.h" +#include "thread.h" struct c2c_hists { struct hists hists; diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 8bd791cca008..ea8db38eedd1 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -18,6 +18,7 @@ #include "util/data.h" #include "util/auxtrace.h" #include "util/jit.h" +#include "util/thread.h" #include diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 2e5be1d63af6..e001c0290793 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -12,6 +12,7 @@ #include "util/data.h" #include "util/mem-events.h" #include "util/debug.h" +#include "util/symbol.h" #define MEM_OPERATION_LOAD 0x1 #define MEM_OPERATION_STORE 0x2 diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 38e2c437b7b3..4e2e61695986 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -29,6 +29,7 @@ #include #include #include "util/symbol.h" +#include "util/thread.h" #include "util/callchain.h" #include "perf.h" diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 1b12a69740b3..69f4570bd4f9 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -14,6 +14,7 @@ #include "../../util/sort.h" #include "../../util/util.h" #include "../../util/top.h" +#include "../../util/thread.h" #include "../../arch/common.h" #include "../browsers/hists.h" diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 5565105c9688..42e432bd2eb4 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -6,6 +6,7 @@ #include "../../util/evsel.h" #include "../../util/srcline.h" #include "../../util/string2.h" +#include "../../util/thread.h" #include "../../util/sane_ctype.h" static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 687b5add4bde..168cc49654e7 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -15,6 +15,7 @@ #include "build-id.h" #include "event.h" #include "symbol.h" +#include "thread.h" #include #include "debug.h" #include "session.h" diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 2944458b9edf..cf0186a088c1 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -9,6 +9,7 @@ #include "evsel.h" #include "annotate.h" #include "srcline.h" +#include "thread.h" #include "ui/progress.h" #include #include diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 19d993f2a305..3041c6b98191 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -19,6 +19,7 @@ #include "perf_regs.h" #include "asm/bug.h" #include "auxtrace.h" +#include "thread.h" #include "thread-stack.h" #include "stat.h" diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 1ffae42f76a1..47b5e7dbcb18 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -5,8 +5,6 @@ #include "event.h" #include "header.h" #include "machine.h" -#include "symbol.h" -#include "thread.h" #include "data.h" #include "ordered-events.h" #include @@ -14,6 +12,7 @@ #include struct ip_callchain; +struct symbol; struct thread; struct auxtrace; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index fe4fd7b5f8e0..5762ae4e9e91 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -6,6 +6,7 @@ #include "hist.h" #include "comm.h" #include "symbol.h" +#include "thread.h" #include "evsel.h" #include "evlist.h" #include "strlist.h" diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 8bcec05ee578..b7c75597e18f 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -21,7 +21,8 @@ #include "parse-events.h" #include "hist.h" #include "srcline.h" -#include "thread.h" + +struct thread; extern regex_t parent_regex; extern const char *sort_order; diff --git a/tools/perf/util/unwind-libdw.h b/tools/perf/util/unwind-libdw.h index 58328669ed16..4a2b269a7b3b 100644 --- a/tools/perf/util/unwind-libdw.h +++ b/tools/perf/util/unwind-libdw.h @@ -2,10 +2,12 @@ #define __PERF_UNWIND_LIBDW_H #include -#include "event.h" -#include "thread.h" #include "unwind.h" +struct machine; +struct perf_sample; +struct thread; + bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg); struct unwind_info { -- cgit v1.2.3-55-g7522 From 04ec75e0befbc60ff473ca1a593cad7501729526 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 25 Oct 2016 17:02:11 -0300 Subject: tools: Update asm-generic/mman-common.h copy from the kernel To get the changes in the commit Fixes: 3209f68b3ca4 ("statx: Include a mask for stx_attributes in struct statx") Silencing this perf build warning: Warning: tools/include/uapi/linux/stat.h differs from kernel No need to change the statx syscall beautifiers in 'perf trace' at this time. Cc: Adrian Hunter Cc: Al Viro Cc: David Ahern Cc: David Howells Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-y8bgiyzuvura62lffvh1zbg9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/uapi/linux/stat.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 51a6b86e3700..d538897b8e08 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -114,7 +114,7 @@ struct statx { __u64 stx_ino; /* Inode number */ __u64 stx_size; /* File size */ __u64 stx_blocks; /* Number of 512-byte blocks allocated */ - __u64 __spare1[1]; + __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ /* 0x40 */ struct statx_timestamp stx_atime; /* Last access time */ struct statx_timestamp stx_btime; /* File creation time */ @@ -152,9 +152,10 @@ struct statx { #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ #define STATX_ALL 0x00000fffU /* All currently supported flags */ +#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* - * Attributes to be found in stx_attributes + * Attributes to be found in stx_attributes and masked in stx_attributes_mask. * * These give information about the features or the state of a file that might * be of use to ordinary userspace programs such as GUIs or ls rather than -- cgit v1.2.3-55-g7522 From e883d09c9eb2ffddfd057c17e6a0cef446ec8c9b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 24 Apr 2017 11:58:54 -0300 Subject: tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel Just a minor fix done in: Fixes: 26a37ab319a2 ("x86/mce: Fix copy/paste error in exception table entries") Cc: Tony Luck Link: http://lkml.kernel.org/n/tip-ni9jzdd5yxlail6pq8cuexw2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/arch/x86/lib/memcpy_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S index 49e6ebac7e73..98dcc112b363 100644 --- a/tools/arch/x86/lib/memcpy_64.S +++ b/tools/arch/x86/lib/memcpy_64.S @@ -286,7 +286,7 @@ ENDPROC(memcpy_mcsafe_unrolled) _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) - _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) + _ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail) -- cgit v1.2.3-55-g7522 From fb7b75619641d778c2b778748ca5cdf2718cc024 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 24 Apr 2017 12:19:08 -0300 Subject: tools arch x86: Sync cpufeatures.h To catch changes made in: 90218ac77d05 ("x86/cpufeature: Detect CPUID faulting support") No changes needed in the tools using this file at this time. Cc: Kyle Huey Cc: Thomas Gleixner Link: http://lkml.kernel.org/n/tip-qiqsj5qg2ljbsbfre2zaf9v4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index b04bb6dfed7f..0fe00446f9ca 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h @@ -187,6 +187,7 @@ * Reuse free bits when adding new feature flags! */ #define X86_FEATURE_RING3MWAIT ( 7*32+ 0) /* Ring 3 MONITOR/MWAIT */ +#define X86_FEATURE_CPUID_FAULT ( 7*32+ 1) /* Intel CPUID faulting */ #define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ #define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ #define X86_FEATURE_CAT_L3 ( 7*32+ 4) /* Cache Allocation Technology L3 */ -- cgit v1.2.3-55-g7522 From 9d43f5e8df6804ae271407500af9062e9278167a Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Thu, 20 Apr 2017 11:24:30 +0200 Subject: perf tools: Fix the code to strip command name Recent commit broke command name strip in perf_event__get_comm_ids function. It replaced left to right search for '\n' with rtrim, which actually does right to left search. It occasionally caught earlier '\n' and kept trash in the command name. Keeping the ltrim, but moving back the left to right '\n' search instead of the rtrim. Signed-off-by: Jiri Olsa Acked-by: Taeung Song Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Yao Jin Fixes: bdd97ca63faa ("perf tools: Refactor the code to strip command name with {l,r}trim()") Link: http://lkml.kernel.org/r/20170420092430.29657-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 2e829ac0f615..142835c0ca0a 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -141,8 +141,15 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, ppids = strstr(bf, "PPid:"); if (name) { + char *nl; + name += 5; /* strlen("Name:") */ - name = rtrim(ltrim(name)); + name = ltrim(name); + + nl = strchr(name, '\n'); + if (nl) + *nl = '\0'; + size = strlen(name); if (size >= len) size = len - 1; -- cgit v1.2.3-55-g7522