diff options
195 files changed, 5661 insertions, 3655 deletions
diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt index 996ce84352cb..7cccc49b6bea 100644 --- a/Documentation/devicetree/bindings/input/gpio-keys.txt +++ b/Documentation/devicetree/bindings/input/gpio-keys.txt | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | Device-Tree bindings for input/gpio_keys.c keyboard driver | 1 | Device-Tree bindings for input/keyboard/gpio_keys.c keyboard driver |
| 2 | 2 | ||
| 3 | Required properties: | 3 | Required properties: |
| 4 | - compatible = "gpio-keys"; | 4 | - compatible = "gpio-keys"; |
diff --git a/MAINTAINERS b/MAINTAINERS index 02a39617ec82..a255240d1452 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -9716,13 +9716,6 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/ | |||
| 9716 | S: Maintained | 9716 | S: Maintained |
| 9717 | F: drivers/media/dvb-frontends/mn88473* | 9717 | F: drivers/media/dvb-frontends/mn88473* |
| 9718 | 9718 | ||
| 9719 | PCI DRIVER FOR MOBIVEIL PCIE IP | ||
| 9720 | M: Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in> | ||
| 9721 | L: linux-pci@vger.kernel.org | ||
| 9722 | S: Supported | ||
| 9723 | F: Documentation/devicetree/bindings/pci/mobiveil-pcie.txt | ||
| 9724 | F: drivers/pci/controller/pcie-mobiveil.c | ||
| 9725 | |||
| 9726 | MODULE SUPPORT | 9719 | MODULE SUPPORT |
| 9727 | M: Jessica Yu <jeyu@kernel.org> | 9720 | M: Jessica Yu <jeyu@kernel.org> |
| 9728 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux.git modules-next | 9721 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux.git modules-next |
| @@ -11137,6 +11130,13 @@ F: include/uapi/linux/switchtec_ioctl.h | |||
| 11137 | F: include/linux/switchtec.h | 11130 | F: include/linux/switchtec.h |
| 11138 | F: drivers/ntb/hw/mscc/ | 11131 | F: drivers/ntb/hw/mscc/ |
| 11139 | 11132 | ||
| 11133 | PCI DRIVER FOR MOBIVEIL PCIE IP | ||
| 11134 | M: Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in> | ||
| 11135 | L: linux-pci@vger.kernel.org | ||
| 11136 | S: Supported | ||
| 11137 | F: Documentation/devicetree/bindings/pci/mobiveil-pcie.txt | ||
| 11138 | F: drivers/pci/controller/pcie-mobiveil.c | ||
| 11139 | |||
| 11140 | PCI DRIVER FOR MVEBU (Marvell Armada 370 and Armada XP SOC support) | 11140 | PCI DRIVER FOR MVEBU (Marvell Armada 370 and Armada XP SOC support) |
| 11141 | M: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 11141 | M: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| 11142 | M: Jason Cooper <jason@lakedaemon.net> | 11142 | M: Jason Cooper <jason@lakedaemon.net> |
| @@ -11203,8 +11203,14 @@ F: tools/pci/ | |||
| 11203 | 11203 | ||
| 11204 | PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC | 11204 | PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC |
| 11205 | M: Russell Currey <ruscur@russell.cc> | 11205 | M: Russell Currey <ruscur@russell.cc> |
| 11206 | M: Sam Bobroff <sbobroff@linux.ibm.com> | ||
| 11207 | M: Oliver O'Halloran <oohall@gmail.com> | ||
| 11206 | L: linuxppc-dev@lists.ozlabs.org | 11208 | L: linuxppc-dev@lists.ozlabs.org |
| 11207 | S: Supported | 11209 | S: Supported |
| 11210 | F: Documentation/PCI/pci-error-recovery.txt | ||
| 11211 | F: drivers/pci/pcie/aer.c | ||
| 11212 | F: drivers/pci/pcie/dpc.c | ||
| 11213 | F: drivers/pci/pcie/err.c | ||
| 11208 | F: Documentation/powerpc/eeh-pci-error-recovery.txt | 11214 | F: Documentation/powerpc/eeh-pci-error-recovery.txt |
| 11209 | F: arch/powerpc/kernel/eeh*.c | 11215 | F: arch/powerpc/kernel/eeh*.c |
| 11210 | F: arch/powerpc/platforms/*/eeh*.c | 11216 | F: arch/powerpc/platforms/*/eeh*.c |
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h index 1a951b00465d..1fffbba8d6a5 100644 --- a/arch/powerpc/include/asm/setup.h +++ b/arch/powerpc/include/asm/setup.h | |||
| @@ -9,6 +9,7 @@ extern void ppc_printk_progress(char *s, unsigned short hex); | |||
| 9 | 9 | ||
| 10 | extern unsigned int rtas_data; | 10 | extern unsigned int rtas_data; |
| 11 | extern unsigned long long memory_limit; | 11 | extern unsigned long long memory_limit; |
| 12 | extern bool init_mem_is_free; | ||
| 12 | extern unsigned long klimit; | 13 | extern unsigned long klimit; |
| 13 | extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); | 14 | extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); |
| 14 | 15 | ||
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index ea04dfb8c092..2d8fc8c9da7a 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
| @@ -1314,9 +1314,7 @@ EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100) | |||
| 1314 | 1314 | ||
| 1315 | #ifdef CONFIG_PPC_DENORMALISATION | 1315 | #ifdef CONFIG_PPC_DENORMALISATION |
| 1316 | mfspr r10,SPRN_HSRR1 | 1316 | mfspr r10,SPRN_HSRR1 |
| 1317 | mfspr r11,SPRN_HSRR0 /* save HSRR0 */ | ||
| 1318 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ | 1317 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ |
| 1319 | addi r11,r11,-4 /* HSRR0 is next instruction */ | ||
| 1320 | bne+ denorm_assist | 1318 | bne+ denorm_assist |
| 1321 | #endif | 1319 | #endif |
| 1322 | 1320 | ||
| @@ -1382,6 +1380,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |||
| 1382 | */ | 1380 | */ |
| 1383 | XVCPSGNDP32(32) | 1381 | XVCPSGNDP32(32) |
| 1384 | denorm_done: | 1382 | denorm_done: |
| 1383 | mfspr r11,SPRN_HSRR0 | ||
| 1384 | subi r11,r11,4 | ||
| 1385 | mtspr SPRN_HSRR0,r11 | 1385 | mtspr SPRN_HSRR0,r11 |
| 1386 | mtcrf 0x80,r9 | 1386 | mtcrf 0x80,r9 |
| 1387 | ld r9,PACA_EXGEN+EX_R9(r13) | 1387 | ld r9,PACA_EXGEN+EX_R9(r13) |
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S index 6bffbc5affe7..7716374786bd 100644 --- a/arch/powerpc/kernel/tm.S +++ b/arch/powerpc/kernel/tm.S | |||
| @@ -176,13 +176,27 @@ _GLOBAL(tm_reclaim) | |||
| 176 | std r1, PACATMSCRATCH(r13) | 176 | std r1, PACATMSCRATCH(r13) |
| 177 | ld r1, PACAR1(r13) | 177 | ld r1, PACAR1(r13) |
| 178 | 178 | ||
| 179 | /* Store the PPR in r11 and reset to decent value */ | ||
| 180 | std r11, GPR11(r1) /* Temporary stash */ | 179 | std r11, GPR11(r1) /* Temporary stash */ |
| 181 | 180 | ||
| 181 | /* | ||
| 182 | * Move the saved user r1 to the kernel stack in case PACATMSCRATCH is | ||
| 183 | * clobbered by an exception once we turn on MSR_RI below. | ||
| 184 | */ | ||
| 185 | ld r11, PACATMSCRATCH(r13) | ||
| 186 | std r11, GPR1(r1) | ||
| 187 | |||
| 188 | /* | ||
| 189 | * Store r13 away so we can free up the scratch SPR for the SLB fault | ||
| 190 | * handler (needed once we start accessing the thread_struct). | ||
| 191 | */ | ||
| 192 | GET_SCRATCH0(r11) | ||
| 193 | std r11, GPR13(r1) | ||
| 194 | |||
| 182 | /* Reset MSR RI so we can take SLB faults again */ | 195 | /* Reset MSR RI so we can take SLB faults again */ |
| 183 | li r11, MSR_RI | 196 | li r11, MSR_RI |
| 184 | mtmsrd r11, 1 | 197 | mtmsrd r11, 1 |
| 185 | 198 | ||
| 199 | /* Store the PPR in r11 and reset to decent value */ | ||
| 186 | mfspr r11, SPRN_PPR | 200 | mfspr r11, SPRN_PPR |
| 187 | HMT_MEDIUM | 201 | HMT_MEDIUM |
| 188 | 202 | ||
| @@ -207,11 +221,11 @@ _GLOBAL(tm_reclaim) | |||
| 207 | SAVE_GPR(8, r7) /* user r8 */ | 221 | SAVE_GPR(8, r7) /* user r8 */ |
| 208 | SAVE_GPR(9, r7) /* user r9 */ | 222 | SAVE_GPR(9, r7) /* user r9 */ |
| 209 | SAVE_GPR(10, r7) /* user r10 */ | 223 | SAVE_GPR(10, r7) /* user r10 */ |
| 210 | ld r3, PACATMSCRATCH(r13) /* user r1 */ | 224 | ld r3, GPR1(r1) /* user r1 */ |
| 211 | ld r4, GPR7(r1) /* user r7 */ | 225 | ld r4, GPR7(r1) /* user r7 */ |
| 212 | ld r5, GPR11(r1) /* user r11 */ | 226 | ld r5, GPR11(r1) /* user r11 */ |
| 213 | ld r6, GPR12(r1) /* user r12 */ | 227 | ld r6, GPR12(r1) /* user r12 */ |
| 214 | GET_SCRATCH0(8) /* user r13 */ | 228 | ld r8, GPR13(r1) /* user r13 */ |
| 215 | std r3, GPR1(r7) | 229 | std r3, GPR1(r7) |
| 216 | std r4, GPR7(r7) | 230 | std r4, GPR7(r7) |
| 217 | std r5, GPR11(r7) | 231 | std r5, GPR11(r7) |
diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S index 886ed94b9c13..d05c8af4ac51 100644 --- a/arch/powerpc/lib/checksum_64.S +++ b/arch/powerpc/lib/checksum_64.S | |||
| @@ -443,6 +443,9 @@ _GLOBAL(csum_ipv6_magic) | |||
| 443 | addc r0, r8, r9 | 443 | addc r0, r8, r9 |
| 444 | ld r10, 0(r4) | 444 | ld r10, 0(r4) |
| 445 | ld r11, 8(r4) | 445 | ld r11, 8(r4) |
| 446 | #ifdef CONFIG_CPU_LITTLE_ENDIAN | ||
| 447 | rotldi r5, r5, 8 | ||
| 448 | #endif | ||
| 446 | adde r0, r0, r10 | 449 | adde r0, r0, r10 |
| 447 | add r5, r5, r7 | 450 | add r5, r5, r7 |
| 448 | adde r0, r0, r11 | 451 | adde r0, r0, r11 |
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 850f3b8f4da5..6ae2777c220d 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c | |||
| @@ -28,6 +28,12 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr, | |||
| 28 | { | 28 | { |
| 29 | int err; | 29 | int err; |
| 30 | 30 | ||
| 31 | /* Make sure we aren't patching a freed init section */ | ||
| 32 | if (init_mem_is_free && init_section_contains(exec_addr, 4)) { | ||
| 33 | pr_debug("Skipping init section patching addr: 0x%px\n", exec_addr); | ||
| 34 | return 0; | ||
| 35 | } | ||
| 36 | |||
| 31 | __put_user_size(instr, patch_addr, 4, err); | 37 | __put_user_size(instr, patch_addr, 4, err); |
| 32 | if (err) | 38 | if (err) |
| 33 | return err; | 39 | return err; |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 5c8530d0c611..04ccb274a620 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
| @@ -63,6 +63,7 @@ | |||
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | unsigned long long memory_limit; | 65 | unsigned long long memory_limit; |
| 66 | bool init_mem_is_free; | ||
| 66 | 67 | ||
| 67 | #ifdef CONFIG_HIGHMEM | 68 | #ifdef CONFIG_HIGHMEM |
| 68 | pte_t *kmap_pte; | 69 | pte_t *kmap_pte; |
| @@ -396,6 +397,7 @@ void free_initmem(void) | |||
| 396 | { | 397 | { |
| 397 | ppc_md.progress = ppc_printk_progress; | 398 | ppc_md.progress = ppc_printk_progress; |
| 398 | mark_initmem_nx(); | 399 | mark_initmem_nx(); |
| 400 | init_mem_is_free = true; | ||
| 399 | free_initmem_default(POISON_FREE_INITMEM); | 401 | free_initmem_default(POISON_FREE_INITMEM); |
| 400 | } | 402 | } |
| 401 | 403 | ||
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 35ac5422903a..59d07bd5374a 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
| @@ -1204,7 +1204,9 @@ int find_and_online_cpu_nid(int cpu) | |||
| 1204 | int new_nid; | 1204 | int new_nid; |
| 1205 | 1205 | ||
| 1206 | /* Use associativity from first thread for all siblings */ | 1206 | /* Use associativity from first thread for all siblings */ |
| 1207 | vphn_get_associativity(cpu, associativity); | 1207 | if (vphn_get_associativity(cpu, associativity)) |
| 1208 | return cpu_to_node(cpu); | ||
| 1209 | |||
| 1208 | new_nid = associativity_to_nid(associativity); | 1210 | new_nid = associativity_to_nid(associativity); |
| 1209 | if (new_nid < 0 || !node_possible(new_nid)) | 1211 | if (new_nid < 0 || !node_possible(new_nid)) |
| 1210 | new_nid = first_online_node; | 1212 | new_nid = first_online_node; |
| @@ -1452,7 +1454,8 @@ static struct timer_list topology_timer; | |||
| 1452 | 1454 | ||
| 1453 | static void reset_topology_timer(void) | 1455 | static void reset_topology_timer(void) |
| 1454 | { | 1456 | { |
| 1455 | mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ); | 1457 | if (vphn_enabled) |
| 1458 | mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ); | ||
| 1456 | } | 1459 | } |
| 1457 | 1460 | ||
| 1458 | #ifdef CONFIG_SMP | 1461 | #ifdef CONFIG_SMP |
diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 333b1f80c435..b271b283c785 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c | |||
| @@ -45,7 +45,7 @@ static void scan_pkey_feature(void) | |||
| 45 | * Since any pkey can be used for data or execute, we will just treat | 45 | * Since any pkey can be used for data or execute, we will just treat |
| 46 | * all keys as equal and track them as one entity. | 46 | * all keys as equal and track them as one entity. |
| 47 | */ | 47 | */ |
| 48 | pkeys_total = be32_to_cpu(vals[0]); | 48 | pkeys_total = vals[0]; |
| 49 | pkeys_devtree_defined = true; | 49 | pkeys_devtree_defined = true; |
| 50 | } | 50 | } |
| 51 | 51 | ||
diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c index 6c5db1acbe8d..fe9691040f54 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c +++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c | |||
| @@ -276,7 +276,7 @@ long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, | |||
| 276 | level_shift = entries_shift + 3; | 276 | level_shift = entries_shift + 3; |
| 277 | level_shift = max_t(unsigned int, level_shift, PAGE_SHIFT); | 277 | level_shift = max_t(unsigned int, level_shift, PAGE_SHIFT); |
| 278 | 278 | ||
| 279 | if ((level_shift - 3) * levels + page_shift >= 60) | 279 | if ((level_shift - 3) * levels + page_shift >= 55) |
| 280 | return -EINVAL; | 280 | return -EINVAL; |
| 281 | 281 | ||
| 282 | /* Allocate TCE table */ | 282 | /* Allocate TCE table */ |
diff --git a/arch/riscv/include/asm/asm-prototypes.h b/arch/riscv/include/asm/asm-prototypes.h new file mode 100644 index 000000000000..c9fecd120d18 --- /dev/null +++ b/arch/riscv/include/asm/asm-prototypes.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef _ASM_RISCV_PROTOTYPES_H | ||
| 3 | |||
| 4 | #include <linux/ftrace.h> | ||
| 5 | #include <asm-generic/asm-prototypes.h> | ||
| 6 | |||
| 7 | #endif /* _ASM_RISCV_PROTOTYPES_H */ | ||
diff --git a/arch/x86/boot/compressed/mem_encrypt.S b/arch/x86/boot/compressed/mem_encrypt.S index eaa843a52907..a480356e0ed8 100644 --- a/arch/x86/boot/compressed/mem_encrypt.S +++ b/arch/x86/boot/compressed/mem_encrypt.S | |||
| @@ -25,20 +25,6 @@ ENTRY(get_sev_encryption_bit) | |||
| 25 | push %ebx | 25 | push %ebx |
| 26 | push %ecx | 26 | push %ecx |
| 27 | push %edx | 27 | push %edx |
| 28 | push %edi | ||
| 29 | |||
| 30 | /* | ||
| 31 | * RIP-relative addressing is needed to access the encryption bit | ||
| 32 | * variable. Since we are running in 32-bit mode we need this call/pop | ||
| 33 | * sequence to get the proper relative addressing. | ||
| 34 | */ | ||
| 35 | call 1f | ||
| 36 | 1: popl %edi | ||
| 37 | subl $1b, %edi | ||
| 38 | |||
| 39 | movl enc_bit(%edi), %eax | ||
| 40 | cmpl $0, %eax | ||
| 41 | jge .Lsev_exit | ||
| 42 | 28 | ||
| 43 | /* Check if running under a hypervisor */ | 29 | /* Check if running under a hypervisor */ |
| 44 | movl $1, %eax | 30 | movl $1, %eax |
| @@ -69,15 +55,12 @@ ENTRY(get_sev_encryption_bit) | |||
| 69 | 55 | ||
| 70 | movl %ebx, %eax | 56 | movl %ebx, %eax |
| 71 | andl $0x3f, %eax /* Return the encryption bit location */ | 57 | andl $0x3f, %eax /* Return the encryption bit location */ |
| 72 | movl %eax, enc_bit(%edi) | ||
| 73 | jmp .Lsev_exit | 58 | jmp .Lsev_exit |
| 74 | 59 | ||
| 75 | .Lno_sev: | 60 | .Lno_sev: |
| 76 | xor %eax, %eax | 61 | xor %eax, %eax |
| 77 | movl %eax, enc_bit(%edi) | ||
| 78 | 62 | ||
| 79 | .Lsev_exit: | 63 | .Lsev_exit: |
| 80 | pop %edi | ||
| 81 | pop %edx | 64 | pop %edx |
| 82 | pop %ecx | 65 | pop %ecx |
| 83 | pop %ebx | 66 | pop %ebx |
| @@ -113,8 +96,6 @@ ENTRY(set_sev_encryption_mask) | |||
| 113 | ENDPROC(set_sev_encryption_mask) | 96 | ENDPROC(set_sev_encryption_mask) |
| 114 | 97 | ||
| 115 | .data | 98 | .data |
| 116 | enc_bit: | ||
| 117 | .int 0xffffffff | ||
| 118 | 99 | ||
| 119 | #ifdef CONFIG_AMD_MEM_ENCRYPT | 100 | #ifdef CONFIG_AMD_MEM_ENCRYPT |
| 120 | .balign 8 | 101 | .balign 8 |
diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 981ba5e8241b..8671de126eac 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | static int num_counters_llc; | 37 | static int num_counters_llc; |
| 38 | static int num_counters_nb; | 38 | static int num_counters_nb; |
| 39 | static bool l3_mask; | ||
| 39 | 40 | ||
| 40 | static HLIST_HEAD(uncore_unused_list); | 41 | static HLIST_HEAD(uncore_unused_list); |
| 41 | 42 | ||
| @@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event) | |||
| 209 | hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; | 210 | hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; |
| 210 | hwc->idx = -1; | 211 | hwc->idx = -1; |
| 211 | 212 | ||
| 213 | /* | ||
| 214 | * SliceMask and ThreadMask need to be set for certain L3 events in | ||
| 215 | * Family 17h. For other events, the two fields do not affect the count. | ||
| 216 | */ | ||
| 217 | if (l3_mask) | ||
| 218 | hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); | ||
| 219 | |||
| 212 | if (event->cpu < 0) | 220 | if (event->cpu < 0) |
| 213 | return -EINVAL; | 221 | return -EINVAL; |
| 214 | 222 | ||
| @@ -525,6 +533,7 @@ static int __init amd_uncore_init(void) | |||
| 525 | amd_llc_pmu.name = "amd_l3"; | 533 | amd_llc_pmu.name = "amd_l3"; |
| 526 | format_attr_event_df.show = &event_show_df; | 534 | format_attr_event_df.show = &event_show_df; |
| 527 | format_attr_event_l3.show = &event_show_l3; | 535 | format_attr_event_l3.show = &event_show_l3; |
| 536 | l3_mask = true; | ||
| 528 | } else { | 537 | } else { |
| 529 | num_counters_nb = NUM_COUNTERS_NB; | 538 | num_counters_nb = NUM_COUNTERS_NB; |
| 530 | num_counters_llc = NUM_COUNTERS_L2; | 539 | num_counters_llc = NUM_COUNTERS_L2; |
| @@ -532,6 +541,7 @@ static int __init amd_uncore_init(void) | |||
| 532 | amd_llc_pmu.name = "amd_l2"; | 541 | amd_llc_pmu.name = "amd_l2"; |
| 533 | format_attr_event_df = format_attr_event; | 542 | format_attr_event_df = format_attr_event; |
| 534 | format_attr_event_l3 = format_attr_event; | 543 | format_attr_event_l3 = format_attr_event; |
| 544 | l3_mask = false; | ||
| 535 | } | 545 | } |
| 536 | 546 | ||
| 537 | amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; | 547 | amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; |
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 3550d800b030..06b708494898 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
| @@ -1605,7 +1605,7 @@ static void __init pmu_check_apic(void) | |||
| 1605 | 1605 | ||
| 1606 | } | 1606 | } |
| 1607 | 1607 | ||
| 1608 | static struct attribute_group x86_pmu_format_group = { | 1608 | static struct attribute_group x86_pmu_format_group __ro_after_init = { |
| 1609 | .name = "format", | 1609 | .name = "format", |
| 1610 | .attrs = NULL, | 1610 | .attrs = NULL, |
| 1611 | }; | 1611 | }; |
| @@ -1736,7 +1736,7 @@ static struct attribute *events_attr[] = { | |||
| 1736 | NULL, | 1736 | NULL, |
| 1737 | }; | 1737 | }; |
| 1738 | 1738 | ||
| 1739 | static struct attribute_group x86_pmu_events_group = { | 1739 | static struct attribute_group x86_pmu_events_group __ro_after_init = { |
| 1740 | .name = "events", | 1740 | .name = "events", |
| 1741 | .attrs = events_attr, | 1741 | .attrs = events_attr, |
| 1742 | }; | 1742 | }; |
| @@ -2251,7 +2251,7 @@ static struct attribute *x86_pmu_attrs[] = { | |||
| 2251 | NULL, | 2251 | NULL, |
| 2252 | }; | 2252 | }; |
| 2253 | 2253 | ||
| 2254 | static struct attribute_group x86_pmu_attr_group = { | 2254 | static struct attribute_group x86_pmu_attr_group __ro_after_init = { |
| 2255 | .attrs = x86_pmu_attrs, | 2255 | .attrs = x86_pmu_attrs, |
| 2256 | }; | 2256 | }; |
| 2257 | 2257 | ||
| @@ -2269,7 +2269,7 @@ static struct attribute *x86_pmu_caps_attrs[] = { | |||
| 2269 | NULL | 2269 | NULL |
| 2270 | }; | 2270 | }; |
| 2271 | 2271 | ||
| 2272 | static struct attribute_group x86_pmu_caps_group = { | 2272 | static struct attribute_group x86_pmu_caps_group __ro_after_init = { |
| 2273 | .name = "caps", | 2273 | .name = "caps", |
| 2274 | .attrs = x86_pmu_caps_attrs, | 2274 | .attrs = x86_pmu_caps_attrs, |
| 2275 | }; | 2275 | }; |
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 8d016ce5b80d..3a0aa83cbd07 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c | |||
| @@ -95,7 +95,7 @@ static ssize_t pt_cap_show(struct device *cdev, | |||
| 95 | return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); | 95 | return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | static struct attribute_group pt_cap_group = { | 98 | static struct attribute_group pt_cap_group __ro_after_init = { |
| 99 | .name = "caps", | 99 | .name = "caps", |
| 100 | }; | 100 | }; |
| 101 | 101 | ||
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 51d7c117e3c7..c07bee31abe8 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c | |||
| @@ -3061,7 +3061,7 @@ static struct event_constraint bdx_uncore_pcu_constraints[] = { | |||
| 3061 | 3061 | ||
| 3062 | void bdx_uncore_cpu_init(void) | 3062 | void bdx_uncore_cpu_init(void) |
| 3063 | { | 3063 | { |
| 3064 | int pkg = topology_phys_to_logical_pkg(0); | 3064 | int pkg = topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id); |
| 3065 | 3065 | ||
| 3066 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) | 3066 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) |
| 3067 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; | 3067 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; |
| @@ -3931,16 +3931,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] = { | |||
| 3931 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), | 3931 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), |
| 3932 | }, | 3932 | }, |
| 3933 | { /* M3UPI0 Link 0 */ | 3933 | { /* M3UPI0 Link 0 */ |
| 3934 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), | 3934 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), |
| 3935 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, SKX_PCI_UNCORE_M3UPI, 0), | 3935 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 0), |
| 3936 | }, | 3936 | }, |
| 3937 | { /* M3UPI0 Link 1 */ | 3937 | { /* M3UPI0 Link 1 */ |
| 3938 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), | 3938 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E), |
| 3939 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 1), | 3939 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, SKX_PCI_UNCORE_M3UPI, 1), |
| 3940 | }, | 3940 | }, |
| 3941 | { /* M3UPI1 Link 2 */ | 3941 | { /* M3UPI1 Link 2 */ |
| 3942 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), | 3942 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), |
| 3943 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, SKX_PCI_UNCORE_M3UPI, 2), | 3943 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, SKX_PCI_UNCORE_M3UPI, 2), |
| 3944 | }, | 3944 | }, |
| 3945 | { /* end: all zeroes */ } | 3945 | { /* end: all zeroes */ } |
| 3946 | }; | 3946 | }; |
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index b2cf84c35a6d..8bdf74902293 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h | |||
| @@ -46,6 +46,14 @@ | |||
| 46 | #define INTEL_ARCH_EVENT_MASK \ | 46 | #define INTEL_ARCH_EVENT_MASK \ |
| 47 | (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) | 47 | (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) |
| 48 | 48 | ||
| 49 | #define AMD64_L3_SLICE_SHIFT 48 | ||
| 50 | #define AMD64_L3_SLICE_MASK \ | ||
| 51 | ((0xFULL) << AMD64_L3_SLICE_SHIFT) | ||
| 52 | |||
| 53 | #define AMD64_L3_THREAD_SHIFT 56 | ||
| 54 | #define AMD64_L3_THREAD_MASK \ | ||
| 55 | ((0xFFULL) << AMD64_L3_THREAD_SHIFT) | ||
| 56 | |||
| 49 | #define X86_RAW_EVENT_MASK \ | 57 | #define X86_RAW_EVENT_MASK \ |
| 50 | (ARCH_PERFMON_EVENTSEL_EVENT | \ | 58 | (ARCH_PERFMON_EVENTSEL_EVENT | \ |
| 51 | ARCH_PERFMON_EVENTSEL_UMASK | \ | 59 | ARCH_PERFMON_EVENTSEL_UMASK | \ |
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 94e1ed667b6e..41317c50a446 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c | |||
| @@ -322,16 +322,11 @@ void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn, | |||
| 322 | 322 | ||
| 323 | /* | 323 | /* |
| 324 | * __blk_mq_update_nr_hw_queues will update the nr_hw_queues and | 324 | * __blk_mq_update_nr_hw_queues will update the nr_hw_queues and |
| 325 | * queue_hw_ctx after freeze the queue. So we could use q_usage_counter | 325 | * queue_hw_ctx after freeze the queue, so we use q_usage_counter |
| 326 | * to avoid race with it. __blk_mq_update_nr_hw_queues will users | 326 | * to avoid race with it. |
| 327 | * synchronize_rcu to ensure all of the users go out of the critical | ||
| 328 | * section below and see zeroed q_usage_counter. | ||
| 329 | */ | 327 | */ |
| 330 | rcu_read_lock(); | 328 | if (!percpu_ref_tryget(&q->q_usage_counter)) |
| 331 | if (percpu_ref_is_zero(&q->q_usage_counter)) { | ||
| 332 | rcu_read_unlock(); | ||
| 333 | return; | 329 | return; |
| 334 | } | ||
| 335 | 330 | ||
| 336 | queue_for_each_hw_ctx(q, hctx, i) { | 331 | queue_for_each_hw_ctx(q, hctx, i) { |
| 337 | struct blk_mq_tags *tags = hctx->tags; | 332 | struct blk_mq_tags *tags = hctx->tags; |
| @@ -347,7 +342,7 @@ void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn, | |||
| 347 | bt_for_each(hctx, &tags->breserved_tags, fn, priv, true); | 342 | bt_for_each(hctx, &tags->breserved_tags, fn, priv, true); |
| 348 | bt_for_each(hctx, &tags->bitmap_tags, fn, priv, false); | 343 | bt_for_each(hctx, &tags->bitmap_tags, fn, priv, false); |
| 349 | } | 344 | } |
| 350 | rcu_read_unlock(); | 345 | blk_queue_exit(q); |
| 351 | } | 346 | } |
| 352 | 347 | ||
| 353 | static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth, | 348 | static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth, |
diff --git a/block/blk-mq.c b/block/blk-mq.c index 85a1c1a59c72..e3c39ea8e17b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
| @@ -1628,7 +1628,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) | |||
| 1628 | BUG_ON(!rq->q); | 1628 | BUG_ON(!rq->q); |
| 1629 | if (rq->mq_ctx != this_ctx) { | 1629 | if (rq->mq_ctx != this_ctx) { |
| 1630 | if (this_ctx) { | 1630 | if (this_ctx) { |
| 1631 | trace_block_unplug(this_q, depth, from_schedule); | 1631 | trace_block_unplug(this_q, depth, !from_schedule); |
| 1632 | blk_mq_sched_insert_requests(this_q, this_ctx, | 1632 | blk_mq_sched_insert_requests(this_q, this_ctx, |
| 1633 | &ctx_list, | 1633 | &ctx_list, |
| 1634 | from_schedule); | 1634 | from_schedule); |
| @@ -1648,7 +1648,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) | |||
| 1648 | * on 'ctx_list'. Do those. | 1648 | * on 'ctx_list'. Do those. |
| 1649 | */ | 1649 | */ |
| 1650 | if (this_ctx) { | 1650 | if (this_ctx) { |
| 1651 | trace_block_unplug(this_q, depth, from_schedule); | 1651 | trace_block_unplug(this_q, depth, !from_schedule); |
| 1652 | blk_mq_sched_insert_requests(this_q, this_ctx, &ctx_list, | 1652 | blk_mq_sched_insert_requests(this_q, this_ctx, &ctx_list, |
| 1653 | from_schedule); | 1653 | from_schedule); |
| 1654 | } | 1654 | } |
diff --git a/block/elevator.c b/block/elevator.c index 6a06b5d040e5..fae58b2f906f 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
| @@ -609,7 +609,7 @@ void elv_drain_elevator(struct request_queue *q) | |||
| 609 | 609 | ||
| 610 | while (e->type->ops.sq.elevator_dispatch_fn(q, 1)) | 610 | while (e->type->ops.sq.elevator_dispatch_fn(q, 1)) |
| 611 | ; | 611 | ; |
| 612 | if (q->nr_sorted && printed++ < 10) { | 612 | if (q->nr_sorted && !blk_queue_is_zoned(q) && printed++ < 10 ) { |
| 613 | printk(KERN_ERR "%s: forced dispatching is broken " | 613 | printk(KERN_ERR "%s: forced dispatching is broken " |
| 614 | "(nr_sorted=%u), please report this\n", | 614 | "(nr_sorted=%u), please report this\n", |
| 615 | q->elevator->type->elevator_name, q->nr_sorted); | 615 | q->elevator->type->elevator_name, q->nr_sorted); |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index a71d817e900d..429d20131c7e 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
| @@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info) | |||
| 2670 | list_del(&gnt_list_entry->node); | 2670 | list_del(&gnt_list_entry->node); |
| 2671 | gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL); | 2671 | gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL); |
| 2672 | rinfo->persistent_gnts_c--; | 2672 | rinfo->persistent_gnts_c--; |
| 2673 | __free_page(gnt_list_entry->page); | 2673 | gnt_list_entry->gref = GRANT_INVALID_REF; |
| 2674 | kfree(gnt_list_entry); | 2674 | list_add_tail(&gnt_list_entry->node, &rinfo->grants); |
| 2675 | } | 2675 | } |
| 2676 | 2676 | ||
| 2677 | spin_unlock_irqrestore(&rinfo->ring_lock, flags); | 2677 | spin_unlock_irqrestore(&rinfo->ring_lock, flags); |
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c index ec8a4376f74f..2fab18fae4fc 100644 --- a/drivers/clocksource/timer-atmel-pit.c +++ b/drivers/clocksource/timer-atmel-pit.c | |||
| @@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node) | |||
| 180 | data->base = of_iomap(node, 0); | 180 | data->base = of_iomap(node, 0); |
| 181 | if (!data->base) { | 181 | if (!data->base) { |
| 182 | pr_err("Could not map PIT address\n"); | 182 | pr_err("Could not map PIT address\n"); |
| 183 | return -ENXIO; | 183 | ret = -ENXIO; |
| 184 | goto exit; | ||
| 184 | } | 185 | } |
| 185 | 186 | ||
| 186 | data->mck = of_clk_get(node, 0); | 187 | data->mck = of_clk_get(node, 0); |
| 187 | if (IS_ERR(data->mck)) { | 188 | if (IS_ERR(data->mck)) { |
| 188 | pr_err("Unable to get mck clk\n"); | 189 | pr_err("Unable to get mck clk\n"); |
| 189 | return PTR_ERR(data->mck); | 190 | ret = PTR_ERR(data->mck); |
| 191 | goto exit; | ||
| 190 | } | 192 | } |
| 191 | 193 | ||
| 192 | ret = clk_prepare_enable(data->mck); | 194 | ret = clk_prepare_enable(data->mck); |
| 193 | if (ret) { | 195 | if (ret) { |
| 194 | pr_err("Unable to enable mck\n"); | 196 | pr_err("Unable to enable mck\n"); |
| 195 | return ret; | 197 | goto exit; |
| 196 | } | 198 | } |
| 197 | 199 | ||
| 198 | /* Get the interrupts property */ | 200 | /* Get the interrupts property */ |
| 199 | data->irq = irq_of_parse_and_map(node, 0); | 201 | data->irq = irq_of_parse_and_map(node, 0); |
| 200 | if (!data->irq) { | 202 | if (!data->irq) { |
| 201 | pr_err("Unable to get IRQ from DT\n"); | 203 | pr_err("Unable to get IRQ from DT\n"); |
| 202 | return -EINVAL; | 204 | ret = -EINVAL; |
| 205 | goto exit; | ||
| 203 | } | 206 | } |
| 204 | 207 | ||
| 205 | /* | 208 | /* |
| @@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node) | |||
| 227 | ret = clocksource_register_hz(&data->clksrc, pit_rate); | 230 | ret = clocksource_register_hz(&data->clksrc, pit_rate); |
| 228 | if (ret) { | 231 | if (ret) { |
| 229 | pr_err("Failed to register clocksource\n"); | 232 | pr_err("Failed to register clocksource\n"); |
| 230 | return ret; | 233 | goto exit; |
| 231 | } | 234 | } |
| 232 | 235 | ||
| 233 | /* Set up irq handler */ | 236 | /* Set up irq handler */ |
| @@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node) | |||
| 236 | "at91_tick", data); | 239 | "at91_tick", data); |
| 237 | if (ret) { | 240 | if (ret) { |
| 238 | pr_err("Unable to setup IRQ\n"); | 241 | pr_err("Unable to setup IRQ\n"); |
| 239 | return ret; | 242 | clocksource_unregister(&data->clksrc); |
| 243 | goto exit; | ||
| 240 | } | 244 | } |
| 241 | 245 | ||
| 242 | /* Set up and register clockevents */ | 246 | /* Set up and register clockevents */ |
| @@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node) | |||
| 254 | clockevents_register_device(&data->clkevt); | 258 | clockevents_register_device(&data->clkevt); |
| 255 | 259 | ||
| 256 | return 0; | 260 | return 0; |
| 261 | |||
| 262 | exit: | ||
| 263 | kfree(data); | ||
| 264 | return ret; | ||
| 257 | } | 265 | } |
| 258 | TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", | 266 | TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", |
| 259 | at91sam926x_pit_dt_init); | 267 | at91sam926x_pit_dt_init); |
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index c020038ebfab..cf93f6419b51 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c | |||
| @@ -130,13 +130,17 @@ static int fttmr010_timer_set_next_event(unsigned long cycles, | |||
| 130 | cr &= ~fttmr010->t1_enable_val; | 130 | cr &= ~fttmr010->t1_enable_val; |
| 131 | writel(cr, fttmr010->base + TIMER_CR); | 131 | writel(cr, fttmr010->base + TIMER_CR); |
| 132 | 132 | ||
| 133 | /* Setup the match register forward/backward in time */ | 133 | if (fttmr010->count_down) { |
| 134 | cr = readl(fttmr010->base + TIMER1_COUNT); | 134 | /* |
| 135 | if (fttmr010->count_down) | 135 | * ASPEED Timer Controller will load TIMER1_LOAD register |
| 136 | cr -= cycles; | 136 | * into TIMER1_COUNT register when the timer is re-enabled. |
| 137 | else | 137 | */ |
| 138 | cr += cycles; | 138 | writel(cycles, fttmr010->base + TIMER1_LOAD); |
| 139 | writel(cr, fttmr010->base + TIMER1_MATCH1); | 139 | } else { |
| 140 | /* Setup the match register forward in time */ | ||
| 141 | cr = readl(fttmr010->base + TIMER1_COUNT); | ||
| 142 | writel(cr + cycles, fttmr010->base + TIMER1_MATCH1); | ||
| 143 | } | ||
| 140 | 144 | ||
| 141 | /* Start */ | 145 | /* Start */ |
| 142 | cr = readl(fttmr010->base + TIMER_CR); | 146 | cr = readl(fttmr010->base + TIMER_CR); |
diff --git a/drivers/clocksource/timer-ti-32k.c b/drivers/clocksource/timer-ti-32k.c index 29e2e1a78a43..6949a9113dbb 100644 --- a/drivers/clocksource/timer-ti-32k.c +++ b/drivers/clocksource/timer-ti-32k.c | |||
| @@ -97,6 +97,9 @@ static int __init ti_32k_timer_init(struct device_node *np) | |||
| 97 | return -ENXIO; | 97 | return -ENXIO; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | if (!of_machine_is_compatible("ti,am43")) | ||
| 101 | ti_32k_timer.cs.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP; | ||
| 102 | |||
| 100 | ti_32k_timer.counter = ti_32k_timer.base; | 103 | ti_32k_timer.counter = ti_32k_timer.base; |
| 101 | 104 | ||
| 102 | /* | 105 | /* |
diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c index a1830fa25fc5..2a3675c24032 100644 --- a/drivers/cpufreq/qcom-cpufreq-kryo.c +++ b/drivers/cpufreq/qcom-cpufreq-kryo.c | |||
| @@ -44,7 +44,7 @@ enum _msm8996_version { | |||
| 44 | 44 | ||
| 45 | struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; | 45 | struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; |
| 46 | 46 | ||
| 47 | static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void) | 47 | static enum _msm8996_version qcom_cpufreq_kryo_get_msm_id(void) |
| 48 | { | 48 | { |
| 49 | size_t len; | 49 | size_t len; |
| 50 | u32 *msm_id; | 50 | u32 *msm_id; |
| @@ -222,7 +222,7 @@ static int __init qcom_cpufreq_kryo_init(void) | |||
| 222 | } | 222 | } |
| 223 | module_init(qcom_cpufreq_kryo_init); | 223 | module_init(qcom_cpufreq_kryo_init); |
| 224 | 224 | ||
| 225 | static void __init qcom_cpufreq_kryo_exit(void) | 225 | static void __exit qcom_cpufreq_kryo_exit(void) |
| 226 | { | 226 | { |
| 227 | platform_device_unregister(kryo_cpufreq_pdev); | 227 | platform_device_unregister(kryo_cpufreq_pdev); |
| 228 | platform_driver_unregister(&qcom_cpufreq_kryo_driver); | 228 | platform_driver_unregister(&qcom_cpufreq_kryo_driver); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c index 0cc5190f4f36..5f3f54073818 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | |||
| @@ -258,6 +258,8 @@ int amdgpu_vce_suspend(struct amdgpu_device *adev) | |||
| 258 | { | 258 | { |
| 259 | int i; | 259 | int i; |
| 260 | 260 | ||
| 261 | cancel_delayed_work_sync(&adev->vce.idle_work); | ||
| 262 | |||
| 261 | if (adev->vce.vcpu_bo == NULL) | 263 | if (adev->vce.vcpu_bo == NULL) |
| 262 | return 0; | 264 | return 0; |
| 263 | 265 | ||
| @@ -268,7 +270,6 @@ int amdgpu_vce_suspend(struct amdgpu_device *adev) | |||
| 268 | if (i == AMDGPU_MAX_VCE_HANDLES) | 270 | if (i == AMDGPU_MAX_VCE_HANDLES) |
| 269 | return 0; | 271 | return 0; |
| 270 | 272 | ||
| 271 | cancel_delayed_work_sync(&adev->vce.idle_work); | ||
| 272 | /* TODO: suspending running encoding sessions isn't supported */ | 273 | /* TODO: suspending running encoding sessions isn't supported */ |
| 273 | return -EINVAL; | 274 | return -EINVAL; |
| 274 | } | 275 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index fd654a4406db..400fc74bbae2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |||
| @@ -153,11 +153,11 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) | |||
| 153 | unsigned size; | 153 | unsigned size; |
| 154 | void *ptr; | 154 | void *ptr; |
| 155 | 155 | ||
| 156 | cancel_delayed_work_sync(&adev->vcn.idle_work); | ||
| 157 | |||
| 156 | if (adev->vcn.vcpu_bo == NULL) | 158 | if (adev->vcn.vcpu_bo == NULL) |
| 157 | return 0; | 159 | return 0; |
| 158 | 160 | ||
| 159 | cancel_delayed_work_sync(&adev->vcn.idle_work); | ||
| 160 | |||
| 161 | size = amdgpu_bo_size(adev->vcn.vcpu_bo); | 161 | size = amdgpu_bo_size(adev->vcn.vcpu_bo); |
| 162 | ptr = adev->vcn.cpu_addr; | 162 | ptr = adev->vcn.cpu_addr; |
| 163 | 163 | ||
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 800f481a6995..96875950845a 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
| @@ -641,6 +641,87 @@ amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state, | |||
| 641 | return NULL; | 641 | return NULL; |
| 642 | } | 642 | } |
| 643 | 643 | ||
| 644 | static void emulated_link_detect(struct dc_link *link) | ||
| 645 | { | ||
| 646 | struct dc_sink_init_data sink_init_data = { 0 }; | ||
| 647 | struct display_sink_capability sink_caps = { 0 }; | ||
| 648 | enum dc_edid_status edid_status; | ||
| 649 | struct dc_context *dc_ctx = link->ctx; | ||
| 650 | struct dc_sink *sink = NULL; | ||
| 651 | struct dc_sink *prev_sink = NULL; | ||
| 652 | |||
| 653 | link->type = dc_connection_none; | ||
| 654 | prev_sink = link->local_sink; | ||
| 655 | |||
| 656 | if (prev_sink != NULL) | ||
| 657 | dc_sink_retain(prev_sink); | ||
| 658 | |||
| 659 | switch (link->connector_signal) { | ||
| 660 | case SIGNAL_TYPE_HDMI_TYPE_A: { | ||
| 661 | sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C; | ||
| 662 | sink_caps.signal = SIGNAL_TYPE_HDMI_TYPE_A; | ||
| 663 | break; | ||
| 664 | } | ||
| 665 | |||
| 666 | case SIGNAL_TYPE_DVI_SINGLE_LINK: { | ||
| 667 | sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C; | ||
| 668 | sink_caps.signal = SIGNAL_TYPE_DVI_SINGLE_LINK; | ||
| 669 | break; | ||
| 670 | } | ||
| 671 | |||
| 672 | case SIGNAL_TYPE_DVI_DUAL_LINK: { | ||
| 673 | sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C; | ||
| 674 | sink_caps.signal = SIGNAL_TYPE_DVI_DUAL_LINK; | ||
| 675 | break; | ||
| 676 | } | ||
| 677 | |||
| 678 | case SIGNAL_TYPE_LVDS: { | ||
| 679 | sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C; | ||
| 680 | sink_caps.signal = SIGNAL_TYPE_LVDS; | ||
| 681 | break; | ||
| 682 | } | ||
| 683 | |||
| 684 | case SIGNAL_TYPE_EDP: { | ||
| 685 | sink_caps.transaction_type = | ||
| 686 | DDC_TRANSACTION_TYPE_I2C_OVER_AUX; | ||
| 687 | sink_caps.signal = SIGNAL_TYPE_EDP; | ||
| 688 | break; | ||
| 689 | } | ||
| 690 | |||
| 691 | case SIGNAL_TYPE_DISPLAY_PORT: { | ||
| 692 | sink_caps.transaction_type = | ||
| 693 | DDC_TRANSACTION_TYPE_I2C_OVER_AUX; | ||
| 694 | sink_caps.signal = SIGNAL_TYPE_VIRTUAL; | ||
| 695 | break; | ||
| 696 | } | ||
| 697 | |||
| 698 | default: | ||
| 699 | DC_ERROR("Invalid connector type! signal:%d\n", | ||
| 700 | link->connector_signal); | ||
| 701 | return; | ||
| 702 | } | ||
| 703 | |||
| 704 | sink_init_data.link = link; | ||
| 705 | sink_init_data.sink_signal = sink_caps.signal; | ||
| 706 | |||
| 707 | sink = dc_sink_create(&sink_init_data); | ||
| 708 | if (!sink) { | ||
| 709 | DC_ERROR("Failed to create sink!\n"); | ||
| 710 | return; | ||
| 711 | } | ||
| 712 | |||
| 713 | link->local_sink = sink; | ||
| 714 | |||
| 715 | edid_status = dm_helpers_read_local_edid( | ||
| 716 | link->ctx, | ||
| 717 | link, | ||
| 718 | sink); | ||
| 719 | |||
| 720 | if (edid_status != EDID_OK) | ||
| 721 | DC_ERROR("Failed to read EDID"); | ||
| 722 | |||
| 723 | } | ||
| 724 | |||
| 644 | static int dm_resume(void *handle) | 725 | static int dm_resume(void *handle) |
| 645 | { | 726 | { |
| 646 | struct amdgpu_device *adev = handle; | 727 | struct amdgpu_device *adev = handle; |
| @@ -654,6 +735,7 @@ static int dm_resume(void *handle) | |||
| 654 | struct drm_plane *plane; | 735 | struct drm_plane *plane; |
| 655 | struct drm_plane_state *new_plane_state; | 736 | struct drm_plane_state *new_plane_state; |
| 656 | struct dm_plane_state *dm_new_plane_state; | 737 | struct dm_plane_state *dm_new_plane_state; |
| 738 | enum dc_connection_type new_connection_type = dc_connection_none; | ||
| 657 | int ret; | 739 | int ret; |
| 658 | int i; | 740 | int i; |
| 659 | 741 | ||
| @@ -684,7 +766,13 @@ static int dm_resume(void *handle) | |||
| 684 | continue; | 766 | continue; |
| 685 | 767 | ||
| 686 | mutex_lock(&aconnector->hpd_lock); | 768 | mutex_lock(&aconnector->hpd_lock); |
| 687 | dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD); | 769 | if (!dc_link_detect_sink(aconnector->dc_link, &new_connection_type)) |
| 770 | DRM_ERROR("KMS: Failed to detect connector\n"); | ||
| 771 | |||
| 772 | if (aconnector->base.force && new_connection_type == dc_connection_none) | ||
| 773 | emulated_link_detect(aconnector->dc_link); | ||
| 774 | else | ||
| 775 | dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD); | ||
| 688 | 776 | ||
| 689 | if (aconnector->fake_enable && aconnector->dc_link->local_sink) | 777 | if (aconnector->fake_enable && aconnector->dc_link->local_sink) |
| 690 | aconnector->fake_enable = false; | 778 | aconnector->fake_enable = false; |
| @@ -922,6 +1010,7 @@ static void handle_hpd_irq(void *param) | |||
| 922 | struct amdgpu_dm_connector *aconnector = (struct amdgpu_dm_connector *)param; | 1010 | struct amdgpu_dm_connector *aconnector = (struct amdgpu_dm_connector *)param; |
| 923 | struct drm_connector *connector = &aconnector->base; | 1011 | struct drm_connector *connector = &aconnector->base; |
| 924 | struct drm_device *dev = connector->dev; | 1012 | struct drm_device *dev = connector->dev; |
| 1013 | enum dc_connection_type new_connection_type = dc_connection_none; | ||
| 925 | 1014 | ||
| 926 | /* In case of failure or MST no need to update connector status or notify the OS | 1015 | /* In case of failure or MST no need to update connector status or notify the OS |
| 927 | * since (for MST case) MST does this in it's own context. | 1016 | * since (for MST case) MST does this in it's own context. |
| @@ -931,7 +1020,21 @@ static void handle_hpd_irq(void *param) | |||
| 931 | if (aconnector->fake_enable) | 1020 | if (aconnector->fake_enable) |
| 932 | aconnector->fake_enable = false; | 1021 | aconnector->fake_enable = false; |
| 933 | 1022 | ||
| 934 | if (dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD)) { | 1023 | if (!dc_link_detect_sink(aconnector->dc_link, &new_connection_type)) |
| 1024 | DRM_ERROR("KMS: Failed to detect connector\n"); | ||
| 1025 | |||
| 1026 | if (aconnector->base.force && new_connection_type == dc_connection_none) { | ||
| 1027 | emulated_link_detect(aconnector->dc_link); | ||
| 1028 | |||
| 1029 | |||
| 1030 | drm_modeset_lock_all(dev); | ||
| 1031 | dm_restore_drm_connector_state(dev, connector); | ||
| 1032 | drm_modeset_unlock_all(dev); | ||
| 1033 | |||
| 1034 | if (aconnector->base.force == DRM_FORCE_UNSPECIFIED) | ||
| 1035 | drm_kms_helper_hotplug_event(dev); | ||
| 1036 | |||
| 1037 | } else if (dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD)) { | ||
| 935 | amdgpu_dm_update_connector_after_detect(aconnector); | 1038 | amdgpu_dm_update_connector_after_detect(aconnector); |
| 936 | 1039 | ||
| 937 | 1040 | ||
| @@ -1031,6 +1134,7 @@ static void handle_hpd_rx_irq(void *param) | |||
| 1031 | struct drm_device *dev = connector->dev; | 1134 | struct drm_device *dev = connector->dev; |
| 1032 | struct dc_link *dc_link = aconnector->dc_link; | 1135 | struct dc_link *dc_link = aconnector->dc_link; |
| 1033 | bool is_mst_root_connector = aconnector->mst_mgr.mst_state; | 1136 | bool is_mst_root_connector = aconnector->mst_mgr.mst_state; |
| 1137 | enum dc_connection_type new_connection_type = dc_connection_none; | ||
| 1034 | 1138 | ||
| 1035 | /* TODO:Temporary add mutex to protect hpd interrupt not have a gpio | 1139 | /* TODO:Temporary add mutex to protect hpd interrupt not have a gpio |
| 1036 | * conflict, after implement i2c helper, this mutex should be | 1140 | * conflict, after implement i2c helper, this mutex should be |
| @@ -1042,7 +1146,24 @@ static void handle_hpd_rx_irq(void *param) | |||
| 1042 | if (dc_link_handle_hpd_rx_irq(dc_link, NULL, NULL) && | 1146 | if (dc_link_handle_hpd_rx_irq(dc_link, NULL, NULL) && |
| 1043 | !is_mst_root_connector) { | 1147 | !is_mst_root_connector) { |
| 1044 | /* Downstream Port status changed. */ | 1148 | /* Downstream Port status changed. */ |
| 1045 | if (dc_link_detect(dc_link, DETECT_REASON_HPDRX)) { | 1149 | if (!dc_link_detect_sink(dc_link, &new_connection_type)) |
| 1150 | DRM_ERROR("KMS: Failed to detect connector\n"); | ||
| 1151 | |||
| 1152 | if (aconnector->base.force && new_connection_type == dc_connection_none) { | ||
| 1153 | emulated_link_detect(dc_link); | ||
| 1154 | |||
| 1155 | if (aconnector->fake_enable) | ||
| 1156 | aconnector->fake_enable = false; | ||
| 1157 | |||
| 1158 | amdgpu_dm_update_connector_after_detect(aconnector); | ||
| 1159 | |||
| 1160 | |||
| 1161 | drm_modeset_lock_all(dev); | ||
| 1162 | dm_restore_drm_connector_state(dev, connector); | ||
| 1163 | drm_modeset_unlock_all(dev); | ||
| 1164 | |||
| 1165 | drm_kms_helper_hotplug_event(dev); | ||
| 1166 | } else if (dc_link_detect(dc_link, DETECT_REASON_HPDRX)) { | ||
| 1046 | 1167 | ||
| 1047 | if (aconnector->fake_enable) | 1168 | if (aconnector->fake_enable) |
| 1048 | aconnector->fake_enable = false; | 1169 | aconnector->fake_enable = false; |
| @@ -1433,6 +1554,7 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) | |||
| 1433 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | 1554 | struct amdgpu_mode_info *mode_info = &adev->mode_info; |
| 1434 | uint32_t link_cnt; | 1555 | uint32_t link_cnt; |
| 1435 | int32_t total_overlay_planes, total_primary_planes; | 1556 | int32_t total_overlay_planes, total_primary_planes; |
| 1557 | enum dc_connection_type new_connection_type = dc_connection_none; | ||
| 1436 | 1558 | ||
| 1437 | link_cnt = dm->dc->caps.max_links; | 1559 | link_cnt = dm->dc->caps.max_links; |
| 1438 | if (amdgpu_dm_mode_config_init(dm->adev)) { | 1560 | if (amdgpu_dm_mode_config_init(dm->adev)) { |
| @@ -1499,7 +1621,14 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) | |||
| 1499 | 1621 | ||
| 1500 | link = dc_get_link_at_index(dm->dc, i); | 1622 | link = dc_get_link_at_index(dm->dc, i); |
| 1501 | 1623 | ||
| 1502 | if (dc_link_detect(link, DETECT_REASON_BOOT)) { | 1624 | if (!dc_link_detect_sink(link, &new_connection_type)) |
| 1625 | DRM_ERROR("KMS: Failed to detect connector\n"); | ||
| 1626 | |||
| 1627 | if (aconnector->base.force && new_connection_type == dc_connection_none) { | ||
| 1628 | emulated_link_detect(link); | ||
| 1629 | amdgpu_dm_update_connector_after_detect(aconnector); | ||
| 1630 | |||
| 1631 | } else if (dc_link_detect(link, DETECT_REASON_BOOT)) { | ||
| 1503 | amdgpu_dm_update_connector_after_detect(aconnector); | 1632 | amdgpu_dm_update_connector_after_detect(aconnector); |
| 1504 | register_backlight_device(dm, link); | 1633 | register_backlight_device(dm, link); |
| 1505 | } | 1634 | } |
| @@ -2494,7 +2623,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, | |||
| 2494 | if (dm_state && dm_state->freesync_capable) | 2623 | if (dm_state && dm_state->freesync_capable) |
| 2495 | stream->ignore_msa_timing_param = true; | 2624 | stream->ignore_msa_timing_param = true; |
| 2496 | finish: | 2625 | finish: |
| 2497 | if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL) | 2626 | if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL && aconnector->base.force != DRM_FORCE_ON) |
| 2498 | dc_sink_release(sink); | 2627 | dc_sink_release(sink); |
| 2499 | 2628 | ||
| 2500 | return stream; | 2629 | return stream; |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 37eaf72ace54..fced3c1c2ef5 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c | |||
| @@ -195,7 +195,7 @@ static bool program_hpd_filter( | |||
| 195 | return result; | 195 | return result; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | static bool detect_sink(struct dc_link *link, enum dc_connection_type *type) | 198 | bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type) |
| 199 | { | 199 | { |
| 200 | uint32_t is_hpd_high = 0; | 200 | uint32_t is_hpd_high = 0; |
| 201 | struct gpio *hpd_pin; | 201 | struct gpio *hpd_pin; |
| @@ -604,7 +604,7 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
| 604 | if (link->connector_signal == SIGNAL_TYPE_VIRTUAL) | 604 | if (link->connector_signal == SIGNAL_TYPE_VIRTUAL) |
| 605 | return false; | 605 | return false; |
| 606 | 606 | ||
| 607 | if (false == detect_sink(link, &new_connection_type)) { | 607 | if (false == dc_link_detect_sink(link, &new_connection_type)) { |
| 608 | BREAK_TO_DEBUGGER(); | 608 | BREAK_TO_DEBUGGER(); |
| 609 | return false; | 609 | return false; |
| 610 | } | 610 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h b/drivers/gpu/drm/amd/display/dc/dc_link.h index d43cefbc43d3..1b48ab9aea89 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_link.h +++ b/drivers/gpu/drm/amd/display/dc/dc_link.h | |||
| @@ -215,6 +215,7 @@ void dc_link_enable_hpd_filter(struct dc_link *link, bool enable); | |||
| 215 | 215 | ||
| 216 | bool dc_link_is_dp_sink_present(struct dc_link *link); | 216 | bool dc_link_is_dp_sink_present(struct dc_link *link); |
| 217 | 217 | ||
| 218 | bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type); | ||
| 218 | /* | 219 | /* |
| 219 | * DPCD access interfaces | 220 | * DPCD access interfaces |
| 220 | */ | 221 | */ |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index 14384d9675a8..b2f308766a9e 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | |||
| @@ -2560,7 +2560,7 @@ static void pplib_apply_display_requirements( | |||
| 2560 | dc->prev_display_config = *pp_display_cfg; | 2560 | dc->prev_display_config = *pp_display_cfg; |
| 2561 | } | 2561 | } |
| 2562 | 2562 | ||
| 2563 | void dce110_set_bandwidth( | 2563 | static void dce110_set_bandwidth( |
| 2564 | struct dc *dc, | 2564 | struct dc *dc, |
| 2565 | struct dc_state *context, | 2565 | struct dc_state *context, |
| 2566 | bool decrease_allowed) | 2566 | bool decrease_allowed) |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h index e4c5db75c4c6..d6db3dbd9015 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h | |||
| @@ -68,11 +68,6 @@ void dce110_fill_display_configs( | |||
| 68 | const struct dc_state *context, | 68 | const struct dc_state *context, |
| 69 | struct dm_pp_display_configuration *pp_display_cfg); | 69 | struct dm_pp_display_configuration *pp_display_cfg); |
| 70 | 70 | ||
| 71 | void dce110_set_bandwidth( | ||
| 72 | struct dc *dc, | ||
| 73 | struct dc_state *context, | ||
| 74 | bool decrease_allowed); | ||
| 75 | |||
| 76 | uint32_t dce110_get_min_vblank_time_us(const struct dc_state *context); | 71 | uint32_t dce110_get_min_vblank_time_us(const struct dc_state *context); |
| 77 | 72 | ||
| 78 | void dp_receiver_power_ctrl(struct dc_link *link, bool on); | 73 | void dp_receiver_power_ctrl(struct dc_link *link, bool on); |
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_hw_sequencer.c index 5853522a6182..eb0f5f9a973b 100644 --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_hw_sequencer.c | |||
| @@ -244,17 +244,6 @@ static void dce120_update_dchub( | |||
| 244 | dh_data->dchub_info_valid = false; | 244 | dh_data->dchub_info_valid = false; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | static void dce120_set_bandwidth( | ||
| 248 | struct dc *dc, | ||
| 249 | struct dc_state *context, | ||
| 250 | bool decrease_allowed) | ||
| 251 | { | ||
| 252 | if (context->stream_count <= 0) | ||
| 253 | return; | ||
| 254 | |||
| 255 | dce110_set_bandwidth(dc, context, decrease_allowed); | ||
| 256 | } | ||
| 257 | |||
| 258 | void dce120_hw_sequencer_construct(struct dc *dc) | 247 | void dce120_hw_sequencer_construct(struct dc *dc) |
| 259 | { | 248 | { |
| 260 | /* All registers used by dce11.2 match those in dce11 in offset and | 249 | /* All registers used by dce11.2 match those in dce11 in offset and |
| @@ -263,6 +252,5 @@ void dce120_hw_sequencer_construct(struct dc *dc) | |||
| 263 | dce110_hw_sequencer_construct(dc); | 252 | dce110_hw_sequencer_construct(dc); |
| 264 | dc->hwss.enable_display_power_gating = dce120_enable_display_power_gating; | 253 | dc->hwss.enable_display_power_gating = dce120_enable_display_power_gating; |
| 265 | dc->hwss.update_dchub = dce120_update_dchub; | 254 | dc->hwss.update_dchub = dce120_update_dchub; |
| 266 | dc->hwss.set_bandwidth = dce120_set_bandwidth; | ||
| 267 | } | 255 | } |
| 268 | 256 | ||
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index 08b5bb219816..94d6dabec2dc 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c | |||
| @@ -754,6 +754,7 @@ static int malidp_bind(struct device *dev) | |||
| 754 | drm->irq_enabled = true; | 754 | drm->irq_enabled = true; |
| 755 | 755 | ||
| 756 | ret = drm_vblank_init(drm, drm->mode_config.num_crtc); | 756 | ret = drm_vblank_init(drm, drm->mode_config.num_crtc); |
| 757 | drm_crtc_vblank_reset(&malidp->crtc); | ||
| 757 | if (ret < 0) { | 758 | if (ret < 0) { |
| 758 | DRM_ERROR("failed to initialise vblank\n"); | 759 | DRM_ERROR("failed to initialise vblank\n"); |
| 759 | goto vblank_fail; | 760 | goto vblank_fail; |
diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c index c94a4422e0e9..2781e462c1ed 100644 --- a/drivers/gpu/drm/arm/malidp_hw.c +++ b/drivers/gpu/drm/arm/malidp_hw.c | |||
| @@ -384,7 +384,8 @@ static long malidp500_se_calc_mclk(struct malidp_hw_device *hwdev, | |||
| 384 | 384 | ||
| 385 | static int malidp500_enable_memwrite(struct malidp_hw_device *hwdev, | 385 | static int malidp500_enable_memwrite(struct malidp_hw_device *hwdev, |
| 386 | dma_addr_t *addrs, s32 *pitches, | 386 | dma_addr_t *addrs, s32 *pitches, |
| 387 | int num_planes, u16 w, u16 h, u32 fmt_id) | 387 | int num_planes, u16 w, u16 h, u32 fmt_id, |
| 388 | const s16 *rgb2yuv_coeffs) | ||
| 388 | { | 389 | { |
| 389 | u32 base = MALIDP500_SE_MEMWRITE_BASE; | 390 | u32 base = MALIDP500_SE_MEMWRITE_BASE; |
| 390 | u32 de_base = malidp_get_block_base(hwdev, MALIDP_DE_BLOCK); | 391 | u32 de_base = malidp_get_block_base(hwdev, MALIDP_DE_BLOCK); |
| @@ -416,6 +417,16 @@ static int malidp500_enable_memwrite(struct malidp_hw_device *hwdev, | |||
| 416 | 417 | ||
| 417 | malidp_hw_write(hwdev, MALIDP_DE_H_ACTIVE(w) | MALIDP_DE_V_ACTIVE(h), | 418 | malidp_hw_write(hwdev, MALIDP_DE_H_ACTIVE(w) | MALIDP_DE_V_ACTIVE(h), |
| 418 | MALIDP500_SE_MEMWRITE_OUT_SIZE); | 419 | MALIDP500_SE_MEMWRITE_OUT_SIZE); |
| 420 | |||
| 421 | if (rgb2yuv_coeffs) { | ||
| 422 | int i; | ||
| 423 | |||
| 424 | for (i = 0; i < MALIDP_COLORADJ_NUM_COEFFS; i++) { | ||
| 425 | malidp_hw_write(hwdev, rgb2yuv_coeffs[i], | ||
| 426 | MALIDP500_SE_RGB_YUV_COEFFS + i * 4); | ||
| 427 | } | ||
| 428 | } | ||
| 429 | |||
| 419 | malidp_hw_setbits(hwdev, MALIDP_SE_MEMWRITE_EN, MALIDP500_SE_CONTROL); | 430 | malidp_hw_setbits(hwdev, MALIDP_SE_MEMWRITE_EN, MALIDP500_SE_CONTROL); |
| 420 | 431 | ||
| 421 | return 0; | 432 | return 0; |
| @@ -658,7 +669,8 @@ static long malidp550_se_calc_mclk(struct malidp_hw_device *hwdev, | |||
| 658 | 669 | ||
| 659 | static int malidp550_enable_memwrite(struct malidp_hw_device *hwdev, | 670 | static int malidp550_enable_memwrite(struct malidp_hw_device *hwdev, |
| 660 | dma_addr_t *addrs, s32 *pitches, | 671 | dma_addr_t *addrs, s32 *pitches, |
| 661 | int num_planes, u16 w, u16 h, u32 fmt_id) | 672 | int num_planes, u16 w, u16 h, u32 fmt_id, |
| 673 | const s16 *rgb2yuv_coeffs) | ||
| 662 | { | 674 | { |
| 663 | u32 base = MALIDP550_SE_MEMWRITE_BASE; | 675 | u32 base = MALIDP550_SE_MEMWRITE_BASE; |
| 664 | u32 de_base = malidp_get_block_base(hwdev, MALIDP_DE_BLOCK); | 676 | u32 de_base = malidp_get_block_base(hwdev, MALIDP_DE_BLOCK); |
| @@ -689,6 +701,15 @@ static int malidp550_enable_memwrite(struct malidp_hw_device *hwdev, | |||
| 689 | malidp_hw_setbits(hwdev, MALIDP550_SE_MEMWRITE_ONESHOT | MALIDP_SE_MEMWRITE_EN, | 701 | malidp_hw_setbits(hwdev, MALIDP550_SE_MEMWRITE_ONESHOT | MALIDP_SE_MEMWRITE_EN, |
| 690 | MALIDP550_SE_CONTROL); | 702 | MALIDP550_SE_CONTROL); |
| 691 | 703 | ||
| 704 | if (rgb2yuv_coeffs) { | ||
| 705 | int i; | ||
| 706 | |||
| 707 | for (i = 0; i < MALIDP_COLORADJ_NUM_COEFFS; i++) { | ||
| 708 | malidp_hw_write(hwdev, rgb2yuv_coeffs[i], | ||
| 709 | MALIDP550_SE_RGB_YUV_COEFFS + i * 4); | ||
| 710 | } | ||
| 711 | } | ||
| 712 | |||
| 692 | return 0; | 713 | return 0; |
| 693 | } | 714 | } |
| 694 | 715 | ||
diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h index ad2e96915d44..9fc94c08190f 100644 --- a/drivers/gpu/drm/arm/malidp_hw.h +++ b/drivers/gpu/drm/arm/malidp_hw.h | |||
| @@ -191,7 +191,8 @@ struct malidp_hw { | |||
| 191 | * @param fmt_id - internal format ID of output buffer | 191 | * @param fmt_id - internal format ID of output buffer |
| 192 | */ | 192 | */ |
| 193 | int (*enable_memwrite)(struct malidp_hw_device *hwdev, dma_addr_t *addrs, | 193 | int (*enable_memwrite)(struct malidp_hw_device *hwdev, dma_addr_t *addrs, |
| 194 | s32 *pitches, int num_planes, u16 w, u16 h, u32 fmt_id); | 194 | s32 *pitches, int num_planes, u16 w, u16 h, u32 fmt_id, |
| 195 | const s16 *rgb2yuv_coeffs); | ||
| 195 | 196 | ||
| 196 | /* | 197 | /* |
| 197 | * Disable the writing to memory of the next frame's content. | 198 | * Disable the writing to memory of the next frame's content. |
diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c index ba6ae66387c9..91472e5e0c8b 100644 --- a/drivers/gpu/drm/arm/malidp_mw.c +++ b/drivers/gpu/drm/arm/malidp_mw.c | |||
| @@ -26,6 +26,8 @@ struct malidp_mw_connector_state { | |||
| 26 | s32 pitches[2]; | 26 | s32 pitches[2]; |
| 27 | u8 format; | 27 | u8 format; |
| 28 | u8 n_planes; | 28 | u8 n_planes; |
| 29 | bool rgb2yuv_initialized; | ||
| 30 | const s16 *rgb2yuv_coeffs; | ||
| 29 | }; | 31 | }; |
| 30 | 32 | ||
| 31 | static int malidp_mw_connector_get_modes(struct drm_connector *connector) | 33 | static int malidp_mw_connector_get_modes(struct drm_connector *connector) |
| @@ -84,7 +86,7 @@ static void malidp_mw_connector_destroy(struct drm_connector *connector) | |||
| 84 | static struct drm_connector_state * | 86 | static struct drm_connector_state * |
| 85 | malidp_mw_connector_duplicate_state(struct drm_connector *connector) | 87 | malidp_mw_connector_duplicate_state(struct drm_connector *connector) |
| 86 | { | 88 | { |
| 87 | struct malidp_mw_connector_state *mw_state; | 89 | struct malidp_mw_connector_state *mw_state, *mw_current_state; |
| 88 | 90 | ||
| 89 | if (WARN_ON(!connector->state)) | 91 | if (WARN_ON(!connector->state)) |
| 90 | return NULL; | 92 | return NULL; |
| @@ -93,7 +95,10 @@ malidp_mw_connector_duplicate_state(struct drm_connector *connector) | |||
| 93 | if (!mw_state) | 95 | if (!mw_state) |
| 94 | return NULL; | 96 | return NULL; |
| 95 | 97 | ||
| 96 | /* No need to preserve any of our driver-local data */ | 98 | mw_current_state = to_mw_state(connector->state); |
| 99 | mw_state->rgb2yuv_coeffs = mw_current_state->rgb2yuv_coeffs; | ||
| 100 | mw_state->rgb2yuv_initialized = mw_current_state->rgb2yuv_initialized; | ||
| 101 | |||
| 97 | __drm_atomic_helper_connector_duplicate_state(connector, &mw_state->base); | 102 | __drm_atomic_helper_connector_duplicate_state(connector, &mw_state->base); |
| 98 | 103 | ||
| 99 | return &mw_state->base; | 104 | return &mw_state->base; |
| @@ -108,6 +113,13 @@ static const struct drm_connector_funcs malidp_mw_connector_funcs = { | |||
| 108 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, | 113 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, |
| 109 | }; | 114 | }; |
| 110 | 115 | ||
| 116 | static const s16 rgb2yuv_coeffs_bt709_limited[MALIDP_COLORADJ_NUM_COEFFS] = { | ||
| 117 | 47, 157, 16, | ||
| 118 | -26, -87, 112, | ||
| 119 | 112, -102, -10, | ||
| 120 | 16, 128, 128 | ||
| 121 | }; | ||
| 122 | |||
| 111 | static int | 123 | static int |
| 112 | malidp_mw_encoder_atomic_check(struct drm_encoder *encoder, | 124 | malidp_mw_encoder_atomic_check(struct drm_encoder *encoder, |
| 113 | struct drm_crtc_state *crtc_state, | 125 | struct drm_crtc_state *crtc_state, |
| @@ -157,6 +169,9 @@ malidp_mw_encoder_atomic_check(struct drm_encoder *encoder, | |||
| 157 | } | 169 | } |
| 158 | mw_state->n_planes = n_planes; | 170 | mw_state->n_planes = n_planes; |
| 159 | 171 | ||
| 172 | if (fb->format->is_yuv) | ||
| 173 | mw_state->rgb2yuv_coeffs = rgb2yuv_coeffs_bt709_limited; | ||
| 174 | |||
| 160 | return 0; | 175 | return 0; |
| 161 | } | 176 | } |
| 162 | 177 | ||
| @@ -239,10 +254,12 @@ void malidp_mw_atomic_commit(struct drm_device *drm, | |||
| 239 | 254 | ||
| 240 | drm_writeback_queue_job(mw_conn, conn_state->writeback_job); | 255 | drm_writeback_queue_job(mw_conn, conn_state->writeback_job); |
| 241 | conn_state->writeback_job = NULL; | 256 | conn_state->writeback_job = NULL; |
| 242 | |||
| 243 | hwdev->hw->enable_memwrite(hwdev, mw_state->addrs, | 257 | hwdev->hw->enable_memwrite(hwdev, mw_state->addrs, |
| 244 | mw_state->pitches, mw_state->n_planes, | 258 | mw_state->pitches, mw_state->n_planes, |
| 245 | fb->width, fb->height, mw_state->format); | 259 | fb->width, fb->height, mw_state->format, |
| 260 | !mw_state->rgb2yuv_initialized ? | ||
| 261 | mw_state->rgb2yuv_coeffs : NULL); | ||
| 262 | mw_state->rgb2yuv_initialized = !!mw_state->rgb2yuv_coeffs; | ||
| 246 | } else { | 263 | } else { |
| 247 | DRM_DEV_DEBUG_DRIVER(drm->dev, "Disable memwrite\n"); | 264 | DRM_DEV_DEBUG_DRIVER(drm->dev, "Disable memwrite\n"); |
| 248 | hwdev->hw->disable_memwrite(hwdev); | 265 | hwdev->hw->disable_memwrite(hwdev); |
diff --git a/drivers/gpu/drm/arm/malidp_regs.h b/drivers/gpu/drm/arm/malidp_regs.h index 3579d36b2a71..6ffe849774f2 100644 --- a/drivers/gpu/drm/arm/malidp_regs.h +++ b/drivers/gpu/drm/arm/malidp_regs.h | |||
| @@ -205,6 +205,7 @@ | |||
| 205 | #define MALIDP500_SE_BASE 0x00c00 | 205 | #define MALIDP500_SE_BASE 0x00c00 |
| 206 | #define MALIDP500_SE_CONTROL 0x00c0c | 206 | #define MALIDP500_SE_CONTROL 0x00c0c |
| 207 | #define MALIDP500_SE_MEMWRITE_OUT_SIZE 0x00c2c | 207 | #define MALIDP500_SE_MEMWRITE_OUT_SIZE 0x00c2c |
| 208 | #define MALIDP500_SE_RGB_YUV_COEFFS 0x00C74 | ||
| 208 | #define MALIDP500_SE_MEMWRITE_BASE 0x00e00 | 209 | #define MALIDP500_SE_MEMWRITE_BASE 0x00e00 |
| 209 | #define MALIDP500_DC_IRQ_BASE 0x00f00 | 210 | #define MALIDP500_DC_IRQ_BASE 0x00f00 |
| 210 | #define MALIDP500_CONFIG_VALID 0x00f00 | 211 | #define MALIDP500_CONFIG_VALID 0x00f00 |
| @@ -238,6 +239,7 @@ | |||
| 238 | #define MALIDP550_SE_CONTROL 0x08010 | 239 | #define MALIDP550_SE_CONTROL 0x08010 |
| 239 | #define MALIDP550_SE_MEMWRITE_ONESHOT (1 << 7) | 240 | #define MALIDP550_SE_MEMWRITE_ONESHOT (1 << 7) |
| 240 | #define MALIDP550_SE_MEMWRITE_OUT_SIZE 0x08030 | 241 | #define MALIDP550_SE_MEMWRITE_OUT_SIZE 0x08030 |
| 242 | #define MALIDP550_SE_RGB_YUV_COEFFS 0x08078 | ||
| 241 | #define MALIDP550_SE_MEMWRITE_BASE 0x08100 | 243 | #define MALIDP550_SE_MEMWRITE_BASE 0x08100 |
| 242 | #define MALIDP550_DC_BASE 0x0c000 | 244 | #define MALIDP550_DC_BASE 0x0c000 |
| 243 | #define MALIDP550_DC_CONTROL 0x0c010 | 245 | #define MALIDP550_DC_CONTROL 0x0c010 |
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index b902361dee6e..1d9a9d2fe0e0 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| 25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
| 26 | 26 | ||
| 27 | #include <drm/drm_device.h> | ||
| 28 | #include <drm/drm_crtc.h> | 27 | #include <drm/drm_crtc.h> |
| 29 | #include <drm/drm_panel.h> | 28 | #include <drm/drm_panel.h> |
| 30 | 29 | ||
| @@ -105,13 +104,6 @@ int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector) | |||
| 105 | if (panel->connector) | 104 | if (panel->connector) |
| 106 | return -EBUSY; | 105 | return -EBUSY; |
| 107 | 106 | ||
| 108 | panel->link = device_link_add(connector->dev->dev, panel->dev, 0); | ||
| 109 | if (!panel->link) { | ||
| 110 | dev_err(panel->dev, "failed to link panel to %s\n", | ||
| 111 | dev_name(connector->dev->dev)); | ||
| 112 | return -EINVAL; | ||
| 113 | } | ||
| 114 | |||
| 115 | panel->connector = connector; | 107 | panel->connector = connector; |
| 116 | panel->drm = connector->dev; | 108 | panel->drm = connector->dev; |
| 117 | 109 | ||
| @@ -133,8 +125,6 @@ EXPORT_SYMBOL(drm_panel_attach); | |||
| 133 | */ | 125 | */ |
| 134 | int drm_panel_detach(struct drm_panel *panel) | 126 | int drm_panel_detach(struct drm_panel *panel) |
| 135 | { | 127 | { |
| 136 | device_link_del(panel->link); | ||
| 137 | |||
| 138 | panel->connector = NULL; | 128 | panel->connector = NULL; |
| 139 | panel->drm = NULL; | 129 | panel->drm = NULL; |
| 140 | 130 | ||
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index adb3cb27d31e..759278fef35a 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c | |||
| @@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, | |||
| 97 | { | 97 | { |
| 98 | int ret; | 98 | int ret; |
| 99 | 99 | ||
| 100 | WARN_ON(*fence); | ||
| 101 | |||
| 100 | *fence = drm_syncobj_fence_get(syncobj); | 102 | *fence = drm_syncobj_fence_get(syncobj); |
| 101 | if (*fence) | 103 | if (*fence) |
| 102 | return 1; | 104 | return 1; |
| @@ -743,6 +745,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, | |||
| 743 | 745 | ||
| 744 | if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { | 746 | if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { |
| 745 | for (i = 0; i < count; ++i) { | 747 | for (i = 0; i < count; ++i) { |
| 748 | if (entries[i].fence) | ||
| 749 | continue; | ||
| 750 | |||
| 746 | drm_syncobj_fence_get_or_add_callback(syncobjs[i], | 751 | drm_syncobj_fence_get_or_add_callback(syncobjs[i], |
| 747 | &entries[i].fence, | 752 | &entries[i].fence, |
| 748 | &entries[i].syncobj_cb, | 753 | &entries[i].syncobj_cb, |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 9b2720b41571..83c1f46670bf 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c | |||
| @@ -592,8 +592,6 @@ static int etnaviv_pdev_probe(struct platform_device *pdev) | |||
| 592 | struct device *dev = &pdev->dev; | 592 | struct device *dev = &pdev->dev; |
| 593 | struct component_match *match = NULL; | 593 | struct component_match *match = NULL; |
| 594 | 594 | ||
| 595 | dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); | ||
| 596 | |||
| 597 | if (!dev->platform_data) { | 595 | if (!dev->platform_data) { |
| 598 | struct device_node *core_node; | 596 | struct device_node *core_node; |
| 599 | 597 | ||
| @@ -655,13 +653,30 @@ static int __init etnaviv_init(void) | |||
| 655 | for_each_compatible_node(np, NULL, "vivante,gc") { | 653 | for_each_compatible_node(np, NULL, "vivante,gc") { |
| 656 | if (!of_device_is_available(np)) | 654 | if (!of_device_is_available(np)) |
| 657 | continue; | 655 | continue; |
| 658 | pdev = platform_device_register_simple("etnaviv", -1, | 656 | |
| 659 | NULL, 0); | 657 | pdev = platform_device_alloc("etnaviv", -1); |
| 660 | if (IS_ERR(pdev)) { | 658 | if (!pdev) { |
| 661 | ret = PTR_ERR(pdev); | 659 | ret = -ENOMEM; |
| 660 | of_node_put(np); | ||
| 661 | goto unregister_platform_driver; | ||
| 662 | } | ||
| 663 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40); | ||
| 664 | pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; | ||
| 665 | |||
| 666 | /* | ||
| 667 | * Apply the same DMA configuration to the virtual etnaviv | ||
| 668 | * device as the GPU we found. This assumes that all Vivante | ||
| 669 | * GPUs in the system share the same DMA constraints. | ||
| 670 | */ | ||
| 671 | of_dma_configure(&pdev->dev, np, true); | ||
| 672 | |||
| 673 | ret = platform_device_add(pdev); | ||
| 674 | if (ret) { | ||
| 675 | platform_device_put(pdev); | ||
| 662 | of_node_put(np); | 676 | of_node_put(np); |
| 663 | goto unregister_platform_driver; | 677 | goto unregister_platform_driver; |
| 664 | } | 678 | } |
| 679 | |||
| 665 | etnaviv_drm = pdev; | 680 | etnaviv_drm = pdev; |
| 666 | of_node_put(np); | 681 | of_node_put(np); |
| 667 | break; | 682 | break; |
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 0bee1f4b914e..3208ad6ad540 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
| @@ -338,6 +338,39 @@ static int add_roce_gid(struct ib_gid_table_entry *entry) | |||
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | /** | 340 | /** |
| 341 | * del_gid - Delete GID table entry | ||
| 342 | * | ||
| 343 | * @ib_dev: IB device whose GID entry to be deleted | ||
| 344 | * @port: Port number of the IB device | ||
| 345 | * @table: GID table of the IB device for a port | ||
| 346 | * @ix: GID entry index to delete | ||
| 347 | * | ||
| 348 | */ | ||
| 349 | static void del_gid(struct ib_device *ib_dev, u8 port, | ||
| 350 | struct ib_gid_table *table, int ix) | ||
| 351 | { | ||
| 352 | struct ib_gid_table_entry *entry; | ||
| 353 | |||
| 354 | lockdep_assert_held(&table->lock); | ||
| 355 | |||
| 356 | pr_debug("%s device=%s port=%d index=%d gid %pI6\n", __func__, | ||
| 357 | ib_dev->name, port, ix, | ||
| 358 | table->data_vec[ix]->attr.gid.raw); | ||
| 359 | |||
| 360 | write_lock_irq(&table->rwlock); | ||
| 361 | entry = table->data_vec[ix]; | ||
| 362 | entry->state = GID_TABLE_ENTRY_PENDING_DEL; | ||
| 363 | /* | ||
| 364 | * For non RoCE protocol, GID entry slot is ready to use. | ||
| 365 | */ | ||
| 366 | if (!rdma_protocol_roce(ib_dev, port)) | ||
| 367 | table->data_vec[ix] = NULL; | ||
| 368 | write_unlock_irq(&table->rwlock); | ||
| 369 | |||
| 370 | put_gid_entry_locked(entry); | ||
| 371 | } | ||
| 372 | |||
| 373 | /** | ||
| 341 | * add_modify_gid - Add or modify GID table entry | 374 | * add_modify_gid - Add or modify GID table entry |
| 342 | * | 375 | * |
| 343 | * @table: GID table in which GID to be added or modified | 376 | * @table: GID table in which GID to be added or modified |
| @@ -358,7 +391,7 @@ static int add_modify_gid(struct ib_gid_table *table, | |||
| 358 | * this index. | 391 | * this index. |
| 359 | */ | 392 | */ |
| 360 | if (is_gid_entry_valid(table->data_vec[attr->index])) | 393 | if (is_gid_entry_valid(table->data_vec[attr->index])) |
| 361 | put_gid_entry(table->data_vec[attr->index]); | 394 | del_gid(attr->device, attr->port_num, table, attr->index); |
| 362 | 395 | ||
| 363 | /* | 396 | /* |
| 364 | * Some HCA's report multiple GID entries with only one valid GID, and | 397 | * Some HCA's report multiple GID entries with only one valid GID, and |
| @@ -386,39 +419,6 @@ done: | |||
| 386 | return ret; | 419 | return ret; |
| 387 | } | 420 | } |
| 388 | 421 | ||
| 389 | /** | ||
| 390 | * del_gid - Delete GID table entry | ||
| 391 | * | ||
| 392 | * @ib_dev: IB device whose GID entry to be deleted | ||
| 393 | * @port: Port number of the IB device | ||
| 394 | * @table: GID table of the IB device for a port | ||
| 395 | * @ix: GID entry index to delete | ||
| 396 | * | ||
| 397 | */ | ||
| 398 | static void del_gid(struct ib_device *ib_dev, u8 port, | ||
| 399 | struct ib_gid_table *table, int ix) | ||
| 400 | { | ||
| 401 | struct ib_gid_table_entry *entry; | ||
| 402 | |||
| 403 | lockdep_assert_held(&table->lock); | ||
| 404 | |||
| 405 | pr_debug("%s device=%s port=%d index=%d gid %pI6\n", __func__, | ||
| 406 | ib_dev->name, port, ix, | ||
| 407 | table->data_vec[ix]->attr.gid.raw); | ||
| 408 | |||
| 409 | write_lock_irq(&table->rwlock); | ||
| 410 | entry = table->data_vec[ix]; | ||
| 411 | entry->state = GID_TABLE_ENTRY_PENDING_DEL; | ||
| 412 | /* | ||
| 413 | * For non RoCE protocol, GID entry slot is ready to use. | ||
| 414 | */ | ||
| 415 | if (!rdma_protocol_roce(ib_dev, port)) | ||
| 416 | table->data_vec[ix] = NULL; | ||
| 417 | write_unlock_irq(&table->rwlock); | ||
| 418 | |||
| 419 | put_gid_entry_locked(entry); | ||
| 420 | } | ||
| 421 | |||
| 422 | /* rwlock should be read locked, or lock should be held */ | 422 | /* rwlock should be read locked, or lock should be held */ |
| 423 | static int find_gid(struct ib_gid_table *table, const union ib_gid *gid, | 423 | static int find_gid(struct ib_gid_table *table, const union ib_gid *gid, |
| 424 | const struct ib_gid_attr *val, bool default_gid, | 424 | const struct ib_gid_attr *val, bool default_gid, |
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 5f437d1570fb..21863ddde63e 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
| @@ -1759,6 +1759,8 @@ static int ucma_close(struct inode *inode, struct file *filp) | |||
| 1759 | mutex_lock(&mut); | 1759 | mutex_lock(&mut); |
| 1760 | if (!ctx->closing) { | 1760 | if (!ctx->closing) { |
| 1761 | mutex_unlock(&mut); | 1761 | mutex_unlock(&mut); |
| 1762 | ucma_put_ctx(ctx); | ||
| 1763 | wait_for_completion(&ctx->comp); | ||
| 1762 | /* rdma_destroy_id ensures that no event handlers are | 1764 | /* rdma_destroy_id ensures that no event handlers are |
| 1763 | * inflight for that id before releasing it. | 1765 | * inflight for that id before releasing it. |
| 1764 | */ | 1766 | */ |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index a21d5214afc3..e012ca80f9d1 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
| @@ -2027,33 +2027,55 @@ static int modify_qp(struct ib_uverbs_file *file, | |||
| 2027 | 2027 | ||
| 2028 | if ((cmd->base.attr_mask & IB_QP_CUR_STATE && | 2028 | if ((cmd->base.attr_mask & IB_QP_CUR_STATE && |
| 2029 | cmd->base.cur_qp_state > IB_QPS_ERR) || | 2029 | cmd->base.cur_qp_state > IB_QPS_ERR) || |
| 2030 | cmd->base.qp_state > IB_QPS_ERR) { | 2030 | (cmd->base.attr_mask & IB_QP_STATE && |
| 2031 | cmd->base.qp_state > IB_QPS_ERR)) { | ||
| 2031 | ret = -EINVAL; | 2032 | ret = -EINVAL; |
| 2032 | goto release_qp; | 2033 | goto release_qp; |
| 2033 | } | 2034 | } |
| 2034 | 2035 | ||
| 2035 | attr->qp_state = cmd->base.qp_state; | 2036 | if (cmd->base.attr_mask & IB_QP_STATE) |
| 2036 | attr->cur_qp_state = cmd->base.cur_qp_state; | 2037 | attr->qp_state = cmd->base.qp_state; |
| 2037 | attr->path_mtu = cmd->base.path_mtu; | 2038 | if (cmd->base.attr_mask & IB_QP_CUR_STATE) |
| 2038 | attr->path_mig_state = cmd->base.path_mig_state; | 2039 | attr->cur_qp_state = cmd->base.cur_qp_state; |
| 2039 | attr->qkey = cmd->base.qkey; | 2040 | if (cmd->base.attr_mask & IB_QP_PATH_MTU) |
| 2040 | attr->rq_psn = cmd->base.rq_psn; | 2041 | attr->path_mtu = cmd->base.path_mtu; |
| 2041 | attr->sq_psn = cmd->base.sq_psn; | 2042 | if (cmd->base.attr_mask & IB_QP_PATH_MIG_STATE) |
| 2042 | attr->dest_qp_num = cmd->base.dest_qp_num; | 2043 | attr->path_mig_state = cmd->base.path_mig_state; |
| 2043 | attr->qp_access_flags = cmd->base.qp_access_flags; | 2044 | if (cmd->base.attr_mask & IB_QP_QKEY) |
| 2044 | attr->pkey_index = cmd->base.pkey_index; | 2045 | attr->qkey = cmd->base.qkey; |
| 2045 | attr->alt_pkey_index = cmd->base.alt_pkey_index; | 2046 | if (cmd->base.attr_mask & IB_QP_RQ_PSN) |
| 2046 | attr->en_sqd_async_notify = cmd->base.en_sqd_async_notify; | 2047 | attr->rq_psn = cmd->base.rq_psn; |
| 2047 | attr->max_rd_atomic = cmd->base.max_rd_atomic; | 2048 | if (cmd->base.attr_mask & IB_QP_SQ_PSN) |
| 2048 | attr->max_dest_rd_atomic = cmd->base.max_dest_rd_atomic; | 2049 | attr->sq_psn = cmd->base.sq_psn; |
| 2049 | attr->min_rnr_timer = cmd->base.min_rnr_timer; | 2050 | if (cmd->base.attr_mask & IB_QP_DEST_QPN) |
| 2050 | attr->port_num = cmd->base.port_num; | 2051 | attr->dest_qp_num = cmd->base.dest_qp_num; |
| 2051 | attr->timeout = cmd->base.timeout; | 2052 | if (cmd->base.attr_mask & IB_QP_ACCESS_FLAGS) |
| 2052 | attr->retry_cnt = cmd->base.retry_cnt; | 2053 | attr->qp_access_flags = cmd->base.qp_access_flags; |
| 2053 | attr->rnr_retry = cmd->base.rnr_retry; | 2054 | if (cmd->base.attr_mask & IB_QP_PKEY_INDEX) |
| 2054 | attr->alt_port_num = cmd->base.alt_port_num; | 2055 | attr->pkey_index = cmd->base.pkey_index; |
| 2055 | attr->alt_timeout = cmd->base.alt_timeout; | 2056 | if (cmd->base.attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) |
| 2056 | attr->rate_limit = cmd->rate_limit; | 2057 | attr->en_sqd_async_notify = cmd->base.en_sqd_async_notify; |
| 2058 | if (cmd->base.attr_mask & IB_QP_MAX_QP_RD_ATOMIC) | ||
| 2059 | attr->max_rd_atomic = cmd->base.max_rd_atomic; | ||
| 2060 | if (cmd->base.attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) | ||
| 2061 | attr->max_dest_rd_atomic = cmd->base.max_dest_rd_atomic; | ||
| 2062 | if (cmd->base.attr_mask & IB_QP_MIN_RNR_TIMER) | ||
| 2063 | attr->min_rnr_timer = cmd->base.min_rnr_timer; | ||
| 2064 | if (cmd->base.attr_mask & IB_QP_PORT) | ||
| 2065 | attr->port_num = cmd->base.port_num; | ||
| 2066 | if (cmd->base.attr_mask & IB_QP_TIMEOUT) | ||
| 2067 | attr->timeout = cmd->base.timeout; | ||
| 2068 | if (cmd->base.attr_mask & IB_QP_RETRY_CNT) | ||
| 2069 | attr->retry_cnt = cmd->base.retry_cnt; | ||
| 2070 | if (cmd->base.attr_mask & IB_QP_RNR_RETRY) | ||
| 2071 | attr->rnr_retry = cmd->base.rnr_retry; | ||
| 2072 | if (cmd->base.attr_mask & IB_QP_ALT_PATH) { | ||
| 2073 | attr->alt_port_num = cmd->base.alt_port_num; | ||
| 2074 | attr->alt_timeout = cmd->base.alt_timeout; | ||
| 2075 | attr->alt_pkey_index = cmd->base.alt_pkey_index; | ||
| 2076 | } | ||
| 2077 | if (cmd->base.attr_mask & IB_QP_RATE_LIMIT) | ||
| 2078 | attr->rate_limit = cmd->rate_limit; | ||
| 2057 | 2079 | ||
| 2058 | if (cmd->base.attr_mask & IB_QP_AV) | 2080 | if (cmd->base.attr_mask & IB_QP_AV) |
| 2059 | copy_ah_attr_from_uverbs(qp->device, &attr->ah_attr, | 2081 | copy_ah_attr_from_uverbs(qp->device, &attr->ah_attr, |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 6d974e2363df..50152c1b1004 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
| @@ -440,6 +440,7 @@ static int ib_uverbs_comp_event_close(struct inode *inode, struct file *filp) | |||
| 440 | list_del(&entry->obj_list); | 440 | list_del(&entry->obj_list); |
| 441 | kfree(entry); | 441 | kfree(entry); |
| 442 | } | 442 | } |
| 443 | file->ev_queue.is_closed = 1; | ||
| 443 | spin_unlock_irq(&file->ev_queue.lock); | 444 | spin_unlock_irq(&file->ev_queue.lock); |
| 444 | 445 | ||
| 445 | uverbs_close_fd(filp); | 446 | uverbs_close_fd(filp); |
diff --git a/drivers/infiniband/core/uverbs_uapi.c b/drivers/infiniband/core/uverbs_uapi.c index 73ea6f0db88f..be854628a7c6 100644 --- a/drivers/infiniband/core/uverbs_uapi.c +++ b/drivers/infiniband/core/uverbs_uapi.c | |||
| @@ -248,6 +248,7 @@ void uverbs_destroy_api(struct uverbs_api *uapi) | |||
| 248 | kfree(rcu_dereference_protected(*slot, true)); | 248 | kfree(rcu_dereference_protected(*slot, true)); |
| 249 | radix_tree_iter_delete(&uapi->radix, &iter, slot); | 249 | radix_tree_iter_delete(&uapi->radix, &iter, slot); |
| 250 | } | 250 | } |
| 251 | kfree(uapi); | ||
| 251 | } | 252 | } |
| 252 | 253 | ||
| 253 | struct uverbs_api *uverbs_alloc_api( | 254 | struct uverbs_api *uverbs_alloc_api( |
diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 20b9f31052bf..85cd1a3593d6 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c | |||
| @@ -78,7 +78,7 @@ static struct list_head bnxt_re_dev_list = LIST_HEAD_INIT(bnxt_re_dev_list); | |||
| 78 | /* Mutex to protect the list of bnxt_re devices added */ | 78 | /* Mutex to protect the list of bnxt_re devices added */ |
| 79 | static DEFINE_MUTEX(bnxt_re_dev_lock); | 79 | static DEFINE_MUTEX(bnxt_re_dev_lock); |
| 80 | static struct workqueue_struct *bnxt_re_wq; | 80 | static struct workqueue_struct *bnxt_re_wq; |
| 81 | static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev, bool lock_wait); | 81 | static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev); |
| 82 | 82 | ||
| 83 | /* SR-IOV helper functions */ | 83 | /* SR-IOV helper functions */ |
| 84 | 84 | ||
| @@ -182,7 +182,7 @@ static void bnxt_re_shutdown(void *p) | |||
| 182 | if (!rdev) | 182 | if (!rdev) |
| 183 | return; | 183 | return; |
| 184 | 184 | ||
| 185 | bnxt_re_ib_unreg(rdev, false); | 185 | bnxt_re_ib_unreg(rdev); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | static void bnxt_re_stop_irq(void *handle) | 188 | static void bnxt_re_stop_irq(void *handle) |
| @@ -251,7 +251,7 @@ static struct bnxt_ulp_ops bnxt_re_ulp_ops = { | |||
| 251 | /* Driver registration routines used to let the networking driver (bnxt_en) | 251 | /* Driver registration routines used to let the networking driver (bnxt_en) |
| 252 | * to know that the RoCE driver is now installed | 252 | * to know that the RoCE driver is now installed |
| 253 | */ | 253 | */ |
| 254 | static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev, bool lock_wait) | 254 | static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev) |
| 255 | { | 255 | { |
| 256 | struct bnxt_en_dev *en_dev; | 256 | struct bnxt_en_dev *en_dev; |
| 257 | int rc; | 257 | int rc; |
| @@ -260,14 +260,9 @@ static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev, bool lock_wait) | |||
| 260 | return -EINVAL; | 260 | return -EINVAL; |
| 261 | 261 | ||
| 262 | en_dev = rdev->en_dev; | 262 | en_dev = rdev->en_dev; |
| 263 | /* Acquire rtnl lock if it is not invokded from netdev event */ | ||
| 264 | if (lock_wait) | ||
| 265 | rtnl_lock(); | ||
| 266 | 263 | ||
| 267 | rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev, | 264 | rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev, |
| 268 | BNXT_ROCE_ULP); | 265 | BNXT_ROCE_ULP); |
| 269 | if (lock_wait) | ||
| 270 | rtnl_unlock(); | ||
| 271 | return rc; | 266 | return rc; |
| 272 | } | 267 | } |
| 273 | 268 | ||
| @@ -281,14 +276,12 @@ static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev) | |||
| 281 | 276 | ||
| 282 | en_dev = rdev->en_dev; | 277 | en_dev = rdev->en_dev; |
| 283 | 278 | ||
| 284 | rtnl_lock(); | ||
| 285 | rc = en_dev->en_ops->bnxt_register_device(en_dev, BNXT_ROCE_ULP, | 279 | rc = en_dev->en_ops->bnxt_register_device(en_dev, BNXT_ROCE_ULP, |
| 286 | &bnxt_re_ulp_ops, rdev); | 280 | &bnxt_re_ulp_ops, rdev); |
| 287 | rtnl_unlock(); | ||
| 288 | return rc; | 281 | return rc; |
| 289 | } | 282 | } |
| 290 | 283 | ||
| 291 | static int bnxt_re_free_msix(struct bnxt_re_dev *rdev, bool lock_wait) | 284 | static int bnxt_re_free_msix(struct bnxt_re_dev *rdev) |
| 292 | { | 285 | { |
| 293 | struct bnxt_en_dev *en_dev; | 286 | struct bnxt_en_dev *en_dev; |
| 294 | int rc; | 287 | int rc; |
| @@ -298,13 +291,9 @@ static int bnxt_re_free_msix(struct bnxt_re_dev *rdev, bool lock_wait) | |||
| 298 | 291 | ||
| 299 | en_dev = rdev->en_dev; | 292 | en_dev = rdev->en_dev; |
| 300 | 293 | ||
| 301 | if (lock_wait) | ||
| 302 | rtnl_lock(); | ||
| 303 | 294 | ||
| 304 | rc = en_dev->en_ops->bnxt_free_msix(rdev->en_dev, BNXT_ROCE_ULP); | 295 | rc = en_dev->en_ops->bnxt_free_msix(rdev->en_dev, BNXT_ROCE_ULP); |
| 305 | 296 | ||
| 306 | if (lock_wait) | ||
| 307 | rtnl_unlock(); | ||
| 308 | return rc; | 297 | return rc; |
| 309 | } | 298 | } |
| 310 | 299 | ||
| @@ -320,7 +309,6 @@ static int bnxt_re_request_msix(struct bnxt_re_dev *rdev) | |||
| 320 | 309 | ||
| 321 | num_msix_want = min_t(u32, BNXT_RE_MAX_MSIX, num_online_cpus()); | 310 | num_msix_want = min_t(u32, BNXT_RE_MAX_MSIX, num_online_cpus()); |
| 322 | 311 | ||
| 323 | rtnl_lock(); | ||
| 324 | num_msix_got = en_dev->en_ops->bnxt_request_msix(en_dev, BNXT_ROCE_ULP, | 312 | num_msix_got = en_dev->en_ops->bnxt_request_msix(en_dev, BNXT_ROCE_ULP, |
| 325 | rdev->msix_entries, | 313 | rdev->msix_entries, |
| 326 | num_msix_want); | 314 | num_msix_want); |
| @@ -335,7 +323,6 @@ static int bnxt_re_request_msix(struct bnxt_re_dev *rdev) | |||
| 335 | } | 323 | } |
| 336 | rdev->num_msix = num_msix_got; | 324 | rdev->num_msix = num_msix_got; |
| 337 | done: | 325 | done: |
| 338 | rtnl_unlock(); | ||
| 339 | return rc; | 326 | return rc; |
| 340 | } | 327 | } |
| 341 | 328 | ||
| @@ -358,24 +345,18 @@ static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg, | |||
| 358 | fw_msg->timeout = timeout; | 345 | fw_msg->timeout = timeout; |
| 359 | } | 346 | } |
| 360 | 347 | ||
| 361 | static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, u16 fw_ring_id, | 348 | static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, u16 fw_ring_id) |
| 362 | bool lock_wait) | ||
| 363 | { | 349 | { |
| 364 | struct bnxt_en_dev *en_dev = rdev->en_dev; | 350 | struct bnxt_en_dev *en_dev = rdev->en_dev; |
| 365 | struct hwrm_ring_free_input req = {0}; | 351 | struct hwrm_ring_free_input req = {0}; |
| 366 | struct hwrm_ring_free_output resp; | 352 | struct hwrm_ring_free_output resp; |
| 367 | struct bnxt_fw_msg fw_msg; | 353 | struct bnxt_fw_msg fw_msg; |
| 368 | bool do_unlock = false; | ||
| 369 | int rc = -EINVAL; | 354 | int rc = -EINVAL; |
| 370 | 355 | ||
| 371 | if (!en_dev) | 356 | if (!en_dev) |
| 372 | return rc; | 357 | return rc; |
| 373 | 358 | ||
| 374 | memset(&fw_msg, 0, sizeof(fw_msg)); | 359 | memset(&fw_msg, 0, sizeof(fw_msg)); |
| 375 | if (lock_wait) { | ||
| 376 | rtnl_lock(); | ||
| 377 | do_unlock = true; | ||
| 378 | } | ||
| 379 | 360 | ||
| 380 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_FREE, -1, -1); | 361 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_FREE, -1, -1); |
| 381 | req.ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; | 362 | req.ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; |
| @@ -386,8 +367,6 @@ static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, u16 fw_ring_id, | |||
| 386 | if (rc) | 367 | if (rc) |
| 387 | dev_err(rdev_to_dev(rdev), | 368 | dev_err(rdev_to_dev(rdev), |
| 388 | "Failed to free HW ring:%d :%#x", req.ring_id, rc); | 369 | "Failed to free HW ring:%d :%#x", req.ring_id, rc); |
| 389 | if (do_unlock) | ||
| 390 | rtnl_unlock(); | ||
| 391 | return rc; | 370 | return rc; |
| 392 | } | 371 | } |
| 393 | 372 | ||
| @@ -405,7 +384,6 @@ static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, dma_addr_t *dma_arr, | |||
| 405 | return rc; | 384 | return rc; |
| 406 | 385 | ||
| 407 | memset(&fw_msg, 0, sizeof(fw_msg)); | 386 | memset(&fw_msg, 0, sizeof(fw_msg)); |
| 408 | rtnl_lock(); | ||
| 409 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1); | 387 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1); |
| 410 | req.enables = 0; | 388 | req.enables = 0; |
| 411 | req.page_tbl_addr = cpu_to_le64(dma_arr[0]); | 389 | req.page_tbl_addr = cpu_to_le64(dma_arr[0]); |
| @@ -426,27 +404,21 @@ static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, dma_addr_t *dma_arr, | |||
| 426 | if (!rc) | 404 | if (!rc) |
| 427 | *fw_ring_id = le16_to_cpu(resp.ring_id); | 405 | *fw_ring_id = le16_to_cpu(resp.ring_id); |
| 428 | 406 | ||
| 429 | rtnl_unlock(); | ||
| 430 | return rc; | 407 | return rc; |
| 431 | } | 408 | } |
| 432 | 409 | ||
| 433 | static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev, | 410 | static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev, |
| 434 | u32 fw_stats_ctx_id, bool lock_wait) | 411 | u32 fw_stats_ctx_id) |
| 435 | { | 412 | { |
| 436 | struct bnxt_en_dev *en_dev = rdev->en_dev; | 413 | struct bnxt_en_dev *en_dev = rdev->en_dev; |
| 437 | struct hwrm_stat_ctx_free_input req = {0}; | 414 | struct hwrm_stat_ctx_free_input req = {0}; |
| 438 | struct bnxt_fw_msg fw_msg; | 415 | struct bnxt_fw_msg fw_msg; |
| 439 | bool do_unlock = false; | ||
| 440 | int rc = -EINVAL; | 416 | int rc = -EINVAL; |
| 441 | 417 | ||
| 442 | if (!en_dev) | 418 | if (!en_dev) |
| 443 | return rc; | 419 | return rc; |
| 444 | 420 | ||
| 445 | memset(&fw_msg, 0, sizeof(fw_msg)); | 421 | memset(&fw_msg, 0, sizeof(fw_msg)); |
| 446 | if (lock_wait) { | ||
| 447 | rtnl_lock(); | ||
| 448 | do_unlock = true; | ||
| 449 | } | ||
| 450 | 422 | ||
| 451 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_FREE, -1, -1); | 423 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_FREE, -1, -1); |
| 452 | req.stat_ctx_id = cpu_to_le32(fw_stats_ctx_id); | 424 | req.stat_ctx_id = cpu_to_le32(fw_stats_ctx_id); |
| @@ -457,8 +429,6 @@ static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev, | |||
| 457 | dev_err(rdev_to_dev(rdev), | 429 | dev_err(rdev_to_dev(rdev), |
| 458 | "Failed to free HW stats context %#x", rc); | 430 | "Failed to free HW stats context %#x", rc); |
| 459 | 431 | ||
| 460 | if (do_unlock) | ||
| 461 | rtnl_unlock(); | ||
| 462 | return rc; | 432 | return rc; |
| 463 | } | 433 | } |
| 464 | 434 | ||
| @@ -478,7 +448,6 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, | |||
| 478 | return rc; | 448 | return rc; |
| 479 | 449 | ||
| 480 | memset(&fw_msg, 0, sizeof(fw_msg)); | 450 | memset(&fw_msg, 0, sizeof(fw_msg)); |
| 481 | rtnl_lock(); | ||
| 482 | 451 | ||
| 483 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1); | 452 | bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1); |
| 484 | req.update_period_ms = cpu_to_le32(1000); | 453 | req.update_period_ms = cpu_to_le32(1000); |
| @@ -490,7 +459,6 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, | |||
| 490 | if (!rc) | 459 | if (!rc) |
| 491 | *fw_stats_ctx_id = le32_to_cpu(resp.stat_ctx_id); | 460 | *fw_stats_ctx_id = le32_to_cpu(resp.stat_ctx_id); |
| 492 | 461 | ||
| 493 | rtnl_unlock(); | ||
| 494 | return rc; | 462 | return rc; |
| 495 | } | 463 | } |
| 496 | 464 | ||
| @@ -929,19 +897,19 @@ fail: | |||
| 929 | return rc; | 897 | return rc; |
| 930 | } | 898 | } |
| 931 | 899 | ||
| 932 | static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev, bool lock_wait) | 900 | static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev) |
| 933 | { | 901 | { |
| 934 | int i; | 902 | int i; |
| 935 | 903 | ||
| 936 | for (i = 0; i < rdev->num_msix - 1; i++) { | 904 | for (i = 0; i < rdev->num_msix - 1; i++) { |
| 937 | bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, lock_wait); | 905 | bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id); |
| 938 | bnxt_qplib_free_nq(&rdev->nq[i]); | 906 | bnxt_qplib_free_nq(&rdev->nq[i]); |
| 939 | } | 907 | } |
| 940 | } | 908 | } |
| 941 | 909 | ||
| 942 | static void bnxt_re_free_res(struct bnxt_re_dev *rdev, bool lock_wait) | 910 | static void bnxt_re_free_res(struct bnxt_re_dev *rdev) |
| 943 | { | 911 | { |
| 944 | bnxt_re_free_nq_res(rdev, lock_wait); | 912 | bnxt_re_free_nq_res(rdev); |
| 945 | 913 | ||
| 946 | if (rdev->qplib_res.dpi_tbl.max) { | 914 | if (rdev->qplib_res.dpi_tbl.max) { |
| 947 | bnxt_qplib_dealloc_dpi(&rdev->qplib_res, | 915 | bnxt_qplib_dealloc_dpi(&rdev->qplib_res, |
| @@ -1219,7 +1187,7 @@ static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev) | |||
| 1219 | return 0; | 1187 | return 0; |
| 1220 | } | 1188 | } |
| 1221 | 1189 | ||
| 1222 | static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev, bool lock_wait) | 1190 | static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev) |
| 1223 | { | 1191 | { |
| 1224 | int i, rc; | 1192 | int i, rc; |
| 1225 | 1193 | ||
| @@ -1234,28 +1202,27 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev, bool lock_wait) | |||
| 1234 | cancel_delayed_work(&rdev->worker); | 1202 | cancel_delayed_work(&rdev->worker); |
| 1235 | 1203 | ||
| 1236 | bnxt_re_cleanup_res(rdev); | 1204 | bnxt_re_cleanup_res(rdev); |
| 1237 | bnxt_re_free_res(rdev, lock_wait); | 1205 | bnxt_re_free_res(rdev); |
| 1238 | 1206 | ||
| 1239 | if (test_and_clear_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags)) { | 1207 | if (test_and_clear_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags)) { |
| 1240 | rc = bnxt_qplib_deinit_rcfw(&rdev->rcfw); | 1208 | rc = bnxt_qplib_deinit_rcfw(&rdev->rcfw); |
| 1241 | if (rc) | 1209 | if (rc) |
| 1242 | dev_warn(rdev_to_dev(rdev), | 1210 | dev_warn(rdev_to_dev(rdev), |
| 1243 | "Failed to deinitialize RCFW: %#x", rc); | 1211 | "Failed to deinitialize RCFW: %#x", rc); |
| 1244 | bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id, | 1212 | bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); |
| 1245 | lock_wait); | ||
| 1246 | bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx); | 1213 | bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx); |
| 1247 | bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); | 1214 | bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); |
| 1248 | bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id, lock_wait); | 1215 | bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id); |
| 1249 | bnxt_qplib_free_rcfw_channel(&rdev->rcfw); | 1216 | bnxt_qplib_free_rcfw_channel(&rdev->rcfw); |
| 1250 | } | 1217 | } |
| 1251 | if (test_and_clear_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags)) { | 1218 | if (test_and_clear_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags)) { |
| 1252 | rc = bnxt_re_free_msix(rdev, lock_wait); | 1219 | rc = bnxt_re_free_msix(rdev); |
| 1253 | if (rc) | 1220 | if (rc) |
| 1254 | dev_warn(rdev_to_dev(rdev), | 1221 | dev_warn(rdev_to_dev(rdev), |
| 1255 | "Failed to free MSI-X vectors: %#x", rc); | 1222 | "Failed to free MSI-X vectors: %#x", rc); |
| 1256 | } | 1223 | } |
| 1257 | if (test_and_clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags)) { | 1224 | if (test_and_clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags)) { |
| 1258 | rc = bnxt_re_unregister_netdev(rdev, lock_wait); | 1225 | rc = bnxt_re_unregister_netdev(rdev); |
| 1259 | if (rc) | 1226 | if (rc) |
| 1260 | dev_warn(rdev_to_dev(rdev), | 1227 | dev_warn(rdev_to_dev(rdev), |
| 1261 | "Failed to unregister with netdev: %#x", rc); | 1228 | "Failed to unregister with netdev: %#x", rc); |
| @@ -1276,6 +1243,12 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) | |||
| 1276 | { | 1243 | { |
| 1277 | int i, j, rc; | 1244 | int i, j, rc; |
| 1278 | 1245 | ||
| 1246 | bool locked; | ||
| 1247 | |||
| 1248 | /* Acquire rtnl lock through out this function */ | ||
| 1249 | rtnl_lock(); | ||
| 1250 | locked = true; | ||
| 1251 | |||
| 1279 | /* Registered a new RoCE device instance to netdev */ | 1252 | /* Registered a new RoCE device instance to netdev */ |
| 1280 | rc = bnxt_re_register_netdev(rdev); | 1253 | rc = bnxt_re_register_netdev(rdev); |
| 1281 | if (rc) { | 1254 | if (rc) { |
| @@ -1374,12 +1347,16 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) | |||
| 1374 | schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000)); | 1347 | schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000)); |
| 1375 | } | 1348 | } |
| 1376 | 1349 | ||
| 1350 | rtnl_unlock(); | ||
| 1351 | locked = false; | ||
| 1352 | |||
| 1377 | /* Register ib dev */ | 1353 | /* Register ib dev */ |
| 1378 | rc = bnxt_re_register_ib(rdev); | 1354 | rc = bnxt_re_register_ib(rdev); |
| 1379 | if (rc) { | 1355 | if (rc) { |
| 1380 | pr_err("Failed to register with IB: %#x\n", rc); | 1356 | pr_err("Failed to register with IB: %#x\n", rc); |
| 1381 | goto fail; | 1357 | goto fail; |
| 1382 | } | 1358 | } |
| 1359 | set_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags); | ||
| 1383 | dev_info(rdev_to_dev(rdev), "Device registered successfully"); | 1360 | dev_info(rdev_to_dev(rdev), "Device registered successfully"); |
| 1384 | for (i = 0; i < ARRAY_SIZE(bnxt_re_attributes); i++) { | 1361 | for (i = 0; i < ARRAY_SIZE(bnxt_re_attributes); i++) { |
| 1385 | rc = device_create_file(&rdev->ibdev.dev, | 1362 | rc = device_create_file(&rdev->ibdev.dev, |
| @@ -1395,7 +1372,6 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) | |||
| 1395 | goto fail; | 1372 | goto fail; |
| 1396 | } | 1373 | } |
| 1397 | } | 1374 | } |
| 1398 | set_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags); | ||
| 1399 | ib_get_eth_speed(&rdev->ibdev, 1, &rdev->active_speed, | 1375 | ib_get_eth_speed(&rdev->ibdev, 1, &rdev->active_speed, |
| 1400 | &rdev->active_width); | 1376 | &rdev->active_width); |
| 1401 | set_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags); | 1377 | set_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags); |
| @@ -1404,17 +1380,21 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) | |||
| 1404 | 1380 | ||
| 1405 | return 0; | 1381 | return 0; |
| 1406 | free_sctx: | 1382 | free_sctx: |
| 1407 | bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id, true); | 1383 | bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); |
| 1408 | free_ctx: | 1384 | free_ctx: |
| 1409 | bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx); | 1385 | bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx); |
| 1410 | disable_rcfw: | 1386 | disable_rcfw: |
| 1411 | bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); | 1387 | bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); |
| 1412 | free_ring: | 1388 | free_ring: |
| 1413 | bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id, true); | 1389 | bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id); |
| 1414 | free_rcfw: | 1390 | free_rcfw: |
| 1415 | bnxt_qplib_free_rcfw_channel(&rdev->rcfw); | 1391 | bnxt_qplib_free_rcfw_channel(&rdev->rcfw); |
| 1416 | fail: | 1392 | fail: |
| 1417 | bnxt_re_ib_unreg(rdev, true); | 1393 | if (!locked) |
| 1394 | rtnl_lock(); | ||
| 1395 | bnxt_re_ib_unreg(rdev); | ||
| 1396 | rtnl_unlock(); | ||
| 1397 | |||
| 1418 | return rc; | 1398 | return rc; |
| 1419 | } | 1399 | } |
| 1420 | 1400 | ||
| @@ -1567,7 +1547,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier, | |||
| 1567 | */ | 1547 | */ |
| 1568 | if (atomic_read(&rdev->sched_count) > 0) | 1548 | if (atomic_read(&rdev->sched_count) > 0) |
| 1569 | goto exit; | 1549 | goto exit; |
| 1570 | bnxt_re_ib_unreg(rdev, false); | 1550 | bnxt_re_ib_unreg(rdev); |
| 1571 | bnxt_re_remove_one(rdev); | 1551 | bnxt_re_remove_one(rdev); |
| 1572 | bnxt_re_dev_unreg(rdev); | 1552 | bnxt_re_dev_unreg(rdev); |
| 1573 | break; | 1553 | break; |
| @@ -1646,7 +1626,10 @@ static void __exit bnxt_re_mod_exit(void) | |||
| 1646 | */ | 1626 | */ |
| 1647 | flush_workqueue(bnxt_re_wq); | 1627 | flush_workqueue(bnxt_re_wq); |
| 1648 | bnxt_re_dev_stop(rdev); | 1628 | bnxt_re_dev_stop(rdev); |
| 1649 | bnxt_re_ib_unreg(rdev, true); | 1629 | /* Acquire the rtnl_lock as the L2 resources are freed here */ |
| 1630 | rtnl_lock(); | ||
| 1631 | bnxt_re_ib_unreg(rdev); | ||
| 1632 | rtnl_unlock(); | ||
| 1650 | bnxt_re_remove_one(rdev); | 1633 | bnxt_re_remove_one(rdev); |
| 1651 | bnxt_re_dev_unreg(rdev); | 1634 | bnxt_re_dev_unreg(rdev); |
| 1652 | } | 1635 | } |
diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index 2c19bf772451..e1668bcc2d13 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c | |||
| @@ -6733,6 +6733,7 @@ void start_freeze_handling(struct hfi1_pportdata *ppd, int flags) | |||
| 6733 | struct hfi1_devdata *dd = ppd->dd; | 6733 | struct hfi1_devdata *dd = ppd->dd; |
| 6734 | struct send_context *sc; | 6734 | struct send_context *sc; |
| 6735 | int i; | 6735 | int i; |
| 6736 | int sc_flags; | ||
| 6736 | 6737 | ||
| 6737 | if (flags & FREEZE_SELF) | 6738 | if (flags & FREEZE_SELF) |
| 6738 | write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK); | 6739 | write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK); |
| @@ -6743,11 +6744,13 @@ void start_freeze_handling(struct hfi1_pportdata *ppd, int flags) | |||
| 6743 | /* notify all SDMA engines that they are going into a freeze */ | 6744 | /* notify all SDMA engines that they are going into a freeze */ |
| 6744 | sdma_freeze_notify(dd, !!(flags & FREEZE_LINK_DOWN)); | 6745 | sdma_freeze_notify(dd, !!(flags & FREEZE_LINK_DOWN)); |
| 6745 | 6746 | ||
| 6747 | sc_flags = SCF_FROZEN | SCF_HALTED | (flags & FREEZE_LINK_DOWN ? | ||
| 6748 | SCF_LINK_DOWN : 0); | ||
| 6746 | /* do halt pre-handling on all enabled send contexts */ | 6749 | /* do halt pre-handling on all enabled send contexts */ |
| 6747 | for (i = 0; i < dd->num_send_contexts; i++) { | 6750 | for (i = 0; i < dd->num_send_contexts; i++) { |
| 6748 | sc = dd->send_contexts[i].sc; | 6751 | sc = dd->send_contexts[i].sc; |
| 6749 | if (sc && (sc->flags & SCF_ENABLED)) | 6752 | if (sc && (sc->flags & SCF_ENABLED)) |
| 6750 | sc_stop(sc, SCF_FROZEN | SCF_HALTED); | 6753 | sc_stop(sc, sc_flags); |
| 6751 | } | 6754 | } |
| 6752 | 6755 | ||
| 6753 | /* Send context are frozen. Notify user space */ | 6756 | /* Send context are frozen. Notify user space */ |
| @@ -10674,6 +10677,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state) | |||
| 10674 | add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK); | 10677 | add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK); |
| 10675 | 10678 | ||
| 10676 | handle_linkup_change(dd, 1); | 10679 | handle_linkup_change(dd, 1); |
| 10680 | pio_kernel_linkup(dd); | ||
| 10677 | 10681 | ||
| 10678 | /* | 10682 | /* |
| 10679 | * After link up, a new link width will have been set. | 10683 | * After link up, a new link width will have been set. |
diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index c2c1cba5b23b..752057647f09 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c | |||
| @@ -86,6 +86,7 @@ void pio_send_control(struct hfi1_devdata *dd, int op) | |||
| 86 | unsigned long flags; | 86 | unsigned long flags; |
| 87 | int write = 1; /* write sendctrl back */ | 87 | int write = 1; /* write sendctrl back */ |
| 88 | int flush = 0; /* re-read sendctrl to make sure it is flushed */ | 88 | int flush = 0; /* re-read sendctrl to make sure it is flushed */ |
| 89 | int i; | ||
| 89 | 90 | ||
| 90 | spin_lock_irqsave(&dd->sendctrl_lock, flags); | 91 | spin_lock_irqsave(&dd->sendctrl_lock, flags); |
| 91 | 92 | ||
| @@ -95,9 +96,13 @@ void pio_send_control(struct hfi1_devdata *dd, int op) | |||
| 95 | reg |= SEND_CTRL_SEND_ENABLE_SMASK; | 96 | reg |= SEND_CTRL_SEND_ENABLE_SMASK; |
| 96 | /* Fall through */ | 97 | /* Fall through */ |
| 97 | case PSC_DATA_VL_ENABLE: | 98 | case PSC_DATA_VL_ENABLE: |
| 99 | mask = 0; | ||
| 100 | for (i = 0; i < ARRAY_SIZE(dd->vld); i++) | ||
| 101 | if (!dd->vld[i].mtu) | ||
| 102 | mask |= BIT_ULL(i); | ||
| 98 | /* Disallow sending on VLs not enabled */ | 103 | /* Disallow sending on VLs not enabled */ |
| 99 | mask = (((~0ull) << num_vls) & SEND_CTRL_UNSUPPORTED_VL_MASK) << | 104 | mask = (mask & SEND_CTRL_UNSUPPORTED_VL_MASK) << |
| 100 | SEND_CTRL_UNSUPPORTED_VL_SHIFT; | 105 | SEND_CTRL_UNSUPPORTED_VL_SHIFT; |
| 101 | reg = (reg & ~SEND_CTRL_UNSUPPORTED_VL_SMASK) | mask; | 106 | reg = (reg & ~SEND_CTRL_UNSUPPORTED_VL_SMASK) | mask; |
| 102 | break; | 107 | break; |
| 103 | case PSC_GLOBAL_DISABLE: | 108 | case PSC_GLOBAL_DISABLE: |
| @@ -921,20 +926,18 @@ void sc_free(struct send_context *sc) | |||
| 921 | void sc_disable(struct send_context *sc) | 926 | void sc_disable(struct send_context *sc) |
| 922 | { | 927 | { |
| 923 | u64 reg; | 928 | u64 reg; |
| 924 | unsigned long flags; | ||
| 925 | struct pio_buf *pbuf; | 929 | struct pio_buf *pbuf; |
| 926 | 930 | ||
| 927 | if (!sc) | 931 | if (!sc) |
| 928 | return; | 932 | return; |
| 929 | 933 | ||
| 930 | /* do all steps, even if already disabled */ | 934 | /* do all steps, even if already disabled */ |
| 931 | spin_lock_irqsave(&sc->alloc_lock, flags); | 935 | spin_lock_irq(&sc->alloc_lock); |
| 932 | reg = read_kctxt_csr(sc->dd, sc->hw_context, SC(CTRL)); | 936 | reg = read_kctxt_csr(sc->dd, sc->hw_context, SC(CTRL)); |
| 933 | reg &= ~SC(CTRL_CTXT_ENABLE_SMASK); | 937 | reg &= ~SC(CTRL_CTXT_ENABLE_SMASK); |
| 934 | sc->flags &= ~SCF_ENABLED; | 938 | sc->flags &= ~SCF_ENABLED; |
| 935 | sc_wait_for_packet_egress(sc, 1); | 939 | sc_wait_for_packet_egress(sc, 1); |
| 936 | write_kctxt_csr(sc->dd, sc->hw_context, SC(CTRL), reg); | 940 | write_kctxt_csr(sc->dd, sc->hw_context, SC(CTRL), reg); |
| 937 | spin_unlock_irqrestore(&sc->alloc_lock, flags); | ||
| 938 | 941 | ||
| 939 | /* | 942 | /* |
| 940 | * Flush any waiters. Once the context is disabled, | 943 | * Flush any waiters. Once the context is disabled, |
| @@ -944,7 +947,7 @@ void sc_disable(struct send_context *sc) | |||
| 944 | * proceed with the flush. | 947 | * proceed with the flush. |
| 945 | */ | 948 | */ |
| 946 | udelay(1); | 949 | udelay(1); |
| 947 | spin_lock_irqsave(&sc->release_lock, flags); | 950 | spin_lock(&sc->release_lock); |
| 948 | if (sc->sr) { /* this context has a shadow ring */ | 951 | if (sc->sr) { /* this context has a shadow ring */ |
| 949 | while (sc->sr_tail != sc->sr_head) { | 952 | while (sc->sr_tail != sc->sr_head) { |
| 950 | pbuf = &sc->sr[sc->sr_tail].pbuf; | 953 | pbuf = &sc->sr[sc->sr_tail].pbuf; |
| @@ -955,7 +958,8 @@ void sc_disable(struct send_context *sc) | |||
| 955 | sc->sr_tail = 0; | 958 | sc->sr_tail = 0; |
| 956 | } | 959 | } |
| 957 | } | 960 | } |
| 958 | spin_unlock_irqrestore(&sc->release_lock, flags); | 961 | spin_unlock(&sc->release_lock); |
| 962 | spin_unlock_irq(&sc->alloc_lock); | ||
| 959 | } | 963 | } |
| 960 | 964 | ||
| 961 | /* return SendEgressCtxtStatus.PacketOccupancy */ | 965 | /* return SendEgressCtxtStatus.PacketOccupancy */ |
| @@ -1178,11 +1182,39 @@ void pio_kernel_unfreeze(struct hfi1_devdata *dd) | |||
| 1178 | sc = dd->send_contexts[i].sc; | 1182 | sc = dd->send_contexts[i].sc; |
| 1179 | if (!sc || !(sc->flags & SCF_FROZEN) || sc->type == SC_USER) | 1183 | if (!sc || !(sc->flags & SCF_FROZEN) || sc->type == SC_USER) |
| 1180 | continue; | 1184 | continue; |
| 1185 | if (sc->flags & SCF_LINK_DOWN) | ||
| 1186 | continue; | ||
| 1181 | 1187 | ||
| 1182 | sc_enable(sc); /* will clear the sc frozen flag */ | 1188 | sc_enable(sc); /* will clear the sc frozen flag */ |
| 1183 | } | 1189 | } |
| 1184 | } | 1190 | } |
| 1185 | 1191 | ||
| 1192 | /** | ||
| 1193 | * pio_kernel_linkup() - Re-enable send contexts after linkup event | ||
| 1194 | * @dd: valid devive data | ||
| 1195 | * | ||
| 1196 | * When the link goes down, the freeze path is taken. However, a link down | ||
| 1197 | * event is different from a freeze because if the send context is re-enabled | ||
| 1198 | * whowever is sending data will start sending data again, which will hang | ||
| 1199 | * any QP that is sending data. | ||
| 1200 | * | ||
| 1201 | * The freeze path now looks at the type of event that occurs and takes this | ||
| 1202 | * path for link down event. | ||
| 1203 | */ | ||
| 1204 | void pio_kernel_linkup(struct hfi1_devdata *dd) | ||
| 1205 | { | ||
| 1206 | struct send_context *sc; | ||
| 1207 | int i; | ||
| 1208 | |||
| 1209 | for (i = 0; i < dd->num_send_contexts; i++) { | ||
| 1210 | sc = dd->send_contexts[i].sc; | ||
| 1211 | if (!sc || !(sc->flags & SCF_LINK_DOWN) || sc->type == SC_USER) | ||
| 1212 | continue; | ||
| 1213 | |||
| 1214 | sc_enable(sc); /* will clear the sc link down flag */ | ||
| 1215 | } | ||
| 1216 | } | ||
| 1217 | |||
| 1186 | /* | 1218 | /* |
| 1187 | * Wait for the SendPioInitCtxt.PioInitInProgress bit to clear. | 1219 | * Wait for the SendPioInitCtxt.PioInitInProgress bit to clear. |
| 1188 | * Returns: | 1220 | * Returns: |
| @@ -1382,11 +1414,10 @@ void sc_stop(struct send_context *sc, int flag) | |||
| 1382 | { | 1414 | { |
| 1383 | unsigned long flags; | 1415 | unsigned long flags; |
| 1384 | 1416 | ||
| 1385 | /* mark the context */ | ||
| 1386 | sc->flags |= flag; | ||
| 1387 | |||
| 1388 | /* stop buffer allocations */ | 1417 | /* stop buffer allocations */ |
| 1389 | spin_lock_irqsave(&sc->alloc_lock, flags); | 1418 | spin_lock_irqsave(&sc->alloc_lock, flags); |
| 1419 | /* mark the context */ | ||
| 1420 | sc->flags |= flag; | ||
| 1390 | sc->flags &= ~SCF_ENABLED; | 1421 | sc->flags &= ~SCF_ENABLED; |
| 1391 | spin_unlock_irqrestore(&sc->alloc_lock, flags); | 1422 | spin_unlock_irqrestore(&sc->alloc_lock, flags); |
| 1392 | wake_up(&sc->halt_wait); | 1423 | wake_up(&sc->halt_wait); |
diff --git a/drivers/infiniband/hw/hfi1/pio.h b/drivers/infiniband/hw/hfi1/pio.h index 058b08f459ab..aaf372c3e5d6 100644 --- a/drivers/infiniband/hw/hfi1/pio.h +++ b/drivers/infiniband/hw/hfi1/pio.h | |||
| @@ -139,6 +139,7 @@ struct send_context { | |||
| 139 | #define SCF_IN_FREE 0x02 | 139 | #define SCF_IN_FREE 0x02 |
| 140 | #define SCF_HALTED 0x04 | 140 | #define SCF_HALTED 0x04 |
| 141 | #define SCF_FROZEN 0x08 | 141 | #define SCF_FROZEN 0x08 |
| 142 | #define SCF_LINK_DOWN 0x10 | ||
| 142 | 143 | ||
| 143 | struct send_context_info { | 144 | struct send_context_info { |
| 144 | struct send_context *sc; /* allocated working context */ | 145 | struct send_context *sc; /* allocated working context */ |
| @@ -306,6 +307,7 @@ void set_pio_integrity(struct send_context *sc); | |||
| 306 | void pio_reset_all(struct hfi1_devdata *dd); | 307 | void pio_reset_all(struct hfi1_devdata *dd); |
| 307 | void pio_freeze(struct hfi1_devdata *dd); | 308 | void pio_freeze(struct hfi1_devdata *dd); |
| 308 | void pio_kernel_unfreeze(struct hfi1_devdata *dd); | 309 | void pio_kernel_unfreeze(struct hfi1_devdata *dd); |
| 310 | void pio_kernel_linkup(struct hfi1_devdata *dd); | ||
| 309 | 311 | ||
| 310 | /* global PIO send control operations */ | 312 | /* global PIO send control operations */ |
| 311 | #define PSC_GLOBAL_ENABLE 0 | 313 | #define PSC_GLOBAL_ENABLE 0 |
diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c index a3a7b33196d6..5c88706121c1 100644 --- a/drivers/infiniband/hw/hfi1/user_sdma.c +++ b/drivers/infiniband/hw/hfi1/user_sdma.c | |||
| @@ -828,7 +828,7 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts) | |||
| 828 | if (READ_ONCE(iovec->offset) == iovec->iov.iov_len) { | 828 | if (READ_ONCE(iovec->offset) == iovec->iov.iov_len) { |
| 829 | if (++req->iov_idx == req->data_iovs) { | 829 | if (++req->iov_idx == req->data_iovs) { |
| 830 | ret = -EFAULT; | 830 | ret = -EFAULT; |
| 831 | goto free_txreq; | 831 | goto free_tx; |
| 832 | } | 832 | } |
| 833 | iovec = &req->iovs[req->iov_idx]; | 833 | iovec = &req->iovs[req->iov_idx]; |
| 834 | WARN_ON(iovec->offset); | 834 | WARN_ON(iovec->offset); |
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c index 13374c727b14..a7c586a5589d 100644 --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c | |||
| @@ -1582,6 +1582,7 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr) | |||
| 1582 | struct hfi1_pportdata *ppd; | 1582 | struct hfi1_pportdata *ppd; |
| 1583 | struct hfi1_devdata *dd; | 1583 | struct hfi1_devdata *dd; |
| 1584 | u8 sc5; | 1584 | u8 sc5; |
| 1585 | u8 sl; | ||
| 1585 | 1586 | ||
| 1586 | if (hfi1_check_mcast(rdma_ah_get_dlid(ah_attr)) && | 1587 | if (hfi1_check_mcast(rdma_ah_get_dlid(ah_attr)) && |
| 1587 | !(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) | 1588 | !(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) |
| @@ -1590,8 +1591,13 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr) | |||
| 1590 | /* test the mapping for validity */ | 1591 | /* test the mapping for validity */ |
| 1591 | ibp = to_iport(ibdev, rdma_ah_get_port_num(ah_attr)); | 1592 | ibp = to_iport(ibdev, rdma_ah_get_port_num(ah_attr)); |
| 1592 | ppd = ppd_from_ibp(ibp); | 1593 | ppd = ppd_from_ibp(ibp); |
| 1593 | sc5 = ibp->sl_to_sc[rdma_ah_get_sl(ah_attr)]; | ||
| 1594 | dd = dd_from_ppd(ppd); | 1594 | dd = dd_from_ppd(ppd); |
| 1595 | |||
| 1596 | sl = rdma_ah_get_sl(ah_attr); | ||
| 1597 | if (sl >= ARRAY_SIZE(ibp->sl_to_sc)) | ||
| 1598 | return -EINVAL; | ||
| 1599 | |||
| 1600 | sc5 = ibp->sl_to_sc[sl]; | ||
| 1595 | if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf) | 1601 | if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf) |
| 1596 | return -EINVAL; | 1602 | return -EINVAL; |
| 1597 | return 0; | 1603 | return 0; |
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c index ac116d63e466..f2f11e652dcd 100644 --- a/drivers/infiniband/hw/mlx5/devx.c +++ b/drivers/infiniband/hw/mlx5/devx.c | |||
| @@ -723,6 +723,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_CREATE)( | |||
| 723 | attrs, MLX5_IB_ATTR_DEVX_OBJ_CREATE_HANDLE); | 723 | attrs, MLX5_IB_ATTR_DEVX_OBJ_CREATE_HANDLE); |
| 724 | struct mlx5_ib_ucontext *c = to_mucontext(uobj->context); | 724 | struct mlx5_ib_ucontext *c = to_mucontext(uobj->context); |
| 725 | struct mlx5_ib_dev *dev = to_mdev(c->ibucontext.device); | 725 | struct mlx5_ib_dev *dev = to_mdev(c->ibucontext.device); |
| 726 | u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; | ||
| 726 | struct devx_obj *obj; | 727 | struct devx_obj *obj; |
| 727 | int err; | 728 | int err; |
| 728 | 729 | ||
| @@ -754,10 +755,12 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_CREATE)( | |||
| 754 | 755 | ||
| 755 | err = uverbs_copy_to(attrs, MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT, cmd_out, cmd_out_len); | 756 | err = uverbs_copy_to(attrs, MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT, cmd_out, cmd_out_len); |
| 756 | if (err) | 757 | if (err) |
| 757 | goto obj_free; | 758 | goto obj_destroy; |
| 758 | 759 | ||
| 759 | return 0; | 760 | return 0; |
| 760 | 761 | ||
| 762 | obj_destroy: | ||
| 763 | mlx5_cmd_exec(obj->mdev, obj->dinbox, obj->dinlen, out, sizeof(out)); | ||
| 761 | obj_free: | 764 | obj_free: |
| 762 | kfree(obj); | 765 | kfree(obj); |
| 763 | return err; | 766 | return err; |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 444d16520506..0b34e909505f 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
| @@ -2951,7 +2951,7 @@ static int srp_reset_device(struct scsi_cmnd *scmnd) | |||
| 2951 | { | 2951 | { |
| 2952 | struct srp_target_port *target = host_to_target(scmnd->device->host); | 2952 | struct srp_target_port *target = host_to_target(scmnd->device->host); |
| 2953 | struct srp_rdma_ch *ch; | 2953 | struct srp_rdma_ch *ch; |
| 2954 | int i; | 2954 | int i, j; |
| 2955 | u8 status; | 2955 | u8 status; |
| 2956 | 2956 | ||
| 2957 | shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n"); | 2957 | shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n"); |
| @@ -2965,8 +2965,8 @@ static int srp_reset_device(struct scsi_cmnd *scmnd) | |||
| 2965 | 2965 | ||
| 2966 | for (i = 0; i < target->ch_count; i++) { | 2966 | for (i = 0; i < target->ch_count; i++) { |
| 2967 | ch = &target->ch[i]; | 2967 | ch = &target->ch[i]; |
| 2968 | for (i = 0; i < target->req_ring_size; ++i) { | 2968 | for (j = 0; j < target->req_ring_size; ++j) { |
| 2969 | struct srp_request *req = &ch->req_ring[i]; | 2969 | struct srp_request *req = &ch->req_ring[j]; |
| 2970 | 2970 | ||
| 2971 | srp_finish_req(ch, req, scmnd->device, DID_RESET << 16); | 2971 | srp_finish_req(ch, req, scmnd->device, DID_RESET << 16); |
| 2972 | } | 2972 | } |
diff --git a/drivers/input/keyboard/atakbd.c b/drivers/input/keyboard/atakbd.c index 6f62da2909ec..6caee807cafa 100644 --- a/drivers/input/keyboard/atakbd.c +++ b/drivers/input/keyboard/atakbd.c | |||
| @@ -75,8 +75,7 @@ MODULE_LICENSE("GPL"); | |||
| 75 | */ | 75 | */ |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | static unsigned char atakbd_keycode[0x72] = { /* American layout */ | 78 | static unsigned char atakbd_keycode[0x73] = { /* American layout */ |
| 79 | [0] = KEY_GRAVE, | ||
| 80 | [1] = KEY_ESC, | 79 | [1] = KEY_ESC, |
| 81 | [2] = KEY_1, | 80 | [2] = KEY_1, |
| 82 | [3] = KEY_2, | 81 | [3] = KEY_2, |
| @@ -117,9 +116,9 @@ static unsigned char atakbd_keycode[0x72] = { /* American layout */ | |||
| 117 | [38] = KEY_L, | 116 | [38] = KEY_L, |
| 118 | [39] = KEY_SEMICOLON, | 117 | [39] = KEY_SEMICOLON, |
| 119 | [40] = KEY_APOSTROPHE, | 118 | [40] = KEY_APOSTROPHE, |
| 120 | [41] = KEY_BACKSLASH, /* FIXME, '#' */ | 119 | [41] = KEY_GRAVE, |
| 121 | [42] = KEY_LEFTSHIFT, | 120 | [42] = KEY_LEFTSHIFT, |
| 122 | [43] = KEY_GRAVE, /* FIXME: '~' */ | 121 | [43] = KEY_BACKSLASH, |
| 123 | [44] = KEY_Z, | 122 | [44] = KEY_Z, |
| 124 | [45] = KEY_X, | 123 | [45] = KEY_X, |
| 125 | [46] = KEY_C, | 124 | [46] = KEY_C, |
| @@ -145,45 +144,34 @@ static unsigned char atakbd_keycode[0x72] = { /* American layout */ | |||
| 145 | [66] = KEY_F8, | 144 | [66] = KEY_F8, |
| 146 | [67] = KEY_F9, | 145 | [67] = KEY_F9, |
| 147 | [68] = KEY_F10, | 146 | [68] = KEY_F10, |
| 148 | [69] = KEY_ESC, | 147 | [71] = KEY_HOME, |
| 149 | [70] = KEY_DELETE, | 148 | [72] = KEY_UP, |
| 150 | [71] = KEY_KP7, | ||
| 151 | [72] = KEY_KP8, | ||
| 152 | [73] = KEY_KP9, | ||
| 153 | [74] = KEY_KPMINUS, | 149 | [74] = KEY_KPMINUS, |
| 154 | [75] = KEY_KP4, | 150 | [75] = KEY_LEFT, |
| 155 | [76] = KEY_KP5, | 151 | [77] = KEY_RIGHT, |
| 156 | [77] = KEY_KP6, | ||
| 157 | [78] = KEY_KPPLUS, | 152 | [78] = KEY_KPPLUS, |
| 158 | [79] = KEY_KP1, | 153 | [80] = KEY_DOWN, |
| 159 | [80] = KEY_KP2, | 154 | [82] = KEY_INSERT, |
| 160 | [81] = KEY_KP3, | 155 | [83] = KEY_DELETE, |
| 161 | [82] = KEY_KP0, | ||
| 162 | [83] = KEY_KPDOT, | ||
| 163 | [90] = KEY_KPLEFTPAREN, | ||
| 164 | [91] = KEY_KPRIGHTPAREN, | ||
| 165 | [92] = KEY_KPASTERISK, /* FIXME */ | ||
| 166 | [93] = KEY_KPASTERISK, | ||
| 167 | [94] = KEY_KPPLUS, | ||
| 168 | [95] = KEY_HELP, | ||
| 169 | [96] = KEY_102ND, | 156 | [96] = KEY_102ND, |
| 170 | [97] = KEY_KPASTERISK, /* FIXME */ | 157 | [97] = KEY_UNDO, |
| 171 | [98] = KEY_KPSLASH, | 158 | [98] = KEY_HELP, |
| 172 | [99] = KEY_KPLEFTPAREN, | 159 | [99] = KEY_KPLEFTPAREN, |
| 173 | [100] = KEY_KPRIGHTPAREN, | 160 | [100] = KEY_KPRIGHTPAREN, |
| 174 | [101] = KEY_KPSLASH, | 161 | [101] = KEY_KPSLASH, |
| 175 | [102] = KEY_KPASTERISK, | 162 | [102] = KEY_KPASTERISK, |
| 176 | [103] = KEY_UP, | 163 | [103] = KEY_KP7, |
| 177 | [104] = KEY_KPASTERISK, /* FIXME */ | 164 | [104] = KEY_KP8, |
| 178 | [105] = KEY_LEFT, | 165 | [105] = KEY_KP9, |
| 179 | [106] = KEY_RIGHT, | 166 | [106] = KEY_KP4, |
| 180 | [107] = KEY_KPASTERISK, /* FIXME */ | 167 | [107] = KEY_KP5, |
| 181 | [108] = KEY_DOWN, | 168 | [108] = KEY_KP6, |
| 182 | [109] = KEY_KPASTERISK, /* FIXME */ | 169 | [109] = KEY_KP1, |
| 183 | [110] = KEY_KPASTERISK, /* FIXME */ | 170 | [110] = KEY_KP2, |
| 184 | [111] = KEY_KPASTERISK, /* FIXME */ | 171 | [111] = KEY_KP3, |
| 185 | [112] = KEY_KPASTERISK, /* FIXME */ | 172 | [112] = KEY_KP0, |
| 186 | [113] = KEY_KPASTERISK /* FIXME */ | 173 | [113] = KEY_KPDOT, |
| 174 | [114] = KEY_KPENTER, | ||
| 187 | }; | 175 | }; |
| 188 | 176 | ||
| 189 | static struct input_dev *atakbd_dev; | 177 | static struct input_dev *atakbd_dev; |
| @@ -191,21 +179,15 @@ static struct input_dev *atakbd_dev; | |||
| 191 | static void atakbd_interrupt(unsigned char scancode, char down) | 179 | static void atakbd_interrupt(unsigned char scancode, char down) |
| 192 | { | 180 | { |
| 193 | 181 | ||
| 194 | if (scancode < 0x72) { /* scancodes < 0xf2 are keys */ | 182 | if (scancode < 0x73) { /* scancodes < 0xf3 are keys */ |
| 195 | 183 | ||
| 196 | // report raw events here? | 184 | // report raw events here? |
| 197 | 185 | ||
| 198 | scancode = atakbd_keycode[scancode]; | 186 | scancode = atakbd_keycode[scancode]; |
| 199 | 187 | ||
| 200 | if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */ | 188 | input_report_key(atakbd_dev, scancode, down); |
| 201 | input_report_key(atakbd_dev, scancode, 1); | 189 | input_sync(atakbd_dev); |
| 202 | input_report_key(atakbd_dev, scancode, 0); | 190 | } else /* scancodes >= 0xf3 are mouse data, most likely */ |
| 203 | input_sync(atakbd_dev); | ||
| 204 | } else { | ||
| 205 | input_report_key(atakbd_dev, scancode, down); | ||
| 206 | input_sync(atakbd_dev); | ||
| 207 | } | ||
| 208 | } else /* scancodes >= 0xf2 are mouse data, most likely */ | ||
| 209 | printk(KERN_INFO "atakbd: unhandled scancode %x\n", scancode); | 191 | printk(KERN_INFO "atakbd: unhandled scancode %x\n", scancode); |
| 210 | 192 | ||
| 211 | return; | 193 | return; |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 96a887f33698..eb14ddf69346 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
| @@ -410,7 +410,7 @@ static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code, | |||
| 410 | min = abs->minimum; | 410 | min = abs->minimum; |
| 411 | max = abs->maximum; | 411 | max = abs->maximum; |
| 412 | 412 | ||
| 413 | if ((min != 0 || max != 0) && max <= min) { | 413 | if ((min != 0 || max != 0) && max < min) { |
| 414 | printk(KERN_DEBUG | 414 | printk(KERN_DEBUG |
| 415 | "%s: invalid abs[%02x] min:%d max:%d\n", | 415 | "%s: invalid abs[%02x] min:%d max:%d\n", |
| 416 | UINPUT_NAME, code, min, max); | 416 | UINPUT_NAME, code, min, max); |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 44f57cf6675b..2d95e8d93cc7 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
| @@ -1178,6 +1178,8 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = { | |||
| 1178 | static const char * const middle_button_pnp_ids[] = { | 1178 | static const char * const middle_button_pnp_ids[] = { |
| 1179 | "LEN2131", /* ThinkPad P52 w/ NFC */ | 1179 | "LEN2131", /* ThinkPad P52 w/ NFC */ |
| 1180 | "LEN2132", /* ThinkPad P52 */ | 1180 | "LEN2132", /* ThinkPad P52 */ |
| 1181 | "LEN2133", /* ThinkPad P72 w/ NFC */ | ||
| 1182 | "LEN2134", /* ThinkPad P72 */ | ||
| 1181 | NULL | 1183 | NULL |
| 1182 | }; | 1184 | }; |
| 1183 | 1185 | ||
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 80e69bb8283e..83ac8c128192 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c | |||
| @@ -241,6 +241,9 @@ static int __maybe_unused egalax_ts_suspend(struct device *dev) | |||
| 241 | struct i2c_client *client = to_i2c_client(dev); | 241 | struct i2c_client *client = to_i2c_client(dev); |
| 242 | int ret; | 242 | int ret; |
| 243 | 243 | ||
| 244 | if (device_may_wakeup(dev)) | ||
| 245 | return enable_irq_wake(client->irq); | ||
| 246 | |||
| 244 | ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN); | 247 | ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN); |
| 245 | return ret > 0 ? 0 : ret; | 248 | return ret > 0 ? 0 : ret; |
| 246 | } | 249 | } |
| @@ -249,6 +252,9 @@ static int __maybe_unused egalax_ts_resume(struct device *dev) | |||
| 249 | { | 252 | { |
| 250 | struct i2c_client *client = to_i2c_client(dev); | 253 | struct i2c_client *client = to_i2c_client(dev); |
| 251 | 254 | ||
| 255 | if (device_may_wakeup(dev)) | ||
| 256 | return disable_irq_wake(client->irq); | ||
| 257 | |||
| 252 | return egalax_wake_up_device(client); | 258 | return egalax_wake_up_device(client); |
| 253 | } | 259 | } |
| 254 | 260 | ||
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 83504dd8100a..954dad29e6e8 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h | |||
| @@ -965,6 +965,7 @@ void bch_prio_write(struct cache *ca); | |||
| 965 | void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent); | 965 | void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent); |
| 966 | 966 | ||
| 967 | extern struct workqueue_struct *bcache_wq; | 967 | extern struct workqueue_struct *bcache_wq; |
| 968 | extern struct workqueue_struct *bch_journal_wq; | ||
| 968 | extern struct mutex bch_register_lock; | 969 | extern struct mutex bch_register_lock; |
| 969 | extern struct list_head bch_cache_sets; | 970 | extern struct list_head bch_cache_sets; |
| 970 | 971 | ||
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 6116bbf870d8..522c7426f3a0 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c | |||
| @@ -485,7 +485,7 @@ static void do_journal_discard(struct cache *ca) | |||
| 485 | 485 | ||
| 486 | closure_get(&ca->set->cl); | 486 | closure_get(&ca->set->cl); |
| 487 | INIT_WORK(&ja->discard_work, journal_discard_work); | 487 | INIT_WORK(&ja->discard_work, journal_discard_work); |
| 488 | schedule_work(&ja->discard_work); | 488 | queue_work(bch_journal_wq, &ja->discard_work); |
| 489 | } | 489 | } |
| 490 | } | 490 | } |
| 491 | 491 | ||
| @@ -592,7 +592,7 @@ static void journal_write_done(struct closure *cl) | |||
| 592 | : &j->w[0]; | 592 | : &j->w[0]; |
| 593 | 593 | ||
| 594 | __closure_wake_up(&w->wait); | 594 | __closure_wake_up(&w->wait); |
| 595 | continue_at_nobarrier(cl, journal_write, system_wq); | 595 | continue_at_nobarrier(cl, journal_write, bch_journal_wq); |
| 596 | } | 596 | } |
| 597 | 597 | ||
| 598 | static void journal_write_unlock(struct closure *cl) | 598 | static void journal_write_unlock(struct closure *cl) |
| @@ -627,7 +627,7 @@ static void journal_write_unlocked(struct closure *cl) | |||
| 627 | spin_unlock(&c->journal.lock); | 627 | spin_unlock(&c->journal.lock); |
| 628 | 628 | ||
| 629 | btree_flush_write(c); | 629 | btree_flush_write(c); |
| 630 | continue_at(cl, journal_write, system_wq); | 630 | continue_at(cl, journal_write, bch_journal_wq); |
| 631 | return; | 631 | return; |
| 632 | } | 632 | } |
| 633 | 633 | ||
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 94c756c66bd7..30ba9aeb5ee8 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
| @@ -47,6 +47,7 @@ static int bcache_major; | |||
| 47 | static DEFINE_IDA(bcache_device_idx); | 47 | static DEFINE_IDA(bcache_device_idx); |
| 48 | static wait_queue_head_t unregister_wait; | 48 | static wait_queue_head_t unregister_wait; |
| 49 | struct workqueue_struct *bcache_wq; | 49 | struct workqueue_struct *bcache_wq; |
| 50 | struct workqueue_struct *bch_journal_wq; | ||
| 50 | 51 | ||
| 51 | #define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE) | 52 | #define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE) |
| 52 | /* limitation of partitions number on single bcache device */ | 53 | /* limitation of partitions number on single bcache device */ |
| @@ -2341,6 +2342,9 @@ static void bcache_exit(void) | |||
| 2341 | kobject_put(bcache_kobj); | 2342 | kobject_put(bcache_kobj); |
| 2342 | if (bcache_wq) | 2343 | if (bcache_wq) |
| 2343 | destroy_workqueue(bcache_wq); | 2344 | destroy_workqueue(bcache_wq); |
| 2345 | if (bch_journal_wq) | ||
| 2346 | destroy_workqueue(bch_journal_wq); | ||
| 2347 | |||
| 2344 | if (bcache_major) | 2348 | if (bcache_major) |
| 2345 | unregister_blkdev(bcache_major, "bcache"); | 2349 | unregister_blkdev(bcache_major, "bcache"); |
| 2346 | unregister_reboot_notifier(&reboot); | 2350 | unregister_reboot_notifier(&reboot); |
| @@ -2370,6 +2374,10 @@ static int __init bcache_init(void) | |||
| 2370 | if (!bcache_wq) | 2374 | if (!bcache_wq) |
| 2371 | goto err; | 2375 | goto err; |
| 2372 | 2376 | ||
| 2377 | bch_journal_wq = alloc_workqueue("bch_journal", WQ_MEM_RECLAIM, 0); | ||
| 2378 | if (!bch_journal_wq) | ||
| 2379 | goto err; | ||
| 2380 | |||
| 2373 | bcache_kobj = kobject_create_and_add("bcache", fs_kobj); | 2381 | bcache_kobj = kobject_create_and_add("bcache", fs_kobj); |
| 2374 | if (!bcache_kobj) | 2382 | if (!bcache_kobj) |
| 2375 | goto err; | 2383 | goto err; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h b/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h index b8f75a22fb6c..f152da1ce046 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | |||
| @@ -753,7 +753,6 @@ struct cpl_abort_req_rss { | |||
| 753 | }; | 753 | }; |
| 754 | 754 | ||
| 755 | struct cpl_abort_req_rss6 { | 755 | struct cpl_abort_req_rss6 { |
| 756 | WR_HDR; | ||
| 757 | union opcode_tid ot; | 756 | union opcode_tid ot; |
| 758 | __be32 srqidx_status; | 757 | __be32 srqidx_status; |
| 759 | }; | 758 | }; |
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 5a9562881d4e..9fe3fff818b8 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c | |||
| @@ -537,8 +537,10 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) | |||
| 537 | 537 | ||
| 538 | INIT_WORK(&ctrl->ana_work, nvme_ana_work); | 538 | INIT_WORK(&ctrl->ana_work, nvme_ana_work); |
| 539 | ctrl->ana_log_buf = kmalloc(ctrl->ana_log_size, GFP_KERNEL); | 539 | ctrl->ana_log_buf = kmalloc(ctrl->ana_log_size, GFP_KERNEL); |
| 540 | if (!ctrl->ana_log_buf) | 540 | if (!ctrl->ana_log_buf) { |
| 541 | error = -ENOMEM; | ||
| 541 | goto out; | 542 | goto out; |
| 543 | } | ||
| 542 | 544 | ||
| 543 | error = nvme_read_ana_log(ctrl, true); | 545 | error = nvme_read_ana_log(ctrl, true); |
| 544 | if (error) | 546 | if (error) |
| @@ -547,7 +549,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) | |||
| 547 | out_free_ana_log_buf: | 549 | out_free_ana_log_buf: |
| 548 | kfree(ctrl->ana_log_buf); | 550 | kfree(ctrl->ana_log_buf); |
| 549 | out: | 551 | out: |
| 550 | return -ENOMEM; | 552 | return error; |
| 551 | } | 553 | } |
| 552 | 554 | ||
| 553 | void nvme_mpath_uninit(struct nvme_ctrl *ctrl) | 555 | void nvme_mpath_uninit(struct nvme_ctrl *ctrl) |
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 778c4f76a884..2153956a0b20 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c | |||
| @@ -135,7 +135,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int index, | |||
| 135 | if (val & PCIE_ATU_ENABLE) | 135 | if (val & PCIE_ATU_ENABLE) |
| 136 | return; | 136 | return; |
| 137 | 137 | ||
| 138 | usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); | 138 | mdelay(LINK_WAIT_IATU); |
| 139 | } | 139 | } |
| 140 | dev_err(pci->dev, "Outbound iATU is not being enabled\n"); | 140 | dev_err(pci->dev, "Outbound iATU is not being enabled\n"); |
| 141 | } | 141 | } |
| @@ -178,7 +178,7 @@ void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, | |||
| 178 | if (val & PCIE_ATU_ENABLE) | 178 | if (val & PCIE_ATU_ENABLE) |
| 179 | return; | 179 | return; |
| 180 | 180 | ||
| 181 | usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); | 181 | mdelay(LINK_WAIT_IATU); |
| 182 | } | 182 | } |
| 183 | dev_err(pci->dev, "Outbound iATU is not being enabled\n"); | 183 | dev_err(pci->dev, "Outbound iATU is not being enabled\n"); |
| 184 | } | 184 | } |
| @@ -236,7 +236,7 @@ static int dw_pcie_prog_inbound_atu_unroll(struct dw_pcie *pci, int index, | |||
| 236 | if (val & PCIE_ATU_ENABLE) | 236 | if (val & PCIE_ATU_ENABLE) |
| 237 | return 0; | 237 | return 0; |
| 238 | 238 | ||
| 239 | usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); | 239 | mdelay(LINK_WAIT_IATU); |
| 240 | } | 240 | } |
| 241 | dev_err(pci->dev, "Inbound iATU is not being enabled\n"); | 241 | dev_err(pci->dev, "Inbound iATU is not being enabled\n"); |
| 242 | 242 | ||
| @@ -282,7 +282,7 @@ int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int bar, | |||
| 282 | if (val & PCIE_ATU_ENABLE) | 282 | if (val & PCIE_ATU_ENABLE) |
| 283 | return 0; | 283 | return 0; |
| 284 | 284 | ||
| 285 | usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); | 285 | mdelay(LINK_WAIT_IATU); |
| 286 | } | 286 | } |
| 287 | dev_err(pci->dev, "Inbound iATU is not being enabled\n"); | 287 | dev_err(pci->dev, "Inbound iATU is not being enabled\n"); |
| 288 | 288 | ||
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 96126fd8403c..9f1a5e399b70 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h | |||
| @@ -26,8 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | /* Parameters for the waiting for iATU enabled routine */ | 27 | /* Parameters for the waiting for iATU enabled routine */ |
| 28 | #define LINK_WAIT_MAX_IATU_RETRIES 5 | 28 | #define LINK_WAIT_MAX_IATU_RETRIES 5 |
| 29 | #define LINK_WAIT_IATU_MIN 9000 | 29 | #define LINK_WAIT_IATU 9 |
| 30 | #define LINK_WAIT_IATU_MAX 10000 | ||
| 31 | 30 | ||
| 32 | /* Synopsys-specific PCIe configuration registers */ | 31 | /* Synopsys-specific PCIe configuration registers */ |
| 33 | #define PCIE_PORT_LINK_CONTROL 0x710 | 32 | #define PCIE_PORT_LINK_CONTROL 0x710 |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index ef0b1b6ba86f..12afa7fdf77e 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
| @@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge) | |||
| 457 | /** | 457 | /** |
| 458 | * enable_slot - enable, configure a slot | 458 | * enable_slot - enable, configure a slot |
| 459 | * @slot: slot to be enabled | 459 | * @slot: slot to be enabled |
| 460 | * @bridge: true if enable is for the whole bridge (not a single slot) | ||
| 460 | * | 461 | * |
| 461 | * This function should be called per *physical slot*, | 462 | * This function should be called per *physical slot*, |
| 462 | * not per each slot object in ACPI namespace. | 463 | * not per each slot object in ACPI namespace. |
| 463 | */ | 464 | */ |
| 464 | static void enable_slot(struct acpiphp_slot *slot) | 465 | static void enable_slot(struct acpiphp_slot *slot, bool bridge) |
| 465 | { | 466 | { |
| 466 | struct pci_dev *dev; | 467 | struct pci_dev *dev; |
| 467 | struct pci_bus *bus = slot->bus; | 468 | struct pci_bus *bus = slot->bus; |
| 468 | struct acpiphp_func *func; | 469 | struct acpiphp_func *func; |
| 469 | 470 | ||
| 470 | if (bus->self && hotplug_is_native(bus->self)) { | 471 | if (bridge && bus->self && hotplug_is_native(bus->self)) { |
| 471 | /* | 472 | /* |
| 472 | * If native hotplug is used, it will take care of hotplug | 473 | * If native hotplug is used, it will take care of hotplug |
| 473 | * slot management and resource allocation for hotplug | 474 | * slot management and resource allocation for hotplug |
| @@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge) | |||
| 701 | trim_stale_devices(dev); | 702 | trim_stale_devices(dev); |
| 702 | 703 | ||
| 703 | /* configure all functions */ | 704 | /* configure all functions */ |
| 704 | enable_slot(slot); | 705 | enable_slot(slot, true); |
| 705 | } else { | 706 | } else { |
| 706 | disable_slot(slot); | 707 | disable_slot(slot); |
| 707 | } | 708 | } |
| @@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context) | |||
| 785 | if (bridge) | 786 | if (bridge) |
| 786 | acpiphp_check_bridge(bridge); | 787 | acpiphp_check_bridge(bridge); |
| 787 | else if (!(slot->flags & SLOT_IS_GOING_AWAY)) | 788 | else if (!(slot->flags & SLOT_IS_GOING_AWAY)) |
| 788 | enable_slot(slot); | 789 | enable_slot(slot, false); |
| 789 | 790 | ||
| 790 | break; | 791 | break; |
| 791 | 792 | ||
| @@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) | |||
| 973 | 974 | ||
| 974 | /* configure all functions */ | 975 | /* configure all functions */ |
| 975 | if (!(slot->flags & SLOT_ENABLED)) | 976 | if (!(slot->flags & SLOT_ENABLED)) |
| 976 | enable_slot(slot); | 977 | enable_slot(slot, false); |
| 977 | 978 | ||
| 978 | pci_unlock_rescan_remove(); | 979 | pci_unlock_rescan_remove(); |
| 979 | return 0; | 980 | return 0; |
diff --git a/drivers/pinctrl/intel/pinctrl-cannonlake.c b/drivers/pinctrl/intel/pinctrl-cannonlake.c index 8d48371caaa2..e7f45d96b0cb 100644 --- a/drivers/pinctrl/intel/pinctrl-cannonlake.c +++ b/drivers/pinctrl/intel/pinctrl-cannonlake.c | |||
| @@ -15,10 +15,11 @@ | |||
| 15 | 15 | ||
| 16 | #include "pinctrl-intel.h" | 16 | #include "pinctrl-intel.h" |
| 17 | 17 | ||
| 18 | #define CNL_PAD_OWN 0x020 | 18 | #define CNL_PAD_OWN 0x020 |
| 19 | #define CNL_PADCFGLOCK 0x080 | 19 | #define CNL_PADCFGLOCK 0x080 |
| 20 | #define CNL_HOSTSW_OWN 0x0b0 | 20 | #define CNL_LP_HOSTSW_OWN 0x0b0 |
| 21 | #define CNL_GPI_IE 0x120 | 21 | #define CNL_H_HOSTSW_OWN 0x0c0 |
| 22 | #define CNL_GPI_IE 0x120 | ||
| 22 | 23 | ||
| 23 | #define CNL_GPP(r, s, e, g) \ | 24 | #define CNL_GPP(r, s, e, g) \ |
| 24 | { \ | 25 | { \ |
| @@ -30,12 +31,12 @@ | |||
| 30 | 31 | ||
| 31 | #define CNL_NO_GPIO -1 | 32 | #define CNL_NO_GPIO -1 |
| 32 | 33 | ||
| 33 | #define CNL_COMMUNITY(b, s, e, g) \ | 34 | #define CNL_COMMUNITY(b, s, e, o, g) \ |
| 34 | { \ | 35 | { \ |
| 35 | .barno = (b), \ | 36 | .barno = (b), \ |
| 36 | .padown_offset = CNL_PAD_OWN, \ | 37 | .padown_offset = CNL_PAD_OWN, \ |
| 37 | .padcfglock_offset = CNL_PADCFGLOCK, \ | 38 | .padcfglock_offset = CNL_PADCFGLOCK, \ |
| 38 | .hostown_offset = CNL_HOSTSW_OWN, \ | 39 | .hostown_offset = (o), \ |
| 39 | .ie_offset = CNL_GPI_IE, \ | 40 | .ie_offset = CNL_GPI_IE, \ |
| 40 | .pin_base = (s), \ | 41 | .pin_base = (s), \ |
| 41 | .npins = ((e) - (s) + 1), \ | 42 | .npins = ((e) - (s) + 1), \ |
| @@ -43,6 +44,12 @@ | |||
| 43 | .ngpps = ARRAY_SIZE(g), \ | 44 | .ngpps = ARRAY_SIZE(g), \ |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 47 | #define CNLLP_COMMUNITY(b, s, e, g) \ | ||
| 48 | CNL_COMMUNITY(b, s, e, CNL_LP_HOSTSW_OWN, g) | ||
| 49 | |||
| 50 | #define CNLH_COMMUNITY(b, s, e, g) \ | ||
| 51 | CNL_COMMUNITY(b, s, e, CNL_H_HOSTSW_OWN, g) | ||
| 52 | |||
| 46 | /* Cannon Lake-H */ | 53 | /* Cannon Lake-H */ |
| 47 | static const struct pinctrl_pin_desc cnlh_pins[] = { | 54 | static const struct pinctrl_pin_desc cnlh_pins[] = { |
| 48 | /* GPP_A */ | 55 | /* GPP_A */ |
| @@ -442,10 +449,10 @@ static const struct intel_function cnlh_functions[] = { | |||
| 442 | }; | 449 | }; |
| 443 | 450 | ||
| 444 | static const struct intel_community cnlh_communities[] = { | 451 | static const struct intel_community cnlh_communities[] = { |
| 445 | CNL_COMMUNITY(0, 0, 50, cnlh_community0_gpps), | 452 | CNLH_COMMUNITY(0, 0, 50, cnlh_community0_gpps), |
| 446 | CNL_COMMUNITY(1, 51, 154, cnlh_community1_gpps), | 453 | CNLH_COMMUNITY(1, 51, 154, cnlh_community1_gpps), |
| 447 | CNL_COMMUNITY(2, 155, 248, cnlh_community3_gpps), | 454 | CNLH_COMMUNITY(2, 155, 248, cnlh_community3_gpps), |
| 448 | CNL_COMMUNITY(3, 249, 298, cnlh_community4_gpps), | 455 | CNLH_COMMUNITY(3, 249, 298, cnlh_community4_gpps), |
| 449 | }; | 456 | }; |
| 450 | 457 | ||
| 451 | static const struct intel_pinctrl_soc_data cnlh_soc_data = { | 458 | static const struct intel_pinctrl_soc_data cnlh_soc_data = { |
| @@ -803,9 +810,9 @@ static const struct intel_padgroup cnllp_community4_gpps[] = { | |||
| 803 | }; | 810 | }; |
| 804 | 811 | ||
| 805 | static const struct intel_community cnllp_communities[] = { | 812 | static const struct intel_community cnllp_communities[] = { |
| 806 | CNL_COMMUNITY(0, 0, 67, cnllp_community0_gpps), | 813 | CNLLP_COMMUNITY(0, 0, 67, cnllp_community0_gpps), |
| 807 | CNL_COMMUNITY(1, 68, 180, cnllp_community1_gpps), | 814 | CNLLP_COMMUNITY(1, 68, 180, cnllp_community1_gpps), |
| 808 | CNL_COMMUNITY(2, 181, 243, cnllp_community4_gpps), | 815 | CNLLP_COMMUNITY(2, 181, 243, cnllp_community4_gpps), |
| 809 | }; | 816 | }; |
| 810 | 817 | ||
| 811 | static const struct intel_pinctrl_soc_data cnllp_soc_data = { | 818 | static const struct intel_pinctrl_soc_data cnllp_soc_data = { |
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index ec8dafc94694..1ea3438ea67e 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c | |||
| @@ -887,36 +887,6 @@ static const struct gpio_chip intel_gpio_chip = { | |||
| 887 | .set_config = gpiochip_generic_config, | 887 | .set_config = gpiochip_generic_config, |
| 888 | }; | 888 | }; |
| 889 | 889 | ||
| 890 | static int intel_gpio_irq_reqres(struct irq_data *d) | ||
| 891 | { | ||
| 892 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
| 893 | struct intel_pinctrl *pctrl = gpiochip_get_data(gc); | ||
| 894 | int pin; | ||
| 895 | int ret; | ||
| 896 | |||
| 897 | pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); | ||
| 898 | if (pin >= 0) { | ||
| 899 | ret = gpiochip_lock_as_irq(gc, pin); | ||
| 900 | if (ret) { | ||
| 901 | dev_err(pctrl->dev, "unable to lock HW IRQ %d for IRQ\n", | ||
| 902 | pin); | ||
| 903 | return ret; | ||
| 904 | } | ||
| 905 | } | ||
| 906 | return 0; | ||
| 907 | } | ||
| 908 | |||
| 909 | static void intel_gpio_irq_relres(struct irq_data *d) | ||
| 910 | { | ||
| 911 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
| 912 | struct intel_pinctrl *pctrl = gpiochip_get_data(gc); | ||
| 913 | int pin; | ||
| 914 | |||
| 915 | pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); | ||
| 916 | if (pin >= 0) | ||
| 917 | gpiochip_unlock_as_irq(gc, pin); | ||
| 918 | } | ||
| 919 | |||
| 920 | static void intel_gpio_irq_ack(struct irq_data *d) | 890 | static void intel_gpio_irq_ack(struct irq_data *d) |
| 921 | { | 891 | { |
| 922 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 892 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
| @@ -1132,8 +1102,6 @@ static irqreturn_t intel_gpio_irq(int irq, void *data) | |||
| 1132 | 1102 | ||
| 1133 | static struct irq_chip intel_gpio_irqchip = { | 1103 | static struct irq_chip intel_gpio_irqchip = { |
| 1134 | .name = "intel-gpio", | 1104 | .name = "intel-gpio", |
| 1135 | .irq_request_resources = intel_gpio_irq_reqres, | ||
| 1136 | .irq_release_resources = intel_gpio_irq_relres, | ||
| 1137 | .irq_enable = intel_gpio_irq_enable, | 1105 | .irq_enable = intel_gpio_irq_enable, |
| 1138 | .irq_ack = intel_gpio_irq_ack, | 1106 | .irq_ack = intel_gpio_irq_ack, |
| 1139 | .irq_mask = intel_gpio_irq_mask, | 1107 | .irq_mask = intel_gpio_irq_mask, |
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 41ccc759b8b8..1425c2874d40 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c | |||
| @@ -348,21 +348,12 @@ static void amd_gpio_irq_enable(struct irq_data *d) | |||
| 348 | unsigned long flags; | 348 | unsigned long flags; |
| 349 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 349 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
| 350 | struct amd_gpio *gpio_dev = gpiochip_get_data(gc); | 350 | struct amd_gpio *gpio_dev = gpiochip_get_data(gc); |
| 351 | u32 mask = BIT(INTERRUPT_ENABLE_OFF) | BIT(INTERRUPT_MASK_OFF); | ||
| 352 | 351 | ||
| 353 | raw_spin_lock_irqsave(&gpio_dev->lock, flags); | 352 | raw_spin_lock_irqsave(&gpio_dev->lock, flags); |
| 354 | pin_reg = readl(gpio_dev->base + (d->hwirq)*4); | 353 | pin_reg = readl(gpio_dev->base + (d->hwirq)*4); |
| 355 | pin_reg |= BIT(INTERRUPT_ENABLE_OFF); | 354 | pin_reg |= BIT(INTERRUPT_ENABLE_OFF); |
| 356 | pin_reg |= BIT(INTERRUPT_MASK_OFF); | 355 | pin_reg |= BIT(INTERRUPT_MASK_OFF); |
| 357 | writel(pin_reg, gpio_dev->base + (d->hwirq)*4); | 356 | writel(pin_reg, gpio_dev->base + (d->hwirq)*4); |
| 358 | /* | ||
| 359 | * When debounce logic is enabled it takes ~900 us before interrupts | ||
| 360 | * can be enabled. During this "debounce warm up" period the | ||
| 361 | * "INTERRUPT_ENABLE" bit will read as 0. Poll the bit here until it | ||
| 362 | * reads back as 1, signaling that interrupts are now enabled. | ||
| 363 | */ | ||
| 364 | while ((readl(gpio_dev->base + (d->hwirq)*4) & mask) != mask) | ||
| 365 | continue; | ||
| 366 | raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); | 357 | raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); |
| 367 | } | 358 | } |
| 368 | 359 | ||
| @@ -426,7 +417,7 @@ static void amd_gpio_irq_eoi(struct irq_data *d) | |||
| 426 | static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) | 417 | static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) |
| 427 | { | 418 | { |
| 428 | int ret = 0; | 419 | int ret = 0; |
| 429 | u32 pin_reg; | 420 | u32 pin_reg, pin_reg_irq_en, mask; |
| 430 | unsigned long flags, irq_flags; | 421 | unsigned long flags, irq_flags; |
| 431 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 422 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
| 432 | struct amd_gpio *gpio_dev = gpiochip_get_data(gc); | 423 | struct amd_gpio *gpio_dev = gpiochip_get_data(gc); |
| @@ -495,6 +486,28 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
| 495 | } | 486 | } |
| 496 | 487 | ||
| 497 | pin_reg |= CLR_INTR_STAT << INTERRUPT_STS_OFF; | 488 | pin_reg |= CLR_INTR_STAT << INTERRUPT_STS_OFF; |
| 489 | /* | ||
| 490 | * If WAKE_INT_MASTER_REG.MaskStsEn is set, a software write to the | ||
| 491 | * debounce registers of any GPIO will block wake/interrupt status | ||
| 492 | * generation for *all* GPIOs for a lenght of time that depends on | ||
| 493 | * WAKE_INT_MASTER_REG.MaskStsLength[11:0]. During this period the | ||
| 494 | * INTERRUPT_ENABLE bit will read as 0. | ||
| 495 | * | ||
| 496 | * We temporarily enable irq for the GPIO whose configuration is | ||
| 497 | * changing, and then wait for it to read back as 1 to know when | ||
| 498 | * debounce has settled and then disable the irq again. | ||
| 499 | * We do this polling with the spinlock held to ensure other GPIO | ||
| 500 | * access routines do not read an incorrect value for the irq enable | ||
| 501 | * bit of other GPIOs. We keep the GPIO masked while polling to avoid | ||
| 502 | * spurious irqs, and disable the irq again after polling. | ||
| 503 | */ | ||
| 504 | mask = BIT(INTERRUPT_ENABLE_OFF); | ||
| 505 | pin_reg_irq_en = pin_reg; | ||
| 506 | pin_reg_irq_en |= mask; | ||
| 507 | pin_reg_irq_en &= ~BIT(INTERRUPT_MASK_OFF); | ||
| 508 | writel(pin_reg_irq_en, gpio_dev->base + (d->hwirq)*4); | ||
| 509 | while ((readl(gpio_dev->base + (d->hwirq)*4) & mask) != mask) | ||
| 510 | continue; | ||
| 498 | writel(pin_reg, gpio_dev->base + (d->hwirq)*4); | 511 | writel(pin_reg, gpio_dev->base + (d->hwirq)*4); |
| 499 | raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); | 512 | raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); |
| 500 | 513 | ||
diff --git a/drivers/regulator/bd71837-regulator.c b/drivers/regulator/bd71837-regulator.c index 0f8ac8dec3e1..a1bd8aaf4d98 100644 --- a/drivers/regulator/bd71837-regulator.c +++ b/drivers/regulator/bd71837-regulator.c | |||
| @@ -569,6 +569,25 @@ static int bd71837_probe(struct platform_device *pdev) | |||
| 569 | BD71837_REG_REGLOCK); | 569 | BD71837_REG_REGLOCK); |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | /* | ||
| 573 | * There is a HW quirk in BD71837. The shutdown sequence timings for | ||
| 574 | * bucks/LDOs which are controlled via register interface are changed. | ||
| 575 | * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the | ||
| 576 | * beginning of shut-down sequence. As bucks 6 and 7 are parent | ||
| 577 | * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage | ||
| 578 | * monitoring to errorneously detect under voltage and force PMIC to | ||
| 579 | * emergency state instead of poweroff. In order to avoid this we | ||
| 580 | * disable voltage monitoring for LDO5 and LDO6 | ||
| 581 | */ | ||
| 582 | err = regmap_update_bits(pmic->mfd->regmap, BD718XX_REG_MVRFLTMASK2, | ||
| 583 | BD718XX_LDO5_VRMON80 | BD718XX_LDO6_VRMON80, | ||
| 584 | BD718XX_LDO5_VRMON80 | BD718XX_LDO6_VRMON80); | ||
| 585 | if (err) { | ||
| 586 | dev_err(&pmic->pdev->dev, | ||
| 587 | "Failed to disable voltage monitoring\n"); | ||
| 588 | goto err; | ||
| 589 | } | ||
| 590 | |||
| 572 | for (i = 0; i < ARRAY_SIZE(pmic_regulator_inits); i++) { | 591 | for (i = 0; i < ARRAY_SIZE(pmic_regulator_inits); i++) { |
| 573 | 592 | ||
| 574 | struct regulator_desc *desc; | 593 | struct regulator_desc *desc; |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index bb1324f93143..9577d8941846 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -3161,7 +3161,7 @@ static inline int regulator_suspend_toggle(struct regulator_dev *rdev, | |||
| 3161 | if (!rstate->changeable) | 3161 | if (!rstate->changeable) |
| 3162 | return -EPERM; | 3162 | return -EPERM; |
| 3163 | 3163 | ||
| 3164 | rstate->enabled = en; | 3164 | rstate->enabled = (en) ? ENABLE_IN_SUSPEND : DISABLE_IN_SUSPEND; |
| 3165 | 3165 | ||
| 3166 | return 0; | 3166 | return 0; |
| 3167 | } | 3167 | } |
| @@ -4395,13 +4395,13 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
| 4395 | !rdev->desc->fixed_uV) | 4395 | !rdev->desc->fixed_uV) |
| 4396 | rdev->is_switch = true; | 4396 | rdev->is_switch = true; |
| 4397 | 4397 | ||
| 4398 | dev_set_drvdata(&rdev->dev, rdev); | ||
| 4398 | ret = device_register(&rdev->dev); | 4399 | ret = device_register(&rdev->dev); |
| 4399 | if (ret != 0) { | 4400 | if (ret != 0) { |
| 4400 | put_device(&rdev->dev); | 4401 | put_device(&rdev->dev); |
| 4401 | goto unset_supplies; | 4402 | goto unset_supplies; |
| 4402 | } | 4403 | } |
| 4403 | 4404 | ||
| 4404 | dev_set_drvdata(&rdev->dev, rdev); | ||
| 4405 | rdev_init_debugfs(rdev); | 4405 | rdev_init_debugfs(rdev); |
| 4406 | 4406 | ||
| 4407 | /* try to resolve regulators supply since a new one was registered */ | 4407 | /* try to resolve regulators supply since a new one was registered */ |
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 638f17d4c848..210fc20f7de7 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
| @@ -213,8 +213,6 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
| 213 | else if (of_property_read_bool(suspend_np, | 213 | else if (of_property_read_bool(suspend_np, |
| 214 | "regulator-off-in-suspend")) | 214 | "regulator-off-in-suspend")) |
| 215 | suspend_state->enabled = DISABLE_IN_SUSPEND; | 215 | suspend_state->enabled = DISABLE_IN_SUSPEND; |
| 216 | else | ||
| 217 | suspend_state->enabled = DO_NOTHING_IN_SUSPEND; | ||
| 218 | 216 | ||
| 219 | if (!of_property_read_u32(np, "regulator-suspend-min-microvolt", | 217 | if (!of_property_read_u32(np, "regulator-suspend-min-microvolt", |
| 220 | &pval)) | 218 | &pval)) |
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index 0626e6e3ea0c..421bfc7dda67 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c | |||
| @@ -300,8 +300,8 @@ static int spi_gpio_request(struct device *dev, | |||
| 300 | *mflags |= SPI_MASTER_NO_RX; | 300 | *mflags |= SPI_MASTER_NO_RX; |
| 301 | 301 | ||
| 302 | spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); | 302 | spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); |
| 303 | if (IS_ERR(spi_gpio->mosi)) | 303 | if (IS_ERR(spi_gpio->sck)) |
| 304 | return PTR_ERR(spi_gpio->mosi); | 304 | return PTR_ERR(spi_gpio->sck); |
| 305 | 305 | ||
| 306 | for (i = 0; i < num_chipselects; i++) { | 306 | for (i = 0; i < num_chipselects; i++) { |
| 307 | spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", | 307 | spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", |
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 95dc4d78618d..b37de1d991d6 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c | |||
| @@ -598,11 +598,13 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx, | |||
| 598 | 598 | ||
| 599 | ret = wait_event_interruptible_timeout(rspi->wait, | 599 | ret = wait_event_interruptible_timeout(rspi->wait, |
| 600 | rspi->dma_callbacked, HZ); | 600 | rspi->dma_callbacked, HZ); |
| 601 | if (ret > 0 && rspi->dma_callbacked) | 601 | if (ret > 0 && rspi->dma_callbacked) { |
| 602 | ret = 0; | 602 | ret = 0; |
| 603 | else if (!ret) { | 603 | } else { |
| 604 | dev_err(&rspi->master->dev, "DMA timeout\n"); | 604 | if (!ret) { |
| 605 | ret = -ETIMEDOUT; | 605 | dev_err(&rspi->master->dev, "DMA timeout\n"); |
| 606 | ret = -ETIMEDOUT; | ||
| 607 | } | ||
| 606 | if (tx) | 608 | if (tx) |
| 607 | dmaengine_terminate_all(rspi->master->dma_tx); | 609 | dmaengine_terminate_all(rspi->master->dma_tx); |
| 608 | if (rx) | 610 | if (rx) |
| @@ -1350,12 +1352,36 @@ static const struct platform_device_id spi_driver_ids[] = { | |||
| 1350 | 1352 | ||
| 1351 | MODULE_DEVICE_TABLE(platform, spi_driver_ids); | 1353 | MODULE_DEVICE_TABLE(platform, spi_driver_ids); |
| 1352 | 1354 | ||
| 1355 | #ifdef CONFIG_PM_SLEEP | ||
| 1356 | static int rspi_suspend(struct device *dev) | ||
| 1357 | { | ||
| 1358 | struct platform_device *pdev = to_platform_device(dev); | ||
| 1359 | struct rspi_data *rspi = platform_get_drvdata(pdev); | ||
| 1360 | |||
| 1361 | return spi_master_suspend(rspi->master); | ||
| 1362 | } | ||
| 1363 | |||
| 1364 | static int rspi_resume(struct device *dev) | ||
| 1365 | { | ||
| 1366 | struct platform_device *pdev = to_platform_device(dev); | ||
| 1367 | struct rspi_data *rspi = platform_get_drvdata(pdev); | ||
| 1368 | |||
| 1369 | return spi_master_resume(rspi->master); | ||
| 1370 | } | ||
| 1371 | |||
| 1372 | static SIMPLE_DEV_PM_OPS(rspi_pm_ops, rspi_suspend, rspi_resume); | ||
| 1373 | #define DEV_PM_OPS &rspi_pm_ops | ||
| 1374 | #else | ||
| 1375 | #define DEV_PM_OPS NULL | ||
| 1376 | #endif /* CONFIG_PM_SLEEP */ | ||
| 1377 | |||
| 1353 | static struct platform_driver rspi_driver = { | 1378 | static struct platform_driver rspi_driver = { |
| 1354 | .probe = rspi_probe, | 1379 | .probe = rspi_probe, |
| 1355 | .remove = rspi_remove, | 1380 | .remove = rspi_remove, |
| 1356 | .id_table = spi_driver_ids, | 1381 | .id_table = spi_driver_ids, |
| 1357 | .driver = { | 1382 | .driver = { |
| 1358 | .name = "renesas_spi", | 1383 | .name = "renesas_spi", |
| 1384 | .pm = DEV_PM_OPS, | ||
| 1359 | .of_match_table = of_match_ptr(rspi_of_match), | 1385 | .of_match_table = of_match_ptr(rspi_of_match), |
| 1360 | }, | 1386 | }, |
| 1361 | }; | 1387 | }; |
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 539d6d1a277a..101cd6aae2ea 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
| @@ -397,7 +397,8 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p, | |||
| 397 | 397 | ||
| 398 | static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p) | 398 | static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p) |
| 399 | { | 399 | { |
| 400 | sh_msiof_write(p, STR, sh_msiof_read(p, STR)); | 400 | sh_msiof_write(p, STR, |
| 401 | sh_msiof_read(p, STR) & ~(STR_TDREQ | STR_RDREQ)); | ||
| 401 | } | 402 | } |
| 402 | 403 | ||
| 403 | static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p, | 404 | static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p, |
| @@ -1426,12 +1427,37 @@ static const struct platform_device_id spi_driver_ids[] = { | |||
| 1426 | }; | 1427 | }; |
| 1427 | MODULE_DEVICE_TABLE(platform, spi_driver_ids); | 1428 | MODULE_DEVICE_TABLE(platform, spi_driver_ids); |
| 1428 | 1429 | ||
| 1430 | #ifdef CONFIG_PM_SLEEP | ||
| 1431 | static int sh_msiof_spi_suspend(struct device *dev) | ||
| 1432 | { | ||
| 1433 | struct platform_device *pdev = to_platform_device(dev); | ||
| 1434 | struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev); | ||
| 1435 | |||
| 1436 | return spi_master_suspend(p->master); | ||
| 1437 | } | ||
| 1438 | |||
| 1439 | static int sh_msiof_spi_resume(struct device *dev) | ||
| 1440 | { | ||
| 1441 | struct platform_device *pdev = to_platform_device(dev); | ||
| 1442 | struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev); | ||
| 1443 | |||
| 1444 | return spi_master_resume(p->master); | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | static SIMPLE_DEV_PM_OPS(sh_msiof_spi_pm_ops, sh_msiof_spi_suspend, | ||
| 1448 | sh_msiof_spi_resume); | ||
| 1449 | #define DEV_PM_OPS &sh_msiof_spi_pm_ops | ||
| 1450 | #else | ||
| 1451 | #define DEV_PM_OPS NULL | ||
| 1452 | #endif /* CONFIG_PM_SLEEP */ | ||
| 1453 | |||
| 1429 | static struct platform_driver sh_msiof_spi_drv = { | 1454 | static struct platform_driver sh_msiof_spi_drv = { |
| 1430 | .probe = sh_msiof_spi_probe, | 1455 | .probe = sh_msiof_spi_probe, |
| 1431 | .remove = sh_msiof_spi_remove, | 1456 | .remove = sh_msiof_spi_remove, |
| 1432 | .id_table = spi_driver_ids, | 1457 | .id_table = spi_driver_ids, |
| 1433 | .driver = { | 1458 | .driver = { |
| 1434 | .name = "spi_sh_msiof", | 1459 | .name = "spi_sh_msiof", |
| 1460 | .pm = DEV_PM_OPS, | ||
| 1435 | .of_match_table = of_match_ptr(sh_msiof_match), | 1461 | .of_match_table = of_match_ptr(sh_msiof_match), |
| 1436 | }, | 1462 | }, |
| 1437 | }; | 1463 | }; |
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index 6f7b946b5ced..1427f343b39a 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c | |||
| @@ -1063,6 +1063,24 @@ static int tegra_slink_probe(struct platform_device *pdev) | |||
| 1063 | goto exit_free_master; | 1063 | goto exit_free_master; |
| 1064 | } | 1064 | } |
| 1065 | 1065 | ||
| 1066 | /* disabled clock may cause interrupt storm upon request */ | ||
| 1067 | tspi->clk = devm_clk_get(&pdev->dev, NULL); | ||
| 1068 | if (IS_ERR(tspi->clk)) { | ||
| 1069 | ret = PTR_ERR(tspi->clk); | ||
| 1070 | dev_err(&pdev->dev, "Can not get clock %d\n", ret); | ||
| 1071 | goto exit_free_master; | ||
| 1072 | } | ||
| 1073 | ret = clk_prepare(tspi->clk); | ||
| 1074 | if (ret < 0) { | ||
| 1075 | dev_err(&pdev->dev, "Clock prepare failed %d\n", ret); | ||
| 1076 | goto exit_free_master; | ||
| 1077 | } | ||
| 1078 | ret = clk_enable(tspi->clk); | ||
| 1079 | if (ret < 0) { | ||
| 1080 | dev_err(&pdev->dev, "Clock enable failed %d\n", ret); | ||
| 1081 | goto exit_free_master; | ||
| 1082 | } | ||
| 1083 | |||
| 1066 | spi_irq = platform_get_irq(pdev, 0); | 1084 | spi_irq = platform_get_irq(pdev, 0); |
| 1067 | tspi->irq = spi_irq; | 1085 | tspi->irq = spi_irq; |
| 1068 | ret = request_threaded_irq(tspi->irq, tegra_slink_isr, | 1086 | ret = request_threaded_irq(tspi->irq, tegra_slink_isr, |
| @@ -1071,14 +1089,7 @@ static int tegra_slink_probe(struct platform_device *pdev) | |||
| 1071 | if (ret < 0) { | 1089 | if (ret < 0) { |
| 1072 | dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n", | 1090 | dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n", |
| 1073 | tspi->irq); | 1091 | tspi->irq); |
| 1074 | goto exit_free_master; | 1092 | goto exit_clk_disable; |
| 1075 | } | ||
| 1076 | |||
| 1077 | tspi->clk = devm_clk_get(&pdev->dev, NULL); | ||
| 1078 | if (IS_ERR(tspi->clk)) { | ||
| 1079 | dev_err(&pdev->dev, "can not get clock\n"); | ||
| 1080 | ret = PTR_ERR(tspi->clk); | ||
| 1081 | goto exit_free_irq; | ||
| 1082 | } | 1093 | } |
| 1083 | 1094 | ||
| 1084 | tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi"); | 1095 | tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi"); |
| @@ -1138,6 +1149,8 @@ exit_rx_dma_free: | |||
| 1138 | tegra_slink_deinit_dma_param(tspi, true); | 1149 | tegra_slink_deinit_dma_param(tspi, true); |
| 1139 | exit_free_irq: | 1150 | exit_free_irq: |
| 1140 | free_irq(spi_irq, tspi); | 1151 | free_irq(spi_irq, tspi); |
| 1152 | exit_clk_disable: | ||
| 1153 | clk_disable(tspi->clk); | ||
| 1141 | exit_free_master: | 1154 | exit_free_master: |
| 1142 | spi_master_put(master); | 1155 | spi_master_put(master); |
| 1143 | return ret; | 1156 | return ret; |
| @@ -1150,6 +1163,8 @@ static int tegra_slink_remove(struct platform_device *pdev) | |||
| 1150 | 1163 | ||
| 1151 | free_irq(tspi->irq, tspi); | 1164 | free_irq(tspi->irq, tspi); |
| 1152 | 1165 | ||
| 1166 | clk_disable(tspi->clk); | ||
| 1167 | |||
| 1153 | if (tspi->tx_dma_chan) | 1168 | if (tspi->tx_dma_chan) |
| 1154 | tegra_slink_deinit_dma_param(tspi, false); | 1169 | tegra_slink_deinit_dma_param(tspi, false); |
| 1155 | 1170 | ||
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 7f7ee18fe179..e4bb9386c045 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
| @@ -1448,6 +1448,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino) | |||
| 1448 | } | 1448 | } |
| 1449 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); | 1449 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); |
| 1450 | ei->i_flags = le32_to_cpu(raw_inode->i_flags); | 1450 | ei->i_flags = le32_to_cpu(raw_inode->i_flags); |
| 1451 | ext2_set_inode_flags(inode); | ||
| 1451 | ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); | 1452 | ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); |
| 1452 | ei->i_frag_no = raw_inode->i_frag; | 1453 | ei->i_frag_no = raw_inode->i_frag; |
| 1453 | ei->i_frag_size = raw_inode->i_fsize; | 1454 | ei->i_frag_size = raw_inode->i_fsize; |
| @@ -1517,7 +1518,6 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino) | |||
| 1517 | new_decode_dev(le32_to_cpu(raw_inode->i_block[1]))); | 1518 | new_decode_dev(le32_to_cpu(raw_inode->i_block[1]))); |
| 1518 | } | 1519 | } |
| 1519 | brelse (bh); | 1520 | brelse (bh); |
| 1520 | ext2_set_inode_flags(inode); | ||
| 1521 | unlock_new_inode(inode); | 1521 | unlock_new_inode(inode); |
| 1522 | return inode; | 1522 | return inode; |
| 1523 | 1523 | ||
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 582a0ec0aa70..777814755fa6 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h | |||
| @@ -89,7 +89,6 @@ struct drm_panel { | |||
| 89 | struct drm_device *drm; | 89 | struct drm_device *drm; |
| 90 | struct drm_connector *connector; | 90 | struct drm_connector *connector; |
| 91 | struct device *dev; | 91 | struct device *dev; |
| 92 | struct device_link *link; | ||
| 93 | 92 | ||
| 94 | const struct drm_panel_funcs *funcs; | 93 | const struct drm_panel_funcs *funcs; |
| 95 | 94 | ||
diff --git a/include/linux/mfd/rohm-bd718x7.h b/include/linux/mfd/rohm-bd718x7.h index a528747f8aed..e8338e5dc10b 100644 --- a/include/linux/mfd/rohm-bd718x7.h +++ b/include/linux/mfd/rohm-bd718x7.h | |||
| @@ -78,9 +78,9 @@ enum { | |||
| 78 | BD71837_REG_TRANS_COND0 = 0x1F, | 78 | BD71837_REG_TRANS_COND0 = 0x1F, |
| 79 | BD71837_REG_TRANS_COND1 = 0x20, | 79 | BD71837_REG_TRANS_COND1 = 0x20, |
| 80 | BD71837_REG_VRFAULTEN = 0x21, | 80 | BD71837_REG_VRFAULTEN = 0x21, |
| 81 | BD71837_REG_MVRFLTMASK0 = 0x22, | 81 | BD718XX_REG_MVRFLTMASK0 = 0x22, |
| 82 | BD71837_REG_MVRFLTMASK1 = 0x23, | 82 | BD718XX_REG_MVRFLTMASK1 = 0x23, |
| 83 | BD71837_REG_MVRFLTMASK2 = 0x24, | 83 | BD718XX_REG_MVRFLTMASK2 = 0x24, |
| 84 | BD71837_REG_RCVCFG = 0x25, | 84 | BD71837_REG_RCVCFG = 0x25, |
| 85 | BD71837_REG_RCVNUM = 0x26, | 85 | BD71837_REG_RCVNUM = 0x26, |
| 86 | BD71837_REG_PWRONCONFIG0 = 0x27, | 86 | BD71837_REG_PWRONCONFIG0 = 0x27, |
| @@ -159,6 +159,33 @@ enum { | |||
| 159 | #define BUCK8_MASK 0x3F | 159 | #define BUCK8_MASK 0x3F |
| 160 | #define BUCK8_DEFAULT 0x1E | 160 | #define BUCK8_DEFAULT 0x1E |
| 161 | 161 | ||
| 162 | /* BD718XX Voltage monitoring masks */ | ||
| 163 | #define BD718XX_BUCK1_VRMON80 0x1 | ||
| 164 | #define BD718XX_BUCK1_VRMON130 0x2 | ||
| 165 | #define BD718XX_BUCK2_VRMON80 0x4 | ||
| 166 | #define BD718XX_BUCK2_VRMON130 0x8 | ||
| 167 | #define BD718XX_1ST_NODVS_BUCK_VRMON80 0x1 | ||
| 168 | #define BD718XX_1ST_NODVS_BUCK_VRMON130 0x2 | ||
| 169 | #define BD718XX_2ND_NODVS_BUCK_VRMON80 0x4 | ||
| 170 | #define BD718XX_2ND_NODVS_BUCK_VRMON130 0x8 | ||
| 171 | #define BD718XX_3RD_NODVS_BUCK_VRMON80 0x10 | ||
| 172 | #define BD718XX_3RD_NODVS_BUCK_VRMON130 0x20 | ||
| 173 | #define BD718XX_4TH_NODVS_BUCK_VRMON80 0x40 | ||
| 174 | #define BD718XX_4TH_NODVS_BUCK_VRMON130 0x80 | ||
| 175 | #define BD718XX_LDO1_VRMON80 0x1 | ||
| 176 | #define BD718XX_LDO2_VRMON80 0x2 | ||
| 177 | #define BD718XX_LDO3_VRMON80 0x4 | ||
| 178 | #define BD718XX_LDO4_VRMON80 0x8 | ||
| 179 | #define BD718XX_LDO5_VRMON80 0x10 | ||
| 180 | #define BD718XX_LDO6_VRMON80 0x20 | ||
| 181 | |||
| 182 | /* BD71837 specific voltage monitoring masks */ | ||
| 183 | #define BD71837_BUCK3_VRMON80 0x10 | ||
| 184 | #define BD71837_BUCK3_VRMON130 0x20 | ||
| 185 | #define BD71837_BUCK4_VRMON80 0x40 | ||
| 186 | #define BD71837_BUCK4_VRMON130 0x80 | ||
| 187 | #define BD71837_LDO7_VRMON80 0x40 | ||
| 188 | |||
| 162 | /* BD71837_REG_IRQ bits */ | 189 | /* BD71837_REG_IRQ bits */ |
| 163 | #define IRQ_SWRST 0x40 | 190 | #define IRQ_SWRST 0x40 |
| 164 | #define IRQ_PWRON_S 0x20 | 191 | #define IRQ_PWRON_S 0x20 |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 3468703d663a..a459a5e973a7 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
| @@ -48,9 +48,9 @@ struct regulator; | |||
| 48 | * DISABLE_IN_SUSPEND - turn off regulator in suspend states | 48 | * DISABLE_IN_SUSPEND - turn off regulator in suspend states |
| 49 | * ENABLE_IN_SUSPEND - keep regulator on in suspend states | 49 | * ENABLE_IN_SUSPEND - keep regulator on in suspend states |
| 50 | */ | 50 | */ |
| 51 | #define DO_NOTHING_IN_SUSPEND (-1) | 51 | #define DO_NOTHING_IN_SUSPEND 0 |
| 52 | #define DISABLE_IN_SUSPEND 0 | 52 | #define DISABLE_IN_SUSPEND 1 |
| 53 | #define ENABLE_IN_SUSPEND 1 | 53 | #define ENABLE_IN_SUSPEND 2 |
| 54 | 54 | ||
| 55 | /* Regulator active discharge flags */ | 55 | /* Regulator active discharge flags */ |
| 56 | enum regulator_active_discharge { | 56 | enum regulator_active_discharge { |
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index b2bd4b4127c4..69ee30456864 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h | |||
| @@ -81,8 +81,10 @@ enum spi_mem_data_dir { | |||
| 81 | * @dummy.buswidth: number of IO lanes used to transmit the dummy bytes | 81 | * @dummy.buswidth: number of IO lanes used to transmit the dummy bytes |
| 82 | * @data.buswidth: number of IO lanes used to send/receive the data | 82 | * @data.buswidth: number of IO lanes used to send/receive the data |
| 83 | * @data.dir: direction of the transfer | 83 | * @data.dir: direction of the transfer |
| 84 | * @data.buf.in: input buffer | 84 | * @data.nbytes: number of data bytes to send/receive. Can be zero if the |
| 85 | * @data.buf.out: output buffer | 85 | * operation does not involve transferring data |
| 86 | * @data.buf.in: input buffer (must be DMA-able) | ||
| 87 | * @data.buf.out: output buffer (must be DMA-able) | ||
| 86 | */ | 88 | */ |
| 87 | struct spi_mem_op { | 89 | struct spi_mem_op { |
| 88 | struct { | 90 | struct { |
| @@ -105,7 +107,6 @@ struct spi_mem_op { | |||
| 105 | u8 buswidth; | 107 | u8 buswidth; |
| 106 | enum spi_mem_data_dir dir; | 108 | enum spi_mem_data_dir dir; |
| 107 | unsigned int nbytes; | 109 | unsigned int nbytes; |
| 108 | /* buf.{in,out} must be DMA-able. */ | ||
| 109 | union { | 110 | union { |
| 110 | void *in; | 111 | void *in; |
| 111 | const void *out; | 112 | const void *out; |
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 9bd54304446f..1b1d63b3634b 100644 --- a/kernel/dma/Kconfig +++ b/kernel/dma/Kconfig | |||
| @@ -23,6 +23,9 @@ config ARCH_HAS_SYNC_DMA_FOR_CPU | |||
| 23 | bool | 23 | bool |
| 24 | select NEED_DMA_MAP_STATE | 24 | select NEED_DMA_MAP_STATE |
| 25 | 25 | ||
| 26 | config ARCH_HAS_SYNC_DMA_FOR_CPU_ALL | ||
| 27 | bool | ||
| 28 | |||
| 26 | config DMA_DIRECT_OPS | 29 | config DMA_DIRECT_OPS |
| 27 | bool | 30 | bool |
| 28 | depends on HAS_DMA | 31 | depends on HAS_DMA |
diff --git a/kernel/events/core.c b/kernel/events/core.c index dcb093e7b377..5a97f34bc14c 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -8314,6 +8314,8 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size, | |||
| 8314 | goto unlock; | 8314 | goto unlock; |
| 8315 | 8315 | ||
| 8316 | list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { | 8316 | list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { |
| 8317 | if (event->cpu != smp_processor_id()) | ||
| 8318 | continue; | ||
| 8317 | if (event->attr.type != PERF_TYPE_TRACEPOINT) | 8319 | if (event->attr.type != PERF_TYPE_TRACEPOINT) |
| 8318 | continue; | 8320 | continue; |
| 8319 | if (event->attr.config != entry->type) | 8321 | if (event->attr.config != entry->type) |
| @@ -9431,9 +9433,7 @@ static void free_pmu_context(struct pmu *pmu) | |||
| 9431 | if (pmu->task_ctx_nr > perf_invalid_context) | 9433 | if (pmu->task_ctx_nr > perf_invalid_context) |
| 9432 | return; | 9434 | return; |
| 9433 | 9435 | ||
| 9434 | mutex_lock(&pmus_lock); | ||
| 9435 | free_percpu(pmu->pmu_cpu_context); | 9436 | free_percpu(pmu->pmu_cpu_context); |
| 9436 | mutex_unlock(&pmus_lock); | ||
| 9437 | } | 9437 | } |
| 9438 | 9438 | ||
| 9439 | /* | 9439 | /* |
| @@ -9689,12 +9689,8 @@ EXPORT_SYMBOL_GPL(perf_pmu_register); | |||
| 9689 | 9689 | ||
| 9690 | void perf_pmu_unregister(struct pmu *pmu) | 9690 | void perf_pmu_unregister(struct pmu *pmu) |
| 9691 | { | 9691 | { |
| 9692 | int remove_device; | ||
| 9693 | |||
| 9694 | mutex_lock(&pmus_lock); | 9692 | mutex_lock(&pmus_lock); |
| 9695 | remove_device = pmu_bus_running; | ||
| 9696 | list_del_rcu(&pmu->entry); | 9693 | list_del_rcu(&pmu->entry); |
| 9697 | mutex_unlock(&pmus_lock); | ||
| 9698 | 9694 | ||
| 9699 | /* | 9695 | /* |
| 9700 | * We dereference the pmu list under both SRCU and regular RCU, so | 9696 | * We dereference the pmu list under both SRCU and regular RCU, so |
| @@ -9706,13 +9702,14 @@ void perf_pmu_unregister(struct pmu *pmu) | |||
| 9706 | free_percpu(pmu->pmu_disable_count); | 9702 | free_percpu(pmu->pmu_disable_count); |
| 9707 | if (pmu->type >= PERF_TYPE_MAX) | 9703 | if (pmu->type >= PERF_TYPE_MAX) |
| 9708 | idr_remove(&pmu_idr, pmu->type); | 9704 | idr_remove(&pmu_idr, pmu->type); |
| 9709 | if (remove_device) { | 9705 | if (pmu_bus_running) { |
| 9710 | if (pmu->nr_addr_filters) | 9706 | if (pmu->nr_addr_filters) |
| 9711 | device_remove_file(pmu->dev, &dev_attr_nr_addr_filters); | 9707 | device_remove_file(pmu->dev, &dev_attr_nr_addr_filters); |
| 9712 | device_del(pmu->dev); | 9708 | device_del(pmu->dev); |
| 9713 | put_device(pmu->dev); | 9709 | put_device(pmu->dev); |
| 9714 | } | 9710 | } |
| 9715 | free_pmu_context(pmu); | 9711 | free_pmu_context(pmu); |
| 9712 | mutex_unlock(&pmus_lock); | ||
| 9716 | } | 9713 | } |
| 9717 | EXPORT_SYMBOL_GPL(perf_pmu_unregister); | 9714 | EXPORT_SYMBOL_GPL(perf_pmu_unregister); |
| 9718 | 9715 | ||
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 5d3cf407e374..4a9937076331 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c | |||
| @@ -459,10 +459,20 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) | |||
| 459 | if (size || handle->aux_flags) { | 459 | if (size || handle->aux_flags) { |
| 460 | /* | 460 | /* |
| 461 | * Only send RECORD_AUX if we have something useful to communicate | 461 | * Only send RECORD_AUX if we have something useful to communicate |
| 462 | * | ||
| 463 | * Note: the OVERWRITE records by themselves are not considered | ||
| 464 | * useful, as they don't communicate any *new* information, | ||
| 465 | * aside from the short-lived offset, that becomes history at | ||
| 466 | * the next event sched-in and therefore isn't useful. | ||
| 467 | * The userspace that needs to copy out AUX data in overwrite | ||
| 468 | * mode should know to use user_page::aux_head for the actual | ||
| 469 | * offset. So, from now on we don't output AUX records that | ||
| 470 | * have *only* OVERWRITE flag set. | ||
| 462 | */ | 471 | */ |
| 463 | 472 | ||
| 464 | perf_event_aux_event(handle->event, aux_head, size, | 473 | if (handle->aux_flags & ~(u64)PERF_AUX_FLAG_OVERWRITE) |
| 465 | handle->aux_flags); | 474 | perf_event_aux_event(handle->event, aux_head, size, |
| 475 | handle->aux_flags); | ||
| 466 | } | 476 | } |
| 467 | 477 | ||
| 468 | rb->user_page->aux_head = rb->aux_head; | 478 | rb->user_page->aux_head = rb->aux_head; |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index ab257be4d924..90e98e233647 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -546,8 +546,14 @@ static void do_free_cleaned_kprobes(void) | |||
| 546 | struct optimized_kprobe *op, *tmp; | 546 | struct optimized_kprobe *op, *tmp; |
| 547 | 547 | ||
| 548 | list_for_each_entry_safe(op, tmp, &freeing_list, list) { | 548 | list_for_each_entry_safe(op, tmp, &freeing_list, list) { |
| 549 | BUG_ON(!kprobe_unused(&op->kp)); | ||
| 550 | list_del_init(&op->list); | 549 | list_del_init(&op->list); |
| 550 | if (WARN_ON_ONCE(!kprobe_unused(&op->kp))) { | ||
| 551 | /* | ||
| 552 | * This must not happen, but if there is a kprobe | ||
| 553 | * still in use, keep it on kprobes hash list. | ||
| 554 | */ | ||
| 555 | continue; | ||
| 556 | } | ||
| 551 | free_aggr_kprobe(&op->kp); | 557 | free_aggr_kprobe(&op->kp); |
| 552 | } | 558 | } |
| 553 | } | 559 | } |
| @@ -700,11 +706,11 @@ static void unoptimize_kprobe(struct kprobe *p, bool force) | |||
| 700 | } | 706 | } |
| 701 | 707 | ||
| 702 | /* Cancel unoptimizing for reusing */ | 708 | /* Cancel unoptimizing for reusing */ |
| 703 | static void reuse_unused_kprobe(struct kprobe *ap) | 709 | static int reuse_unused_kprobe(struct kprobe *ap) |
| 704 | { | 710 | { |
| 705 | struct optimized_kprobe *op; | 711 | struct optimized_kprobe *op; |
| 712 | int ret; | ||
| 706 | 713 | ||
| 707 | BUG_ON(!kprobe_unused(ap)); | ||
| 708 | /* | 714 | /* |
| 709 | * Unused kprobe MUST be on the way of delayed unoptimizing (means | 715 | * Unused kprobe MUST be on the way of delayed unoptimizing (means |
| 710 | * there is still a relative jump) and disabled. | 716 | * there is still a relative jump) and disabled. |
| @@ -714,8 +720,12 @@ static void reuse_unused_kprobe(struct kprobe *ap) | |||
| 714 | /* Enable the probe again */ | 720 | /* Enable the probe again */ |
| 715 | ap->flags &= ~KPROBE_FLAG_DISABLED; | 721 | ap->flags &= ~KPROBE_FLAG_DISABLED; |
| 716 | /* Optimize it again (remove from op->list) */ | 722 | /* Optimize it again (remove from op->list) */ |
| 717 | BUG_ON(!kprobe_optready(ap)); | 723 | ret = kprobe_optready(ap); |
| 724 | if (ret) | ||
| 725 | return ret; | ||
| 726 | |||
| 718 | optimize_kprobe(ap); | 727 | optimize_kprobe(ap); |
| 728 | return 0; | ||
| 719 | } | 729 | } |
| 720 | 730 | ||
| 721 | /* Remove optimized instructions */ | 731 | /* Remove optimized instructions */ |
| @@ -940,11 +950,16 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt) | |||
| 940 | #define kprobe_disarmed(p) kprobe_disabled(p) | 950 | #define kprobe_disarmed(p) kprobe_disabled(p) |
| 941 | #define wait_for_kprobe_optimizer() do {} while (0) | 951 | #define wait_for_kprobe_optimizer() do {} while (0) |
| 942 | 952 | ||
| 943 | /* There should be no unused kprobes can be reused without optimization */ | 953 | static int reuse_unused_kprobe(struct kprobe *ap) |
| 944 | static void reuse_unused_kprobe(struct kprobe *ap) | ||
| 945 | { | 954 | { |
| 955 | /* | ||
| 956 | * If the optimized kprobe is NOT supported, the aggr kprobe is | ||
| 957 | * released at the same time that the last aggregated kprobe is | ||
| 958 | * unregistered. | ||
| 959 | * Thus there should be no chance to reuse unused kprobe. | ||
| 960 | */ | ||
| 946 | printk(KERN_ERR "Error: There should be no unused kprobe here.\n"); | 961 | printk(KERN_ERR "Error: There should be no unused kprobe here.\n"); |
| 947 | BUG_ON(kprobe_unused(ap)); | 962 | return -EINVAL; |
| 948 | } | 963 | } |
| 949 | 964 | ||
| 950 | static void free_aggr_kprobe(struct kprobe *p) | 965 | static void free_aggr_kprobe(struct kprobe *p) |
| @@ -1259,8 +1274,6 @@ NOKPROBE_SYMBOL(cleanup_rp_inst); | |||
| 1259 | /* Add the new probe to ap->list */ | 1274 | /* Add the new probe to ap->list */ |
| 1260 | static int add_new_kprobe(struct kprobe *ap, struct kprobe *p) | 1275 | static int add_new_kprobe(struct kprobe *ap, struct kprobe *p) |
| 1261 | { | 1276 | { |
| 1262 | BUG_ON(kprobe_gone(ap) || kprobe_gone(p)); | ||
| 1263 | |||
| 1264 | if (p->post_handler) | 1277 | if (p->post_handler) |
| 1265 | unoptimize_kprobe(ap, true); /* Fall back to normal kprobe */ | 1278 | unoptimize_kprobe(ap, true); /* Fall back to normal kprobe */ |
| 1266 | 1279 | ||
| @@ -1318,9 +1331,12 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p) | |||
| 1318 | goto out; | 1331 | goto out; |
| 1319 | } | 1332 | } |
| 1320 | init_aggr_kprobe(ap, orig_p); | 1333 | init_aggr_kprobe(ap, orig_p); |
| 1321 | } else if (kprobe_unused(ap)) | 1334 | } else if (kprobe_unused(ap)) { |
| 1322 | /* This probe is going to die. Rescue it */ | 1335 | /* This probe is going to die. Rescue it */ |
| 1323 | reuse_unused_kprobe(ap); | 1336 | ret = reuse_unused_kprobe(ap); |
| 1337 | if (ret) | ||
| 1338 | goto out; | ||
| 1339 | } | ||
| 1324 | 1340 | ||
| 1325 | if (kprobe_gone(ap)) { | 1341 | if (kprobe_gone(ap)) { |
| 1326 | /* | 1342 | /* |
| @@ -1704,7 +1720,6 @@ noclean: | |||
| 1704 | return 0; | 1720 | return 0; |
| 1705 | 1721 | ||
| 1706 | disarmed: | 1722 | disarmed: |
| 1707 | BUG_ON(!kprobe_disarmed(ap)); | ||
| 1708 | hlist_del_rcu(&ap->hlist); | 1723 | hlist_del_rcu(&ap->hlist); |
| 1709 | return 0; | 1724 | return 0; |
| 1710 | } | 1725 | } |
diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h index 7a8b61ad44cb..094649667bae 100644 --- a/tools/include/linux/err.h +++ b/tools/include/linux/err.h | |||
| @@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr) | |||
| 52 | return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr); | 52 | return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr) | ||
| 56 | { | ||
| 57 | if (IS_ERR(ptr)) | ||
| 58 | return PTR_ERR(ptr); | ||
| 59 | else | ||
| 60 | return 0; | ||
| 61 | } | ||
| 55 | #endif /* _LINUX_ERR_H */ | 62 | #endif /* _LINUX_ERR_H */ |
diff --git a/tools/lib/subcmd/pager.c b/tools/lib/subcmd/pager.c index 9997a8805a82..e3d47b59b14d 100644 --- a/tools/lib/subcmd/pager.c +++ b/tools/lib/subcmd/pager.c | |||
| @@ -23,6 +23,13 @@ void pager_init(const char *pager_env) | |||
| 23 | subcmd_config.pager_env = pager_env; | 23 | subcmd_config.pager_env = pager_env; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | static const char *forced_pager; | ||
| 27 | |||
| 28 | void force_pager(const char *pager) | ||
| 29 | { | ||
| 30 | forced_pager = pager; | ||
| 31 | } | ||
| 32 | |||
| 26 | static void pager_preexec(void) | 33 | static void pager_preexec(void) |
| 27 | { | 34 | { |
| 28 | /* | 35 | /* |
| @@ -66,7 +73,9 @@ void setup_pager(void) | |||
| 66 | const char *pager = getenv(subcmd_config.pager_env); | 73 | const char *pager = getenv(subcmd_config.pager_env); |
| 67 | struct winsize sz; | 74 | struct winsize sz; |
| 68 | 75 | ||
| 69 | if (!isatty(1)) | 76 | if (forced_pager) |
| 77 | pager = forced_pager; | ||
| 78 | if (!isatty(1) && !forced_pager) | ||
| 70 | return; | 79 | return; |
| 71 | if (ioctl(1, TIOCGWINSZ, &sz) == 0) | 80 | if (ioctl(1, TIOCGWINSZ, &sz) == 0) |
| 72 | pager_columns = sz.ws_col; | 81 | pager_columns = sz.ws_col; |
diff --git a/tools/lib/subcmd/pager.h b/tools/lib/subcmd/pager.h index f1a53cf29880..a818964693ab 100644 --- a/tools/lib/subcmd/pager.h +++ b/tools/lib/subcmd/pager.h | |||
| @@ -7,5 +7,6 @@ extern void pager_init(const char *pager_env); | |||
| 7 | extern void setup_pager(void); | 7 | extern void setup_pager(void); |
| 8 | extern int pager_in_use(void); | 8 | extern int pager_in_use(void); |
| 9 | extern int pager_get_columns(void); | 9 | extern int pager_get_columns(void); |
| 10 | extern void force_pager(const char *); | ||
| 10 | 11 | ||
| 11 | #endif /* __SUBCMD_PAGER_H */ | 12 | #endif /* __SUBCMD_PAGER_H */ |
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index ce1e20227c64..7980fc6c3bac 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <netinet/in.h> | 24 | #include <netinet/in.h> |
| 25 | #include "event-parse.h" | 25 | #include "event-parse.h" |
| 26 | #include "event-utils.h" | 26 | #include "event-utils.h" |
| 27 | #include "trace-seq.h" | ||
| 27 | 28 | ||
| 28 | static const char *input_buf; | 29 | static const char *input_buf; |
| 29 | static unsigned long long input_buf_ptr; | 30 | static unsigned long long input_buf_ptr; |
| @@ -94,7 +95,7 @@ struct tep_function_handler { | |||
| 94 | 95 | ||
| 95 | static unsigned long long | 96 | static unsigned long long |
| 96 | process_defined_func(struct trace_seq *s, void *data, int size, | 97 | process_defined_func(struct trace_seq *s, void *data, int size, |
| 97 | struct event_format *event, struct print_arg *arg); | 98 | struct tep_event_format *event, struct tep_print_arg *arg); |
| 98 | 99 | ||
| 99 | static void free_func_handle(struct tep_function_handler *func); | 100 | static void free_func_handle(struct tep_function_handler *func); |
| 100 | 101 | ||
| @@ -117,9 +118,9 @@ void breakpoint(void) | |||
| 117 | x++; | 118 | x++; |
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | struct print_arg *alloc_arg(void) | 121 | struct tep_print_arg *alloc_arg(void) |
| 121 | { | 122 | { |
| 122 | return calloc(1, sizeof(struct print_arg)); | 123 | return calloc(1, sizeof(struct tep_print_arg)); |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | struct cmdline { | 126 | struct cmdline { |
| @@ -737,16 +738,16 @@ void tep_print_printk(struct tep_handle *pevent) | |||
| 737 | } | 738 | } |
| 738 | } | 739 | } |
| 739 | 740 | ||
| 740 | static struct event_format *alloc_event(void) | 741 | static struct tep_event_format *alloc_event(void) |
| 741 | { | 742 | { |
| 742 | return calloc(1, sizeof(struct event_format)); | 743 | return calloc(1, sizeof(struct tep_event_format)); |
| 743 | } | 744 | } |
| 744 | 745 | ||
| 745 | static int add_event(struct tep_handle *pevent, struct event_format *event) | 746 | static int add_event(struct tep_handle *pevent, struct tep_event_format *event) |
| 746 | { | 747 | { |
| 747 | int i; | 748 | int i; |
| 748 | struct event_format **events = realloc(pevent->events, sizeof(event) * | 749 | struct tep_event_format **events = realloc(pevent->events, sizeof(event) * |
| 749 | (pevent->nr_events + 1)); | 750 | (pevent->nr_events + 1)); |
| 750 | if (!events) | 751 | if (!events) |
| 751 | return -1; | 752 | return -1; |
| 752 | 753 | ||
| @@ -769,20 +770,20 @@ static int add_event(struct tep_handle *pevent, struct event_format *event) | |||
| 769 | return 0; | 770 | return 0; |
| 770 | } | 771 | } |
| 771 | 772 | ||
| 772 | static int event_item_type(enum event_type type) | 773 | static int event_item_type(enum tep_event_type type) |
| 773 | { | 774 | { |
| 774 | switch (type) { | 775 | switch (type) { |
| 775 | case EVENT_ITEM ... EVENT_SQUOTE: | 776 | case TEP_EVENT_ITEM ... TEP_EVENT_SQUOTE: |
| 776 | return 1; | 777 | return 1; |
| 777 | case EVENT_ERROR ... EVENT_DELIM: | 778 | case TEP_EVENT_ERROR ... TEP_EVENT_DELIM: |
| 778 | default: | 779 | default: |
| 779 | return 0; | 780 | return 0; |
| 780 | } | 781 | } |
| 781 | } | 782 | } |
| 782 | 783 | ||
| 783 | static void free_flag_sym(struct print_flag_sym *fsym) | 784 | static void free_flag_sym(struct tep_print_flag_sym *fsym) |
| 784 | { | 785 | { |
| 785 | struct print_flag_sym *next; | 786 | struct tep_print_flag_sym *next; |
| 786 | 787 | ||
| 787 | while (fsym) { | 788 | while (fsym) { |
| 788 | next = fsym->next; | 789 | next = fsym->next; |
| @@ -793,60 +794,60 @@ static void free_flag_sym(struct print_flag_sym *fsym) | |||
| 793 | } | 794 | } |
| 794 | } | 795 | } |
| 795 | 796 | ||
| 796 | static void free_arg(struct print_arg *arg) | 797 | static void free_arg(struct tep_print_arg *arg) |
| 797 | { | 798 | { |
| 798 | struct print_arg *farg; | 799 | struct tep_print_arg *farg; |
| 799 | 800 | ||
| 800 | if (!arg) | 801 | if (!arg) |
| 801 | return; | 802 | return; |
| 802 | 803 | ||
| 803 | switch (arg->type) { | 804 | switch (arg->type) { |
| 804 | case PRINT_ATOM: | 805 | case TEP_PRINT_ATOM: |
| 805 | free(arg->atom.atom); | 806 | free(arg->atom.atom); |
| 806 | break; | 807 | break; |
| 807 | case PRINT_FIELD: | 808 | case TEP_PRINT_FIELD: |
| 808 | free(arg->field.name); | 809 | free(arg->field.name); |
| 809 | break; | 810 | break; |
| 810 | case PRINT_FLAGS: | 811 | case TEP_PRINT_FLAGS: |
| 811 | free_arg(arg->flags.field); | 812 | free_arg(arg->flags.field); |
| 812 | free(arg->flags.delim); | 813 | free(arg->flags.delim); |
| 813 | free_flag_sym(arg->flags.flags); | 814 | free_flag_sym(arg->flags.flags); |
| 814 | break; | 815 | break; |
| 815 | case PRINT_SYMBOL: | 816 | case TEP_PRINT_SYMBOL: |
| 816 | free_arg(arg->symbol.field); | 817 | free_arg(arg->symbol.field); |
| 817 | free_flag_sym(arg->symbol.symbols); | 818 | free_flag_sym(arg->symbol.symbols); |
| 818 | break; | 819 | break; |
| 819 | case PRINT_HEX: | 820 | case TEP_PRINT_HEX: |
| 820 | case PRINT_HEX_STR: | 821 | case TEP_PRINT_HEX_STR: |
| 821 | free_arg(arg->hex.field); | 822 | free_arg(arg->hex.field); |
| 822 | free_arg(arg->hex.size); | 823 | free_arg(arg->hex.size); |
| 823 | break; | 824 | break; |
| 824 | case PRINT_INT_ARRAY: | 825 | case TEP_PRINT_INT_ARRAY: |
| 825 | free_arg(arg->int_array.field); | 826 | free_arg(arg->int_array.field); |
| 826 | free_arg(arg->int_array.count); | 827 | free_arg(arg->int_array.count); |
| 827 | free_arg(arg->int_array.el_size); | 828 | free_arg(arg->int_array.el_size); |
| 828 | break; | 829 | break; |
| 829 | case PRINT_TYPE: | 830 | case TEP_PRINT_TYPE: |
| 830 | free(arg->typecast.type); | 831 | free(arg->typecast.type); |
| 831 | free_arg(arg->typecast.item); | 832 | free_arg(arg->typecast.item); |
| 832 | break; | 833 | break; |
| 833 | case PRINT_STRING: | 834 | case TEP_PRINT_STRING: |
| 834 | case PRINT_BSTRING: | 835 | case TEP_PRINT_BSTRING: |
| 835 | free(arg->string.string); | 836 | free(arg->string.string); |
| 836 | break; | 837 | break; |
| 837 | case PRINT_BITMASK: | 838 | case TEP_PRINT_BITMASK: |
| 838 | free(arg->bitmask.bitmask); | 839 | free(arg->bitmask.bitmask); |
| 839 | break; | 840 | break; |
| 840 | case PRINT_DYNAMIC_ARRAY: | 841 | case TEP_PRINT_DYNAMIC_ARRAY: |
| 841 | case PRINT_DYNAMIC_ARRAY_LEN: | 842 | case TEP_PRINT_DYNAMIC_ARRAY_LEN: |
| 842 | free(arg->dynarray.index); | 843 | free(arg->dynarray.index); |
| 843 | break; | 844 | break; |
| 844 | case PRINT_OP: | 845 | case TEP_PRINT_OP: |
| 845 | free(arg->op.op); | 846 | free(arg->op.op); |
| 846 | free_arg(arg->op.left); | 847 | free_arg(arg->op.left); |
| 847 | free_arg(arg->op.right); | 848 | free_arg(arg->op.right); |
| 848 | break; | 849 | break; |
| 849 | case PRINT_FUNC: | 850 | case TEP_PRINT_FUNC: |
| 850 | while (arg->func.args) { | 851 | while (arg->func.args) { |
| 851 | farg = arg->func.args; | 852 | farg = arg->func.args; |
| 852 | arg->func.args = farg->next; | 853 | arg->func.args = farg->next; |
| @@ -854,7 +855,7 @@ static void free_arg(struct print_arg *arg) | |||
| 854 | } | 855 | } |
| 855 | break; | 856 | break; |
| 856 | 857 | ||
| 857 | case PRINT_NULL: | 858 | case TEP_PRINT_NULL: |
| 858 | default: | 859 | default: |
| 859 | break; | 860 | break; |
| 860 | } | 861 | } |
| @@ -862,24 +863,24 @@ static void free_arg(struct print_arg *arg) | |||
| 862 | free(arg); | 863 | free(arg); |
| 863 | } | 864 | } |
| 864 | 865 | ||
| 865 | static enum event_type get_type(int ch) | 866 | static enum tep_event_type get_type(int ch) |
| 866 | { | 867 | { |
| 867 | if (ch == '\n') | 868 | if (ch == '\n') |
| 868 | return EVENT_NEWLINE; | 869 | return TEP_EVENT_NEWLINE; |
| 869 | if (isspace(ch)) | 870 | if (isspace(ch)) |
| 870 | return EVENT_SPACE; | 871 | return TEP_EVENT_SPACE; |
| 871 | if (isalnum(ch) || ch == '_') | 872 | if (isalnum(ch) || ch == '_') |
| 872 | return EVENT_ITEM; | 873 | return TEP_EVENT_ITEM; |
| 873 | if (ch == '\'') | 874 | if (ch == '\'') |
| 874 | return EVENT_SQUOTE; | 875 | return TEP_EVENT_SQUOTE; |
| 875 | if (ch == '"') | 876 | if (ch == '"') |
| 876 | return EVENT_DQUOTE; | 877 | return TEP_EVENT_DQUOTE; |
| 877 | if (!isprint(ch)) | 878 | if (!isprint(ch)) |
| 878 | return EVENT_NONE; | 879 | return TEP_EVENT_NONE; |
| 879 | if (ch == '(' || ch == ')' || ch == ',') | 880 | if (ch == '(' || ch == ')' || ch == ',') |
| 880 | return EVENT_DELIM; | 881 | return TEP_EVENT_DELIM; |
| 881 | 882 | ||
| 882 | return EVENT_OP; | 883 | return TEP_EVENT_OP; |
| 883 | } | 884 | } |
| 884 | 885 | ||
| 885 | static int __read_char(void) | 886 | static int __read_char(void) |
| @@ -927,38 +928,38 @@ static int extend_token(char **tok, char *buf, int size) | |||
| 927 | return 0; | 928 | return 0; |
| 928 | } | 929 | } |
| 929 | 930 | ||
| 930 | static enum event_type force_token(const char *str, char **tok); | 931 | static enum tep_event_type force_token(const char *str, char **tok); |
| 931 | 932 | ||
| 932 | static enum event_type __read_token(char **tok) | 933 | static enum tep_event_type __read_token(char **tok) |
| 933 | { | 934 | { |
| 934 | char buf[BUFSIZ]; | 935 | char buf[BUFSIZ]; |
| 935 | int ch, last_ch, quote_ch, next_ch; | 936 | int ch, last_ch, quote_ch, next_ch; |
| 936 | int i = 0; | 937 | int i = 0; |
| 937 | int tok_size = 0; | 938 | int tok_size = 0; |
| 938 | enum event_type type; | 939 | enum tep_event_type type; |
| 939 | 940 | ||
| 940 | *tok = NULL; | 941 | *tok = NULL; |
| 941 | 942 | ||
| 942 | 943 | ||
| 943 | ch = __read_char(); | 944 | ch = __read_char(); |
| 944 | if (ch < 0) | 945 | if (ch < 0) |
| 945 | return EVENT_NONE; | 946 | return TEP_EVENT_NONE; |
| 946 | 947 | ||
| 947 | type = get_type(ch); | 948 | type = get_type(ch); |
| 948 | if (type == EVENT_NONE) | 949 | if (type == TEP_EVENT_NONE) |
| 949 | return type; | 950 | return type; |
| 950 | 951 | ||
| 951 | buf[i++] = ch; | 952 | buf[i++] = ch; |
| 952 | 953 | ||
| 953 | switch (type) { | 954 | switch (type) { |
| 954 | case EVENT_NEWLINE: | 955 | case TEP_EVENT_NEWLINE: |
| 955 | case EVENT_DELIM: | 956 | case TEP_EVENT_DELIM: |
| 956 | if (asprintf(tok, "%c", ch) < 0) | 957 | if (asprintf(tok, "%c", ch) < 0) |
| 957 | return EVENT_ERROR; | 958 | return TEP_EVENT_ERROR; |
| 958 | 959 | ||
| 959 | return type; | 960 | return type; |
| 960 | 961 | ||
| 961 | case EVENT_OP: | 962 | case TEP_EVENT_OP: |
| 962 | switch (ch) { | 963 | switch (ch) { |
| 963 | case '-': | 964 | case '-': |
| 964 | next_ch = __peek_char(); | 965 | next_ch = __peek_char(); |
| @@ -1001,8 +1002,8 @@ static enum event_type __read_token(char **tok) | |||
| 1001 | buf[i++] = __read_char(); | 1002 | buf[i++] = __read_char(); |
| 1002 | goto out; | 1003 | goto out; |
| 1003 | 1004 | ||
| 1004 | case EVENT_DQUOTE: | 1005 | case TEP_EVENT_DQUOTE: |
| 1005 | case EVENT_SQUOTE: | 1006 | case TEP_EVENT_SQUOTE: |
| 1006 | /* don't keep quotes */ | 1007 | /* don't keep quotes */ |
| 1007 | i--; | 1008 | i--; |
| 1008 | quote_ch = ch; | 1009 | quote_ch = ch; |
| @@ -1014,7 +1015,7 @@ static enum event_type __read_token(char **tok) | |||
| 1014 | tok_size += BUFSIZ; | 1015 | tok_size += BUFSIZ; |
| 1015 | 1016 | ||
| 1016 | if (extend_token(tok, buf, tok_size) < 0) | 1017 | if (extend_token(tok, buf, tok_size) < 0) |
| 1017 | return EVENT_NONE; | 1018 | return TEP_EVENT_NONE; |
| 1018 | i = 0; | 1019 | i = 0; |
| 1019 | } | 1020 | } |
| 1020 | last_ch = ch; | 1021 | last_ch = ch; |
| @@ -1031,7 +1032,7 @@ static enum event_type __read_token(char **tok) | |||
| 1031 | * For strings (double quotes) check the next token. | 1032 | * For strings (double quotes) check the next token. |
| 1032 | * If it is another string, concatinate the two. | 1033 | * If it is another string, concatinate the two. |
| 1033 | */ | 1034 | */ |
| 1034 | if (type == EVENT_DQUOTE) { | 1035 | if (type == TEP_EVENT_DQUOTE) { |
| 1035 | unsigned long long save_input_buf_ptr = input_buf_ptr; | 1036 | unsigned long long save_input_buf_ptr = input_buf_ptr; |
| 1036 | 1037 | ||
| 1037 | do { | 1038 | do { |
| @@ -1044,8 +1045,8 @@ static enum event_type __read_token(char **tok) | |||
| 1044 | 1045 | ||
| 1045 | goto out; | 1046 | goto out; |
| 1046 | 1047 | ||
| 1047 | case EVENT_ERROR ... EVENT_SPACE: | 1048 | case TEP_EVENT_ERROR ... TEP_EVENT_SPACE: |
| 1048 | case EVENT_ITEM: | 1049 | case TEP_EVENT_ITEM: |
| 1049 | default: | 1050 | default: |
| 1050 | break; | 1051 | break; |
| 1051 | } | 1052 | } |
| @@ -1056,7 +1057,7 @@ static enum event_type __read_token(char **tok) | |||
| 1056 | tok_size += BUFSIZ; | 1057 | tok_size += BUFSIZ; |
| 1057 | 1058 | ||
| 1058 | if (extend_token(tok, buf, tok_size) < 0) | 1059 | if (extend_token(tok, buf, tok_size) < 0) |
| 1059 | return EVENT_NONE; | 1060 | return TEP_EVENT_NONE; |
| 1060 | i = 0; | 1061 | i = 0; |
| 1061 | } | 1062 | } |
| 1062 | ch = __read_char(); | 1063 | ch = __read_char(); |
| @@ -1066,9 +1067,9 @@ static enum event_type __read_token(char **tok) | |||
| 1066 | out: | 1067 | out: |
| 1067 | buf[i] = 0; | 1068 | buf[i] = 0; |
| 1068 | if (extend_token(tok, buf, tok_size + i + 1) < 0) | 1069 | if (extend_token(tok, buf, tok_size + i + 1) < 0) |
| 1069 | return EVENT_NONE; | 1070 | return TEP_EVENT_NONE; |
| 1070 | 1071 | ||
| 1071 | if (type == EVENT_ITEM) { | 1072 | if (type == TEP_EVENT_ITEM) { |
| 1072 | /* | 1073 | /* |
| 1073 | * Older versions of the kernel has a bug that | 1074 | * Older versions of the kernel has a bug that |
| 1074 | * creates invalid symbols and will break the mac80211 | 1075 | * creates invalid symbols and will break the mac80211 |
| @@ -1095,12 +1096,12 @@ static enum event_type __read_token(char **tok) | |||
| 1095 | return type; | 1096 | return type; |
| 1096 | } | 1097 | } |
| 1097 | 1098 | ||
| 1098 | static enum event_type force_token(const char *str, char **tok) | 1099 | static enum tep_event_type force_token(const char *str, char **tok) |
| 1099 | { | 1100 | { |
| 1100 | const char *save_input_buf; | 1101 | const char *save_input_buf; |
| 1101 | unsigned long long save_input_buf_ptr; | 1102 | unsigned long long save_input_buf_ptr; |
| 1102 | unsigned long long save_input_buf_siz; | 1103 | unsigned long long save_input_buf_siz; |
| 1103 | enum event_type type; | 1104 | enum tep_event_type type; |
| 1104 | 1105 | ||
| 1105 | /* save off the current input pointers */ | 1106 | /* save off the current input pointers */ |
| 1106 | save_input_buf = input_buf; | 1107 | save_input_buf = input_buf; |
| @@ -1125,13 +1126,13 @@ static void free_token(char *tok) | |||
| 1125 | free(tok); | 1126 | free(tok); |
| 1126 | } | 1127 | } |
| 1127 | 1128 | ||
| 1128 | static enum event_type read_token(char **tok) | 1129 | static enum tep_event_type read_token(char **tok) |
| 1129 | { | 1130 | { |
| 1130 | enum event_type type; | 1131 | enum tep_event_type type; |
| 1131 | 1132 | ||
| 1132 | for (;;) { | 1133 | for (;;) { |
| 1133 | type = __read_token(tok); | 1134 | type = __read_token(tok); |
| 1134 | if (type != EVENT_SPACE) | 1135 | if (type != TEP_EVENT_SPACE) |
| 1135 | return type; | 1136 | return type; |
| 1136 | 1137 | ||
| 1137 | free_token(*tok); | 1138 | free_token(*tok); |
| @@ -1139,7 +1140,7 @@ static enum event_type read_token(char **tok) | |||
| 1139 | 1140 | ||
| 1140 | /* not reached */ | 1141 | /* not reached */ |
| 1141 | *tok = NULL; | 1142 | *tok = NULL; |
| 1142 | return EVENT_NONE; | 1143 | return TEP_EVENT_NONE; |
| 1143 | } | 1144 | } |
| 1144 | 1145 | ||
| 1145 | /** | 1146 | /** |
| @@ -1151,7 +1152,7 @@ static enum event_type read_token(char **tok) | |||
| 1151 | * | 1152 | * |
| 1152 | * Returns the token type. | 1153 | * Returns the token type. |
| 1153 | */ | 1154 | */ |
| 1154 | enum event_type tep_read_token(char **tok) | 1155 | enum tep_event_type tep_read_token(char **tok) |
| 1155 | { | 1156 | { |
| 1156 | return read_token(tok); | 1157 | return read_token(tok); |
| 1157 | } | 1158 | } |
| @@ -1166,13 +1167,13 @@ void tep_free_token(char *token) | |||
| 1166 | } | 1167 | } |
| 1167 | 1168 | ||
| 1168 | /* no newline */ | 1169 | /* no newline */ |
| 1169 | static enum event_type read_token_item(char **tok) | 1170 | static enum tep_event_type read_token_item(char **tok) |
| 1170 | { | 1171 | { |
| 1171 | enum event_type type; | 1172 | enum tep_event_type type; |
| 1172 | 1173 | ||
| 1173 | for (;;) { | 1174 | for (;;) { |
| 1174 | type = __read_token(tok); | 1175 | type = __read_token(tok); |
| 1175 | if (type != EVENT_SPACE && type != EVENT_NEWLINE) | 1176 | if (type != TEP_EVENT_SPACE && type != TEP_EVENT_NEWLINE) |
| 1176 | return type; | 1177 | return type; |
| 1177 | free_token(*tok); | 1178 | free_token(*tok); |
| 1178 | *tok = NULL; | 1179 | *tok = NULL; |
| @@ -1180,10 +1181,10 @@ static enum event_type read_token_item(char **tok) | |||
| 1180 | 1181 | ||
| 1181 | /* not reached */ | 1182 | /* not reached */ |
| 1182 | *tok = NULL; | 1183 | *tok = NULL; |
| 1183 | return EVENT_NONE; | 1184 | return TEP_EVENT_NONE; |
| 1184 | } | 1185 | } |
| 1185 | 1186 | ||
| 1186 | static int test_type(enum event_type type, enum event_type expect) | 1187 | static int test_type(enum tep_event_type type, enum tep_event_type expect) |
| 1187 | { | 1188 | { |
| 1188 | if (type != expect) { | 1189 | if (type != expect) { |
| 1189 | do_warning("Error: expected type %d but read %d", | 1190 | do_warning("Error: expected type %d but read %d", |
| @@ -1193,8 +1194,8 @@ static int test_type(enum event_type type, enum event_type expect) | |||
| 1193 | return 0; | 1194 | return 0; |
| 1194 | } | 1195 | } |
| 1195 | 1196 | ||
| 1196 | static int test_type_token(enum event_type type, const char *token, | 1197 | static int test_type_token(enum tep_event_type type, const char *token, |
| 1197 | enum event_type expect, const char *expect_tok) | 1198 | enum tep_event_type expect, const char *expect_tok) |
| 1198 | { | 1199 | { |
| 1199 | if (type != expect) { | 1200 | if (type != expect) { |
| 1200 | do_warning("Error: expected type %d but read %d", | 1201 | do_warning("Error: expected type %d but read %d", |
| @@ -1210,9 +1211,9 @@ static int test_type_token(enum event_type type, const char *token, | |||
| 1210 | return 0; | 1211 | return 0; |
| 1211 | } | 1212 | } |
| 1212 | 1213 | ||
| 1213 | static int __read_expect_type(enum event_type expect, char **tok, int newline_ok) | 1214 | static int __read_expect_type(enum tep_event_type expect, char **tok, int newline_ok) |
| 1214 | { | 1215 | { |
| 1215 | enum event_type type; | 1216 | enum tep_event_type type; |
| 1216 | 1217 | ||
| 1217 | if (newline_ok) | 1218 | if (newline_ok) |
| 1218 | type = read_token(tok); | 1219 | type = read_token(tok); |
| @@ -1221,15 +1222,15 @@ static int __read_expect_type(enum event_type expect, char **tok, int newline_ok | |||
| 1221 | return test_type(type, expect); | 1222 | return test_type(type, expect); |
| 1222 | } | 1223 | } |
| 1223 | 1224 | ||
| 1224 | static int read_expect_type(enum event_type expect, char **tok) | 1225 | static int read_expect_type(enum tep_event_type expect, char **tok) |
| 1225 | { | 1226 | { |
| 1226 | return __read_expect_type(expect, tok, 1); | 1227 | return __read_expect_type(expect, tok, 1); |
| 1227 | } | 1228 | } |
| 1228 | 1229 | ||
| 1229 | static int __read_expected(enum event_type expect, const char *str, | 1230 | static int __read_expected(enum tep_event_type expect, const char *str, |
| 1230 | int newline_ok) | 1231 | int newline_ok) |
| 1231 | { | 1232 | { |
| 1232 | enum event_type type; | 1233 | enum tep_event_type type; |
| 1233 | char *token; | 1234 | char *token; |
| 1234 | int ret; | 1235 | int ret; |
| 1235 | 1236 | ||
| @@ -1245,12 +1246,12 @@ static int __read_expected(enum event_type expect, const char *str, | |||
| 1245 | return ret; | 1246 | return ret; |
| 1246 | } | 1247 | } |
| 1247 | 1248 | ||
| 1248 | static int read_expected(enum event_type expect, const char *str) | 1249 | static int read_expected(enum tep_event_type expect, const char *str) |
| 1249 | { | 1250 | { |
| 1250 | return __read_expected(expect, str, 1); | 1251 | return __read_expected(expect, str, 1); |
| 1251 | } | 1252 | } |
| 1252 | 1253 | ||
| 1253 | static int read_expected_item(enum event_type expect, const char *str) | 1254 | static int read_expected_item(enum tep_event_type expect, const char *str) |
| 1254 | { | 1255 | { |
| 1255 | return __read_expected(expect, str, 0); | 1256 | return __read_expected(expect, str, 0); |
| 1256 | } | 1257 | } |
| @@ -1259,13 +1260,13 @@ static char *event_read_name(void) | |||
| 1259 | { | 1260 | { |
| 1260 | char *token; | 1261 | char *token; |
| 1261 | 1262 | ||
| 1262 | if (read_expected(EVENT_ITEM, "name") < 0) | 1263 | if (read_expected(TEP_EVENT_ITEM, "name") < 0) |
| 1263 | return NULL; | 1264 | return NULL; |
| 1264 | 1265 | ||
| 1265 | if (read_expected(EVENT_OP, ":") < 0) | 1266 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 1266 | return NULL; | 1267 | return NULL; |
| 1267 | 1268 | ||
| 1268 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 1269 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 1269 | goto fail; | 1270 | goto fail; |
| 1270 | 1271 | ||
| 1271 | return token; | 1272 | return token; |
| @@ -1280,13 +1281,13 @@ static int event_read_id(void) | |||
| 1280 | char *token; | 1281 | char *token; |
| 1281 | int id; | 1282 | int id; |
| 1282 | 1283 | ||
| 1283 | if (read_expected_item(EVENT_ITEM, "ID") < 0) | 1284 | if (read_expected_item(TEP_EVENT_ITEM, "ID") < 0) |
| 1284 | return -1; | 1285 | return -1; |
| 1285 | 1286 | ||
| 1286 | if (read_expected(EVENT_OP, ":") < 0) | 1287 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 1287 | return -1; | 1288 | return -1; |
| 1288 | 1289 | ||
| 1289 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 1290 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 1290 | goto fail; | 1291 | goto fail; |
| 1291 | 1292 | ||
| 1292 | id = strtoul(token, NULL, 0); | 1293 | id = strtoul(token, NULL, 0); |
| @@ -1298,9 +1299,9 @@ static int event_read_id(void) | |||
| 1298 | return -1; | 1299 | return -1; |
| 1299 | } | 1300 | } |
| 1300 | 1301 | ||
| 1301 | static int field_is_string(struct format_field *field) | 1302 | static int field_is_string(struct tep_format_field *field) |
| 1302 | { | 1303 | { |
| 1303 | if ((field->flags & FIELD_IS_ARRAY) && | 1304 | if ((field->flags & TEP_FIELD_IS_ARRAY) && |
| 1304 | (strstr(field->type, "char") || strstr(field->type, "u8") || | 1305 | (strstr(field->type, "char") || strstr(field->type, "u8") || |
| 1305 | strstr(field->type, "s8"))) | 1306 | strstr(field->type, "s8"))) |
| 1306 | return 1; | 1307 | return 1; |
| @@ -1308,7 +1309,7 @@ static int field_is_string(struct format_field *field) | |||
| 1308 | return 0; | 1309 | return 0; |
| 1309 | } | 1310 | } |
| 1310 | 1311 | ||
| 1311 | static int field_is_dynamic(struct format_field *field) | 1312 | static int field_is_dynamic(struct tep_format_field *field) |
| 1312 | { | 1313 | { |
| 1313 | if (strncmp(field->type, "__data_loc", 10) == 0) | 1314 | if (strncmp(field->type, "__data_loc", 10) == 0) |
| 1314 | return 1; | 1315 | return 1; |
| @@ -1316,7 +1317,7 @@ static int field_is_dynamic(struct format_field *field) | |||
| 1316 | return 0; | 1317 | return 0; |
| 1317 | } | 1318 | } |
| 1318 | 1319 | ||
| 1319 | static int field_is_long(struct format_field *field) | 1320 | static int field_is_long(struct tep_format_field *field) |
| 1320 | { | 1321 | { |
| 1321 | /* includes long long */ | 1322 | /* includes long long */ |
| 1322 | if (strstr(field->type, "long")) | 1323 | if (strstr(field->type, "long")) |
| @@ -1327,7 +1328,7 @@ static int field_is_long(struct format_field *field) | |||
| 1327 | 1328 | ||
| 1328 | static unsigned int type_size(const char *name) | 1329 | static unsigned int type_size(const char *name) |
| 1329 | { | 1330 | { |
| 1330 | /* This covers all FIELD_IS_STRING types. */ | 1331 | /* This covers all TEP_FIELD_IS_STRING types. */ |
| 1331 | static struct { | 1332 | static struct { |
| 1332 | const char *type; | 1333 | const char *type; |
| 1333 | unsigned int size; | 1334 | unsigned int size; |
| @@ -1353,10 +1354,10 @@ static unsigned int type_size(const char *name) | |||
| 1353 | return 0; | 1354 | return 0; |
| 1354 | } | 1355 | } |
| 1355 | 1356 | ||
| 1356 | static int event_read_fields(struct event_format *event, struct format_field **fields) | 1357 | static int event_read_fields(struct tep_event_format *event, struct tep_format_field **fields) |
| 1357 | { | 1358 | { |
| 1358 | struct format_field *field = NULL; | 1359 | struct tep_format_field *field = NULL; |
| 1359 | enum event_type type; | 1360 | enum tep_event_type type; |
| 1360 | char *token; | 1361 | char *token; |
| 1361 | char *last_token; | 1362 | char *last_token; |
| 1362 | int count = 0; | 1363 | int count = 0; |
| @@ -1365,14 +1366,14 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1365 | unsigned int size_dynamic = 0; | 1366 | unsigned int size_dynamic = 0; |
| 1366 | 1367 | ||
| 1367 | type = read_token(&token); | 1368 | type = read_token(&token); |
| 1368 | if (type == EVENT_NEWLINE) { | 1369 | if (type == TEP_EVENT_NEWLINE) { |
| 1369 | free_token(token); | 1370 | free_token(token); |
| 1370 | return count; | 1371 | return count; |
| 1371 | } | 1372 | } |
| 1372 | 1373 | ||
| 1373 | count++; | 1374 | count++; |
| 1374 | 1375 | ||
| 1375 | if (test_type_token(type, token, EVENT_ITEM, "field")) | 1376 | if (test_type_token(type, token, TEP_EVENT_ITEM, "field")) |
| 1376 | goto fail; | 1377 | goto fail; |
| 1377 | free_token(token); | 1378 | free_token(token); |
| 1378 | 1379 | ||
| @@ -1381,17 +1382,17 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1381 | * The ftrace fields may still use the "special" name. | 1382 | * The ftrace fields may still use the "special" name. |
| 1382 | * Just ignore it. | 1383 | * Just ignore it. |
| 1383 | */ | 1384 | */ |
| 1384 | if (event->flags & EVENT_FL_ISFTRACE && | 1385 | if (event->flags & TEP_EVENT_FL_ISFTRACE && |
| 1385 | type == EVENT_ITEM && strcmp(token, "special") == 0) { | 1386 | type == TEP_EVENT_ITEM && strcmp(token, "special") == 0) { |
| 1386 | free_token(token); | 1387 | free_token(token); |
| 1387 | type = read_token(&token); | 1388 | type = read_token(&token); |
| 1388 | } | 1389 | } |
| 1389 | 1390 | ||
| 1390 | if (test_type_token(type, token, EVENT_OP, ":") < 0) | 1391 | if (test_type_token(type, token, TEP_EVENT_OP, ":") < 0) |
| 1391 | goto fail; | 1392 | goto fail; |
| 1392 | 1393 | ||
| 1393 | free_token(token); | 1394 | free_token(token); |
| 1394 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 1395 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 1395 | goto fail; | 1396 | goto fail; |
| 1396 | 1397 | ||
| 1397 | last_token = token; | 1398 | last_token = token; |
| @@ -1405,17 +1406,17 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1405 | /* read the rest of the type */ | 1406 | /* read the rest of the type */ |
| 1406 | for (;;) { | 1407 | for (;;) { |
| 1407 | type = read_token(&token); | 1408 | type = read_token(&token); |
| 1408 | if (type == EVENT_ITEM || | 1409 | if (type == TEP_EVENT_ITEM || |
| 1409 | (type == EVENT_OP && strcmp(token, "*") == 0) || | 1410 | (type == TEP_EVENT_OP && strcmp(token, "*") == 0) || |
| 1410 | /* | 1411 | /* |
| 1411 | * Some of the ftrace fields are broken and have | 1412 | * Some of the ftrace fields are broken and have |
| 1412 | * an illegal "." in them. | 1413 | * an illegal "." in them. |
| 1413 | */ | 1414 | */ |
| 1414 | (event->flags & EVENT_FL_ISFTRACE && | 1415 | (event->flags & TEP_EVENT_FL_ISFTRACE && |
| 1415 | type == EVENT_OP && strcmp(token, ".") == 0)) { | 1416 | type == TEP_EVENT_OP && strcmp(token, ".") == 0)) { |
| 1416 | 1417 | ||
| 1417 | if (strcmp(token, "*") == 0) | 1418 | if (strcmp(token, "*") == 0) |
| 1418 | field->flags |= FIELD_IS_POINTER; | 1419 | field->flags |= TEP_FIELD_IS_POINTER; |
| 1419 | 1420 | ||
| 1420 | if (field->type) { | 1421 | if (field->type) { |
| 1421 | char *new_type; | 1422 | char *new_type; |
| @@ -1445,27 +1446,27 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1445 | } | 1446 | } |
| 1446 | field->name = field->alias = last_token; | 1447 | field->name = field->alias = last_token; |
| 1447 | 1448 | ||
| 1448 | if (test_type(type, EVENT_OP)) | 1449 | if (test_type(type, TEP_EVENT_OP)) |
| 1449 | goto fail; | 1450 | goto fail; |
| 1450 | 1451 | ||
| 1451 | if (strcmp(token, "[") == 0) { | 1452 | if (strcmp(token, "[") == 0) { |
| 1452 | enum event_type last_type = type; | 1453 | enum tep_event_type last_type = type; |
| 1453 | char *brackets = token; | 1454 | char *brackets = token; |
| 1454 | char *new_brackets; | 1455 | char *new_brackets; |
| 1455 | int len; | 1456 | int len; |
| 1456 | 1457 | ||
| 1457 | field->flags |= FIELD_IS_ARRAY; | 1458 | field->flags |= TEP_FIELD_IS_ARRAY; |
| 1458 | 1459 | ||
| 1459 | type = read_token(&token); | 1460 | type = read_token(&token); |
| 1460 | 1461 | ||
| 1461 | if (type == EVENT_ITEM) | 1462 | if (type == TEP_EVENT_ITEM) |
| 1462 | field->arraylen = strtoul(token, NULL, 0); | 1463 | field->arraylen = strtoul(token, NULL, 0); |
| 1463 | else | 1464 | else |
| 1464 | field->arraylen = 0; | 1465 | field->arraylen = 0; |
| 1465 | 1466 | ||
| 1466 | while (strcmp(token, "]") != 0) { | 1467 | while (strcmp(token, "]") != 0) { |
| 1467 | if (last_type == EVENT_ITEM && | 1468 | if (last_type == TEP_EVENT_ITEM && |
| 1468 | type == EVENT_ITEM) | 1469 | type == TEP_EVENT_ITEM) |
| 1469 | len = 2; | 1470 | len = 2; |
| 1470 | else | 1471 | else |
| 1471 | len = 1; | 1472 | len = 1; |
| @@ -1486,7 +1487,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1486 | field->arraylen = strtoul(token, NULL, 0); | 1487 | field->arraylen = strtoul(token, NULL, 0); |
| 1487 | free_token(token); | 1488 | free_token(token); |
| 1488 | type = read_token(&token); | 1489 | type = read_token(&token); |
| 1489 | if (type == EVENT_NONE) { | 1490 | if (type == TEP_EVENT_NONE) { |
| 1490 | do_warning_event(event, "failed to find token"); | 1491 | do_warning_event(event, "failed to find token"); |
| 1491 | goto fail; | 1492 | goto fail; |
| 1492 | } | 1493 | } |
| @@ -1509,7 +1510,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1509 | * If the next token is not an OP, then it is of | 1510 | * If the next token is not an OP, then it is of |
| 1510 | * the format: type [] item; | 1511 | * the format: type [] item; |
| 1511 | */ | 1512 | */ |
| 1512 | if (type == EVENT_ITEM) { | 1513 | if (type == TEP_EVENT_ITEM) { |
| 1513 | char *new_type; | 1514 | char *new_type; |
| 1514 | new_type = realloc(field->type, | 1515 | new_type = realloc(field->type, |
| 1515 | strlen(field->type) + | 1516 | strlen(field->type) + |
| @@ -1543,79 +1544,79 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
| 1543 | } | 1544 | } |
| 1544 | 1545 | ||
| 1545 | if (field_is_string(field)) | 1546 | if (field_is_string(field)) |
| 1546 | field->flags |= FIELD_IS_STRING; | 1547 | field->flags |= TEP_FIELD_IS_STRING; |
| 1547 | if (field_is_dynamic(field)) | 1548 | if (field_is_dynamic(field)) |
| 1548 | field->flags |= FIELD_IS_DYNAMIC; | 1549 | field->flags |= TEP_FIELD_IS_DYNAMIC; |
| 1549 | if (field_is_long(field)) | 1550 | if (field_is_long(field)) |
| 1550 | field->flags |= FIELD_IS_LONG; | 1551 | field->flags |= TEP_FIELD_IS_LONG; |
| 1551 | 1552 | ||
| 1552 | if (test_type_token(type, token, EVENT_OP, ";")) | 1553 | if (test_type_token(type, token, TEP_EVENT_OP, ";")) |
| 1553 | goto fail; | 1554 | goto fail; |
| 1554 | free_token(token); | 1555 | free_token(token); |
| 1555 | 1556 | ||
| 1556 | if (read_expected(EVENT_ITEM, "offset") < 0) | 1557 | if (read_expected(TEP_EVENT_ITEM, "offset") < 0) |
| 1557 | goto fail_expect; | 1558 | goto fail_expect; |
| 1558 | 1559 | ||
| 1559 | if (read_expected(EVENT_OP, ":") < 0) | 1560 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 1560 | goto fail_expect; | 1561 | goto fail_expect; |
| 1561 | 1562 | ||
| 1562 | if (read_expect_type(EVENT_ITEM, &token)) | 1563 | if (read_expect_type(TEP_EVENT_ITEM, &token)) |
| 1563 | goto fail; | 1564 | goto fail; |
| 1564 | field->offset = strtoul(token, NULL, 0); | 1565 | field->offset = strtoul(token, NULL, 0); |
| 1565 | free_token(token); | 1566 | free_token(token); |
| 1566 | 1567 | ||
| 1567 | if (read_expected(EVENT_OP, ";") < 0) | 1568 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 1568 | goto fail_expect; | 1569 | goto fail_expect; |
| 1569 | 1570 | ||
| 1570 | if (read_expected(EVENT_ITEM, "size") < 0) | 1571 | if (read_expected(TEP_EVENT_ITEM, "size") < 0) |
| 1571 | goto fail_expect; | 1572 | goto fail_expect; |
| 1572 | 1573 | ||
| 1573 | if (read_expected(EVENT_OP, ":") < 0) | 1574 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 1574 | goto fail_expect; | 1575 | goto fail_expect; |
| 1575 | 1576 | ||
| 1576 | if (read_expect_type(EVENT_ITEM, &token)) | 1577 | if (read_expect_type(TEP_EVENT_ITEM, &token)) |
| 1577 | goto fail; | 1578 | goto fail; |
| 1578 | field->size = strtoul(token, NULL, 0); | 1579 | field->size = strtoul(token, NULL, 0); |
| 1579 | free_token(token); | 1580 | free_token(token); |
| 1580 | 1581 | ||
| 1581 | if (read_expected(EVENT_OP, ";") < 0) | 1582 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 1582 | goto fail_expect; | 1583 | goto fail_expect; |
| 1583 | 1584 | ||
| 1584 | type = read_token(&token); | 1585 | type = read_token(&token); |
| 1585 | if (type != EVENT_NEWLINE) { | 1586 | if (type != TEP_EVENT_NEWLINE) { |
| 1586 | /* newer versions of the kernel have a "signed" type */ | 1587 | /* newer versions of the kernel have a "signed" type */ |
| 1587 | if (test_type_token(type, token, EVENT_ITEM, "signed")) | 1588 | if (test_type_token(type, token, TEP_EVENT_ITEM, "signed")) |
| 1588 | goto fail; | 1589 | goto fail; |
| 1589 | 1590 | ||
| 1590 | free_token(token); | 1591 | free_token(token); |
| 1591 | 1592 | ||
| 1592 | if (read_expected(EVENT_OP, ":") < 0) | 1593 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 1593 | goto fail_expect; | 1594 | goto fail_expect; |
| 1594 | 1595 | ||
| 1595 | if (read_expect_type(EVENT_ITEM, &token)) | 1596 | if (read_expect_type(TEP_EVENT_ITEM, &token)) |
| 1596 | goto fail; | 1597 | goto fail; |
| 1597 | 1598 | ||
| 1598 | if (strtoul(token, NULL, 0)) | 1599 | if (strtoul(token, NULL, 0)) |
| 1599 | field->flags |= FIELD_IS_SIGNED; | 1600 | field->flags |= TEP_FIELD_IS_SIGNED; |
| 1600 | 1601 | ||
| 1601 | free_token(token); | 1602 | free_token(token); |
| 1602 | if (read_expected(EVENT_OP, ";") < 0) | 1603 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 1603 | goto fail_expect; | 1604 | goto fail_expect; |
| 1604 | 1605 | ||
| 1605 | if (read_expect_type(EVENT_NEWLINE, &token)) | 1606 | if (read_expect_type(TEP_EVENT_NEWLINE, &token)) |
| 1606 | goto fail; | 1607 | goto fail; |
| 1607 | } | 1608 | } |
| 1608 | 1609 | ||
| 1609 | free_token(token); | 1610 | free_token(token); |
| 1610 | 1611 | ||
| 1611 | if (field->flags & FIELD_IS_ARRAY) { | 1612 | if (field->flags & TEP_FIELD_IS_ARRAY) { |
| 1612 | if (field->arraylen) | 1613 | if (field->arraylen) |
| 1613 | field->elementsize = field->size / field->arraylen; | 1614 | field->elementsize = field->size / field->arraylen; |
| 1614 | else if (field->flags & FIELD_IS_DYNAMIC) | 1615 | else if (field->flags & TEP_FIELD_IS_DYNAMIC) |
| 1615 | field->elementsize = size_dynamic; | 1616 | field->elementsize = size_dynamic; |
| 1616 | else if (field->flags & FIELD_IS_STRING) | 1617 | else if (field->flags & TEP_FIELD_IS_STRING) |
| 1617 | field->elementsize = 1; | 1618 | field->elementsize = 1; |
| 1618 | else if (field->flags & FIELD_IS_LONG) | 1619 | else if (field->flags & TEP_FIELD_IS_LONG) |
| 1619 | field->elementsize = event->pevent ? | 1620 | field->elementsize = event->pevent ? |
| 1620 | event->pevent->long_size : | 1621 | event->pevent->long_size : |
| 1621 | sizeof(long); | 1622 | sizeof(long); |
| @@ -1640,18 +1641,18 @@ fail_expect: | |||
| 1640 | return -1; | 1641 | return -1; |
| 1641 | } | 1642 | } |
| 1642 | 1643 | ||
| 1643 | static int event_read_format(struct event_format *event) | 1644 | static int event_read_format(struct tep_event_format *event) |
| 1644 | { | 1645 | { |
| 1645 | char *token; | 1646 | char *token; |
| 1646 | int ret; | 1647 | int ret; |
| 1647 | 1648 | ||
| 1648 | if (read_expected_item(EVENT_ITEM, "format") < 0) | 1649 | if (read_expected_item(TEP_EVENT_ITEM, "format") < 0) |
| 1649 | return -1; | 1650 | return -1; |
| 1650 | 1651 | ||
| 1651 | if (read_expected(EVENT_OP, ":") < 0) | 1652 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 1652 | return -1; | 1653 | return -1; |
| 1653 | 1654 | ||
| 1654 | if (read_expect_type(EVENT_NEWLINE, &token)) | 1655 | if (read_expect_type(TEP_EVENT_NEWLINE, &token)) |
| 1655 | goto fail; | 1656 | goto fail; |
| 1656 | free_token(token); | 1657 | free_token(token); |
| 1657 | 1658 | ||
| @@ -1672,14 +1673,14 @@ static int event_read_format(struct event_format *event) | |||
| 1672 | return -1; | 1673 | return -1; |
| 1673 | } | 1674 | } |
| 1674 | 1675 | ||
| 1675 | static enum event_type | 1676 | static enum tep_event_type |
| 1676 | process_arg_token(struct event_format *event, struct print_arg *arg, | 1677 | process_arg_token(struct tep_event_format *event, struct tep_print_arg *arg, |
| 1677 | char **tok, enum event_type type); | 1678 | char **tok, enum tep_event_type type); |
| 1678 | 1679 | ||
| 1679 | static enum event_type | 1680 | static enum tep_event_type |
| 1680 | process_arg(struct event_format *event, struct print_arg *arg, char **tok) | 1681 | process_arg(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 1681 | { | 1682 | { |
| 1682 | enum event_type type; | 1683 | enum tep_event_type type; |
| 1683 | char *token; | 1684 | char *token; |
| 1684 | 1685 | ||
| 1685 | type = read_token(&token); | 1686 | type = read_token(&token); |
| @@ -1688,32 +1689,32 @@ process_arg(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 1688 | return process_arg_token(event, arg, tok, type); | 1689 | return process_arg_token(event, arg, tok, type); |
| 1689 | } | 1690 | } |
| 1690 | 1691 | ||
| 1691 | static enum event_type | 1692 | static enum tep_event_type |
| 1692 | process_op(struct event_format *event, struct print_arg *arg, char **tok); | 1693 | process_op(struct tep_event_format *event, struct tep_print_arg *arg, char **tok); |
| 1693 | 1694 | ||
| 1694 | /* | 1695 | /* |
| 1695 | * For __print_symbolic() and __print_flags, we need to completely | 1696 | * For __print_symbolic() and __print_flags, we need to completely |
| 1696 | * evaluate the first argument, which defines what to print next. | 1697 | * evaluate the first argument, which defines what to print next. |
| 1697 | */ | 1698 | */ |
| 1698 | static enum event_type | 1699 | static enum tep_event_type |
| 1699 | process_field_arg(struct event_format *event, struct print_arg *arg, char **tok) | 1700 | process_field_arg(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 1700 | { | 1701 | { |
| 1701 | enum event_type type; | 1702 | enum tep_event_type type; |
| 1702 | 1703 | ||
| 1703 | type = process_arg(event, arg, tok); | 1704 | type = process_arg(event, arg, tok); |
| 1704 | 1705 | ||
| 1705 | while (type == EVENT_OP) { | 1706 | while (type == TEP_EVENT_OP) { |
| 1706 | type = process_op(event, arg, tok); | 1707 | type = process_op(event, arg, tok); |
| 1707 | } | 1708 | } |
| 1708 | 1709 | ||
| 1709 | return type; | 1710 | return type; |
| 1710 | } | 1711 | } |
| 1711 | 1712 | ||
| 1712 | static enum event_type | 1713 | static enum tep_event_type |
| 1713 | process_cond(struct event_format *event, struct print_arg *top, char **tok) | 1714 | process_cond(struct tep_event_format *event, struct tep_print_arg *top, char **tok) |
| 1714 | { | 1715 | { |
| 1715 | struct print_arg *arg, *left, *right; | 1716 | struct tep_print_arg *arg, *left, *right; |
| 1716 | enum event_type type; | 1717 | enum tep_event_type type; |
| 1717 | char *token = NULL; | 1718 | char *token = NULL; |
| 1718 | 1719 | ||
| 1719 | arg = alloc_arg(); | 1720 | arg = alloc_arg(); |
| @@ -1728,7 +1729,7 @@ process_cond(struct event_format *event, struct print_arg *top, char **tok) | |||
| 1728 | goto out_free; | 1729 | goto out_free; |
| 1729 | } | 1730 | } |
| 1730 | 1731 | ||
| 1731 | arg->type = PRINT_OP; | 1732 | arg->type = TEP_PRINT_OP; |
| 1732 | arg->op.left = left; | 1733 | arg->op.left = left; |
| 1733 | arg->op.right = right; | 1734 | arg->op.right = right; |
| 1734 | 1735 | ||
| @@ -1736,16 +1737,16 @@ process_cond(struct event_format *event, struct print_arg *top, char **tok) | |||
| 1736 | type = process_arg(event, left, &token); | 1737 | type = process_arg(event, left, &token); |
| 1737 | 1738 | ||
| 1738 | again: | 1739 | again: |
| 1739 | if (type == EVENT_ERROR) | 1740 | if (type == TEP_EVENT_ERROR) |
| 1740 | goto out_free; | 1741 | goto out_free; |
| 1741 | 1742 | ||
| 1742 | /* Handle other operations in the arguments */ | 1743 | /* Handle other operations in the arguments */ |
| 1743 | if (type == EVENT_OP && strcmp(token, ":") != 0) { | 1744 | if (type == TEP_EVENT_OP && strcmp(token, ":") != 0) { |
| 1744 | type = process_op(event, left, &token); | 1745 | type = process_op(event, left, &token); |
| 1745 | goto again; | 1746 | goto again; |
| 1746 | } | 1747 | } |
| 1747 | 1748 | ||
| 1748 | if (test_type_token(type, token, EVENT_OP, ":")) | 1749 | if (test_type_token(type, token, TEP_EVENT_OP, ":")) |
| 1749 | goto out_free; | 1750 | goto out_free; |
| 1750 | 1751 | ||
| 1751 | arg->op.op = token; | 1752 | arg->op.op = token; |
| @@ -1762,14 +1763,14 @@ out_free: | |||
| 1762 | top->op.right = NULL; | 1763 | top->op.right = NULL; |
| 1763 | free_token(token); | 1764 | free_token(token); |
| 1764 | free_arg(arg); | 1765 | free_arg(arg); |
| 1765 | return EVENT_ERROR; | 1766 | return TEP_EVENT_ERROR; |
| 1766 | } | 1767 | } |
| 1767 | 1768 | ||
| 1768 | static enum event_type | 1769 | static enum tep_event_type |
| 1769 | process_array(struct event_format *event, struct print_arg *top, char **tok) | 1770 | process_array(struct tep_event_format *event, struct tep_print_arg *top, char **tok) |
| 1770 | { | 1771 | { |
| 1771 | struct print_arg *arg; | 1772 | struct tep_print_arg *arg; |
| 1772 | enum event_type type; | 1773 | enum tep_event_type type; |
| 1773 | char *token = NULL; | 1774 | char *token = NULL; |
| 1774 | 1775 | ||
| 1775 | arg = alloc_arg(); | 1776 | arg = alloc_arg(); |
| @@ -1777,12 +1778,12 @@ process_array(struct event_format *event, struct print_arg *top, char **tok) | |||
| 1777 | do_warning_event(event, "%s: not enough memory!", __func__); | 1778 | do_warning_event(event, "%s: not enough memory!", __func__); |
| 1778 | /* '*tok' is set to top->op.op. No need to free. */ | 1779 | /* '*tok' is set to top->op.op. No need to free. */ |
| 1779 | *tok = NULL; | 1780 | *tok = NULL; |
| 1780 | return EVENT_ERROR; | 1781 | return TEP_EVENT_ERROR; |
| 1781 | } | 1782 | } |
| 1782 | 1783 | ||
| 1783 | *tok = NULL; | 1784 | *tok = NULL; |
| 1784 | type = process_arg(event, arg, &token); | 1785 | type = process_arg(event, arg, &token); |
| 1785 | if (test_type_token(type, token, EVENT_OP, "]")) | 1786 | if (test_type_token(type, token, TEP_EVENT_OP, "]")) |
| 1786 | goto out_free; | 1787 | goto out_free; |
| 1787 | 1788 | ||
| 1788 | top->op.right = arg; | 1789 | top->op.right = arg; |
| @@ -1796,7 +1797,7 @@ process_array(struct event_format *event, struct print_arg *top, char **tok) | |||
| 1796 | out_free: | 1797 | out_free: |
| 1797 | free_token(token); | 1798 | free_token(token); |
| 1798 | free_arg(arg); | 1799 | free_arg(arg); |
| 1799 | return EVENT_ERROR; | 1800 | return TEP_EVENT_ERROR; |
| 1800 | } | 1801 | } |
| 1801 | 1802 | ||
| 1802 | static int get_op_prio(char *op) | 1803 | static int get_op_prio(char *op) |
| @@ -1854,11 +1855,11 @@ static int get_op_prio(char *op) | |||
| 1854 | } | 1855 | } |
| 1855 | } | 1856 | } |
| 1856 | 1857 | ||
| 1857 | static int set_op_prio(struct print_arg *arg) | 1858 | static int set_op_prio(struct tep_print_arg *arg) |
| 1858 | { | 1859 | { |
| 1859 | 1860 | ||
| 1860 | /* single ops are the greatest */ | 1861 | /* single ops are the greatest */ |
| 1861 | if (!arg->op.left || arg->op.left->type == PRINT_NULL) | 1862 | if (!arg->op.left || arg->op.left->type == TEP_PRINT_NULL) |
| 1862 | arg->op.prio = 0; | 1863 | arg->op.prio = 0; |
| 1863 | else | 1864 | else |
| 1864 | arg->op.prio = get_op_prio(arg->op.op); | 1865 | arg->op.prio = get_op_prio(arg->op.op); |
| @@ -1867,17 +1868,17 @@ static int set_op_prio(struct print_arg *arg) | |||
| 1867 | } | 1868 | } |
| 1868 | 1869 | ||
| 1869 | /* Note, *tok does not get freed, but will most likely be saved */ | 1870 | /* Note, *tok does not get freed, but will most likely be saved */ |
| 1870 | static enum event_type | 1871 | static enum tep_event_type |
| 1871 | process_op(struct event_format *event, struct print_arg *arg, char **tok) | 1872 | process_op(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 1872 | { | 1873 | { |
| 1873 | struct print_arg *left, *right = NULL; | 1874 | struct tep_print_arg *left, *right = NULL; |
| 1874 | enum event_type type; | 1875 | enum tep_event_type type; |
| 1875 | char *token; | 1876 | char *token; |
| 1876 | 1877 | ||
| 1877 | /* the op is passed in via tok */ | 1878 | /* the op is passed in via tok */ |
| 1878 | token = *tok; | 1879 | token = *tok; |
| 1879 | 1880 | ||
| 1880 | if (arg->type == PRINT_OP && !arg->op.left) { | 1881 | if (arg->type == TEP_PRINT_OP && !arg->op.left) { |
| 1881 | /* handle single op */ | 1882 | /* handle single op */ |
| 1882 | if (token[1]) { | 1883 | if (token[1]) { |
| 1883 | do_warning_event(event, "bad op token %s", token); | 1884 | do_warning_event(event, "bad op token %s", token); |
| @@ -1900,7 +1901,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 1900 | if (!left) | 1901 | if (!left) |
| 1901 | goto out_warn_free; | 1902 | goto out_warn_free; |
| 1902 | 1903 | ||
| 1903 | left->type = PRINT_NULL; | 1904 | left->type = TEP_PRINT_NULL; |
| 1904 | arg->op.left = left; | 1905 | arg->op.left = left; |
| 1905 | 1906 | ||
| 1906 | right = alloc_arg(); | 1907 | right = alloc_arg(); |
| @@ -1922,7 +1923,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 1922 | /* copy the top arg to the left */ | 1923 | /* copy the top arg to the left */ |
| 1923 | *left = *arg; | 1924 | *left = *arg; |
| 1924 | 1925 | ||
| 1925 | arg->type = PRINT_OP; | 1926 | arg->type = TEP_PRINT_OP; |
| 1926 | arg->op.op = token; | 1927 | arg->op.op = token; |
| 1927 | arg->op.left = left; | 1928 | arg->op.left = left; |
| 1928 | arg->op.prio = 0; | 1929 | arg->op.prio = 0; |
| @@ -1956,13 +1957,13 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 1956 | /* copy the top arg to the left */ | 1957 | /* copy the top arg to the left */ |
| 1957 | *left = *arg; | 1958 | *left = *arg; |
| 1958 | 1959 | ||
| 1959 | arg->type = PRINT_OP; | 1960 | arg->type = TEP_PRINT_OP; |
| 1960 | arg->op.op = token; | 1961 | arg->op.op = token; |
| 1961 | arg->op.left = left; | 1962 | arg->op.left = left; |
| 1962 | arg->op.right = NULL; | 1963 | arg->op.right = NULL; |
| 1963 | 1964 | ||
| 1964 | if (set_op_prio(arg) == -1) { | 1965 | if (set_op_prio(arg) == -1) { |
| 1965 | event->flags |= EVENT_FL_FAILED; | 1966 | event->flags |= TEP_EVENT_FL_FAILED; |
| 1966 | /* arg->op.op (= token) will be freed at out_free */ | 1967 | /* arg->op.op (= token) will be freed at out_free */ |
| 1967 | arg->op.op = NULL; | 1968 | arg->op.op = NULL; |
| 1968 | goto out_free; | 1969 | goto out_free; |
| @@ -1973,10 +1974,10 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 1973 | 1974 | ||
| 1974 | /* could just be a type pointer */ | 1975 | /* could just be a type pointer */ |
| 1975 | if ((strcmp(arg->op.op, "*") == 0) && | 1976 | if ((strcmp(arg->op.op, "*") == 0) && |
| 1976 | type == EVENT_DELIM && (strcmp(token, ")") == 0)) { | 1977 | type == TEP_EVENT_DELIM && (strcmp(token, ")") == 0)) { |
| 1977 | char *new_atom; | 1978 | char *new_atom; |
| 1978 | 1979 | ||
| 1979 | if (left->type != PRINT_ATOM) { | 1980 | if (left->type != TEP_PRINT_ATOM) { |
| 1980 | do_warning_event(event, "bad pointer type"); | 1981 | do_warning_event(event, "bad pointer type"); |
| 1981 | goto out_free; | 1982 | goto out_free; |
| 1982 | } | 1983 | } |
| @@ -1999,16 +2000,16 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 1999 | goto out_warn_free; | 2000 | goto out_warn_free; |
| 2000 | 2001 | ||
| 2001 | type = process_arg_token(event, right, tok, type); | 2002 | type = process_arg_token(event, right, tok, type); |
| 2002 | if (type == EVENT_ERROR) { | 2003 | if (type == TEP_EVENT_ERROR) { |
| 2003 | free_arg(right); | 2004 | free_arg(right); |
| 2004 | /* token was freed in process_arg_token() via *tok */ | 2005 | /* token was freed in process_arg_token() via *tok */ |
| 2005 | token = NULL; | 2006 | token = NULL; |
| 2006 | goto out_free; | 2007 | goto out_free; |
| 2007 | } | 2008 | } |
| 2008 | 2009 | ||
| 2009 | if (right->type == PRINT_OP && | 2010 | if (right->type == TEP_PRINT_OP && |
| 2010 | get_op_prio(arg->op.op) < get_op_prio(right->op.op)) { | 2011 | get_op_prio(arg->op.op) < get_op_prio(right->op.op)) { |
| 2011 | struct print_arg tmp; | 2012 | struct tep_print_arg tmp; |
| 2012 | 2013 | ||
| 2013 | /* rotate ops according to the priority */ | 2014 | /* rotate ops according to the priority */ |
| 2014 | arg->op.right = right->op.left; | 2015 | arg->op.right = right->op.left; |
| @@ -2030,7 +2031,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2030 | 2031 | ||
| 2031 | *left = *arg; | 2032 | *left = *arg; |
| 2032 | 2033 | ||
| 2033 | arg->type = PRINT_OP; | 2034 | arg->type = TEP_PRINT_OP; |
| 2034 | arg->op.op = token; | 2035 | arg->op.op = token; |
| 2035 | arg->op.left = left; | 2036 | arg->op.left = left; |
| 2036 | 2037 | ||
| @@ -2041,12 +2042,12 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2041 | 2042 | ||
| 2042 | } else { | 2043 | } else { |
| 2043 | do_warning_event(event, "unknown op '%s'", token); | 2044 | do_warning_event(event, "unknown op '%s'", token); |
| 2044 | event->flags |= EVENT_FL_FAILED; | 2045 | event->flags |= TEP_EVENT_FL_FAILED; |
| 2045 | /* the arg is now the left side */ | 2046 | /* the arg is now the left side */ |
| 2046 | goto out_free; | 2047 | goto out_free; |
| 2047 | } | 2048 | } |
| 2048 | 2049 | ||
| 2049 | if (type == EVENT_OP && strcmp(*tok, ":") != 0) { | 2050 | if (type == TEP_EVENT_OP && strcmp(*tok, ":") != 0) { |
| 2050 | int prio; | 2051 | int prio; |
| 2051 | 2052 | ||
| 2052 | /* higher prios need to be closer to the root */ | 2053 | /* higher prios need to be closer to the root */ |
| @@ -2065,34 +2066,34 @@ out_warn_free: | |||
| 2065 | out_free: | 2066 | out_free: |
| 2066 | free_token(token); | 2067 | free_token(token); |
| 2067 | *tok = NULL; | 2068 | *tok = NULL; |
| 2068 | return EVENT_ERROR; | 2069 | return TEP_EVENT_ERROR; |
| 2069 | } | 2070 | } |
| 2070 | 2071 | ||
| 2071 | static enum event_type | 2072 | static enum tep_event_type |
| 2072 | process_entry(struct event_format *event __maybe_unused, struct print_arg *arg, | 2073 | process_entry(struct tep_event_format *event __maybe_unused, struct tep_print_arg *arg, |
| 2073 | char **tok) | 2074 | char **tok) |
| 2074 | { | 2075 | { |
| 2075 | enum event_type type; | 2076 | enum tep_event_type type; |
| 2076 | char *field; | 2077 | char *field; |
| 2077 | char *token; | 2078 | char *token; |
| 2078 | 2079 | ||
| 2079 | if (read_expected(EVENT_OP, "->") < 0) | 2080 | if (read_expected(TEP_EVENT_OP, "->") < 0) |
| 2080 | goto out_err; | 2081 | goto out_err; |
| 2081 | 2082 | ||
| 2082 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 2083 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 2083 | goto out_free; | 2084 | goto out_free; |
| 2084 | field = token; | 2085 | field = token; |
| 2085 | 2086 | ||
| 2086 | arg->type = PRINT_FIELD; | 2087 | arg->type = TEP_PRINT_FIELD; |
| 2087 | arg->field.name = field; | 2088 | arg->field.name = field; |
| 2088 | 2089 | ||
| 2089 | if (is_flag_field) { | 2090 | if (is_flag_field) { |
| 2090 | arg->field.field = tep_find_any_field(event, arg->field.name); | 2091 | arg->field.field = tep_find_any_field(event, arg->field.name); |
| 2091 | arg->field.field->flags |= FIELD_IS_FLAG; | 2092 | arg->field.field->flags |= TEP_FIELD_IS_FLAG; |
| 2092 | is_flag_field = 0; | 2093 | is_flag_field = 0; |
| 2093 | } else if (is_symbolic_field) { | 2094 | } else if (is_symbolic_field) { |
| 2094 | arg->field.field = tep_find_any_field(event, arg->field.name); | 2095 | arg->field.field = tep_find_any_field(event, arg->field.name); |
| 2095 | arg->field.field->flags |= FIELD_IS_SYMBOLIC; | 2096 | arg->field.field->flags |= TEP_FIELD_IS_SYMBOLIC; |
| 2096 | is_symbolic_field = 0; | 2097 | is_symbolic_field = 0; |
| 2097 | } | 2098 | } |
| 2098 | 2099 | ||
| @@ -2105,14 +2106,14 @@ process_entry(struct event_format *event __maybe_unused, struct print_arg *arg, | |||
| 2105 | free_token(token); | 2106 | free_token(token); |
| 2106 | out_err: | 2107 | out_err: |
| 2107 | *tok = NULL; | 2108 | *tok = NULL; |
| 2108 | return EVENT_ERROR; | 2109 | return TEP_EVENT_ERROR; |
| 2109 | } | 2110 | } |
| 2110 | 2111 | ||
| 2111 | static int alloc_and_process_delim(struct event_format *event, char *next_token, | 2112 | static int alloc_and_process_delim(struct tep_event_format *event, char *next_token, |
| 2112 | struct print_arg **print_arg) | 2113 | struct tep_print_arg **print_arg) |
| 2113 | { | 2114 | { |
| 2114 | struct print_arg *field; | 2115 | struct tep_print_arg *field; |
| 2115 | enum event_type type; | 2116 | enum tep_event_type type; |
| 2116 | char *token; | 2117 | char *token; |
| 2117 | int ret = 0; | 2118 | int ret = 0; |
| 2118 | 2119 | ||
| @@ -2125,7 +2126,7 @@ static int alloc_and_process_delim(struct event_format *event, char *next_token, | |||
| 2125 | 2126 | ||
| 2126 | type = process_arg(event, field, &token); | 2127 | type = process_arg(event, field, &token); |
| 2127 | 2128 | ||
| 2128 | if (test_type_token(type, token, EVENT_DELIM, next_token)) { | 2129 | if (test_type_token(type, token, TEP_EVENT_DELIM, next_token)) { |
| 2129 | errno = EINVAL; | 2130 | errno = EINVAL; |
| 2130 | ret = -1; | 2131 | ret = -1; |
| 2131 | free_arg(field); | 2132 | free_arg(field); |
| @@ -2140,7 +2141,7 @@ out_free_token: | |||
| 2140 | return ret; | 2141 | return ret; |
| 2141 | } | 2142 | } |
| 2142 | 2143 | ||
| 2143 | static char *arg_eval (struct print_arg *arg); | 2144 | static char *arg_eval (struct tep_print_arg *arg); |
| 2144 | 2145 | ||
| 2145 | static unsigned long long | 2146 | static unsigned long long |
| 2146 | eval_type_str(unsigned long long val, const char *type, int pointer) | 2147 | eval_type_str(unsigned long long val, const char *type, int pointer) |
| @@ -2237,9 +2238,9 @@ eval_type_str(unsigned long long val, const char *type, int pointer) | |||
| 2237 | * Try to figure out the type. | 2238 | * Try to figure out the type. |
| 2238 | */ | 2239 | */ |
| 2239 | static unsigned long long | 2240 | static unsigned long long |
| 2240 | eval_type(unsigned long long val, struct print_arg *arg, int pointer) | 2241 | eval_type(unsigned long long val, struct tep_print_arg *arg, int pointer) |
| 2241 | { | 2242 | { |
| 2242 | if (arg->type != PRINT_TYPE) { | 2243 | if (arg->type != TEP_PRINT_TYPE) { |
| 2243 | do_warning("expected type argument"); | 2244 | do_warning("expected type argument"); |
| 2244 | return 0; | 2245 | return 0; |
| 2245 | } | 2246 | } |
| @@ -2247,22 +2248,22 @@ eval_type(unsigned long long val, struct print_arg *arg, int pointer) | |||
| 2247 | return eval_type_str(val, arg->typecast.type, pointer); | 2248 | return eval_type_str(val, arg->typecast.type, pointer); |
| 2248 | } | 2249 | } |
| 2249 | 2250 | ||
| 2250 | static int arg_num_eval(struct print_arg *arg, long long *val) | 2251 | static int arg_num_eval(struct tep_print_arg *arg, long long *val) |
| 2251 | { | 2252 | { |
| 2252 | long long left, right; | 2253 | long long left, right; |
| 2253 | int ret = 1; | 2254 | int ret = 1; |
| 2254 | 2255 | ||
| 2255 | switch (arg->type) { | 2256 | switch (arg->type) { |
| 2256 | case PRINT_ATOM: | 2257 | case TEP_PRINT_ATOM: |
| 2257 | *val = strtoll(arg->atom.atom, NULL, 0); | 2258 | *val = strtoll(arg->atom.atom, NULL, 0); |
| 2258 | break; | 2259 | break; |
| 2259 | case PRINT_TYPE: | 2260 | case TEP_PRINT_TYPE: |
| 2260 | ret = arg_num_eval(arg->typecast.item, val); | 2261 | ret = arg_num_eval(arg->typecast.item, val); |
| 2261 | if (!ret) | 2262 | if (!ret) |
| 2262 | break; | 2263 | break; |
| 2263 | *val = eval_type(*val, arg, 0); | 2264 | *val = eval_type(*val, arg, 0); |
| 2264 | break; | 2265 | break; |
| 2265 | case PRINT_OP: | 2266 | case TEP_PRINT_OP: |
| 2266 | switch (arg->op.op[0]) { | 2267 | switch (arg->op.op[0]) { |
| 2267 | case '|': | 2268 | case '|': |
| 2268 | ret = arg_num_eval(arg->op.left, &left); | 2269 | ret = arg_num_eval(arg->op.left, &left); |
| @@ -2365,7 +2366,7 @@ static int arg_num_eval(struct print_arg *arg, long long *val) | |||
| 2365 | break; | 2366 | break; |
| 2366 | case '-': | 2367 | case '-': |
| 2367 | /* check for negative */ | 2368 | /* check for negative */ |
| 2368 | if (arg->op.left->type == PRINT_NULL) | 2369 | if (arg->op.left->type == TEP_PRINT_NULL) |
| 2369 | left = 0; | 2370 | left = 0; |
| 2370 | else | 2371 | else |
| 2371 | ret = arg_num_eval(arg->op.left, &left); | 2372 | ret = arg_num_eval(arg->op.left, &left); |
| @@ -2377,7 +2378,7 @@ static int arg_num_eval(struct print_arg *arg, long long *val) | |||
| 2377 | *val = left - right; | 2378 | *val = left - right; |
| 2378 | break; | 2379 | break; |
| 2379 | case '+': | 2380 | case '+': |
| 2380 | if (arg->op.left->type == PRINT_NULL) | 2381 | if (arg->op.left->type == TEP_PRINT_NULL) |
| 2381 | left = 0; | 2382 | left = 0; |
| 2382 | else | 2383 | else |
| 2383 | ret = arg_num_eval(arg->op.left, &left); | 2384 | ret = arg_num_eval(arg->op.left, &left); |
| @@ -2400,11 +2401,11 @@ static int arg_num_eval(struct print_arg *arg, long long *val) | |||
| 2400 | } | 2401 | } |
| 2401 | break; | 2402 | break; |
| 2402 | 2403 | ||
| 2403 | case PRINT_NULL: | 2404 | case TEP_PRINT_NULL: |
| 2404 | case PRINT_FIELD ... PRINT_SYMBOL: | 2405 | case TEP_PRINT_FIELD ... TEP_PRINT_SYMBOL: |
| 2405 | case PRINT_STRING: | 2406 | case TEP_PRINT_STRING: |
| 2406 | case PRINT_BSTRING: | 2407 | case TEP_PRINT_BSTRING: |
| 2407 | case PRINT_BITMASK: | 2408 | case TEP_PRINT_BITMASK: |
| 2408 | default: | 2409 | default: |
| 2409 | do_warning("invalid eval type %d", arg->type); | 2410 | do_warning("invalid eval type %d", arg->type); |
| 2410 | ret = 0; | 2411 | ret = 0; |
| @@ -2413,27 +2414,27 @@ static int arg_num_eval(struct print_arg *arg, long long *val) | |||
| 2413 | return ret; | 2414 | return ret; |
| 2414 | } | 2415 | } |
| 2415 | 2416 | ||
| 2416 | static char *arg_eval (struct print_arg *arg) | 2417 | static char *arg_eval (struct tep_print_arg *arg) |
| 2417 | { | 2418 | { |
| 2418 | long long val; | 2419 | long long val; |
| 2419 | static char buf[20]; | 2420 | static char buf[20]; |
| 2420 | 2421 | ||
| 2421 | switch (arg->type) { | 2422 | switch (arg->type) { |
| 2422 | case PRINT_ATOM: | 2423 | case TEP_PRINT_ATOM: |
| 2423 | return arg->atom.atom; | 2424 | return arg->atom.atom; |
| 2424 | case PRINT_TYPE: | 2425 | case TEP_PRINT_TYPE: |
| 2425 | return arg_eval(arg->typecast.item); | 2426 | return arg_eval(arg->typecast.item); |
| 2426 | case PRINT_OP: | 2427 | case TEP_PRINT_OP: |
| 2427 | if (!arg_num_eval(arg, &val)) | 2428 | if (!arg_num_eval(arg, &val)) |
| 2428 | break; | 2429 | break; |
| 2429 | sprintf(buf, "%lld", val); | 2430 | sprintf(buf, "%lld", val); |
| 2430 | return buf; | 2431 | return buf; |
| 2431 | 2432 | ||
| 2432 | case PRINT_NULL: | 2433 | case TEP_PRINT_NULL: |
| 2433 | case PRINT_FIELD ... PRINT_SYMBOL: | 2434 | case TEP_PRINT_FIELD ... TEP_PRINT_SYMBOL: |
| 2434 | case PRINT_STRING: | 2435 | case TEP_PRINT_STRING: |
| 2435 | case PRINT_BSTRING: | 2436 | case TEP_PRINT_BSTRING: |
| 2436 | case PRINT_BITMASK: | 2437 | case TEP_PRINT_BITMASK: |
| 2437 | default: | 2438 | default: |
| 2438 | do_warning("invalid eval type %d", arg->type); | 2439 | do_warning("invalid eval type %d", arg->type); |
| 2439 | break; | 2440 | break; |
| @@ -2442,19 +2443,19 @@ static char *arg_eval (struct print_arg *arg) | |||
| 2442 | return NULL; | 2443 | return NULL; |
| 2443 | } | 2444 | } |
| 2444 | 2445 | ||
| 2445 | static enum event_type | 2446 | static enum tep_event_type |
| 2446 | process_fields(struct event_format *event, struct print_flag_sym **list, char **tok) | 2447 | process_fields(struct tep_event_format *event, struct tep_print_flag_sym **list, char **tok) |
| 2447 | { | 2448 | { |
| 2448 | enum event_type type; | 2449 | enum tep_event_type type; |
| 2449 | struct print_arg *arg = NULL; | 2450 | struct tep_print_arg *arg = NULL; |
| 2450 | struct print_flag_sym *field; | 2451 | struct tep_print_flag_sym *field; |
| 2451 | char *token = *tok; | 2452 | char *token = *tok; |
| 2452 | char *value; | 2453 | char *value; |
| 2453 | 2454 | ||
| 2454 | do { | 2455 | do { |
| 2455 | free_token(token); | 2456 | free_token(token); |
| 2456 | type = read_token_item(&token); | 2457 | type = read_token_item(&token); |
| 2457 | if (test_type_token(type, token, EVENT_OP, "{")) | 2458 | if (test_type_token(type, token, TEP_EVENT_OP, "{")) |
| 2458 | break; | 2459 | break; |
| 2459 | 2460 | ||
| 2460 | arg = alloc_arg(); | 2461 | arg = alloc_arg(); |
| @@ -2464,13 +2465,13 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
| 2464 | free_token(token); | 2465 | free_token(token); |
| 2465 | type = process_arg(event, arg, &token); | 2466 | type = process_arg(event, arg, &token); |
| 2466 | 2467 | ||
| 2467 | if (type == EVENT_OP) | 2468 | if (type == TEP_EVENT_OP) |
| 2468 | type = process_op(event, arg, &token); | 2469 | type = process_op(event, arg, &token); |
| 2469 | 2470 | ||
| 2470 | if (type == EVENT_ERROR) | 2471 | if (type == TEP_EVENT_ERROR) |
| 2471 | goto out_free; | 2472 | goto out_free; |
| 2472 | 2473 | ||
| 2473 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 2474 | if (test_type_token(type, token, TEP_EVENT_DELIM, ",")) |
| 2474 | goto out_free; | 2475 | goto out_free; |
| 2475 | 2476 | ||
| 2476 | field = calloc(1, sizeof(*field)); | 2477 | field = calloc(1, sizeof(*field)); |
| @@ -2491,7 +2492,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
| 2491 | 2492 | ||
| 2492 | free_token(token); | 2493 | free_token(token); |
| 2493 | type = process_arg(event, arg, &token); | 2494 | type = process_arg(event, arg, &token); |
| 2494 | if (test_type_token(type, token, EVENT_OP, "}")) | 2495 | if (test_type_token(type, token, TEP_EVENT_OP, "}")) |
| 2495 | goto out_free_field; | 2496 | goto out_free_field; |
| 2496 | 2497 | ||
| 2497 | value = arg_eval(arg); | 2498 | value = arg_eval(arg); |
| @@ -2508,7 +2509,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
| 2508 | 2509 | ||
| 2509 | free_token(token); | 2510 | free_token(token); |
| 2510 | type = read_token_item(&token); | 2511 | type = read_token_item(&token); |
| 2511 | } while (type == EVENT_DELIM && strcmp(token, ",") == 0); | 2512 | } while (type == TEP_EVENT_DELIM && strcmp(token, ",") == 0); |
| 2512 | 2513 | ||
| 2513 | *tok = token; | 2514 | *tok = token; |
| 2514 | return type; | 2515 | return type; |
| @@ -2520,18 +2521,18 @@ out_free: | |||
| 2520 | free_token(token); | 2521 | free_token(token); |
| 2521 | *tok = NULL; | 2522 | *tok = NULL; |
| 2522 | 2523 | ||
| 2523 | return EVENT_ERROR; | 2524 | return TEP_EVENT_ERROR; |
| 2524 | } | 2525 | } |
| 2525 | 2526 | ||
| 2526 | static enum event_type | 2527 | static enum tep_event_type |
| 2527 | process_flags(struct event_format *event, struct print_arg *arg, char **tok) | 2528 | process_flags(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 2528 | { | 2529 | { |
| 2529 | struct print_arg *field; | 2530 | struct tep_print_arg *field; |
| 2530 | enum event_type type; | 2531 | enum tep_event_type type; |
| 2531 | char *token = NULL; | 2532 | char *token = NULL; |
| 2532 | 2533 | ||
| 2533 | memset(arg, 0, sizeof(*arg)); | 2534 | memset(arg, 0, sizeof(*arg)); |
| 2534 | arg->type = PRINT_FLAGS; | 2535 | arg->type = TEP_PRINT_FLAGS; |
| 2535 | 2536 | ||
| 2536 | field = alloc_arg(); | 2537 | field = alloc_arg(); |
| 2537 | if (!field) { | 2538 | if (!field) { |
| @@ -2542,10 +2543,10 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2542 | type = process_field_arg(event, field, &token); | 2543 | type = process_field_arg(event, field, &token); |
| 2543 | 2544 | ||
| 2544 | /* Handle operations in the first argument */ | 2545 | /* Handle operations in the first argument */ |
| 2545 | while (type == EVENT_OP) | 2546 | while (type == TEP_EVENT_OP) |
| 2546 | type = process_op(event, field, &token); | 2547 | type = process_op(event, field, &token); |
| 2547 | 2548 | ||
| 2548 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 2549 | if (test_type_token(type, token, TEP_EVENT_DELIM, ",")) |
| 2549 | goto out_free_field; | 2550 | goto out_free_field; |
| 2550 | free_token(token); | 2551 | free_token(token); |
| 2551 | 2552 | ||
| @@ -2557,11 +2558,11 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2557 | type = read_token_item(&token); | 2558 | type = read_token_item(&token); |
| 2558 | } | 2559 | } |
| 2559 | 2560 | ||
| 2560 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 2561 | if (test_type_token(type, token, TEP_EVENT_DELIM, ",")) |
| 2561 | goto out_free; | 2562 | goto out_free; |
| 2562 | 2563 | ||
| 2563 | type = process_fields(event, &arg->flags.flags, &token); | 2564 | type = process_fields(event, &arg->flags.flags, &token); |
| 2564 | if (test_type_token(type, token, EVENT_DELIM, ")")) | 2565 | if (test_type_token(type, token, TEP_EVENT_DELIM, ")")) |
| 2565 | goto out_free; | 2566 | goto out_free; |
| 2566 | 2567 | ||
| 2567 | free_token(token); | 2568 | free_token(token); |
| @@ -2573,18 +2574,18 @@ out_free_field: | |||
| 2573 | out_free: | 2574 | out_free: |
| 2574 | free_token(token); | 2575 | free_token(token); |
| 2575 | *tok = NULL; | 2576 | *tok = NULL; |
| 2576 | return EVENT_ERROR; | 2577 | return TEP_EVENT_ERROR; |
| 2577 | } | 2578 | } |
| 2578 | 2579 | ||
| 2579 | static enum event_type | 2580 | static enum tep_event_type |
| 2580 | process_symbols(struct event_format *event, struct print_arg *arg, char **tok) | 2581 | process_symbols(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 2581 | { | 2582 | { |
| 2582 | struct print_arg *field; | 2583 | struct tep_print_arg *field; |
| 2583 | enum event_type type; | 2584 | enum tep_event_type type; |
| 2584 | char *token = NULL; | 2585 | char *token = NULL; |
| 2585 | 2586 | ||
| 2586 | memset(arg, 0, sizeof(*arg)); | 2587 | memset(arg, 0, sizeof(*arg)); |
| 2587 | arg->type = PRINT_SYMBOL; | 2588 | arg->type = TEP_PRINT_SYMBOL; |
| 2588 | 2589 | ||
| 2589 | field = alloc_arg(); | 2590 | field = alloc_arg(); |
| 2590 | if (!field) { | 2591 | if (!field) { |
| @@ -2594,13 +2595,13 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2594 | 2595 | ||
| 2595 | type = process_field_arg(event, field, &token); | 2596 | type = process_field_arg(event, field, &token); |
| 2596 | 2597 | ||
| 2597 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 2598 | if (test_type_token(type, token, TEP_EVENT_DELIM, ",")) |
| 2598 | goto out_free_field; | 2599 | goto out_free_field; |
| 2599 | 2600 | ||
| 2600 | arg->symbol.field = field; | 2601 | arg->symbol.field = field; |
| 2601 | 2602 | ||
| 2602 | type = process_fields(event, &arg->symbol.symbols, &token); | 2603 | type = process_fields(event, &arg->symbol.symbols, &token); |
| 2603 | if (test_type_token(type, token, EVENT_DELIM, ")")) | 2604 | if (test_type_token(type, token, TEP_EVENT_DELIM, ")")) |
| 2604 | goto out_free; | 2605 | goto out_free; |
| 2605 | 2606 | ||
| 2606 | free_token(token); | 2607 | free_token(token); |
| @@ -2612,12 +2613,12 @@ out_free_field: | |||
| 2612 | out_free: | 2613 | out_free: |
| 2613 | free_token(token); | 2614 | free_token(token); |
| 2614 | *tok = NULL; | 2615 | *tok = NULL; |
| 2615 | return EVENT_ERROR; | 2616 | return TEP_EVENT_ERROR; |
| 2616 | } | 2617 | } |
| 2617 | 2618 | ||
| 2618 | static enum event_type | 2619 | static enum tep_event_type |
| 2619 | process_hex_common(struct event_format *event, struct print_arg *arg, | 2620 | process_hex_common(struct tep_event_format *event, struct tep_print_arg *arg, |
| 2620 | char **tok, enum print_arg_type type) | 2621 | char **tok, enum tep_print_arg_type type) |
| 2621 | { | 2622 | { |
| 2622 | memset(arg, 0, sizeof(*arg)); | 2623 | memset(arg, 0, sizeof(*arg)); |
| 2623 | arg->type = type; | 2624 | arg->type = type; |
| @@ -2635,27 +2636,27 @@ free_field: | |||
| 2635 | arg->hex.field = NULL; | 2636 | arg->hex.field = NULL; |
| 2636 | out: | 2637 | out: |
| 2637 | *tok = NULL; | 2638 | *tok = NULL; |
| 2638 | return EVENT_ERROR; | 2639 | return TEP_EVENT_ERROR; |
| 2639 | } | 2640 | } |
| 2640 | 2641 | ||
| 2641 | static enum event_type | 2642 | static enum tep_event_type |
| 2642 | process_hex(struct event_format *event, struct print_arg *arg, char **tok) | 2643 | process_hex(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 2643 | { | 2644 | { |
| 2644 | return process_hex_common(event, arg, tok, PRINT_HEX); | 2645 | return process_hex_common(event, arg, tok, TEP_PRINT_HEX); |
| 2645 | } | 2646 | } |
| 2646 | 2647 | ||
| 2647 | static enum event_type | 2648 | static enum tep_event_type |
| 2648 | process_hex_str(struct event_format *event, struct print_arg *arg, | 2649 | process_hex_str(struct tep_event_format *event, struct tep_print_arg *arg, |
| 2649 | char **tok) | 2650 | char **tok) |
| 2650 | { | 2651 | { |
| 2651 | return process_hex_common(event, arg, tok, PRINT_HEX_STR); | 2652 | return process_hex_common(event, arg, tok, TEP_PRINT_HEX_STR); |
| 2652 | } | 2653 | } |
| 2653 | 2654 | ||
| 2654 | static enum event_type | 2655 | static enum tep_event_type |
| 2655 | process_int_array(struct event_format *event, struct print_arg *arg, char **tok) | 2656 | process_int_array(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 2656 | { | 2657 | { |
| 2657 | memset(arg, 0, sizeof(*arg)); | 2658 | memset(arg, 0, sizeof(*arg)); |
| 2658 | arg->type = PRINT_INT_ARRAY; | 2659 | arg->type = TEP_PRINT_INT_ARRAY; |
| 2659 | 2660 | ||
| 2660 | if (alloc_and_process_delim(event, ",", &arg->int_array.field)) | 2661 | if (alloc_and_process_delim(event, ",", &arg->int_array.field)) |
| 2661 | goto out; | 2662 | goto out; |
| @@ -2676,18 +2677,18 @@ free_field: | |||
| 2676 | arg->int_array.field = NULL; | 2677 | arg->int_array.field = NULL; |
| 2677 | out: | 2678 | out: |
| 2678 | *tok = NULL; | 2679 | *tok = NULL; |
| 2679 | return EVENT_ERROR; | 2680 | return TEP_EVENT_ERROR; |
| 2680 | } | 2681 | } |
| 2681 | 2682 | ||
| 2682 | static enum event_type | 2683 | static enum tep_event_type |
| 2683 | process_dynamic_array(struct event_format *event, struct print_arg *arg, char **tok) | 2684 | process_dynamic_array(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 2684 | { | 2685 | { |
| 2685 | struct format_field *field; | 2686 | struct tep_format_field *field; |
| 2686 | enum event_type type; | 2687 | enum tep_event_type type; |
| 2687 | char *token; | 2688 | char *token; |
| 2688 | 2689 | ||
| 2689 | memset(arg, 0, sizeof(*arg)); | 2690 | memset(arg, 0, sizeof(*arg)); |
| 2690 | arg->type = PRINT_DYNAMIC_ARRAY; | 2691 | arg->type = TEP_PRINT_DYNAMIC_ARRAY; |
| 2691 | 2692 | ||
| 2692 | /* | 2693 | /* |
| 2693 | * The item within the parenthesis is another field that holds | 2694 | * The item within the parenthesis is another field that holds |
| @@ -2695,7 +2696,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
| 2695 | */ | 2696 | */ |
| 2696 | type = read_token(&token); | 2697 | type = read_token(&token); |
| 2697 | *tok = token; | 2698 | *tok = token; |
| 2698 | if (type != EVENT_ITEM) | 2699 | if (type != TEP_EVENT_ITEM) |
| 2699 | goto out_free; | 2700 | goto out_free; |
| 2700 | 2701 | ||
| 2701 | /* Find the field */ | 2702 | /* Find the field */ |
| @@ -2707,13 +2708,13 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
| 2707 | arg->dynarray.field = field; | 2708 | arg->dynarray.field = field; |
| 2708 | arg->dynarray.index = 0; | 2709 | arg->dynarray.index = 0; |
| 2709 | 2710 | ||
| 2710 | if (read_expected(EVENT_DELIM, ")") < 0) | 2711 | if (read_expected(TEP_EVENT_DELIM, ")") < 0) |
| 2711 | goto out_free; | 2712 | goto out_free; |
| 2712 | 2713 | ||
| 2713 | free_token(token); | 2714 | free_token(token); |
| 2714 | type = read_token_item(&token); | 2715 | type = read_token_item(&token); |
| 2715 | *tok = token; | 2716 | *tok = token; |
| 2716 | if (type != EVENT_OP || strcmp(token, "[") != 0) | 2717 | if (type != TEP_EVENT_OP || strcmp(token, "[") != 0) |
| 2717 | return type; | 2718 | return type; |
| 2718 | 2719 | ||
| 2719 | free_token(token); | 2720 | free_token(token); |
| @@ -2721,14 +2722,14 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
| 2721 | if (!arg) { | 2722 | if (!arg) { |
| 2722 | do_warning_event(event, "%s: not enough memory!", __func__); | 2723 | do_warning_event(event, "%s: not enough memory!", __func__); |
| 2723 | *tok = NULL; | 2724 | *tok = NULL; |
| 2724 | return EVENT_ERROR; | 2725 | return TEP_EVENT_ERROR; |
| 2725 | } | 2726 | } |
| 2726 | 2727 | ||
| 2727 | type = process_arg(event, arg, &token); | 2728 | type = process_arg(event, arg, &token); |
| 2728 | if (type == EVENT_ERROR) | 2729 | if (type == TEP_EVENT_ERROR) |
| 2729 | goto out_free_arg; | 2730 | goto out_free_arg; |
| 2730 | 2731 | ||
| 2731 | if (!test_type_token(type, token, EVENT_OP, "]")) | 2732 | if (!test_type_token(type, token, TEP_EVENT_OP, "]")) |
| 2732 | goto out_free_arg; | 2733 | goto out_free_arg; |
| 2733 | 2734 | ||
| 2734 | free_token(token); | 2735 | free_token(token); |
| @@ -2740,21 +2741,21 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
| 2740 | out_free: | 2741 | out_free: |
| 2741 | free_token(token); | 2742 | free_token(token); |
| 2742 | *tok = NULL; | 2743 | *tok = NULL; |
| 2743 | return EVENT_ERROR; | 2744 | return TEP_EVENT_ERROR; |
| 2744 | } | 2745 | } |
| 2745 | 2746 | ||
| 2746 | static enum event_type | 2747 | static enum tep_event_type |
| 2747 | process_dynamic_array_len(struct event_format *event, struct print_arg *arg, | 2748 | process_dynamic_array_len(struct tep_event_format *event, struct tep_print_arg *arg, |
| 2748 | char **tok) | 2749 | char **tok) |
| 2749 | { | 2750 | { |
| 2750 | struct format_field *field; | 2751 | struct tep_format_field *field; |
| 2751 | enum event_type type; | 2752 | enum tep_event_type type; |
| 2752 | char *token; | 2753 | char *token; |
| 2753 | 2754 | ||
| 2754 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 2755 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 2755 | goto out_free; | 2756 | goto out_free; |
| 2756 | 2757 | ||
| 2757 | arg->type = PRINT_DYNAMIC_ARRAY_LEN; | 2758 | arg->type = TEP_PRINT_DYNAMIC_ARRAY_LEN; |
| 2758 | 2759 | ||
| 2759 | /* Find the field */ | 2760 | /* Find the field */ |
| 2760 | field = tep_find_field(event, token); | 2761 | field = tep_find_field(event, token); |
| @@ -2764,7 +2765,7 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg, | |||
| 2764 | arg->dynarray.field = field; | 2765 | arg->dynarray.field = field; |
| 2765 | arg->dynarray.index = 0; | 2766 | arg->dynarray.index = 0; |
| 2766 | 2767 | ||
| 2767 | if (read_expected(EVENT_DELIM, ")") < 0) | 2768 | if (read_expected(TEP_EVENT_DELIM, ")") < 0) |
| 2768 | goto out_err; | 2769 | goto out_err; |
| 2769 | 2770 | ||
| 2770 | type = read_token(&token); | 2771 | type = read_token(&token); |
| @@ -2776,28 +2777,28 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg, | |||
| 2776 | free_token(token); | 2777 | free_token(token); |
| 2777 | out_err: | 2778 | out_err: |
| 2778 | *tok = NULL; | 2779 | *tok = NULL; |
| 2779 | return EVENT_ERROR; | 2780 | return TEP_EVENT_ERROR; |
| 2780 | } | 2781 | } |
| 2781 | 2782 | ||
| 2782 | static enum event_type | 2783 | static enum tep_event_type |
| 2783 | process_paren(struct event_format *event, struct print_arg *arg, char **tok) | 2784 | process_paren(struct tep_event_format *event, struct tep_print_arg *arg, char **tok) |
| 2784 | { | 2785 | { |
| 2785 | struct print_arg *item_arg; | 2786 | struct tep_print_arg *item_arg; |
| 2786 | enum event_type type; | 2787 | enum tep_event_type type; |
| 2787 | char *token; | 2788 | char *token; |
| 2788 | 2789 | ||
| 2789 | type = process_arg(event, arg, &token); | 2790 | type = process_arg(event, arg, &token); |
| 2790 | 2791 | ||
| 2791 | if (type == EVENT_ERROR) | 2792 | if (type == TEP_EVENT_ERROR) |
| 2792 | goto out_free; | 2793 | goto out_free; |
| 2793 | 2794 | ||
| 2794 | if (type == EVENT_OP) | 2795 | if (type == TEP_EVENT_OP) |
| 2795 | type = process_op(event, arg, &token); | 2796 | type = process_op(event, arg, &token); |
| 2796 | 2797 | ||
| 2797 | if (type == EVENT_ERROR) | 2798 | if (type == TEP_EVENT_ERROR) |
| 2798 | goto out_free; | 2799 | goto out_free; |
| 2799 | 2800 | ||
| 2800 | if (test_type_token(type, token, EVENT_DELIM, ")")) | 2801 | if (test_type_token(type, token, TEP_EVENT_DELIM, ")")) |
| 2801 | goto out_free; | 2802 | goto out_free; |
| 2802 | 2803 | ||
| 2803 | free_token(token); | 2804 | free_token(token); |
| @@ -2808,13 +2809,13 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2808 | * this was a typecast. | 2809 | * this was a typecast. |
| 2809 | */ | 2810 | */ |
| 2810 | if (event_item_type(type) || | 2811 | if (event_item_type(type) || |
| 2811 | (type == EVENT_DELIM && strcmp(token, "(") == 0)) { | 2812 | (type == TEP_EVENT_DELIM && strcmp(token, "(") == 0)) { |
| 2812 | 2813 | ||
| 2813 | /* make this a typecast and contine */ | 2814 | /* make this a typecast and contine */ |
| 2814 | 2815 | ||
| 2815 | /* prevous must be an atom */ | 2816 | /* prevous must be an atom */ |
| 2816 | if (arg->type != PRINT_ATOM) { | 2817 | if (arg->type != TEP_PRINT_ATOM) { |
| 2817 | do_warning_event(event, "previous needed to be PRINT_ATOM"); | 2818 | do_warning_event(event, "previous needed to be TEP_PRINT_ATOM"); |
| 2818 | goto out_free; | 2819 | goto out_free; |
| 2819 | } | 2820 | } |
| 2820 | 2821 | ||
| @@ -2825,7 +2826,7 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2825 | goto out_free; | 2826 | goto out_free; |
| 2826 | } | 2827 | } |
| 2827 | 2828 | ||
| 2828 | arg->type = PRINT_TYPE; | 2829 | arg->type = TEP_PRINT_TYPE; |
| 2829 | arg->typecast.type = arg->atom.atom; | 2830 | arg->typecast.type = arg->atom.atom; |
| 2830 | arg->typecast.item = item_arg; | 2831 | arg->typecast.item = item_arg; |
| 2831 | type = process_arg_token(event, item_arg, &token, type); | 2832 | type = process_arg_token(event, item_arg, &token, type); |
| @@ -2838,25 +2839,25 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok) | |||
| 2838 | out_free: | 2839 | out_free: |
| 2839 | free_token(token); | 2840 | free_token(token); |
| 2840 | *tok = NULL; | 2841 | *tok = NULL; |
| 2841 | return EVENT_ERROR; | 2842 | return TEP_EVENT_ERROR; |
| 2842 | } | 2843 | } |
| 2843 | 2844 | ||
| 2844 | 2845 | ||
| 2845 | static enum event_type | 2846 | static enum tep_event_type |
| 2846 | process_str(struct event_format *event __maybe_unused, struct print_arg *arg, | 2847 | process_str(struct tep_event_format *event __maybe_unused, struct tep_print_arg *arg, |
| 2847 | char **tok) | 2848 | char **tok) |
| 2848 | { | 2849 | { |
| 2849 | enum event_type type; | 2850 | enum tep_event_type type; |
| 2850 | char *token; | 2851 | char *token; |
| 2851 | 2852 | ||
| 2852 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 2853 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 2853 | goto out_free; | 2854 | goto out_free; |
| 2854 | 2855 | ||
| 2855 | arg->type = PRINT_STRING; | 2856 | arg->type = TEP_PRINT_STRING; |
| 2856 | arg->string.string = token; | 2857 | arg->string.string = token; |
| 2857 | arg->string.offset = -1; | 2858 | arg->string.offset = -1; |
| 2858 | 2859 | ||
| 2859 | if (read_expected(EVENT_DELIM, ")") < 0) | 2860 | if (read_expected(TEP_EVENT_DELIM, ")") < 0) |
| 2860 | goto out_err; | 2861 | goto out_err; |
| 2861 | 2862 | ||
| 2862 | type = read_token(&token); | 2863 | type = read_token(&token); |
| @@ -2868,24 +2869,24 @@ process_str(struct event_format *event __maybe_unused, struct print_arg *arg, | |||
| 2868 | free_token(token); | 2869 | free_token(token); |
| 2869 | out_err: | 2870 | out_err: |
| 2870 | *tok = NULL; | 2871 | *tok = NULL; |
| 2871 | return EVENT_ERROR; | 2872 | return TEP_EVENT_ERROR; |
| 2872 | } | 2873 | } |
| 2873 | 2874 | ||
| 2874 | static enum event_type | 2875 | static enum tep_event_type |
| 2875 | process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg, | 2876 | process_bitmask(struct tep_event_format *event __maybe_unused, struct tep_print_arg *arg, |
| 2876 | char **tok) | 2877 | char **tok) |
| 2877 | { | 2878 | { |
| 2878 | enum event_type type; | 2879 | enum tep_event_type type; |
| 2879 | char *token; | 2880 | char *token; |
| 2880 | 2881 | ||
| 2881 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 2882 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 2882 | goto out_free; | 2883 | goto out_free; |
| 2883 | 2884 | ||
| 2884 | arg->type = PRINT_BITMASK; | 2885 | arg->type = TEP_PRINT_BITMASK; |
| 2885 | arg->bitmask.bitmask = token; | 2886 | arg->bitmask.bitmask = token; |
| 2886 | arg->bitmask.offset = -1; | 2887 | arg->bitmask.offset = -1; |
| 2887 | 2888 | ||
| 2888 | if (read_expected(EVENT_DELIM, ")") < 0) | 2889 | if (read_expected(TEP_EVENT_DELIM, ")") < 0) |
| 2889 | goto out_err; | 2890 | goto out_err; |
| 2890 | 2891 | ||
| 2891 | type = read_token(&token); | 2892 | type = read_token(&token); |
| @@ -2897,7 +2898,7 @@ process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg | |||
| 2897 | free_token(token); | 2898 | free_token(token); |
| 2898 | out_err: | 2899 | out_err: |
| 2899 | *tok = NULL; | 2900 | *tok = NULL; |
| 2900 | return EVENT_ERROR; | 2901 | return TEP_EVENT_ERROR; |
| 2901 | } | 2902 | } |
| 2902 | 2903 | ||
| 2903 | static struct tep_function_handler * | 2904 | static struct tep_function_handler * |
| @@ -2932,17 +2933,17 @@ static void remove_func_handler(struct tep_handle *pevent, char *func_name) | |||
| 2932 | } | 2933 | } |
| 2933 | } | 2934 | } |
| 2934 | 2935 | ||
| 2935 | static enum event_type | 2936 | static enum tep_event_type |
| 2936 | process_func_handler(struct event_format *event, struct tep_function_handler *func, | 2937 | process_func_handler(struct tep_event_format *event, struct tep_function_handler *func, |
| 2937 | struct print_arg *arg, char **tok) | 2938 | struct tep_print_arg *arg, char **tok) |
| 2938 | { | 2939 | { |
| 2939 | struct print_arg **next_arg; | 2940 | struct tep_print_arg **next_arg; |
| 2940 | struct print_arg *farg; | 2941 | struct tep_print_arg *farg; |
| 2941 | enum event_type type; | 2942 | enum tep_event_type type; |
| 2942 | char *token; | 2943 | char *token; |
| 2943 | int i; | 2944 | int i; |
| 2944 | 2945 | ||
| 2945 | arg->type = PRINT_FUNC; | 2946 | arg->type = TEP_PRINT_FUNC; |
| 2946 | arg->func.func = func; | 2947 | arg->func.func = func; |
| 2947 | 2948 | ||
| 2948 | *tok = NULL; | 2949 | *tok = NULL; |
| @@ -2953,12 +2954,12 @@ process_func_handler(struct event_format *event, struct tep_function_handler *fu | |||
| 2953 | if (!farg) { | 2954 | if (!farg) { |
| 2954 | do_warning_event(event, "%s: not enough memory!", | 2955 | do_warning_event(event, "%s: not enough memory!", |
| 2955 | __func__); | 2956 | __func__); |
| 2956 | return EVENT_ERROR; | 2957 | return TEP_EVENT_ERROR; |
| 2957 | } | 2958 | } |
| 2958 | 2959 | ||
| 2959 | type = process_arg(event, farg, &token); | 2960 | type = process_arg(event, farg, &token); |
| 2960 | if (i < (func->nr_args - 1)) { | 2961 | if (i < (func->nr_args - 1)) { |
| 2961 | if (type != EVENT_DELIM || strcmp(token, ",") != 0) { | 2962 | if (type != TEP_EVENT_DELIM || strcmp(token, ",") != 0) { |
| 2962 | do_warning_event(event, | 2963 | do_warning_event(event, |
| 2963 | "Error: function '%s()' expects %d arguments but event %s only uses %d", | 2964 | "Error: function '%s()' expects %d arguments but event %s only uses %d", |
| 2964 | func->name, func->nr_args, | 2965 | func->name, func->nr_args, |
| @@ -2966,7 +2967,7 @@ process_func_handler(struct event_format *event, struct tep_function_handler *fu | |||
| 2966 | goto err; | 2967 | goto err; |
| 2967 | } | 2968 | } |
| 2968 | } else { | 2969 | } else { |
| 2969 | if (type != EVENT_DELIM || strcmp(token, ")") != 0) { | 2970 | if (type != TEP_EVENT_DELIM || strcmp(token, ")") != 0) { |
| 2970 | do_warning_event(event, | 2971 | do_warning_event(event, |
| 2971 | "Error: function '%s()' only expects %d arguments but event %s has more", | 2972 | "Error: function '%s()' only expects %d arguments but event %s has more", |
| 2972 | func->name, func->nr_args, event->name); | 2973 | func->name, func->nr_args, event->name); |
| @@ -2987,11 +2988,11 @@ process_func_handler(struct event_format *event, struct tep_function_handler *fu | |||
| 2987 | err: | 2988 | err: |
| 2988 | free_arg(farg); | 2989 | free_arg(farg); |
| 2989 | free_token(token); | 2990 | free_token(token); |
| 2990 | return EVENT_ERROR; | 2991 | return TEP_EVENT_ERROR; |
| 2991 | } | 2992 | } |
| 2992 | 2993 | ||
| 2993 | static enum event_type | 2994 | static enum tep_event_type |
| 2994 | process_function(struct event_format *event, struct print_arg *arg, | 2995 | process_function(struct tep_event_format *event, struct tep_print_arg *arg, |
| 2995 | char *token, char **tok) | 2996 | char *token, char **tok) |
| 2996 | { | 2997 | { |
| 2997 | struct tep_function_handler *func; | 2998 | struct tep_function_handler *func; |
| @@ -3043,12 +3044,12 @@ process_function(struct event_format *event, struct print_arg *arg, | |||
| 3043 | 3044 | ||
| 3044 | do_warning_event(event, "function %s not defined", token); | 3045 | do_warning_event(event, "function %s not defined", token); |
| 3045 | free_token(token); | 3046 | free_token(token); |
| 3046 | return EVENT_ERROR; | 3047 | return TEP_EVENT_ERROR; |
| 3047 | } | 3048 | } |
| 3048 | 3049 | ||
| 3049 | static enum event_type | 3050 | static enum tep_event_type |
| 3050 | process_arg_token(struct event_format *event, struct print_arg *arg, | 3051 | process_arg_token(struct tep_event_format *event, struct tep_print_arg *arg, |
| 3051 | char **tok, enum event_type type) | 3052 | char **tok, enum tep_event_type type) |
| 3052 | { | 3053 | { |
| 3053 | char *token; | 3054 | char *token; |
| 3054 | char *atom; | 3055 | char *atom; |
| @@ -3056,7 +3057,7 @@ process_arg_token(struct event_format *event, struct print_arg *arg, | |||
| 3056 | token = *tok; | 3057 | token = *tok; |
| 3057 | 3058 | ||
| 3058 | switch (type) { | 3059 | switch (type) { |
| 3059 | case EVENT_ITEM: | 3060 | case TEP_EVENT_ITEM: |
| 3060 | if (strcmp(token, "REC") == 0) { | 3061 | if (strcmp(token, "REC") == 0) { |
| 3061 | free_token(token); | 3062 | free_token(token); |
| 3062 | type = process_entry(event, arg, &token); | 3063 | type = process_entry(event, arg, &token); |
| @@ -3070,7 +3071,7 @@ process_arg_token(struct event_format *event, struct print_arg *arg, | |||
| 3070 | * If the next token is a parenthesis, then this | 3071 | * If the next token is a parenthesis, then this |
| 3071 | * is a function. | 3072 | * is a function. |
| 3072 | */ | 3073 | */ |
| 3073 | if (type == EVENT_DELIM && strcmp(token, "(") == 0) { | 3074 | if (type == TEP_EVENT_DELIM && strcmp(token, "(") == 0) { |
| 3074 | free_token(token); | 3075 | free_token(token); |
| 3075 | token = NULL; | 3076 | token = NULL; |
| 3076 | /* this will free atom. */ | 3077 | /* this will free atom. */ |
| @@ -3078,7 +3079,7 @@ process_arg_token(struct event_format *event, struct print_arg *arg, | |||
| 3078 | break; | 3079 | break; |
| 3079 | } | 3080 | } |
| 3080 | /* atoms can be more than one token long */ | 3081 | /* atoms can be more than one token long */ |
| 3081 | while (type == EVENT_ITEM) { | 3082 | while (type == TEP_EVENT_ITEM) { |
| 3082 | char *new_atom; | 3083 | char *new_atom; |
| 3083 | new_atom = realloc(atom, | 3084 | new_atom = realloc(atom, |
| 3084 | strlen(atom) + strlen(token) + 2); | 3085 | strlen(atom) + strlen(token) + 2); |
| @@ -3086,7 +3087,7 @@ process_arg_token(struct event_format *event, struct print_arg *arg, | |||
| 3086 | free(atom); | 3087 | free(atom); |
| 3087 | *tok = NULL; | 3088 | *tok = NULL; |
| 3088 | free_token(token); | 3089 | free_token(token); |
| 3089 | return EVENT_ERROR; | 3090 | return TEP_EVENT_ERROR; |
| 3090 | } | 3091 | } |
| 3091 | atom = new_atom; | 3092 | atom = new_atom; |
| 3092 | strcat(atom, " "); | 3093 | strcat(atom, " "); |
| @@ -3095,55 +3096,55 @@ process_arg_token(struct event_format *event, struct print_arg *arg, | |||
| 3095 | type = read_token_item(&token); | 3096 | type = read_token_item(&token); |
| 3096 | } | 3097 | } |
| 3097 | 3098 | ||
| 3098 | arg->type = PRINT_ATOM; | 3099 | arg->type = TEP_PRINT_ATOM; |
| 3099 | arg->atom.atom = atom; | 3100 | arg->atom.atom = atom; |
| 3100 | break; | 3101 | break; |
| 3101 | 3102 | ||
| 3102 | case EVENT_DQUOTE: | 3103 | case TEP_EVENT_DQUOTE: |
| 3103 | case EVENT_SQUOTE: | 3104 | case TEP_EVENT_SQUOTE: |
| 3104 | arg->type = PRINT_ATOM; | 3105 | arg->type = TEP_PRINT_ATOM; |
| 3105 | arg->atom.atom = token; | 3106 | arg->atom.atom = token; |
| 3106 | type = read_token_item(&token); | 3107 | type = read_token_item(&token); |
| 3107 | break; | 3108 | break; |
| 3108 | case EVENT_DELIM: | 3109 | case TEP_EVENT_DELIM: |
| 3109 | if (strcmp(token, "(") == 0) { | 3110 | if (strcmp(token, "(") == 0) { |
| 3110 | free_token(token); | 3111 | free_token(token); |
| 3111 | type = process_paren(event, arg, &token); | 3112 | type = process_paren(event, arg, &token); |
| 3112 | break; | 3113 | break; |
| 3113 | } | 3114 | } |
| 3114 | case EVENT_OP: | 3115 | case TEP_EVENT_OP: |
| 3115 | /* handle single ops */ | 3116 | /* handle single ops */ |
| 3116 | arg->type = PRINT_OP; | 3117 | arg->type = TEP_PRINT_OP; |
| 3117 | arg->op.op = token; | 3118 | arg->op.op = token; |
| 3118 | arg->op.left = NULL; | 3119 | arg->op.left = NULL; |
| 3119 | type = process_op(event, arg, &token); | 3120 | type = process_op(event, arg, &token); |
| 3120 | 3121 | ||
| 3121 | /* On error, the op is freed */ | 3122 | /* On error, the op is freed */ |
| 3122 | if (type == EVENT_ERROR) | 3123 | if (type == TEP_EVENT_ERROR) |
| 3123 | arg->op.op = NULL; | 3124 | arg->op.op = NULL; |
| 3124 | 3125 | ||
| 3125 | /* return error type if errored */ | 3126 | /* return error type if errored */ |
| 3126 | break; | 3127 | break; |
| 3127 | 3128 | ||
| 3128 | case EVENT_ERROR ... EVENT_NEWLINE: | 3129 | case TEP_EVENT_ERROR ... TEP_EVENT_NEWLINE: |
| 3129 | default: | 3130 | default: |
| 3130 | do_warning_event(event, "unexpected type %d", type); | 3131 | do_warning_event(event, "unexpected type %d", type); |
| 3131 | return EVENT_ERROR; | 3132 | return TEP_EVENT_ERROR; |
| 3132 | } | 3133 | } |
| 3133 | *tok = token; | 3134 | *tok = token; |
| 3134 | 3135 | ||
| 3135 | return type; | 3136 | return type; |
| 3136 | } | 3137 | } |
| 3137 | 3138 | ||
| 3138 | static int event_read_print_args(struct event_format *event, struct print_arg **list) | 3139 | static int event_read_print_args(struct tep_event_format *event, struct tep_print_arg **list) |
| 3139 | { | 3140 | { |
| 3140 | enum event_type type = EVENT_ERROR; | 3141 | enum tep_event_type type = TEP_EVENT_ERROR; |
| 3141 | struct print_arg *arg; | 3142 | struct tep_print_arg *arg; |
| 3142 | char *token; | 3143 | char *token; |
| 3143 | int args = 0; | 3144 | int args = 0; |
| 3144 | 3145 | ||
| 3145 | do { | 3146 | do { |
| 3146 | if (type == EVENT_NEWLINE) { | 3147 | if (type == TEP_EVENT_NEWLINE) { |
| 3147 | type = read_token_item(&token); | 3148 | type = read_token_item(&token); |
| 3148 | continue; | 3149 | continue; |
| 3149 | } | 3150 | } |
| @@ -3157,7 +3158,7 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** | |||
| 3157 | 3158 | ||
| 3158 | type = process_arg(event, arg, &token); | 3159 | type = process_arg(event, arg, &token); |
| 3159 | 3160 | ||
| 3160 | if (type == EVENT_ERROR) { | 3161 | if (type == TEP_EVENT_ERROR) { |
| 3161 | free_token(token); | 3162 | free_token(token); |
| 3162 | free_arg(arg); | 3163 | free_arg(arg); |
| 3163 | return -1; | 3164 | return -1; |
| @@ -3166,10 +3167,10 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** | |||
| 3166 | *list = arg; | 3167 | *list = arg; |
| 3167 | args++; | 3168 | args++; |
| 3168 | 3169 | ||
| 3169 | if (type == EVENT_OP) { | 3170 | if (type == TEP_EVENT_OP) { |
| 3170 | type = process_op(event, arg, &token); | 3171 | type = process_op(event, arg, &token); |
| 3171 | free_token(token); | 3172 | free_token(token); |
| 3172 | if (type == EVENT_ERROR) { | 3173 | if (type == TEP_EVENT_ERROR) { |
| 3173 | *list = NULL; | 3174 | *list = NULL; |
| 3174 | free_arg(arg); | 3175 | free_arg(arg); |
| 3175 | return -1; | 3176 | return -1; |
| @@ -3178,37 +3179,37 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** | |||
| 3178 | continue; | 3179 | continue; |
| 3179 | } | 3180 | } |
| 3180 | 3181 | ||
| 3181 | if (type == EVENT_DELIM && strcmp(token, ",") == 0) { | 3182 | if (type == TEP_EVENT_DELIM && strcmp(token, ",") == 0) { |
| 3182 | free_token(token); | 3183 | free_token(token); |
| 3183 | *list = arg; | 3184 | *list = arg; |
| 3184 | list = &arg->next; | 3185 | list = &arg->next; |
| 3185 | continue; | 3186 | continue; |
| 3186 | } | 3187 | } |
| 3187 | break; | 3188 | break; |
| 3188 | } while (type != EVENT_NONE); | 3189 | } while (type != TEP_EVENT_NONE); |
| 3189 | 3190 | ||
| 3190 | if (type != EVENT_NONE && type != EVENT_ERROR) | 3191 | if (type != TEP_EVENT_NONE && type != TEP_EVENT_ERROR) |
| 3191 | free_token(token); | 3192 | free_token(token); |
| 3192 | 3193 | ||
| 3193 | return args; | 3194 | return args; |
| 3194 | } | 3195 | } |
| 3195 | 3196 | ||
| 3196 | static int event_read_print(struct event_format *event) | 3197 | static int event_read_print(struct tep_event_format *event) |
| 3197 | { | 3198 | { |
| 3198 | enum event_type type; | 3199 | enum tep_event_type type; |
| 3199 | char *token; | 3200 | char *token; |
| 3200 | int ret; | 3201 | int ret; |
| 3201 | 3202 | ||
| 3202 | if (read_expected_item(EVENT_ITEM, "print") < 0) | 3203 | if (read_expected_item(TEP_EVENT_ITEM, "print") < 0) |
| 3203 | return -1; | 3204 | return -1; |
| 3204 | 3205 | ||
| 3205 | if (read_expected(EVENT_ITEM, "fmt") < 0) | 3206 | if (read_expected(TEP_EVENT_ITEM, "fmt") < 0) |
| 3206 | return -1; | 3207 | return -1; |
| 3207 | 3208 | ||
| 3208 | if (read_expected(EVENT_OP, ":") < 0) | 3209 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 3209 | return -1; | 3210 | return -1; |
| 3210 | 3211 | ||
| 3211 | if (read_expect_type(EVENT_DQUOTE, &token) < 0) | 3212 | if (read_expect_type(TEP_EVENT_DQUOTE, &token) < 0) |
| 3212 | goto fail; | 3213 | goto fail; |
| 3213 | 3214 | ||
| 3214 | concat: | 3215 | concat: |
| @@ -3218,11 +3219,11 @@ static int event_read_print(struct event_format *event) | |||
| 3218 | /* ok to have no arg */ | 3219 | /* ok to have no arg */ |
| 3219 | type = read_token_item(&token); | 3220 | type = read_token_item(&token); |
| 3220 | 3221 | ||
| 3221 | if (type == EVENT_NONE) | 3222 | if (type == TEP_EVENT_NONE) |
| 3222 | return 0; | 3223 | return 0; |
| 3223 | 3224 | ||
| 3224 | /* Handle concatenation of print lines */ | 3225 | /* Handle concatenation of print lines */ |
| 3225 | if (type == EVENT_DQUOTE) { | 3226 | if (type == TEP_EVENT_DQUOTE) { |
| 3226 | char *cat; | 3227 | char *cat; |
| 3227 | 3228 | ||
| 3228 | if (asprintf(&cat, "%s%s", event->print_fmt.format, token) < 0) | 3229 | if (asprintf(&cat, "%s%s", event->print_fmt.format, token) < 0) |
| @@ -3234,7 +3235,7 @@ static int event_read_print(struct event_format *event) | |||
| 3234 | goto concat; | 3235 | goto concat; |
| 3235 | } | 3236 | } |
| 3236 | 3237 | ||
| 3237 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 3238 | if (test_type_token(type, token, TEP_EVENT_DELIM, ",")) |
| 3238 | goto fail; | 3239 | goto fail; |
| 3239 | 3240 | ||
| 3240 | free_token(token); | 3241 | free_token(token); |
| @@ -3258,10 +3259,10 @@ static int event_read_print(struct event_format *event) | |||
| 3258 | * Returns a common field from the event by the given @name. | 3259 | * Returns a common field from the event by the given @name. |
| 3259 | * This only searchs the common fields and not all field. | 3260 | * This only searchs the common fields and not all field. |
| 3260 | */ | 3261 | */ |
| 3261 | struct format_field * | 3262 | struct tep_format_field * |
| 3262 | tep_find_common_field(struct event_format *event, const char *name) | 3263 | tep_find_common_field(struct tep_event_format *event, const char *name) |
| 3263 | { | 3264 | { |
| 3264 | struct format_field *format; | 3265 | struct tep_format_field *format; |
| 3265 | 3266 | ||
| 3266 | for (format = event->format.common_fields; | 3267 | for (format = event->format.common_fields; |
| 3267 | format; format = format->next) { | 3268 | format; format = format->next) { |
| @@ -3280,10 +3281,10 @@ tep_find_common_field(struct event_format *event, const char *name) | |||
| 3280 | * Returns a non-common field by the given @name. | 3281 | * Returns a non-common field by the given @name. |
| 3281 | * This does not search common fields. | 3282 | * This does not search common fields. |
| 3282 | */ | 3283 | */ |
| 3283 | struct format_field * | 3284 | struct tep_format_field * |
| 3284 | tep_find_field(struct event_format *event, const char *name) | 3285 | tep_find_field(struct tep_event_format *event, const char *name) |
| 3285 | { | 3286 | { |
| 3286 | struct format_field *format; | 3287 | struct tep_format_field *format; |
| 3287 | 3288 | ||
| 3288 | for (format = event->format.fields; | 3289 | for (format = event->format.fields; |
| 3289 | format; format = format->next) { | 3290 | format; format = format->next) { |
| @@ -3303,10 +3304,10 @@ tep_find_field(struct event_format *event, const char *name) | |||
| 3303 | * This searchs the common field names first, then | 3304 | * This searchs the common field names first, then |
| 3304 | * the non-common ones if a common one was not found. | 3305 | * the non-common ones if a common one was not found. |
| 3305 | */ | 3306 | */ |
| 3306 | struct format_field * | 3307 | struct tep_format_field * |
| 3307 | tep_find_any_field(struct event_format *event, const char *name) | 3308 | tep_find_any_field(struct tep_event_format *event, const char *name) |
| 3308 | { | 3309 | { |
| 3309 | struct format_field *format; | 3310 | struct tep_format_field *format; |
| 3310 | 3311 | ||
| 3311 | format = tep_find_common_field(event, name); | 3312 | format = tep_find_common_field(event, name); |
| 3312 | if (format) | 3313 | if (format) |
| @@ -3330,11 +3331,11 @@ unsigned long long tep_read_number(struct tep_handle *pevent, | |||
| 3330 | case 1: | 3331 | case 1: |
| 3331 | return *(unsigned char *)ptr; | 3332 | return *(unsigned char *)ptr; |
| 3332 | case 2: | 3333 | case 2: |
| 3333 | return data2host2(pevent, ptr); | 3334 | return tep_data2host2(pevent, ptr); |
| 3334 | case 4: | 3335 | case 4: |
| 3335 | return data2host4(pevent, ptr); | 3336 | return tep_data2host4(pevent, ptr); |
| 3336 | case 8: | 3337 | case 8: |
| 3337 | return data2host8(pevent, ptr); | 3338 | return tep_data2host8(pevent, ptr); |
| 3338 | default: | 3339 | default: |
| 3339 | /* BUG! */ | 3340 | /* BUG! */ |
| 3340 | return 0; | 3341 | return 0; |
| @@ -3352,7 +3353,7 @@ unsigned long long tep_read_number(struct tep_handle *pevent, | |||
| 3352 | * | 3353 | * |
| 3353 | * Returns 0 on success, -1 otherwise. | 3354 | * Returns 0 on success, -1 otherwise. |
| 3354 | */ | 3355 | */ |
| 3355 | int tep_read_number_field(struct format_field *field, const void *data, | 3356 | int tep_read_number_field(struct tep_format_field *field, const void *data, |
| 3356 | unsigned long long *value) | 3357 | unsigned long long *value) |
| 3357 | { | 3358 | { |
| 3358 | if (!field) | 3359 | if (!field) |
| @@ -3373,8 +3374,8 @@ int tep_read_number_field(struct format_field *field, const void *data, | |||
| 3373 | static int get_common_info(struct tep_handle *pevent, | 3374 | static int get_common_info(struct tep_handle *pevent, |
| 3374 | const char *type, int *offset, int *size) | 3375 | const char *type, int *offset, int *size) |
| 3375 | { | 3376 | { |
| 3376 | struct event_format *event; | 3377 | struct tep_event_format *event; |
| 3377 | struct format_field *field; | 3378 | struct tep_format_field *field; |
| 3378 | 3379 | ||
| 3379 | /* | 3380 | /* |
| 3380 | * All events should have the same common elements. | 3381 | * All events should have the same common elements. |
| @@ -3460,11 +3461,11 @@ static int events_id_cmp(const void *a, const void *b); | |||
| 3460 | * | 3461 | * |
| 3461 | * Returns an event that has a given @id. | 3462 | * Returns an event that has a given @id. |
| 3462 | */ | 3463 | */ |
| 3463 | struct event_format *tep_find_event(struct tep_handle *pevent, int id) | 3464 | struct tep_event_format *tep_find_event(struct tep_handle *pevent, int id) |
| 3464 | { | 3465 | { |
| 3465 | struct event_format **eventptr; | 3466 | struct tep_event_format **eventptr; |
| 3466 | struct event_format key; | 3467 | struct tep_event_format key; |
| 3467 | struct event_format *pkey = &key; | 3468 | struct tep_event_format *pkey = &key; |
| 3468 | 3469 | ||
| 3469 | /* Check cache first */ | 3470 | /* Check cache first */ |
| 3470 | if (pevent->last_event && pevent->last_event->id == id) | 3471 | if (pevent->last_event && pevent->last_event->id == id) |
| @@ -3492,11 +3493,11 @@ struct event_format *tep_find_event(struct tep_handle *pevent, int id) | |||
| 3492 | * This returns an event with a given @name and under the system | 3493 | * This returns an event with a given @name and under the system |
| 3493 | * @sys. If @sys is NULL the first event with @name is returned. | 3494 | * @sys. If @sys is NULL the first event with @name is returned. |
| 3494 | */ | 3495 | */ |
| 3495 | struct event_format * | 3496 | struct tep_event_format * |
| 3496 | tep_find_event_by_name(struct tep_handle *pevent, | 3497 | tep_find_event_by_name(struct tep_handle *pevent, |
| 3497 | const char *sys, const char *name) | 3498 | const char *sys, const char *name) |
| 3498 | { | 3499 | { |
| 3499 | struct event_format *event; | 3500 | struct tep_event_format *event; |
| 3500 | int i; | 3501 | int i; |
| 3501 | 3502 | ||
| 3502 | if (pevent->last_event && | 3503 | if (pevent->last_event && |
| @@ -3521,23 +3522,23 @@ tep_find_event_by_name(struct tep_handle *pevent, | |||
| 3521 | } | 3522 | } |
| 3522 | 3523 | ||
| 3523 | static unsigned long long | 3524 | static unsigned long long |
| 3524 | eval_num_arg(void *data, int size, struct event_format *event, struct print_arg *arg) | 3525 | eval_num_arg(void *data, int size, struct tep_event_format *event, struct tep_print_arg *arg) |
| 3525 | { | 3526 | { |
| 3526 | struct tep_handle *pevent = event->pevent; | 3527 | struct tep_handle *pevent = event->pevent; |
| 3527 | unsigned long long val = 0; | 3528 | unsigned long long val = 0; |
| 3528 | unsigned long long left, right; | 3529 | unsigned long long left, right; |
| 3529 | struct print_arg *typearg = NULL; | 3530 | struct tep_print_arg *typearg = NULL; |
| 3530 | struct print_arg *larg; | 3531 | struct tep_print_arg *larg; |
| 3531 | unsigned long offset; | 3532 | unsigned long offset; |
| 3532 | unsigned int field_size; | 3533 | unsigned int field_size; |
| 3533 | 3534 | ||
| 3534 | switch (arg->type) { | 3535 | switch (arg->type) { |
| 3535 | case PRINT_NULL: | 3536 | case TEP_PRINT_NULL: |
| 3536 | /* ?? */ | 3537 | /* ?? */ |
| 3537 | return 0; | 3538 | return 0; |
| 3538 | case PRINT_ATOM: | 3539 | case TEP_PRINT_ATOM: |
| 3539 | return strtoull(arg->atom.atom, NULL, 0); | 3540 | return strtoull(arg->atom.atom, NULL, 0); |
| 3540 | case PRINT_FIELD: | 3541 | case TEP_PRINT_FIELD: |
| 3541 | if (!arg->field.field) { | 3542 | if (!arg->field.field) { |
| 3542 | arg->field.field = tep_find_any_field(event, arg->field.name); | 3543 | arg->field.field = tep_find_any_field(event, arg->field.name); |
| 3543 | if (!arg->field.field) | 3544 | if (!arg->field.field) |
| @@ -3548,27 +3549,27 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
| 3548 | val = tep_read_number(pevent, data + arg->field.field->offset, | 3549 | val = tep_read_number(pevent, data + arg->field.field->offset, |
| 3549 | arg->field.field->size); | 3550 | arg->field.field->size); |
| 3550 | break; | 3551 | break; |
| 3551 | case PRINT_FLAGS: | 3552 | case TEP_PRINT_FLAGS: |
| 3552 | case PRINT_SYMBOL: | 3553 | case TEP_PRINT_SYMBOL: |
| 3553 | case PRINT_INT_ARRAY: | 3554 | case TEP_PRINT_INT_ARRAY: |
| 3554 | case PRINT_HEX: | 3555 | case TEP_PRINT_HEX: |
| 3555 | case PRINT_HEX_STR: | 3556 | case TEP_PRINT_HEX_STR: |
| 3556 | break; | 3557 | break; |
| 3557 | case PRINT_TYPE: | 3558 | case TEP_PRINT_TYPE: |
| 3558 | val = eval_num_arg(data, size, event, arg->typecast.item); | 3559 | val = eval_num_arg(data, size, event, arg->typecast.item); |
| 3559 | return eval_type(val, arg, 0); | 3560 | return eval_type(val, arg, 0); |
| 3560 | case PRINT_STRING: | 3561 | case TEP_PRINT_STRING: |
| 3561 | case PRINT_BSTRING: | 3562 | case TEP_PRINT_BSTRING: |
| 3562 | case PRINT_BITMASK: | 3563 | case TEP_PRINT_BITMASK: |
| 3563 | return 0; | 3564 | return 0; |
| 3564 | case PRINT_FUNC: { | 3565 | case TEP_PRINT_FUNC: { |
| 3565 | struct trace_seq s; | 3566 | struct trace_seq s; |
| 3566 | trace_seq_init(&s); | 3567 | trace_seq_init(&s); |
| 3567 | val = process_defined_func(&s, data, size, event, arg); | 3568 | val = process_defined_func(&s, data, size, event, arg); |
| 3568 | trace_seq_destroy(&s); | 3569 | trace_seq_destroy(&s); |
| 3569 | return val; | 3570 | return val; |
| 3570 | } | 3571 | } |
| 3571 | case PRINT_OP: | 3572 | case TEP_PRINT_OP: |
| 3572 | if (strcmp(arg->op.op, "[") == 0) { | 3573 | if (strcmp(arg->op.op, "[") == 0) { |
| 3573 | /* | 3574 | /* |
| 3574 | * Arrays are special, since we don't want | 3575 | * Arrays are special, since we don't want |
| @@ -3578,7 +3579,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
| 3578 | 3579 | ||
| 3579 | /* handle typecasts */ | 3580 | /* handle typecasts */ |
| 3580 | larg = arg->op.left; | 3581 | larg = arg->op.left; |
| 3581 | while (larg->type == PRINT_TYPE) { | 3582 | while (larg->type == TEP_PRINT_TYPE) { |
| 3582 | if (!typearg) | 3583 | if (!typearg) |
| 3583 | typearg = larg; | 3584 | typearg = larg; |
| 3584 | larg = larg->typecast.item; | 3585 | larg = larg->typecast.item; |
| @@ -3588,7 +3589,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
| 3588 | field_size = pevent->long_size; | 3589 | field_size = pevent->long_size; |
| 3589 | 3590 | ||
| 3590 | switch (larg->type) { | 3591 | switch (larg->type) { |
| 3591 | case PRINT_DYNAMIC_ARRAY: | 3592 | case TEP_PRINT_DYNAMIC_ARRAY: |
| 3592 | offset = tep_read_number(pevent, | 3593 | offset = tep_read_number(pevent, |
| 3593 | data + larg->dynarray.field->offset, | 3594 | data + larg->dynarray.field->offset, |
| 3594 | larg->dynarray.field->size); | 3595 | larg->dynarray.field->size); |
| @@ -3602,7 +3603,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
| 3602 | offset &= 0xffff; | 3603 | offset &= 0xffff; |
| 3603 | offset += right; | 3604 | offset += right; |
| 3604 | break; | 3605 | break; |
| 3605 | case PRINT_FIELD: | 3606 | case TEP_PRINT_FIELD: |
| 3606 | if (!larg->field.field) { | 3607 | if (!larg->field.field) { |
| 3607 | larg->field.field = | 3608 | larg->field.field = |
| 3608 | tep_find_any_field(event, larg->field.name); | 3609 | tep_find_any_field(event, larg->field.name); |
| @@ -3718,7 +3719,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
| 3718 | goto out_warning_op; | 3719 | goto out_warning_op; |
| 3719 | } | 3720 | } |
| 3720 | break; | 3721 | break; |
| 3721 | case PRINT_DYNAMIC_ARRAY_LEN: | 3722 | case TEP_PRINT_DYNAMIC_ARRAY_LEN: |
| 3722 | offset = tep_read_number(pevent, | 3723 | offset = tep_read_number(pevent, |
| 3723 | data + arg->dynarray.field->offset, | 3724 | data + arg->dynarray.field->offset, |
| 3724 | arg->dynarray.field->size); | 3725 | arg->dynarray.field->size); |
| @@ -3729,7 +3730,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
| 3729 | */ | 3730 | */ |
| 3730 | val = (unsigned long long)(offset >> 16); | 3731 | val = (unsigned long long)(offset >> 16); |
| 3731 | break; | 3732 | break; |
| 3732 | case PRINT_DYNAMIC_ARRAY: | 3733 | case TEP_PRINT_DYNAMIC_ARRAY: |
| 3733 | /* Without [], we pass the address to the dynamic data */ | 3734 | /* Without [], we pass the address to the dynamic data */ |
| 3734 | offset = tep_read_number(pevent, | 3735 | offset = tep_read_number(pevent, |
| 3735 | data + arg->dynarray.field->offset, | 3736 | data + arg->dynarray.field->offset, |
| @@ -3861,12 +3862,12 @@ static void print_bitmask_to_seq(struct tep_handle *pevent, | |||
| 3861 | } | 3862 | } |
| 3862 | 3863 | ||
| 3863 | static void print_str_arg(struct trace_seq *s, void *data, int size, | 3864 | static void print_str_arg(struct trace_seq *s, void *data, int size, |
| 3864 | struct event_format *event, const char *format, | 3865 | struct tep_event_format *event, const char *format, |
| 3865 | int len_arg, struct print_arg *arg) | 3866 | int len_arg, struct tep_print_arg *arg) |
| 3866 | { | 3867 | { |
| 3867 | struct tep_handle *pevent = event->pevent; | 3868 | struct tep_handle *pevent = event->pevent; |
| 3868 | struct print_flag_sym *flag; | 3869 | struct tep_print_flag_sym *flag; |
| 3869 | struct format_field *field; | 3870 | struct tep_format_field *field; |
| 3870 | struct printk_map *printk; | 3871 | struct printk_map *printk; |
| 3871 | long long val, fval; | 3872 | long long val, fval; |
| 3872 | unsigned long long addr; | 3873 | unsigned long long addr; |
| @@ -3876,13 +3877,13 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 3876 | int i, len; | 3877 | int i, len; |
| 3877 | 3878 | ||
| 3878 | switch (arg->type) { | 3879 | switch (arg->type) { |
| 3879 | case PRINT_NULL: | 3880 | case TEP_PRINT_NULL: |
| 3880 | /* ?? */ | 3881 | /* ?? */ |
| 3881 | return; | 3882 | return; |
| 3882 | case PRINT_ATOM: | 3883 | case TEP_PRINT_ATOM: |
| 3883 | print_str_to_seq(s, format, len_arg, arg->atom.atom); | 3884 | print_str_to_seq(s, format, len_arg, arg->atom.atom); |
| 3884 | return; | 3885 | return; |
| 3885 | case PRINT_FIELD: | 3886 | case TEP_PRINT_FIELD: |
| 3886 | field = arg->field.field; | 3887 | field = arg->field.field; |
| 3887 | if (!field) { | 3888 | if (!field) { |
| 3888 | field = tep_find_any_field(event, arg->field.name); | 3889 | field = tep_find_any_field(event, arg->field.name); |
| @@ -3900,7 +3901,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 3900 | * and the size is the same as long_size, assume that it | 3901 | * and the size is the same as long_size, assume that it |
| 3901 | * is a pointer. | 3902 | * is a pointer. |
| 3902 | */ | 3903 | */ |
| 3903 | if (!(field->flags & FIELD_IS_ARRAY) && | 3904 | if (!(field->flags & TEP_FIELD_IS_ARRAY) && |
| 3904 | field->size == pevent->long_size) { | 3905 | field->size == pevent->long_size) { |
| 3905 | 3906 | ||
| 3906 | /* Handle heterogeneous recording and processing | 3907 | /* Handle heterogeneous recording and processing |
| @@ -3939,7 +3940,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 3939 | print_str_to_seq(s, format, len_arg, str); | 3940 | print_str_to_seq(s, format, len_arg, str); |
| 3940 | free(str); | 3941 | free(str); |
| 3941 | break; | 3942 | break; |
| 3942 | case PRINT_FLAGS: | 3943 | case TEP_PRINT_FLAGS: |
| 3943 | val = eval_num_arg(data, size, event, arg->flags.field); | 3944 | val = eval_num_arg(data, size, event, arg->flags.field); |
| 3944 | print = 0; | 3945 | print = 0; |
| 3945 | for (flag = arg->flags.flags; flag; flag = flag->next) { | 3946 | for (flag = arg->flags.flags; flag; flag = flag->next) { |
| @@ -3962,7 +3963,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 3962 | trace_seq_printf(s, "0x%llx", val); | 3963 | trace_seq_printf(s, "0x%llx", val); |
| 3963 | } | 3964 | } |
| 3964 | break; | 3965 | break; |
| 3965 | case PRINT_SYMBOL: | 3966 | case TEP_PRINT_SYMBOL: |
| 3966 | val = eval_num_arg(data, size, event, arg->symbol.field); | 3967 | val = eval_num_arg(data, size, event, arg->symbol.field); |
| 3967 | for (flag = arg->symbol.symbols; flag; flag = flag->next) { | 3968 | for (flag = arg->symbol.symbols; flag; flag = flag->next) { |
| 3968 | fval = eval_flag(flag->value); | 3969 | fval = eval_flag(flag->value); |
| @@ -3974,9 +3975,9 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 3974 | if (!flag) | 3975 | if (!flag) |
| 3975 | trace_seq_printf(s, "0x%llx", val); | 3976 | trace_seq_printf(s, "0x%llx", val); |
| 3976 | break; | 3977 | break; |
| 3977 | case PRINT_HEX: | 3978 | case TEP_PRINT_HEX: |
| 3978 | case PRINT_HEX_STR: | 3979 | case TEP_PRINT_HEX_STR: |
| 3979 | if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { | 3980 | if (arg->hex.field->type == TEP_PRINT_DYNAMIC_ARRAY) { |
| 3980 | unsigned long offset; | 3981 | unsigned long offset; |
| 3981 | offset = tep_read_number(pevent, | 3982 | offset = tep_read_number(pevent, |
| 3982 | data + arg->hex.field->dynarray.field->offset, | 3983 | data + arg->hex.field->dynarray.field->offset, |
| @@ -3995,19 +3996,19 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 3995 | } | 3996 | } |
| 3996 | len = eval_num_arg(data, size, event, arg->hex.size); | 3997 | len = eval_num_arg(data, size, event, arg->hex.size); |
| 3997 | for (i = 0; i < len; i++) { | 3998 | for (i = 0; i < len; i++) { |
| 3998 | if (i && arg->type == PRINT_HEX) | 3999 | if (i && arg->type == TEP_PRINT_HEX) |
| 3999 | trace_seq_putc(s, ' '); | 4000 | trace_seq_putc(s, ' '); |
| 4000 | trace_seq_printf(s, "%02x", hex[i]); | 4001 | trace_seq_printf(s, "%02x", hex[i]); |
| 4001 | } | 4002 | } |
| 4002 | break; | 4003 | break; |
| 4003 | 4004 | ||
| 4004 | case PRINT_INT_ARRAY: { | 4005 | case TEP_PRINT_INT_ARRAY: { |
| 4005 | void *num; | 4006 | void *num; |
| 4006 | int el_size; | 4007 | int el_size; |
| 4007 | 4008 | ||
| 4008 | if (arg->int_array.field->type == PRINT_DYNAMIC_ARRAY) { | 4009 | if (arg->int_array.field->type == TEP_PRINT_DYNAMIC_ARRAY) { |
| 4009 | unsigned long offset; | 4010 | unsigned long offset; |
| 4010 | struct format_field *field = | 4011 | struct tep_format_field *field = |
| 4011 | arg->int_array.field->dynarray.field; | 4012 | arg->int_array.field->dynarray.field; |
| 4012 | offset = tep_read_number(pevent, | 4013 | offset = tep_read_number(pevent, |
| 4013 | data + field->offset, | 4014 | data + field->offset, |
| @@ -4049,43 +4050,43 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 4049 | } | 4050 | } |
| 4050 | break; | 4051 | break; |
| 4051 | } | 4052 | } |
| 4052 | case PRINT_TYPE: | 4053 | case TEP_PRINT_TYPE: |
| 4053 | break; | 4054 | break; |
| 4054 | case PRINT_STRING: { | 4055 | case TEP_PRINT_STRING: { |
| 4055 | int str_offset; | 4056 | int str_offset; |
| 4056 | 4057 | ||
| 4057 | if (arg->string.offset == -1) { | 4058 | if (arg->string.offset == -1) { |
| 4058 | struct format_field *f; | 4059 | struct tep_format_field *f; |
| 4059 | 4060 | ||
| 4060 | f = tep_find_any_field(event, arg->string.string); | 4061 | f = tep_find_any_field(event, arg->string.string); |
| 4061 | arg->string.offset = f->offset; | 4062 | arg->string.offset = f->offset; |
| 4062 | } | 4063 | } |
| 4063 | str_offset = data2host4(pevent, data + arg->string.offset); | 4064 | str_offset = tep_data2host4(pevent, data + arg->string.offset); |
| 4064 | str_offset &= 0xffff; | 4065 | str_offset &= 0xffff; |
| 4065 | print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset); | 4066 | print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset); |
| 4066 | break; | 4067 | break; |
| 4067 | } | 4068 | } |
| 4068 | case PRINT_BSTRING: | 4069 | case TEP_PRINT_BSTRING: |
| 4069 | print_str_to_seq(s, format, len_arg, arg->string.string); | 4070 | print_str_to_seq(s, format, len_arg, arg->string.string); |
| 4070 | break; | 4071 | break; |
| 4071 | case PRINT_BITMASK: { | 4072 | case TEP_PRINT_BITMASK: { |
| 4072 | int bitmask_offset; | 4073 | int bitmask_offset; |
| 4073 | int bitmask_size; | 4074 | int bitmask_size; |
| 4074 | 4075 | ||
| 4075 | if (arg->bitmask.offset == -1) { | 4076 | if (arg->bitmask.offset == -1) { |
| 4076 | struct format_field *f; | 4077 | struct tep_format_field *f; |
| 4077 | 4078 | ||
| 4078 | f = tep_find_any_field(event, arg->bitmask.bitmask); | 4079 | f = tep_find_any_field(event, arg->bitmask.bitmask); |
| 4079 | arg->bitmask.offset = f->offset; | 4080 | arg->bitmask.offset = f->offset; |
| 4080 | } | 4081 | } |
| 4081 | bitmask_offset = data2host4(pevent, data + arg->bitmask.offset); | 4082 | bitmask_offset = tep_data2host4(pevent, data + arg->bitmask.offset); |
| 4082 | bitmask_size = bitmask_offset >> 16; | 4083 | bitmask_size = bitmask_offset >> 16; |
| 4083 | bitmask_offset &= 0xffff; | 4084 | bitmask_offset &= 0xffff; |
| 4084 | print_bitmask_to_seq(pevent, s, format, len_arg, | 4085 | print_bitmask_to_seq(pevent, s, format, len_arg, |
| 4085 | data + bitmask_offset, bitmask_size); | 4086 | data + bitmask_offset, bitmask_size); |
| 4086 | break; | 4087 | break; |
| 4087 | } | 4088 | } |
| 4088 | case PRINT_OP: | 4089 | case TEP_PRINT_OP: |
| 4089 | /* | 4090 | /* |
| 4090 | * The only op for string should be ? : | 4091 | * The only op for string should be ? : |
| 4091 | */ | 4092 | */ |
| @@ -4099,7 +4100,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
| 4099 | print_str_arg(s, data, size, event, | 4100 | print_str_arg(s, data, size, event, |
| 4100 | format, len_arg, arg->op.right->op.right); | 4101 | format, len_arg, arg->op.right->op.right); |
| 4101 | break; | 4102 | break; |
| 4102 | case PRINT_FUNC: | 4103 | case TEP_PRINT_FUNC: |
| 4103 | process_defined_func(s, data, size, event, arg); | 4104 | process_defined_func(s, data, size, event, arg); |
| 4104 | break; | 4105 | break; |
| 4105 | default: | 4106 | default: |
| @@ -4116,13 +4117,13 @@ out_warning_field: | |||
| 4116 | 4117 | ||
| 4117 | static unsigned long long | 4118 | static unsigned long long |
| 4118 | process_defined_func(struct trace_seq *s, void *data, int size, | 4119 | process_defined_func(struct trace_seq *s, void *data, int size, |
| 4119 | struct event_format *event, struct print_arg *arg) | 4120 | struct tep_event_format *event, struct tep_print_arg *arg) |
| 4120 | { | 4121 | { |
| 4121 | struct tep_function_handler *func_handle = arg->func.func; | 4122 | struct tep_function_handler *func_handle = arg->func.func; |
| 4122 | struct func_params *param; | 4123 | struct func_params *param; |
| 4123 | unsigned long long *args; | 4124 | unsigned long long *args; |
| 4124 | unsigned long long ret; | 4125 | unsigned long long ret; |
| 4125 | struct print_arg *farg; | 4126 | struct tep_print_arg *farg; |
| 4126 | struct trace_seq str; | 4127 | struct trace_seq str; |
| 4127 | struct save_str { | 4128 | struct save_str { |
| 4128 | struct save_str *next; | 4129 | struct save_str *next; |
| @@ -4199,9 +4200,9 @@ out_free: | |||
| 4199 | return ret; | 4200 | return ret; |
| 4200 | } | 4201 | } |
| 4201 | 4202 | ||
| 4202 | static void free_args(struct print_arg *args) | 4203 | static void free_args(struct tep_print_arg *args) |
| 4203 | { | 4204 | { |
| 4204 | struct print_arg *next; | 4205 | struct tep_print_arg *next; |
| 4205 | 4206 | ||
| 4206 | while (args) { | 4207 | while (args) { |
| 4207 | next = args->next; | 4208 | next = args->next; |
| @@ -4211,11 +4212,11 @@ static void free_args(struct print_arg *args) | |||
| 4211 | } | 4212 | } |
| 4212 | } | 4213 | } |
| 4213 | 4214 | ||
| 4214 | static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struct event_format *event) | 4215 | static struct tep_print_arg *make_bprint_args(char *fmt, void *data, int size, struct tep_event_format *event) |
| 4215 | { | 4216 | { |
| 4216 | struct tep_handle *pevent = event->pevent; | 4217 | struct tep_handle *pevent = event->pevent; |
| 4217 | struct format_field *field, *ip_field; | 4218 | struct tep_format_field *field, *ip_field; |
| 4218 | struct print_arg *args, *arg, **next; | 4219 | struct tep_print_arg *args, *arg, **next; |
| 4219 | unsigned long long ip, val; | 4220 | unsigned long long ip, val; |
| 4220 | char *ptr; | 4221 | char *ptr; |
| 4221 | void *bptr; | 4222 | void *bptr; |
| @@ -4254,7 +4255,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
| 4254 | arg->next = NULL; | 4255 | arg->next = NULL; |
| 4255 | next = &arg->next; | 4256 | next = &arg->next; |
| 4256 | 4257 | ||
| 4257 | arg->type = PRINT_ATOM; | 4258 | arg->type = TEP_PRINT_ATOM; |
| 4258 | 4259 | ||
| 4259 | if (asprintf(&arg->atom.atom, "%lld", ip) < 0) | 4260 | if (asprintf(&arg->atom.atom, "%lld", ip) < 0) |
| 4260 | goto out_free; | 4261 | goto out_free; |
| @@ -4342,7 +4343,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
| 4342 | goto out_free; | 4343 | goto out_free; |
| 4343 | } | 4344 | } |
| 4344 | arg->next = NULL; | 4345 | arg->next = NULL; |
| 4345 | arg->type = PRINT_ATOM; | 4346 | arg->type = TEP_PRINT_ATOM; |
| 4346 | if (asprintf(&arg->atom.atom, "%lld", val) < 0) { | 4347 | if (asprintf(&arg->atom.atom, "%lld", val) < 0) { |
| 4347 | free(arg); | 4348 | free(arg); |
| 4348 | goto out_free; | 4349 | goto out_free; |
| @@ -4366,7 +4367,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
| 4366 | goto out_free; | 4367 | goto out_free; |
| 4367 | } | 4368 | } |
| 4368 | arg->next = NULL; | 4369 | arg->next = NULL; |
| 4369 | arg->type = PRINT_BSTRING; | 4370 | arg->type = TEP_PRINT_BSTRING; |
| 4370 | arg->string.string = strdup(bptr); | 4371 | arg->string.string = strdup(bptr); |
| 4371 | if (!arg->string.string) | 4372 | if (!arg->string.string) |
| 4372 | goto out_free; | 4373 | goto out_free; |
| @@ -4388,11 +4389,11 @@ out_free: | |||
| 4388 | 4389 | ||
| 4389 | static char * | 4390 | static char * |
| 4390 | get_bprint_format(void *data, int size __maybe_unused, | 4391 | get_bprint_format(void *data, int size __maybe_unused, |
| 4391 | struct event_format *event) | 4392 | struct tep_event_format *event) |
| 4392 | { | 4393 | { |
| 4393 | struct tep_handle *pevent = event->pevent; | 4394 | struct tep_handle *pevent = event->pevent; |
| 4394 | unsigned long long addr; | 4395 | unsigned long long addr; |
| 4395 | struct format_field *field; | 4396 | struct tep_format_field *field; |
| 4396 | struct printk_map *printk; | 4397 | struct printk_map *printk; |
| 4397 | char *format; | 4398 | char *format; |
| 4398 | 4399 | ||
| @@ -4423,17 +4424,17 @@ get_bprint_format(void *data, int size __maybe_unused, | |||
| 4423 | } | 4424 | } |
| 4424 | 4425 | ||
| 4425 | static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size, | 4426 | static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size, |
| 4426 | struct event_format *event, struct print_arg *arg) | 4427 | struct tep_event_format *event, struct tep_print_arg *arg) |
| 4427 | { | 4428 | { |
| 4428 | unsigned char *buf; | 4429 | unsigned char *buf; |
| 4429 | const char *fmt = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x"; | 4430 | const char *fmt = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x"; |
| 4430 | 4431 | ||
| 4431 | if (arg->type == PRINT_FUNC) { | 4432 | if (arg->type == TEP_PRINT_FUNC) { |
| 4432 | process_defined_func(s, data, size, event, arg); | 4433 | process_defined_func(s, data, size, event, arg); |
| 4433 | return; | 4434 | return; |
| 4434 | } | 4435 | } |
| 4435 | 4436 | ||
| 4436 | if (arg->type != PRINT_FIELD) { | 4437 | if (arg->type != TEP_PRINT_FIELD) { |
| 4437 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", | 4438 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", |
| 4438 | arg->type); | 4439 | arg->type); |
| 4439 | return; | 4440 | return; |
| @@ -4576,17 +4577,17 @@ static void print_ip6_addr(struct trace_seq *s, char i, unsigned char *buf) | |||
| 4576 | * %pISpc print an IP address based on sockaddr; p adds port. | 4577 | * %pISpc print an IP address based on sockaddr; p adds port. |
| 4577 | */ | 4578 | */ |
| 4578 | static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i, | 4579 | static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i, |
| 4579 | void *data, int size, struct event_format *event, | 4580 | void *data, int size, struct tep_event_format *event, |
| 4580 | struct print_arg *arg) | 4581 | struct tep_print_arg *arg) |
| 4581 | { | 4582 | { |
| 4582 | unsigned char *buf; | 4583 | unsigned char *buf; |
| 4583 | 4584 | ||
| 4584 | if (arg->type == PRINT_FUNC) { | 4585 | if (arg->type == TEP_PRINT_FUNC) { |
| 4585 | process_defined_func(s, data, size, event, arg); | 4586 | process_defined_func(s, data, size, event, arg); |
| 4586 | return 0; | 4587 | return 0; |
| 4587 | } | 4588 | } |
| 4588 | 4589 | ||
| 4589 | if (arg->type != PRINT_FIELD) { | 4590 | if (arg->type != TEP_PRINT_FIELD) { |
| 4590 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", arg->type); | 4591 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", arg->type); |
| 4591 | return 0; | 4592 | return 0; |
| 4592 | } | 4593 | } |
| @@ -4613,8 +4614,8 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i, | |||
| 4613 | } | 4614 | } |
| 4614 | 4615 | ||
| 4615 | static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i, | 4616 | static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i, |
| 4616 | void *data, int size, struct event_format *event, | 4617 | void *data, int size, struct tep_event_format *event, |
| 4617 | struct print_arg *arg) | 4618 | struct tep_print_arg *arg) |
| 4618 | { | 4619 | { |
| 4619 | char have_c = 0; | 4620 | char have_c = 0; |
| 4620 | unsigned char *buf; | 4621 | unsigned char *buf; |
| @@ -4627,12 +4628,12 @@ static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i, | |||
| 4627 | rc++; | 4628 | rc++; |
| 4628 | } | 4629 | } |
| 4629 | 4630 | ||
| 4630 | if (arg->type == PRINT_FUNC) { | 4631 | if (arg->type == TEP_PRINT_FUNC) { |
| 4631 | process_defined_func(s, data, size, event, arg); | 4632 | process_defined_func(s, data, size, event, arg); |
| 4632 | return rc; | 4633 | return rc; |
| 4633 | } | 4634 | } |
| 4634 | 4635 | ||
| 4635 | if (arg->type != PRINT_FIELD) { | 4636 | if (arg->type != TEP_PRINT_FIELD) { |
| 4636 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", arg->type); | 4637 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", arg->type); |
| 4637 | return rc; | 4638 | return rc; |
| 4638 | } | 4639 | } |
| @@ -4663,8 +4664,8 @@ static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i, | |||
| 4663 | } | 4664 | } |
| 4664 | 4665 | ||
| 4665 | static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, | 4666 | static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, |
| 4666 | void *data, int size, struct event_format *event, | 4667 | void *data, int size, struct tep_event_format *event, |
| 4667 | struct print_arg *arg) | 4668 | struct tep_print_arg *arg) |
| 4668 | { | 4669 | { |
| 4669 | char have_c = 0, have_p = 0; | 4670 | char have_c = 0, have_p = 0; |
| 4670 | unsigned char *buf; | 4671 | unsigned char *buf; |
| @@ -4685,12 +4686,12 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, | |||
| 4685 | } | 4686 | } |
| 4686 | } | 4687 | } |
| 4687 | 4688 | ||
| 4688 | if (arg->type == PRINT_FUNC) { | 4689 | if (arg->type == TEP_PRINT_FUNC) { |
| 4689 | process_defined_func(s, data, size, event, arg); | 4690 | process_defined_func(s, data, size, event, arg); |
| 4690 | return rc; | 4691 | return rc; |
| 4691 | } | 4692 | } |
| 4692 | 4693 | ||
| 4693 | if (arg->type != PRINT_FIELD) { | 4694 | if (arg->type != TEP_PRINT_FIELD) { |
| 4694 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", arg->type); | 4695 | trace_seq_printf(s, "ARG TYPE NOT FIELD BUT %d", arg->type); |
| 4695 | return rc; | 4696 | return rc; |
| 4696 | } | 4697 | } |
| @@ -4745,8 +4746,8 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, | |||
| 4745 | } | 4746 | } |
| 4746 | 4747 | ||
| 4747 | static int print_ip_arg(struct trace_seq *s, const char *ptr, | 4748 | static int print_ip_arg(struct trace_seq *s, const char *ptr, |
| 4748 | void *data, int size, struct event_format *event, | 4749 | void *data, int size, struct tep_event_format *event, |
| 4749 | struct print_arg *arg) | 4750 | struct tep_print_arg *arg) |
| 4750 | { | 4751 | { |
| 4751 | char i = *ptr; /* 'i' or 'I' */ | 4752 | char i = *ptr; /* 'i' or 'I' */ |
| 4752 | char ver; | 4753 | char ver; |
| @@ -4787,22 +4788,22 @@ static int is_printable_array(char *p, unsigned int len) | |||
| 4787 | } | 4788 | } |
| 4788 | 4789 | ||
| 4789 | void tep_print_field(struct trace_seq *s, void *data, | 4790 | void tep_print_field(struct trace_seq *s, void *data, |
| 4790 | struct format_field *field) | 4791 | struct tep_format_field *field) |
| 4791 | { | 4792 | { |
| 4792 | unsigned long long val; | 4793 | unsigned long long val; |
| 4793 | unsigned int offset, len, i; | 4794 | unsigned int offset, len, i; |
| 4794 | struct tep_handle *pevent = field->event->pevent; | 4795 | struct tep_handle *pevent = field->event->pevent; |
| 4795 | 4796 | ||
| 4796 | if (field->flags & FIELD_IS_ARRAY) { | 4797 | if (field->flags & TEP_FIELD_IS_ARRAY) { |
| 4797 | offset = field->offset; | 4798 | offset = field->offset; |
| 4798 | len = field->size; | 4799 | len = field->size; |
| 4799 | if (field->flags & FIELD_IS_DYNAMIC) { | 4800 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 4800 | val = tep_read_number(pevent, data + offset, len); | 4801 | val = tep_read_number(pevent, data + offset, len); |
| 4801 | offset = val; | 4802 | offset = val; |
| 4802 | len = offset >> 16; | 4803 | len = offset >> 16; |
| 4803 | offset &= 0xffff; | 4804 | offset &= 0xffff; |
| 4804 | } | 4805 | } |
| 4805 | if (field->flags & FIELD_IS_STRING && | 4806 | if (field->flags & TEP_FIELD_IS_STRING && |
| 4806 | is_printable_array(data + offset, len)) { | 4807 | is_printable_array(data + offset, len)) { |
| 4807 | trace_seq_printf(s, "%s", (char *)data + offset); | 4808 | trace_seq_printf(s, "%s", (char *)data + offset); |
| 4808 | } else { | 4809 | } else { |
| @@ -4814,21 +4815,21 @@ void tep_print_field(struct trace_seq *s, void *data, | |||
| 4814 | *((unsigned char *)data + offset + i)); | 4815 | *((unsigned char *)data + offset + i)); |
| 4815 | } | 4816 | } |
| 4816 | trace_seq_putc(s, ']'); | 4817 | trace_seq_putc(s, ']'); |
| 4817 | field->flags &= ~FIELD_IS_STRING; | 4818 | field->flags &= ~TEP_FIELD_IS_STRING; |
| 4818 | } | 4819 | } |
| 4819 | } else { | 4820 | } else { |
| 4820 | val = tep_read_number(pevent, data + field->offset, | 4821 | val = tep_read_number(pevent, data + field->offset, |
| 4821 | field->size); | 4822 | field->size); |
| 4822 | if (field->flags & FIELD_IS_POINTER) { | 4823 | if (field->flags & TEP_FIELD_IS_POINTER) { |
| 4823 | trace_seq_printf(s, "0x%llx", val); | 4824 | trace_seq_printf(s, "0x%llx", val); |
| 4824 | } else if (field->flags & FIELD_IS_SIGNED) { | 4825 | } else if (field->flags & TEP_FIELD_IS_SIGNED) { |
| 4825 | switch (field->size) { | 4826 | switch (field->size) { |
| 4826 | case 4: | 4827 | case 4: |
| 4827 | /* | 4828 | /* |
| 4828 | * If field is long then print it in hex. | 4829 | * If field is long then print it in hex. |
| 4829 | * A long usually stores pointers. | 4830 | * A long usually stores pointers. |
| 4830 | */ | 4831 | */ |
| 4831 | if (field->flags & FIELD_IS_LONG) | 4832 | if (field->flags & TEP_FIELD_IS_LONG) |
| 4832 | trace_seq_printf(s, "0x%x", (int)val); | 4833 | trace_seq_printf(s, "0x%x", (int)val); |
| 4833 | else | 4834 | else |
| 4834 | trace_seq_printf(s, "%d", (int)val); | 4835 | trace_seq_printf(s, "%d", (int)val); |
| @@ -4843,7 +4844,7 @@ void tep_print_field(struct trace_seq *s, void *data, | |||
| 4843 | trace_seq_printf(s, "%lld", val); | 4844 | trace_seq_printf(s, "%lld", val); |
| 4844 | } | 4845 | } |
| 4845 | } else { | 4846 | } else { |
| 4846 | if (field->flags & FIELD_IS_LONG) | 4847 | if (field->flags & TEP_FIELD_IS_LONG) |
| 4847 | trace_seq_printf(s, "0x%llx", val); | 4848 | trace_seq_printf(s, "0x%llx", val); |
| 4848 | else | 4849 | else |
| 4849 | trace_seq_printf(s, "%llu", val); | 4850 | trace_seq_printf(s, "%llu", val); |
| @@ -4852,9 +4853,9 @@ void tep_print_field(struct trace_seq *s, void *data, | |||
| 4852 | } | 4853 | } |
| 4853 | 4854 | ||
| 4854 | void tep_print_fields(struct trace_seq *s, void *data, | 4855 | void tep_print_fields(struct trace_seq *s, void *data, |
| 4855 | int size __maybe_unused, struct event_format *event) | 4856 | int size __maybe_unused, struct tep_event_format *event) |
| 4856 | { | 4857 | { |
| 4857 | struct format_field *field; | 4858 | struct tep_format_field *field; |
| 4858 | 4859 | ||
| 4859 | field = event->format.fields; | 4860 | field = event->format.fields; |
| 4860 | while (field) { | 4861 | while (field) { |
| @@ -4864,12 +4865,12 @@ void tep_print_fields(struct trace_seq *s, void *data, | |||
| 4864 | } | 4865 | } |
| 4865 | } | 4866 | } |
| 4866 | 4867 | ||
| 4867 | static void pretty_print(struct trace_seq *s, void *data, int size, struct event_format *event) | 4868 | static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_event_format *event) |
| 4868 | { | 4869 | { |
| 4869 | struct tep_handle *pevent = event->pevent; | 4870 | struct tep_handle *pevent = event->pevent; |
| 4870 | struct print_fmt *print_fmt = &event->print_fmt; | 4871 | struct tep_print_fmt *print_fmt = &event->print_fmt; |
| 4871 | struct print_arg *arg = print_fmt->args; | 4872 | struct tep_print_arg *arg = print_fmt->args; |
| 4872 | struct print_arg *args = NULL; | 4873 | struct tep_print_arg *args = NULL; |
| 4873 | const char *ptr = print_fmt->format; | 4874 | const char *ptr = print_fmt->format; |
| 4874 | unsigned long long val; | 4875 | unsigned long long val; |
| 4875 | struct func_map *func; | 4876 | struct func_map *func; |
| @@ -4883,13 +4884,13 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 4883 | int len; | 4884 | int len; |
| 4884 | int ls; | 4885 | int ls; |
| 4885 | 4886 | ||
| 4886 | if (event->flags & EVENT_FL_FAILED) { | 4887 | if (event->flags & TEP_EVENT_FL_FAILED) { |
| 4887 | trace_seq_printf(s, "[FAILED TO PARSE]"); | 4888 | trace_seq_printf(s, "[FAILED TO PARSE]"); |
| 4888 | tep_print_fields(s, data, size, event); | 4889 | tep_print_fields(s, data, size, event); |
| 4889 | return; | 4890 | return; |
| 4890 | } | 4891 | } |
| 4891 | 4892 | ||
| 4892 | if (event->flags & EVENT_FL_ISBPRINT) { | 4893 | if (event->flags & TEP_EVENT_FL_ISBPRINT) { |
| 4893 | bprint_fmt = get_bprint_format(data, size, event); | 4894 | bprint_fmt = get_bprint_format(data, size, event); |
| 4894 | args = make_bprint_args(bprint_fmt, data, size, event); | 4895 | args = make_bprint_args(bprint_fmt, data, size, event); |
| 4895 | arg = args; | 4896 | arg = args; |
| @@ -4944,7 +4945,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 4944 | /* The argument is the length. */ | 4945 | /* The argument is the length. */ |
| 4945 | if (!arg) { | 4946 | if (!arg) { |
| 4946 | do_warning_event(event, "no argument match"); | 4947 | do_warning_event(event, "no argument match"); |
| 4947 | event->flags |= EVENT_FL_FAILED; | 4948 | event->flags |= TEP_EVENT_FL_FAILED; |
| 4948 | goto out_failed; | 4949 | goto out_failed; |
| 4949 | } | 4950 | } |
| 4950 | len_arg = eval_num_arg(data, size, event, arg); | 4951 | len_arg = eval_num_arg(data, size, event, arg); |
| @@ -4966,7 +4967,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 4966 | if (isalnum(ptr[1])) | 4967 | if (isalnum(ptr[1])) |
| 4967 | ptr++; | 4968 | ptr++; |
| 4968 | 4969 | ||
| 4969 | if (arg->type == PRINT_BSTRING) { | 4970 | if (arg->type == TEP_PRINT_BSTRING) { |
| 4970 | trace_seq_puts(s, arg->string.string); | 4971 | trace_seq_puts(s, arg->string.string); |
| 4971 | break; | 4972 | break; |
| 4972 | } | 4973 | } |
| @@ -4997,7 +4998,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 4997 | case 'u': | 4998 | case 'u': |
| 4998 | if (!arg) { | 4999 | if (!arg) { |
| 4999 | do_warning_event(event, "no argument match"); | 5000 | do_warning_event(event, "no argument match"); |
| 5000 | event->flags |= EVENT_FL_FAILED; | 5001 | event->flags |= TEP_EVENT_FL_FAILED; |
| 5001 | goto out_failed; | 5002 | goto out_failed; |
| 5002 | } | 5003 | } |
| 5003 | 5004 | ||
| @@ -5007,7 +5008,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 5007 | /* should never happen */ | 5008 | /* should never happen */ |
| 5008 | if (len > 31) { | 5009 | if (len > 31) { |
| 5009 | do_warning_event(event, "bad format!"); | 5010 | do_warning_event(event, "bad format!"); |
| 5010 | event->flags |= EVENT_FL_FAILED; | 5011 | event->flags |= TEP_EVENT_FL_FAILED; |
| 5011 | len = 31; | 5012 | len = 31; |
| 5012 | } | 5013 | } |
| 5013 | 5014 | ||
| @@ -5073,13 +5074,13 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 5073 | break; | 5074 | break; |
| 5074 | default: | 5075 | default: |
| 5075 | do_warning_event(event, "bad count (%d)", ls); | 5076 | do_warning_event(event, "bad count (%d)", ls); |
| 5076 | event->flags |= EVENT_FL_FAILED; | 5077 | event->flags |= TEP_EVENT_FL_FAILED; |
| 5077 | } | 5078 | } |
| 5078 | break; | 5079 | break; |
| 5079 | case 's': | 5080 | case 's': |
| 5080 | if (!arg) { | 5081 | if (!arg) { |
| 5081 | do_warning_event(event, "no matching argument"); | 5082 | do_warning_event(event, "no matching argument"); |
| 5082 | event->flags |= EVENT_FL_FAILED; | 5083 | event->flags |= TEP_EVENT_FL_FAILED; |
| 5083 | goto out_failed; | 5084 | goto out_failed; |
| 5084 | } | 5085 | } |
| 5085 | 5086 | ||
| @@ -5089,7 +5090,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 5089 | /* should never happen */ | 5090 | /* should never happen */ |
| 5090 | if (len > 31) { | 5091 | if (len > 31) { |
| 5091 | do_warning_event(event, "bad format!"); | 5092 | do_warning_event(event, "bad format!"); |
| 5092 | event->flags |= EVENT_FL_FAILED; | 5093 | event->flags |= TEP_EVENT_FL_FAILED; |
| 5093 | len = 31; | 5094 | len = 31; |
| 5094 | } | 5095 | } |
| 5095 | 5096 | ||
| @@ -5114,7 +5115,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 5114 | trace_seq_putc(s, *ptr); | 5115 | trace_seq_putc(s, *ptr); |
| 5115 | } | 5116 | } |
| 5116 | 5117 | ||
| 5117 | if (event->flags & EVENT_FL_FAILED) { | 5118 | if (event->flags & TEP_EVENT_FL_FAILED) { |
| 5118 | out_failed: | 5119 | out_failed: |
| 5119 | trace_seq_printf(s, "[FAILED TO PARSE]"); | 5120 | trace_seq_printf(s, "[FAILED TO PARSE]"); |
| 5120 | } | 5121 | } |
| @@ -5227,7 +5228,7 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec) | |||
| 5227 | * | 5228 | * |
| 5228 | * This returns the event form a given @type; | 5229 | * This returns the event form a given @type; |
| 5229 | */ | 5230 | */ |
| 5230 | struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type) | 5231 | struct tep_event_format *tep_data_event_from_type(struct tep_handle *pevent, int type) |
| 5231 | { | 5232 | { |
| 5232 | return tep_find_event(pevent, type); | 5233 | return tep_find_event(pevent, type); |
| 5233 | } | 5234 | } |
| @@ -5385,16 +5386,16 @@ int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) | |||
| 5385 | * This parses the raw @data using the given @event information and | 5386 | * This parses the raw @data using the given @event information and |
| 5386 | * writes the print format into the trace_seq. | 5387 | * writes the print format into the trace_seq. |
| 5387 | */ | 5388 | */ |
| 5388 | void tep_event_info(struct trace_seq *s, struct event_format *event, | 5389 | void tep_event_info(struct trace_seq *s, struct tep_event_format *event, |
| 5389 | struct tep_record *record) | 5390 | struct tep_record *record) |
| 5390 | { | 5391 | { |
| 5391 | int print_pretty = 1; | 5392 | int print_pretty = 1; |
| 5392 | 5393 | ||
| 5393 | if (event->pevent->print_raw || (event->flags & EVENT_FL_PRINTRAW)) | 5394 | if (event->pevent->print_raw || (event->flags & TEP_EVENT_FL_PRINTRAW)) |
| 5394 | tep_print_fields(s, record->data, record->size, event); | 5395 | tep_print_fields(s, record->data, record->size, event); |
| 5395 | else { | 5396 | else { |
| 5396 | 5397 | ||
| 5397 | if (event->handler && !(event->flags & EVENT_FL_NOHANDLE)) | 5398 | if (event->handler && !(event->flags & TEP_EVENT_FL_NOHANDLE)) |
| 5398 | print_pretty = event->handler(s, record, event, | 5399 | print_pretty = event->handler(s, record, event, |
| 5399 | event->context); | 5400 | event->context); |
| 5400 | 5401 | ||
| @@ -5426,7 +5427,7 @@ static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) | |||
| 5426 | * Returns the associated event for a given record, or NULL if non is | 5427 | * Returns the associated event for a given record, or NULL if non is |
| 5427 | * is found. | 5428 | * is found. |
| 5428 | */ | 5429 | */ |
| 5429 | struct event_format * | 5430 | struct tep_event_format * |
| 5430 | tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record) | 5431 | tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record) |
| 5431 | { | 5432 | { |
| 5432 | int type; | 5433 | int type; |
| @@ -5451,7 +5452,7 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record) | |||
| 5451 | * Writes the tasks comm, pid and CPU to @s. | 5452 | * Writes the tasks comm, pid and CPU to @s. |
| 5452 | */ | 5453 | */ |
| 5453 | void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, | 5454 | void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, |
| 5454 | struct event_format *event, | 5455 | struct tep_event_format *event, |
| 5455 | struct tep_record *record) | 5456 | struct tep_record *record) |
| 5456 | { | 5457 | { |
| 5457 | void *data = record->data; | 5458 | void *data = record->data; |
| @@ -5479,7 +5480,7 @@ void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, | |||
| 5479 | * Writes the timestamp of the record into @s. | 5480 | * Writes the timestamp of the record into @s. |
| 5480 | */ | 5481 | */ |
| 5481 | void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, | 5482 | void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, |
| 5482 | struct event_format *event, | 5483 | struct tep_event_format *event, |
| 5483 | struct tep_record *record, | 5484 | struct tep_record *record, |
| 5484 | bool use_trace_clock) | 5485 | bool use_trace_clock) |
| 5485 | { | 5486 | { |
| @@ -5529,7 +5530,7 @@ void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, | |||
| 5529 | * Writes the parsing of the record's data to @s. | 5530 | * Writes the parsing of the record's data to @s. |
| 5530 | */ | 5531 | */ |
| 5531 | void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, | 5532 | void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, |
| 5532 | struct event_format *event, | 5533 | struct tep_event_format *event, |
| 5533 | struct tep_record *record) | 5534 | struct tep_record *record) |
| 5534 | { | 5535 | { |
| 5535 | static const char *spaces = " "; /* 20 spaces */ | 5536 | static const char *spaces = " "; /* 20 spaces */ |
| @@ -5548,7 +5549,7 @@ void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, | |||
| 5548 | void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, | 5549 | void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, |
| 5549 | struct tep_record *record, bool use_trace_clock) | 5550 | struct tep_record *record, bool use_trace_clock) |
| 5550 | { | 5551 | { |
| 5551 | struct event_format *event; | 5552 | struct tep_event_format *event; |
| 5552 | 5553 | ||
| 5553 | event = tep_find_event_by_record(pevent, record); | 5554 | event = tep_find_event_by_record(pevent, record); |
| 5554 | if (!event) { | 5555 | if (!event) { |
| @@ -5570,8 +5571,8 @@ void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, | |||
| 5570 | 5571 | ||
| 5571 | static int events_id_cmp(const void *a, const void *b) | 5572 | static int events_id_cmp(const void *a, const void *b) |
| 5572 | { | 5573 | { |
| 5573 | struct event_format * const * ea = a; | 5574 | struct tep_event_format * const * ea = a; |
| 5574 | struct event_format * const * eb = b; | 5575 | struct tep_event_format * const * eb = b; |
| 5575 | 5576 | ||
| 5576 | if ((*ea)->id < (*eb)->id) | 5577 | if ((*ea)->id < (*eb)->id) |
| 5577 | return -1; | 5578 | return -1; |
| @@ -5584,8 +5585,8 @@ static int events_id_cmp(const void *a, const void *b) | |||
| 5584 | 5585 | ||
| 5585 | static int events_name_cmp(const void *a, const void *b) | 5586 | static int events_name_cmp(const void *a, const void *b) |
| 5586 | { | 5587 | { |
| 5587 | struct event_format * const * ea = a; | 5588 | struct tep_event_format * const * ea = a; |
| 5588 | struct event_format * const * eb = b; | 5589 | struct tep_event_format * const * eb = b; |
| 5589 | int res; | 5590 | int res; |
| 5590 | 5591 | ||
| 5591 | res = strcmp((*ea)->name, (*eb)->name); | 5592 | res = strcmp((*ea)->name, (*eb)->name); |
| @@ -5601,8 +5602,8 @@ static int events_name_cmp(const void *a, const void *b) | |||
| 5601 | 5602 | ||
| 5602 | static int events_system_cmp(const void *a, const void *b) | 5603 | static int events_system_cmp(const void *a, const void *b) |
| 5603 | { | 5604 | { |
| 5604 | struct event_format * const * ea = a; | 5605 | struct tep_event_format * const * ea = a; |
| 5605 | struct event_format * const * eb = b; | 5606 | struct tep_event_format * const * eb = b; |
| 5606 | int res; | 5607 | int res; |
| 5607 | 5608 | ||
| 5608 | res = strcmp((*ea)->system, (*eb)->system); | 5609 | res = strcmp((*ea)->system, (*eb)->system); |
| @@ -5616,9 +5617,9 @@ static int events_system_cmp(const void *a, const void *b) | |||
| 5616 | return events_id_cmp(a, b); | 5617 | return events_id_cmp(a, b); |
| 5617 | } | 5618 | } |
| 5618 | 5619 | ||
| 5619 | struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type sort_type) | 5620 | struct tep_event_format **tep_list_events(struct tep_handle *pevent, enum tep_event_sort_type sort_type) |
| 5620 | { | 5621 | { |
| 5621 | struct event_format **events; | 5622 | struct tep_event_format **events; |
| 5622 | int (*sort)(const void *a, const void *b); | 5623 | int (*sort)(const void *a, const void *b); |
| 5623 | 5624 | ||
| 5624 | events = pevent->sort_events; | 5625 | events = pevent->sort_events; |
| @@ -5637,20 +5638,20 @@ struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort | |||
| 5637 | pevent->sort_events = events; | 5638 | pevent->sort_events = events; |
| 5638 | 5639 | ||
| 5639 | /* the internal events are sorted by id */ | 5640 | /* the internal events are sorted by id */ |
| 5640 | if (sort_type == EVENT_SORT_ID) { | 5641 | if (sort_type == TEP_EVENT_SORT_ID) { |
| 5641 | pevent->last_type = sort_type; | 5642 | pevent->last_type = sort_type; |
| 5642 | return events; | 5643 | return events; |
| 5643 | } | 5644 | } |
| 5644 | } | 5645 | } |
| 5645 | 5646 | ||
| 5646 | switch (sort_type) { | 5647 | switch (sort_type) { |
| 5647 | case EVENT_SORT_ID: | 5648 | case TEP_EVENT_SORT_ID: |
| 5648 | sort = events_id_cmp; | 5649 | sort = events_id_cmp; |
| 5649 | break; | 5650 | break; |
| 5650 | case EVENT_SORT_NAME: | 5651 | case TEP_EVENT_SORT_NAME: |
| 5651 | sort = events_name_cmp; | 5652 | sort = events_name_cmp; |
| 5652 | break; | 5653 | break; |
| 5653 | case EVENT_SORT_SYSTEM: | 5654 | case TEP_EVENT_SORT_SYSTEM: |
| 5654 | sort = events_system_cmp; | 5655 | sort = events_system_cmp; |
| 5655 | break; | 5656 | break; |
| 5656 | default: | 5657 | default: |
| @@ -5663,12 +5664,12 @@ struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort | |||
| 5663 | return events; | 5664 | return events; |
| 5664 | } | 5665 | } |
| 5665 | 5666 | ||
| 5666 | static struct format_field ** | 5667 | static struct tep_format_field ** |
| 5667 | get_event_fields(const char *type, const char *name, | 5668 | get_event_fields(const char *type, const char *name, |
| 5668 | int count, struct format_field *list) | 5669 | int count, struct tep_format_field *list) |
| 5669 | { | 5670 | { |
| 5670 | struct format_field **fields; | 5671 | struct tep_format_field **fields; |
| 5671 | struct format_field *field; | 5672 | struct tep_format_field *field; |
| 5672 | int i = 0; | 5673 | int i = 0; |
| 5673 | 5674 | ||
| 5674 | fields = malloc(sizeof(*fields) * (count + 1)); | 5675 | fields = malloc(sizeof(*fields) * (count + 1)); |
| @@ -5701,7 +5702,7 @@ get_event_fields(const char *type, const char *name, | |||
| 5701 | * Returns an allocated array of fields. The last item in the array is NULL. | 5702 | * Returns an allocated array of fields. The last item in the array is NULL. |
| 5702 | * The array must be freed with free(). | 5703 | * The array must be freed with free(). |
| 5703 | */ | 5704 | */ |
| 5704 | struct format_field **tep_event_common_fields(struct event_format *event) | 5705 | struct tep_format_field **tep_event_common_fields(struct tep_event_format *event) |
| 5705 | { | 5706 | { |
| 5706 | return get_event_fields("common", event->name, | 5707 | return get_event_fields("common", event->name, |
| 5707 | event->format.nr_common, | 5708 | event->format.nr_common, |
| @@ -5715,14 +5716,14 @@ struct format_field **tep_event_common_fields(struct event_format *event) | |||
| 5715 | * Returns an allocated array of fields. The last item in the array is NULL. | 5716 | * Returns an allocated array of fields. The last item in the array is NULL. |
| 5716 | * The array must be freed with free(). | 5717 | * The array must be freed with free(). |
| 5717 | */ | 5718 | */ |
| 5718 | struct format_field **tep_event_fields(struct event_format *event) | 5719 | struct tep_format_field **tep_event_fields(struct tep_event_format *event) |
| 5719 | { | 5720 | { |
| 5720 | return get_event_fields("event", event->name, | 5721 | return get_event_fields("event", event->name, |
| 5721 | event->format.nr_fields, | 5722 | event->format.nr_fields, |
| 5722 | event->format.fields); | 5723 | event->format.fields); |
| 5723 | } | 5724 | } |
| 5724 | 5725 | ||
| 5725 | static void print_fields(struct trace_seq *s, struct print_flag_sym *field) | 5726 | static void print_fields(struct trace_seq *s, struct tep_print_flag_sym *field) |
| 5726 | { | 5727 | { |
| 5727 | trace_seq_printf(s, "{ %s, %s }", field->value, field->str); | 5728 | trace_seq_printf(s, "{ %s, %s }", field->value, field->str); |
| 5728 | if (field->next) { | 5729 | if (field->next) { |
| @@ -5732,22 +5733,22 @@ static void print_fields(struct trace_seq *s, struct print_flag_sym *field) | |||
| 5732 | } | 5733 | } |
| 5733 | 5734 | ||
| 5734 | /* for debugging */ | 5735 | /* for debugging */ |
| 5735 | static void print_args(struct print_arg *args) | 5736 | static void print_args(struct tep_print_arg *args) |
| 5736 | { | 5737 | { |
| 5737 | int print_paren = 1; | 5738 | int print_paren = 1; |
| 5738 | struct trace_seq s; | 5739 | struct trace_seq s; |
| 5739 | 5740 | ||
| 5740 | switch (args->type) { | 5741 | switch (args->type) { |
| 5741 | case PRINT_NULL: | 5742 | case TEP_PRINT_NULL: |
| 5742 | printf("null"); | 5743 | printf("null"); |
| 5743 | break; | 5744 | break; |
| 5744 | case PRINT_ATOM: | 5745 | case TEP_PRINT_ATOM: |
| 5745 | printf("%s", args->atom.atom); | 5746 | printf("%s", args->atom.atom); |
| 5746 | break; | 5747 | break; |
| 5747 | case PRINT_FIELD: | 5748 | case TEP_PRINT_FIELD: |
| 5748 | printf("REC->%s", args->field.name); | 5749 | printf("REC->%s", args->field.name); |
| 5749 | break; | 5750 | break; |
| 5750 | case PRINT_FLAGS: | 5751 | case TEP_PRINT_FLAGS: |
| 5751 | printf("__print_flags("); | 5752 | printf("__print_flags("); |
| 5752 | print_args(args->flags.field); | 5753 | print_args(args->flags.field); |
| 5753 | printf(", %s, ", args->flags.delim); | 5754 | printf(", %s, ", args->flags.delim); |
| @@ -5757,7 +5758,7 @@ static void print_args(struct print_arg *args) | |||
| 5757 | trace_seq_destroy(&s); | 5758 | trace_seq_destroy(&s); |
| 5758 | printf(")"); | 5759 | printf(")"); |
| 5759 | break; | 5760 | break; |
| 5760 | case PRINT_SYMBOL: | 5761 | case TEP_PRINT_SYMBOL: |
| 5761 | printf("__print_symbolic("); | 5762 | printf("__print_symbolic("); |
| 5762 | print_args(args->symbol.field); | 5763 | print_args(args->symbol.field); |
| 5763 | printf(", "); | 5764 | printf(", "); |
| @@ -5767,21 +5768,21 @@ static void print_args(struct print_arg *args) | |||
| 5767 | trace_seq_destroy(&s); | 5768 | trace_seq_destroy(&s); |
| 5768 | printf(")"); | 5769 | printf(")"); |
| 5769 | break; | 5770 | break; |
| 5770 | case PRINT_HEX: | 5771 | case TEP_PRINT_HEX: |
| 5771 | printf("__print_hex("); | 5772 | printf("__print_hex("); |
| 5772 | print_args(args->hex.field); | 5773 | print_args(args->hex.field); |
| 5773 | printf(", "); | 5774 | printf(", "); |
| 5774 | print_args(args->hex.size); | 5775 | print_args(args->hex.size); |
| 5775 | printf(")"); | 5776 | printf(")"); |
| 5776 | break; | 5777 | break; |
| 5777 | case PRINT_HEX_STR: | 5778 | case TEP_PRINT_HEX_STR: |
| 5778 | printf("__print_hex_str("); | 5779 | printf("__print_hex_str("); |
| 5779 | print_args(args->hex.field); | 5780 | print_args(args->hex.field); |
| 5780 | printf(", "); | 5781 | printf(", "); |
| 5781 | print_args(args->hex.size); | 5782 | print_args(args->hex.size); |
| 5782 | printf(")"); | 5783 | printf(")"); |
| 5783 | break; | 5784 | break; |
| 5784 | case PRINT_INT_ARRAY: | 5785 | case TEP_PRINT_INT_ARRAY: |
| 5785 | printf("__print_array("); | 5786 | printf("__print_array("); |
| 5786 | print_args(args->int_array.field); | 5787 | print_args(args->int_array.field); |
| 5787 | printf(", "); | 5788 | printf(", "); |
| @@ -5790,18 +5791,18 @@ static void print_args(struct print_arg *args) | |||
| 5790 | print_args(args->int_array.el_size); | 5791 | print_args(args->int_array.el_size); |
| 5791 | printf(")"); | 5792 | printf(")"); |
| 5792 | break; | 5793 | break; |
| 5793 | case PRINT_STRING: | 5794 | case TEP_PRINT_STRING: |
| 5794 | case PRINT_BSTRING: | 5795 | case TEP_PRINT_BSTRING: |
| 5795 | printf("__get_str(%s)", args->string.string); | 5796 | printf("__get_str(%s)", args->string.string); |
| 5796 | break; | 5797 | break; |
| 5797 | case PRINT_BITMASK: | 5798 | case TEP_PRINT_BITMASK: |
| 5798 | printf("__get_bitmask(%s)", args->bitmask.bitmask); | 5799 | printf("__get_bitmask(%s)", args->bitmask.bitmask); |
| 5799 | break; | 5800 | break; |
| 5800 | case PRINT_TYPE: | 5801 | case TEP_PRINT_TYPE: |
| 5801 | printf("(%s)", args->typecast.type); | 5802 | printf("(%s)", args->typecast.type); |
| 5802 | print_args(args->typecast.item); | 5803 | print_args(args->typecast.item); |
| 5803 | break; | 5804 | break; |
| 5804 | case PRINT_OP: | 5805 | case TEP_PRINT_OP: |
| 5805 | if (strcmp(args->op.op, ":") == 0) | 5806 | if (strcmp(args->op.op, ":") == 0) |
| 5806 | print_paren = 0; | 5807 | print_paren = 0; |
| 5807 | if (print_paren) | 5808 | if (print_paren) |
| @@ -5833,13 +5834,13 @@ static void parse_header_field(const char *field, | |||
| 5833 | save_input_buf_ptr = input_buf_ptr; | 5834 | save_input_buf_ptr = input_buf_ptr; |
| 5834 | save_input_buf_siz = input_buf_siz; | 5835 | save_input_buf_siz = input_buf_siz; |
| 5835 | 5836 | ||
| 5836 | if (read_expected(EVENT_ITEM, "field") < 0) | 5837 | if (read_expected(TEP_EVENT_ITEM, "field") < 0) |
| 5837 | return; | 5838 | return; |
| 5838 | if (read_expected(EVENT_OP, ":") < 0) | 5839 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 5839 | return; | 5840 | return; |
| 5840 | 5841 | ||
| 5841 | /* type */ | 5842 | /* type */ |
| 5842 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 5843 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 5843 | goto fail; | 5844 | goto fail; |
| 5844 | free_token(token); | 5845 | free_token(token); |
| 5845 | 5846 | ||
| @@ -5847,42 +5848,42 @@ static void parse_header_field(const char *field, | |||
| 5847 | * If this is not a mandatory field, then test it first. | 5848 | * If this is not a mandatory field, then test it first. |
| 5848 | */ | 5849 | */ |
| 5849 | if (mandatory) { | 5850 | if (mandatory) { |
| 5850 | if (read_expected(EVENT_ITEM, field) < 0) | 5851 | if (read_expected(TEP_EVENT_ITEM, field) < 0) |
| 5851 | return; | 5852 | return; |
| 5852 | } else { | 5853 | } else { |
| 5853 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 5854 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 5854 | goto fail; | 5855 | goto fail; |
| 5855 | if (strcmp(token, field) != 0) | 5856 | if (strcmp(token, field) != 0) |
| 5856 | goto discard; | 5857 | goto discard; |
| 5857 | free_token(token); | 5858 | free_token(token); |
| 5858 | } | 5859 | } |
| 5859 | 5860 | ||
| 5860 | if (read_expected(EVENT_OP, ";") < 0) | 5861 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 5861 | return; | 5862 | return; |
| 5862 | if (read_expected(EVENT_ITEM, "offset") < 0) | 5863 | if (read_expected(TEP_EVENT_ITEM, "offset") < 0) |
| 5863 | return; | 5864 | return; |
| 5864 | if (read_expected(EVENT_OP, ":") < 0) | 5865 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 5865 | return; | 5866 | return; |
| 5866 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 5867 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 5867 | goto fail; | 5868 | goto fail; |
| 5868 | *offset = atoi(token); | 5869 | *offset = atoi(token); |
| 5869 | free_token(token); | 5870 | free_token(token); |
| 5870 | if (read_expected(EVENT_OP, ";") < 0) | 5871 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 5871 | return; | 5872 | return; |
| 5872 | if (read_expected(EVENT_ITEM, "size") < 0) | 5873 | if (read_expected(TEP_EVENT_ITEM, "size") < 0) |
| 5873 | return; | 5874 | return; |
| 5874 | if (read_expected(EVENT_OP, ":") < 0) | 5875 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 5875 | return; | 5876 | return; |
| 5876 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 5877 | if (read_expect_type(TEP_EVENT_ITEM, &token) < 0) |
| 5877 | goto fail; | 5878 | goto fail; |
| 5878 | *size = atoi(token); | 5879 | *size = atoi(token); |
| 5879 | free_token(token); | 5880 | free_token(token); |
| 5880 | if (read_expected(EVENT_OP, ";") < 0) | 5881 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 5881 | return; | 5882 | return; |
| 5882 | type = read_token(&token); | 5883 | type = read_token(&token); |
| 5883 | if (type != EVENT_NEWLINE) { | 5884 | if (type != TEP_EVENT_NEWLINE) { |
| 5884 | /* newer versions of the kernel have a "signed" type */ | 5885 | /* newer versions of the kernel have a "signed" type */ |
| 5885 | if (type != EVENT_ITEM) | 5886 | if (type != TEP_EVENT_ITEM) |
| 5886 | goto fail; | 5887 | goto fail; |
| 5887 | 5888 | ||
| 5888 | if (strcmp(token, "signed") != 0) | 5889 | if (strcmp(token, "signed") != 0) |
| @@ -5890,17 +5891,17 @@ static void parse_header_field(const char *field, | |||
| 5890 | 5891 | ||
| 5891 | free_token(token); | 5892 | free_token(token); |
| 5892 | 5893 | ||
| 5893 | if (read_expected(EVENT_OP, ":") < 0) | 5894 | if (read_expected(TEP_EVENT_OP, ":") < 0) |
| 5894 | return; | 5895 | return; |
| 5895 | 5896 | ||
| 5896 | if (read_expect_type(EVENT_ITEM, &token)) | 5897 | if (read_expect_type(TEP_EVENT_ITEM, &token)) |
| 5897 | goto fail; | 5898 | goto fail; |
| 5898 | 5899 | ||
| 5899 | free_token(token); | 5900 | free_token(token); |
| 5900 | if (read_expected(EVENT_OP, ";") < 0) | 5901 | if (read_expected(TEP_EVENT_OP, ";") < 0) |
| 5901 | return; | 5902 | return; |
| 5902 | 5903 | ||
| 5903 | if (read_expect_type(EVENT_NEWLINE, &token)) | 5904 | if (read_expect_type(TEP_EVENT_NEWLINE, &token)) |
| 5904 | goto fail; | 5905 | goto fail; |
| 5905 | } | 5906 | } |
| 5906 | fail: | 5907 | fail: |
| @@ -5957,7 +5958,7 @@ int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long si | |||
| 5957 | return 0; | 5958 | return 0; |
| 5958 | } | 5959 | } |
| 5959 | 5960 | ||
| 5960 | static int event_matches(struct event_format *event, | 5961 | static int event_matches(struct tep_event_format *event, |
| 5961 | int id, const char *sys_name, | 5962 | int id, const char *sys_name, |
| 5962 | const char *event_name) | 5963 | const char *event_name) |
| 5963 | { | 5964 | { |
| @@ -5980,7 +5981,7 @@ static void free_handler(struct event_handler *handle) | |||
| 5980 | free(handle); | 5981 | free(handle); |
| 5981 | } | 5982 | } |
| 5982 | 5983 | ||
| 5983 | static int find_event_handle(struct tep_handle *pevent, struct event_format *event) | 5984 | static int find_event_handle(struct tep_handle *pevent, struct tep_event_format *event) |
| 5984 | { | 5985 | { |
| 5985 | struct event_handler *handle, **next; | 5986 | struct event_handler *handle, **next; |
| 5986 | 5987 | ||
| @@ -6021,11 +6022,11 @@ static int find_event_handle(struct tep_handle *pevent, struct event_format *eve | |||
| 6021 | * | 6022 | * |
| 6022 | * /sys/kernel/debug/tracing/events/.../.../format | 6023 | * /sys/kernel/debug/tracing/events/.../.../format |
| 6023 | */ | 6024 | */ |
| 6024 | enum tep_errno __tep_parse_format(struct event_format **eventp, | 6025 | enum tep_errno __tep_parse_format(struct tep_event_format **eventp, |
| 6025 | struct tep_handle *pevent, const char *buf, | 6026 | struct tep_handle *pevent, const char *buf, |
| 6026 | unsigned long size, const char *sys) | 6027 | unsigned long size, const char *sys) |
| 6027 | { | 6028 | { |
| 6028 | struct event_format *event; | 6029 | struct tep_event_format *event; |
| 6029 | int ret; | 6030 | int ret; |
| 6030 | 6031 | ||
| 6031 | init_input_buf(buf, size); | 6032 | init_input_buf(buf, size); |
| @@ -6042,10 +6043,10 @@ enum tep_errno __tep_parse_format(struct event_format **eventp, | |||
| 6042 | } | 6043 | } |
| 6043 | 6044 | ||
| 6044 | if (strcmp(sys, "ftrace") == 0) { | 6045 | if (strcmp(sys, "ftrace") == 0) { |
| 6045 | event->flags |= EVENT_FL_ISFTRACE; | 6046 | event->flags |= TEP_EVENT_FL_ISFTRACE; |
| 6046 | 6047 | ||
| 6047 | if (strcmp(event->name, "bprint") == 0) | 6048 | if (strcmp(event->name, "bprint") == 0) |
| 6048 | event->flags |= EVENT_FL_ISBPRINT; | 6049 | event->flags |= TEP_EVENT_FL_ISBPRINT; |
| 6049 | } | 6050 | } |
| 6050 | 6051 | ||
| 6051 | event->id = event_read_id(); | 6052 | event->id = event_read_id(); |
| @@ -6088,22 +6089,22 @@ enum tep_errno __tep_parse_format(struct event_format **eventp, | |||
| 6088 | goto event_parse_failed; | 6089 | goto event_parse_failed; |
| 6089 | } | 6090 | } |
| 6090 | 6091 | ||
| 6091 | if (!ret && (event->flags & EVENT_FL_ISFTRACE)) { | 6092 | if (!ret && (event->flags & TEP_EVENT_FL_ISFTRACE)) { |
| 6092 | struct format_field *field; | 6093 | struct tep_format_field *field; |
| 6093 | struct print_arg *arg, **list; | 6094 | struct tep_print_arg *arg, **list; |
| 6094 | 6095 | ||
| 6095 | /* old ftrace had no args */ | 6096 | /* old ftrace had no args */ |
| 6096 | list = &event->print_fmt.args; | 6097 | list = &event->print_fmt.args; |
| 6097 | for (field = event->format.fields; field; field = field->next) { | 6098 | for (field = event->format.fields; field; field = field->next) { |
| 6098 | arg = alloc_arg(); | 6099 | arg = alloc_arg(); |
| 6099 | if (!arg) { | 6100 | if (!arg) { |
| 6100 | event->flags |= EVENT_FL_FAILED; | 6101 | event->flags |= TEP_EVENT_FL_FAILED; |
| 6101 | return TEP_ERRNO__OLD_FTRACE_ARG_FAILED; | 6102 | return TEP_ERRNO__OLD_FTRACE_ARG_FAILED; |
| 6102 | } | 6103 | } |
| 6103 | arg->type = PRINT_FIELD; | 6104 | arg->type = TEP_PRINT_FIELD; |
| 6104 | arg->field.name = strdup(field->name); | 6105 | arg->field.name = strdup(field->name); |
| 6105 | if (!arg->field.name) { | 6106 | if (!arg->field.name) { |
| 6106 | event->flags |= EVENT_FL_FAILED; | 6107 | event->flags |= TEP_EVENT_FL_FAILED; |
| 6107 | free_arg(arg); | 6108 | free_arg(arg); |
| 6108 | return TEP_ERRNO__OLD_FTRACE_ARG_FAILED; | 6109 | return TEP_ERRNO__OLD_FTRACE_ARG_FAILED; |
| 6109 | } | 6110 | } |
| @@ -6117,7 +6118,7 @@ enum tep_errno __tep_parse_format(struct event_format **eventp, | |||
| 6117 | return 0; | 6118 | return 0; |
| 6118 | 6119 | ||
| 6119 | event_parse_failed: | 6120 | event_parse_failed: |
| 6120 | event->flags |= EVENT_FL_FAILED; | 6121 | event->flags |= TEP_EVENT_FL_FAILED; |
| 6121 | return ret; | 6122 | return ret; |
| 6122 | 6123 | ||
| 6123 | event_alloc_failed: | 6124 | event_alloc_failed: |
| @@ -6130,12 +6131,12 @@ enum tep_errno __tep_parse_format(struct event_format **eventp, | |||
| 6130 | 6131 | ||
| 6131 | static enum tep_errno | 6132 | static enum tep_errno |
| 6132 | __parse_event(struct tep_handle *pevent, | 6133 | __parse_event(struct tep_handle *pevent, |
| 6133 | struct event_format **eventp, | 6134 | struct tep_event_format **eventp, |
| 6134 | const char *buf, unsigned long size, | 6135 | const char *buf, unsigned long size, |
| 6135 | const char *sys) | 6136 | const char *sys) |
| 6136 | { | 6137 | { |
| 6137 | int ret = __tep_parse_format(eventp, pevent, buf, size, sys); | 6138 | int ret = __tep_parse_format(eventp, pevent, buf, size, sys); |
| 6138 | struct event_format *event = *eventp; | 6139 | struct tep_event_format *event = *eventp; |
| 6139 | 6140 | ||
| 6140 | if (event == NULL) | 6141 | if (event == NULL) |
| 6141 | return ret; | 6142 | return ret; |
| @@ -6172,7 +6173,7 @@ event_add_failed: | |||
| 6172 | * /sys/kernel/debug/tracing/events/.../.../format | 6173 | * /sys/kernel/debug/tracing/events/.../.../format |
| 6173 | */ | 6174 | */ |
| 6174 | enum tep_errno tep_parse_format(struct tep_handle *pevent, | 6175 | enum tep_errno tep_parse_format(struct tep_handle *pevent, |
| 6175 | struct event_format **eventp, | 6176 | struct tep_event_format **eventp, |
| 6176 | const char *buf, | 6177 | const char *buf, |
| 6177 | unsigned long size, const char *sys) | 6178 | unsigned long size, const char *sys) |
| 6178 | { | 6179 | { |
| @@ -6196,7 +6197,7 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent, | |||
| 6196 | enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf, | 6197 | enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf, |
| 6197 | unsigned long size, const char *sys) | 6198 | unsigned long size, const char *sys) |
| 6198 | { | 6199 | { |
| 6199 | struct event_format *event = NULL; | 6200 | struct tep_event_format *event = NULL; |
| 6200 | return __parse_event(pevent, &event, buf, size, sys); | 6201 | return __parse_event(pevent, &event, buf, size, sys); |
| 6201 | } | 6202 | } |
| 6202 | 6203 | ||
| @@ -6229,7 +6230,7 @@ int tep_strerror(struct tep_handle *pevent __maybe_unused, | |||
| 6229 | return 0; | 6230 | return 0; |
| 6230 | } | 6231 | } |
| 6231 | 6232 | ||
| 6232 | int get_field_val(struct trace_seq *s, struct format_field *field, | 6233 | int get_field_val(struct trace_seq *s, struct tep_format_field *field, |
| 6233 | const char *name, struct tep_record *record, | 6234 | const char *name, struct tep_record *record, |
| 6234 | unsigned long long *val, int err) | 6235 | unsigned long long *val, int err) |
| 6235 | { | 6236 | { |
| @@ -6262,11 +6263,11 @@ int get_field_val(struct trace_seq *s, struct format_field *field, | |||
| 6262 | * | 6263 | * |
| 6263 | * On failure, it returns NULL. | 6264 | * On failure, it returns NULL. |
| 6264 | */ | 6265 | */ |
| 6265 | void *tep_get_field_raw(struct trace_seq *s, struct event_format *event, | 6266 | void *tep_get_field_raw(struct trace_seq *s, struct tep_event_format *event, |
| 6266 | const char *name, struct tep_record *record, | 6267 | const char *name, struct tep_record *record, |
| 6267 | int *len, int err) | 6268 | int *len, int err) |
| 6268 | { | 6269 | { |
| 6269 | struct format_field *field; | 6270 | struct tep_format_field *field; |
| 6270 | void *data = record->data; | 6271 | void *data = record->data; |
| 6271 | unsigned offset; | 6272 | unsigned offset; |
| 6272 | int dummy; | 6273 | int dummy; |
| @@ -6287,7 +6288,7 @@ void *tep_get_field_raw(struct trace_seq *s, struct event_format *event, | |||
| 6287 | len = &dummy; | 6288 | len = &dummy; |
| 6288 | 6289 | ||
| 6289 | offset = field->offset; | 6290 | offset = field->offset; |
| 6290 | if (field->flags & FIELD_IS_DYNAMIC) { | 6291 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 6291 | offset = tep_read_number(event->pevent, | 6292 | offset = tep_read_number(event->pevent, |
| 6292 | data + offset, field->size); | 6293 | data + offset, field->size); |
| 6293 | *len = offset >> 16; | 6294 | *len = offset >> 16; |
| @@ -6309,11 +6310,11 @@ void *tep_get_field_raw(struct trace_seq *s, struct event_format *event, | |||
| 6309 | * | 6310 | * |
| 6310 | * Returns 0 on success -1 on field not found. | 6311 | * Returns 0 on success -1 on field not found. |
| 6311 | */ | 6312 | */ |
| 6312 | int tep_get_field_val(struct trace_seq *s, struct event_format *event, | 6313 | int tep_get_field_val(struct trace_seq *s, struct tep_event_format *event, |
| 6313 | const char *name, struct tep_record *record, | 6314 | const char *name, struct tep_record *record, |
| 6314 | unsigned long long *val, int err) | 6315 | unsigned long long *val, int err) |
| 6315 | { | 6316 | { |
| 6316 | struct format_field *field; | 6317 | struct tep_format_field *field; |
| 6317 | 6318 | ||
| 6318 | if (!event) | 6319 | if (!event) |
| 6319 | return -1; | 6320 | return -1; |
| @@ -6334,11 +6335,11 @@ int tep_get_field_val(struct trace_seq *s, struct event_format *event, | |||
| 6334 | * | 6335 | * |
| 6335 | * Returns 0 on success -1 on field not found. | 6336 | * Returns 0 on success -1 on field not found. |
| 6336 | */ | 6337 | */ |
| 6337 | int tep_get_common_field_val(struct trace_seq *s, struct event_format *event, | 6338 | int tep_get_common_field_val(struct trace_seq *s, struct tep_event_format *event, |
| 6338 | const char *name, struct tep_record *record, | 6339 | const char *name, struct tep_record *record, |
| 6339 | unsigned long long *val, int err) | 6340 | unsigned long long *val, int err) |
| 6340 | { | 6341 | { |
| 6341 | struct format_field *field; | 6342 | struct tep_format_field *field; |
| 6342 | 6343 | ||
| 6343 | if (!event) | 6344 | if (!event) |
| 6344 | return -1; | 6345 | return -1; |
| @@ -6359,11 +6360,11 @@ int tep_get_common_field_val(struct trace_seq *s, struct event_format *event, | |||
| 6359 | * | 6360 | * |
| 6360 | * Returns 0 on success -1 on field not found. | 6361 | * Returns 0 on success -1 on field not found. |
| 6361 | */ | 6362 | */ |
| 6362 | int tep_get_any_field_val(struct trace_seq *s, struct event_format *event, | 6363 | int tep_get_any_field_val(struct trace_seq *s, struct tep_event_format *event, |
| 6363 | const char *name, struct tep_record *record, | 6364 | const char *name, struct tep_record *record, |
| 6364 | unsigned long long *val, int err) | 6365 | unsigned long long *val, int err) |
| 6365 | { | 6366 | { |
| 6366 | struct format_field *field; | 6367 | struct tep_format_field *field; |
| 6367 | 6368 | ||
| 6368 | if (!event) | 6369 | if (!event) |
| 6369 | return -1; | 6370 | return -1; |
| @@ -6385,10 +6386,10 @@ int tep_get_any_field_val(struct trace_seq *s, struct event_format *event, | |||
| 6385 | * Returns: 0 on success, -1 field not found, or 1 if buffer is full. | 6386 | * Returns: 0 on success, -1 field not found, or 1 if buffer is full. |
| 6386 | */ | 6387 | */ |
| 6387 | int tep_print_num_field(struct trace_seq *s, const char *fmt, | 6388 | int tep_print_num_field(struct trace_seq *s, const char *fmt, |
| 6388 | struct event_format *event, const char *name, | 6389 | struct tep_event_format *event, const char *name, |
| 6389 | struct tep_record *record, int err) | 6390 | struct tep_record *record, int err) |
| 6390 | { | 6391 | { |
| 6391 | struct format_field *field = tep_find_field(event, name); | 6392 | struct tep_format_field *field = tep_find_field(event, name); |
| 6392 | unsigned long long val; | 6393 | unsigned long long val; |
| 6393 | 6394 | ||
| 6394 | if (!field) | 6395 | if (!field) |
| @@ -6417,10 +6418,10 @@ int tep_print_num_field(struct trace_seq *s, const char *fmt, | |||
| 6417 | * Returns: 0 on success, -1 field not found, or 1 if buffer is full. | 6418 | * Returns: 0 on success, -1 field not found, or 1 if buffer is full. |
| 6418 | */ | 6419 | */ |
| 6419 | int tep_print_func_field(struct trace_seq *s, const char *fmt, | 6420 | int tep_print_func_field(struct trace_seq *s, const char *fmt, |
| 6420 | struct event_format *event, const char *name, | 6421 | struct tep_event_format *event, const char *name, |
| 6421 | struct tep_record *record, int err) | 6422 | struct tep_record *record, int err) |
| 6422 | { | 6423 | { |
| 6423 | struct format_field *field = tep_find_field(event, name); | 6424 | struct tep_format_field *field = tep_find_field(event, name); |
| 6424 | struct tep_handle *pevent = event->pevent; | 6425 | struct tep_handle *pevent = event->pevent; |
| 6425 | unsigned long long val; | 6426 | unsigned long long val; |
| 6426 | struct func_map *func; | 6427 | struct func_map *func; |
| @@ -6577,11 +6578,11 @@ int tep_unregister_print_function(struct tep_handle *pevent, | |||
| 6577 | return -1; | 6578 | return -1; |
| 6578 | } | 6579 | } |
| 6579 | 6580 | ||
| 6580 | static struct event_format *search_event(struct tep_handle *pevent, int id, | 6581 | static struct tep_event_format *search_event(struct tep_handle *pevent, int id, |
| 6581 | const char *sys_name, | 6582 | const char *sys_name, |
| 6582 | const char *event_name) | 6583 | const char *event_name) |
| 6583 | { | 6584 | { |
| 6584 | struct event_format *event; | 6585 | struct tep_event_format *event; |
| 6585 | 6586 | ||
| 6586 | if (id >= 0) { | 6587 | if (id >= 0) { |
| 6587 | /* search by id */ | 6588 | /* search by id */ |
| @@ -6621,7 +6622,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id, | |||
| 6621 | const char *sys_name, const char *event_name, | 6622 | const char *sys_name, const char *event_name, |
| 6622 | tep_event_handler_func func, void *context) | 6623 | tep_event_handler_func func, void *context) |
| 6623 | { | 6624 | { |
| 6624 | struct event_format *event; | 6625 | struct tep_event_format *event; |
| 6625 | struct event_handler *handle; | 6626 | struct event_handler *handle; |
| 6626 | 6627 | ||
| 6627 | event = search_event(pevent, id, sys_name, event_name); | 6628 | event = search_event(pevent, id, sys_name, event_name); |
| @@ -6705,7 +6706,7 @@ int tep_unregister_event_handler(struct tep_handle *pevent, int id, | |||
| 6705 | const char *sys_name, const char *event_name, | 6706 | const char *sys_name, const char *event_name, |
| 6706 | tep_event_handler_func func, void *context) | 6707 | tep_event_handler_func func, void *context) |
| 6707 | { | 6708 | { |
| 6708 | struct event_format *event; | 6709 | struct tep_event_format *event; |
| 6709 | struct event_handler *handle; | 6710 | struct event_handler *handle; |
| 6710 | struct event_handler **next; | 6711 | struct event_handler **next; |
| 6711 | 6712 | ||
| @@ -6757,7 +6758,7 @@ void tep_ref(struct tep_handle *pevent) | |||
| 6757 | pevent->ref_count++; | 6758 | pevent->ref_count++; |
| 6758 | } | 6759 | } |
| 6759 | 6760 | ||
| 6760 | void tep_free_format_field(struct format_field *field) | 6761 | void tep_free_format_field(struct tep_format_field *field) |
| 6761 | { | 6762 | { |
| 6762 | free(field->type); | 6763 | free(field->type); |
| 6763 | if (field->alias != field->name) | 6764 | if (field->alias != field->name) |
| @@ -6766,9 +6767,9 @@ void tep_free_format_field(struct format_field *field) | |||
| 6766 | free(field); | 6767 | free(field); |
| 6767 | } | 6768 | } |
| 6768 | 6769 | ||
| 6769 | static void free_format_fields(struct format_field *field) | 6770 | static void free_format_fields(struct tep_format_field *field) |
| 6770 | { | 6771 | { |
| 6771 | struct format_field *next; | 6772 | struct tep_format_field *next; |
| 6772 | 6773 | ||
| 6773 | while (field) { | 6774 | while (field) { |
| 6774 | next = field->next; | 6775 | next = field->next; |
| @@ -6777,13 +6778,13 @@ static void free_format_fields(struct format_field *field) | |||
| 6777 | } | 6778 | } |
| 6778 | } | 6779 | } |
| 6779 | 6780 | ||
| 6780 | static void free_formats(struct format *format) | 6781 | static void free_formats(struct tep_format *format) |
| 6781 | { | 6782 | { |
| 6782 | free_format_fields(format->common_fields); | 6783 | free_format_fields(format->common_fields); |
| 6783 | free_format_fields(format->fields); | 6784 | free_format_fields(format->fields); |
| 6784 | } | 6785 | } |
| 6785 | 6786 | ||
| 6786 | void tep_free_format(struct event_format *event) | 6787 | void tep_free_format(struct tep_event_format *event) |
| 6787 | { | 6788 | { |
| 6788 | free(event->name); | 6789 | free(event->name); |
| 6789 | free(event->system); | 6790 | free(event->system); |
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 44b7c2d41f9f..9c29a5f7aa39 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
| @@ -26,17 +26,12 @@ | |||
| 26 | #include <regex.h> | 26 | #include <regex.h> |
| 27 | #include <string.h> | 27 | #include <string.h> |
| 28 | 28 | ||
| 29 | #include "trace-seq.h" | ||
| 30 | |||
| 29 | #ifndef __maybe_unused | 31 | #ifndef __maybe_unused |
| 30 | #define __maybe_unused __attribute__((unused)) | 32 | #define __maybe_unused __attribute__((unused)) |
| 31 | #endif | 33 | #endif |
| 32 | 34 | ||
| 33 | /* ----------------------- trace_seq ----------------------- */ | ||
| 34 | |||
| 35 | |||
| 36 | #ifndef TRACE_SEQ_BUF_SIZE | ||
| 37 | #define TRACE_SEQ_BUF_SIZE 4096 | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #ifndef DEBUG_RECORD | 35 | #ifndef DEBUG_RECORD |
| 41 | #define DEBUG_RECORD 0 | 36 | #define DEBUG_RECORD 0 |
| 42 | #endif | 37 | #endif |
| @@ -59,51 +54,14 @@ struct tep_record { | |||
| 59 | #endif | 54 | #endif |
| 60 | }; | 55 | }; |
| 61 | 56 | ||
| 62 | enum trace_seq_fail { | 57 | /* ----------------------- tep ----------------------- */ |
| 63 | TRACE_SEQ__GOOD, | ||
| 64 | TRACE_SEQ__BUFFER_POISONED, | ||
| 65 | TRACE_SEQ__MEM_ALLOC_FAILED, | ||
| 66 | }; | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Trace sequences are used to allow a function to call several other functions | ||
| 70 | * to create a string of data to use (up to a max of PAGE_SIZE). | ||
| 71 | */ | ||
| 72 | |||
| 73 | struct trace_seq { | ||
| 74 | char *buffer; | ||
| 75 | unsigned int buffer_size; | ||
| 76 | unsigned int len; | ||
| 77 | unsigned int readpos; | ||
| 78 | enum trace_seq_fail state; | ||
| 79 | }; | ||
| 80 | |||
| 81 | void trace_seq_init(struct trace_seq *s); | ||
| 82 | void trace_seq_reset(struct trace_seq *s); | ||
| 83 | void trace_seq_destroy(struct trace_seq *s); | ||
| 84 | |||
| 85 | extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | ||
| 86 | __attribute__ ((format (printf, 2, 3))); | ||
| 87 | extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | ||
| 88 | __attribute__ ((format (printf, 2, 0))); | ||
| 89 | |||
| 90 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | ||
| 91 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | ||
| 92 | |||
| 93 | extern void trace_seq_terminate(struct trace_seq *s); | ||
| 94 | |||
| 95 | extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp); | ||
| 96 | extern int trace_seq_do_printf(struct trace_seq *s); | ||
| 97 | |||
| 98 | |||
| 99 | /* ----------------------- pevent ----------------------- */ | ||
| 100 | 58 | ||
| 101 | struct tep_handle; | 59 | struct tep_handle; |
| 102 | struct event_format; | 60 | struct tep_event_format; |
| 103 | 61 | ||
| 104 | typedef int (*tep_event_handler_func)(struct trace_seq *s, | 62 | typedef int (*tep_event_handler_func)(struct trace_seq *s, |
| 105 | struct tep_record *record, | 63 | struct tep_record *record, |
| 106 | struct event_format *event, | 64 | struct tep_event_format *event, |
| 107 | void *context); | 65 | void *context); |
| 108 | 66 | ||
| 109 | typedef int (*tep_plugin_load_func)(struct tep_handle *pevent); | 67 | typedef int (*tep_plugin_load_func)(struct tep_handle *pevent); |
| @@ -172,20 +130,20 @@ struct tep_plugin_option { | |||
| 172 | #define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS) | 130 | #define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS) |
| 173 | #define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS) | 131 | #define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS) |
| 174 | 132 | ||
| 175 | enum format_flags { | 133 | enum tep_format_flags { |
| 176 | FIELD_IS_ARRAY = 1, | 134 | TEP_FIELD_IS_ARRAY = 1, |
| 177 | FIELD_IS_POINTER = 2, | 135 | TEP_FIELD_IS_POINTER = 2, |
| 178 | FIELD_IS_SIGNED = 4, | 136 | TEP_FIELD_IS_SIGNED = 4, |
| 179 | FIELD_IS_STRING = 8, | 137 | TEP_FIELD_IS_STRING = 8, |
| 180 | FIELD_IS_DYNAMIC = 16, | 138 | TEP_FIELD_IS_DYNAMIC = 16, |
| 181 | FIELD_IS_LONG = 32, | 139 | TEP_FIELD_IS_LONG = 32, |
| 182 | FIELD_IS_FLAG = 64, | 140 | TEP_FIELD_IS_FLAG = 64, |
| 183 | FIELD_IS_SYMBOLIC = 128, | 141 | TEP_FIELD_IS_SYMBOLIC = 128, |
| 184 | }; | 142 | }; |
| 185 | 143 | ||
| 186 | struct format_field { | 144 | struct tep_format_field { |
| 187 | struct format_field *next; | 145 | struct tep_format_field *next; |
| 188 | struct event_format *event; | 146 | struct tep_event_format *event; |
| 189 | char *type; | 147 | char *type; |
| 190 | char *name; | 148 | char *name; |
| 191 | char *alias; | 149 | char *alias; |
| @@ -196,169 +154,169 @@ struct format_field { | |||
| 196 | unsigned long flags; | 154 | unsigned long flags; |
| 197 | }; | 155 | }; |
| 198 | 156 | ||
| 199 | struct format { | 157 | struct tep_format { |
| 200 | int nr_common; | 158 | int nr_common; |
| 201 | int nr_fields; | 159 | int nr_fields; |
| 202 | struct format_field *common_fields; | 160 | struct tep_format_field *common_fields; |
| 203 | struct format_field *fields; | 161 | struct tep_format_field *fields; |
| 204 | }; | 162 | }; |
| 205 | 163 | ||
| 206 | struct print_arg_atom { | 164 | struct tep_print_arg_atom { |
| 207 | char *atom; | 165 | char *atom; |
| 208 | }; | 166 | }; |
| 209 | 167 | ||
| 210 | struct print_arg_string { | 168 | struct tep_print_arg_string { |
| 211 | char *string; | 169 | char *string; |
| 212 | int offset; | 170 | int offset; |
| 213 | }; | 171 | }; |
| 214 | 172 | ||
| 215 | struct print_arg_bitmask { | 173 | struct tep_print_arg_bitmask { |
| 216 | char *bitmask; | 174 | char *bitmask; |
| 217 | int offset; | 175 | int offset; |
| 218 | }; | 176 | }; |
| 219 | 177 | ||
| 220 | struct print_arg_field { | 178 | struct tep_print_arg_field { |
| 221 | char *name; | 179 | char *name; |
| 222 | struct format_field *field; | 180 | struct tep_format_field *field; |
| 223 | }; | 181 | }; |
| 224 | 182 | ||
| 225 | struct print_flag_sym { | 183 | struct tep_print_flag_sym { |
| 226 | struct print_flag_sym *next; | 184 | struct tep_print_flag_sym *next; |
| 227 | char *value; | 185 | char *value; |
| 228 | char *str; | 186 | char *str; |
| 229 | }; | 187 | }; |
| 230 | 188 | ||
| 231 | struct print_arg_typecast { | 189 | struct tep_print_arg_typecast { |
| 232 | char *type; | 190 | char *type; |
| 233 | struct print_arg *item; | 191 | struct tep_print_arg *item; |
| 234 | }; | 192 | }; |
| 235 | 193 | ||
| 236 | struct print_arg_flags { | 194 | struct tep_print_arg_flags { |
| 237 | struct print_arg *field; | 195 | struct tep_print_arg *field; |
| 238 | char *delim; | 196 | char *delim; |
| 239 | struct print_flag_sym *flags; | 197 | struct tep_print_flag_sym *flags; |
| 240 | }; | 198 | }; |
| 241 | 199 | ||
| 242 | struct print_arg_symbol { | 200 | struct tep_print_arg_symbol { |
| 243 | struct print_arg *field; | 201 | struct tep_print_arg *field; |
| 244 | struct print_flag_sym *symbols; | 202 | struct tep_print_flag_sym *symbols; |
| 245 | }; | 203 | }; |
| 246 | 204 | ||
| 247 | struct print_arg_hex { | 205 | struct tep_print_arg_hex { |
| 248 | struct print_arg *field; | 206 | struct tep_print_arg *field; |
| 249 | struct print_arg *size; | 207 | struct tep_print_arg *size; |
| 250 | }; | 208 | }; |
| 251 | 209 | ||
| 252 | struct print_arg_int_array { | 210 | struct tep_print_arg_int_array { |
| 253 | struct print_arg *field; | 211 | struct tep_print_arg *field; |
| 254 | struct print_arg *count; | 212 | struct tep_print_arg *count; |
| 255 | struct print_arg *el_size; | 213 | struct tep_print_arg *el_size; |
| 256 | }; | 214 | }; |
| 257 | 215 | ||
| 258 | struct print_arg_dynarray { | 216 | struct tep_print_arg_dynarray { |
| 259 | struct format_field *field; | 217 | struct tep_format_field *field; |
| 260 | struct print_arg *index; | 218 | struct tep_print_arg *index; |
| 261 | }; | 219 | }; |
| 262 | 220 | ||
| 263 | struct print_arg; | 221 | struct tep_print_arg; |
| 264 | 222 | ||
| 265 | struct print_arg_op { | 223 | struct tep_print_arg_op { |
| 266 | char *op; | 224 | char *op; |
| 267 | int prio; | 225 | int prio; |
| 268 | struct print_arg *left; | 226 | struct tep_print_arg *left; |
| 269 | struct print_arg *right; | 227 | struct tep_print_arg *right; |
| 270 | }; | 228 | }; |
| 271 | 229 | ||
| 272 | struct tep_function_handler; | 230 | struct tep_function_handler; |
| 273 | 231 | ||
| 274 | struct print_arg_func { | 232 | struct tep_print_arg_func { |
| 275 | struct tep_function_handler *func; | 233 | struct tep_function_handler *func; |
| 276 | struct print_arg *args; | 234 | struct tep_print_arg *args; |
| 277 | }; | 235 | }; |
| 278 | 236 | ||
| 279 | enum print_arg_type { | 237 | enum tep_print_arg_type { |
| 280 | PRINT_NULL, | 238 | TEP_PRINT_NULL, |
| 281 | PRINT_ATOM, | 239 | TEP_PRINT_ATOM, |
| 282 | PRINT_FIELD, | 240 | TEP_PRINT_FIELD, |
| 283 | PRINT_FLAGS, | 241 | TEP_PRINT_FLAGS, |
| 284 | PRINT_SYMBOL, | 242 | TEP_PRINT_SYMBOL, |
| 285 | PRINT_HEX, | 243 | TEP_PRINT_HEX, |
| 286 | PRINT_INT_ARRAY, | 244 | TEP_PRINT_INT_ARRAY, |
| 287 | PRINT_TYPE, | 245 | TEP_PRINT_TYPE, |
| 288 | PRINT_STRING, | 246 | TEP_PRINT_STRING, |
| 289 | PRINT_BSTRING, | 247 | TEP_PRINT_BSTRING, |
| 290 | PRINT_DYNAMIC_ARRAY, | 248 | TEP_PRINT_DYNAMIC_ARRAY, |
| 291 | PRINT_OP, | 249 | TEP_PRINT_OP, |
| 292 | PRINT_FUNC, | 250 | TEP_PRINT_FUNC, |
| 293 | PRINT_BITMASK, | 251 | TEP_PRINT_BITMASK, |
| 294 | PRINT_DYNAMIC_ARRAY_LEN, | 252 | TEP_PRINT_DYNAMIC_ARRAY_LEN, |
| 295 | PRINT_HEX_STR, | 253 | TEP_PRINT_HEX_STR, |
| 296 | }; | 254 | }; |
| 297 | 255 | ||
| 298 | struct print_arg { | 256 | struct tep_print_arg { |
| 299 | struct print_arg *next; | 257 | struct tep_print_arg *next; |
| 300 | enum print_arg_type type; | 258 | enum tep_print_arg_type type; |
| 301 | union { | 259 | union { |
| 302 | struct print_arg_atom atom; | 260 | struct tep_print_arg_atom atom; |
| 303 | struct print_arg_field field; | 261 | struct tep_print_arg_field field; |
| 304 | struct print_arg_typecast typecast; | 262 | struct tep_print_arg_typecast typecast; |
| 305 | struct print_arg_flags flags; | 263 | struct tep_print_arg_flags flags; |
| 306 | struct print_arg_symbol symbol; | 264 | struct tep_print_arg_symbol symbol; |
| 307 | struct print_arg_hex hex; | 265 | struct tep_print_arg_hex hex; |
| 308 | struct print_arg_int_array int_array; | 266 | struct tep_print_arg_int_array int_array; |
| 309 | struct print_arg_func func; | 267 | struct tep_print_arg_func func; |
| 310 | struct print_arg_string string; | 268 | struct tep_print_arg_string string; |
| 311 | struct print_arg_bitmask bitmask; | 269 | struct tep_print_arg_bitmask bitmask; |
| 312 | struct print_arg_op op; | 270 | struct tep_print_arg_op op; |
| 313 | struct print_arg_dynarray dynarray; | 271 | struct tep_print_arg_dynarray dynarray; |
| 314 | }; | 272 | }; |
| 315 | }; | 273 | }; |
| 316 | 274 | ||
| 317 | struct print_fmt { | 275 | struct tep_print_fmt { |
| 318 | char *format; | 276 | char *format; |
| 319 | struct print_arg *args; | 277 | struct tep_print_arg *args; |
| 320 | }; | 278 | }; |
| 321 | 279 | ||
| 322 | struct event_format { | 280 | struct tep_event_format { |
| 323 | struct tep_handle *pevent; | 281 | struct tep_handle *pevent; |
| 324 | char *name; | 282 | char *name; |
| 325 | int id; | 283 | int id; |
| 326 | int flags; | 284 | int flags; |
| 327 | struct format format; | 285 | struct tep_format format; |
| 328 | struct print_fmt print_fmt; | 286 | struct tep_print_fmt print_fmt; |
| 329 | char *system; | 287 | char *system; |
| 330 | tep_event_handler_func handler; | 288 | tep_event_handler_func handler; |
| 331 | void *context; | 289 | void *context; |
| 332 | }; | 290 | }; |
| 333 | 291 | ||
| 334 | enum { | 292 | enum { |
| 335 | EVENT_FL_ISFTRACE = 0x01, | 293 | TEP_EVENT_FL_ISFTRACE = 0x01, |
| 336 | EVENT_FL_ISPRINT = 0x02, | 294 | TEP_EVENT_FL_ISPRINT = 0x02, |
| 337 | EVENT_FL_ISBPRINT = 0x04, | 295 | TEP_EVENT_FL_ISBPRINT = 0x04, |
| 338 | EVENT_FL_ISFUNCENT = 0x10, | 296 | TEP_EVENT_FL_ISFUNCENT = 0x10, |
| 339 | EVENT_FL_ISFUNCRET = 0x20, | 297 | TEP_EVENT_FL_ISFUNCRET = 0x20, |
| 340 | EVENT_FL_NOHANDLE = 0x40, | 298 | TEP_EVENT_FL_NOHANDLE = 0x40, |
| 341 | EVENT_FL_PRINTRAW = 0x80, | 299 | TEP_EVENT_FL_PRINTRAW = 0x80, |
| 342 | 300 | ||
| 343 | EVENT_FL_FAILED = 0x80000000 | 301 | TEP_EVENT_FL_FAILED = 0x80000000 |
| 344 | }; | 302 | }; |
| 345 | 303 | ||
| 346 | enum event_sort_type { | 304 | enum tep_event_sort_type { |
| 347 | EVENT_SORT_ID, | 305 | TEP_EVENT_SORT_ID, |
| 348 | EVENT_SORT_NAME, | 306 | TEP_EVENT_SORT_NAME, |
| 349 | EVENT_SORT_SYSTEM, | 307 | TEP_EVENT_SORT_SYSTEM, |
| 350 | }; | 308 | }; |
| 351 | 309 | ||
| 352 | enum event_type { | 310 | enum tep_event_type { |
| 353 | EVENT_ERROR, | 311 | TEP_EVENT_ERROR, |
| 354 | EVENT_NONE, | 312 | TEP_EVENT_NONE, |
| 355 | EVENT_SPACE, | 313 | TEP_EVENT_SPACE, |
| 356 | EVENT_NEWLINE, | 314 | TEP_EVENT_NEWLINE, |
| 357 | EVENT_OP, | 315 | TEP_EVENT_OP, |
| 358 | EVENT_DELIM, | 316 | TEP_EVENT_DELIM, |
| 359 | EVENT_ITEM, | 317 | TEP_EVENT_ITEM, |
| 360 | EVENT_DQUOTE, | 318 | TEP_EVENT_DQUOTE, |
| 361 | EVENT_SQUOTE, | 319 | TEP_EVENT_SQUOTE, |
| 362 | }; | 320 | }; |
| 363 | 321 | ||
| 364 | typedef unsigned long long (*tep_func_handler)(struct trace_seq *s, | 322 | typedef unsigned long long (*tep_func_handler)(struct trace_seq *s, |
| @@ -431,12 +389,12 @@ enum tep_errno { | |||
| 431 | }; | 389 | }; |
| 432 | #undef _PE | 390 | #undef _PE |
| 433 | 391 | ||
| 434 | struct plugin_list; | 392 | struct tep_plugin_list; |
| 435 | 393 | ||
| 436 | #define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) | 394 | #define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) |
| 437 | 395 | ||
| 438 | struct plugin_list *tep_load_plugins(struct tep_handle *pevent); | 396 | struct tep_plugin_list *tep_load_plugins(struct tep_handle *pevent); |
| 439 | void tep_unload_plugins(struct plugin_list *plugin_list, | 397 | void tep_unload_plugins(struct tep_plugin_list *plugin_list, |
| 440 | struct tep_handle *pevent); | 398 | struct tep_handle *pevent); |
| 441 | char **tep_plugin_list_options(void); | 399 | char **tep_plugin_list_options(void); |
| 442 | void tep_plugin_free_options_list(char **list); | 400 | void tep_plugin_free_options_list(char **list); |
| @@ -445,7 +403,7 @@ int tep_plugin_add_options(const char *name, | |||
| 445 | void tep_plugin_remove_options(struct tep_plugin_option *options); | 403 | void tep_plugin_remove_options(struct tep_plugin_option *options); |
| 446 | void tep_print_plugins(struct trace_seq *s, | 404 | void tep_print_plugins(struct trace_seq *s, |
| 447 | const char *prefix, const char *suffix, | 405 | const char *prefix, const char *suffix, |
| 448 | const struct plugin_list *list); | 406 | const struct tep_plugin_list *list); |
| 449 | 407 | ||
| 450 | struct cmdline; | 408 | struct cmdline; |
| 451 | struct cmdline_list; | 409 | struct cmdline_list; |
| @@ -493,10 +451,10 @@ struct tep_handle { | |||
| 493 | unsigned int printk_count; | 451 | unsigned int printk_count; |
| 494 | 452 | ||
| 495 | 453 | ||
| 496 | struct event_format **events; | 454 | struct tep_event_format **events; |
| 497 | int nr_events; | 455 | int nr_events; |
| 498 | struct event_format **sort_events; | 456 | struct tep_event_format **sort_events; |
| 499 | enum event_sort_type last_type; | 457 | enum tep_event_sort_type last_type; |
| 500 | 458 | ||
| 501 | int type_offset; | 459 | int type_offset; |
| 502 | int type_size; | 460 | int type_size; |
| @@ -519,15 +477,15 @@ struct tep_handle { | |||
| 519 | 477 | ||
| 520 | int flags; | 478 | int flags; |
| 521 | 479 | ||
| 522 | struct format_field *bprint_ip_field; | 480 | struct tep_format_field *bprint_ip_field; |
| 523 | struct format_field *bprint_fmt_field; | 481 | struct tep_format_field *bprint_fmt_field; |
| 524 | struct format_field *bprint_buf_field; | 482 | struct tep_format_field *bprint_buf_field; |
| 525 | 483 | ||
| 526 | struct event_handler *handlers; | 484 | struct event_handler *handlers; |
| 527 | struct tep_function_handler *func_handlers; | 485 | struct tep_function_handler *func_handlers; |
| 528 | 486 | ||
| 529 | /* cache */ | 487 | /* cache */ |
| 530 | struct event_format *last_event; | 488 | struct tep_event_format *last_event; |
| 531 | 489 | ||
| 532 | char *trace_clock; | 490 | char *trace_clock; |
| 533 | }; | 491 | }; |
| @@ -538,7 +496,7 @@ static inline void tep_set_flag(struct tep_handle *pevent, int flag) | |||
| 538 | } | 496 | } |
| 539 | 497 | ||
| 540 | static inline unsigned short | 498 | static inline unsigned short |
| 541 | __data2host2(struct tep_handle *pevent, unsigned short data) | 499 | __tep_data2host2(struct tep_handle *pevent, unsigned short data) |
| 542 | { | 500 | { |
| 543 | unsigned short swap; | 501 | unsigned short swap; |
| 544 | 502 | ||
| @@ -552,7 +510,7 @@ __data2host2(struct tep_handle *pevent, unsigned short data) | |||
| 552 | } | 510 | } |
| 553 | 511 | ||
| 554 | static inline unsigned int | 512 | static inline unsigned int |
| 555 | __data2host4(struct tep_handle *pevent, unsigned int data) | 513 | __tep_data2host4(struct tep_handle *pevent, unsigned int data) |
| 556 | { | 514 | { |
| 557 | unsigned int swap; | 515 | unsigned int swap; |
| 558 | 516 | ||
| @@ -568,7 +526,7 @@ __data2host4(struct tep_handle *pevent, unsigned int data) | |||
| 568 | } | 526 | } |
| 569 | 527 | ||
| 570 | static inline unsigned long long | 528 | static inline unsigned long long |
| 571 | __data2host8(struct tep_handle *pevent, unsigned long long data) | 529 | __tep_data2host8(struct tep_handle *pevent, unsigned long long data) |
| 572 | { | 530 | { |
| 573 | unsigned long long swap; | 531 | unsigned long long swap; |
| 574 | 532 | ||
| @@ -587,14 +545,14 @@ __data2host8(struct tep_handle *pevent, unsigned long long data) | |||
| 587 | return swap; | 545 | return swap; |
| 588 | } | 546 | } |
| 589 | 547 | ||
| 590 | #define data2host2(pevent, ptr) __data2host2(pevent, *(unsigned short *)(ptr)) | 548 | #define tep_data2host2(pevent, ptr) __tep_data2host2(pevent, *(unsigned short *)(ptr)) |
| 591 | #define data2host4(pevent, ptr) __data2host4(pevent, *(unsigned int *)(ptr)) | 549 | #define tep_data2host4(pevent, ptr) __tep_data2host4(pevent, *(unsigned int *)(ptr)) |
| 592 | #define data2host8(pevent, ptr) \ | 550 | #define tep_data2host8(pevent, ptr) \ |
| 593 | ({ \ | 551 | ({ \ |
| 594 | unsigned long long __val; \ | 552 | unsigned long long __val; \ |
| 595 | \ | 553 | \ |
| 596 | memcpy(&__val, (ptr), sizeof(unsigned long long)); \ | 554 | memcpy(&__val, (ptr), sizeof(unsigned long long)); \ |
| 597 | __data2host8(pevent, __val); \ | 555 | __tep_data2host8(pevent, __val); \ |
| 598 | }) | 556 | }) |
| 599 | 557 | ||
| 600 | static inline int tep_host_bigendian(void) | 558 | static inline int tep_host_bigendian(void) |
| @@ -627,14 +585,14 @@ int tep_register_print_string(struct tep_handle *pevent, const char *fmt, | |||
| 627 | int tep_pid_is_registered(struct tep_handle *pevent, int pid); | 585 | int tep_pid_is_registered(struct tep_handle *pevent, int pid); |
| 628 | 586 | ||
| 629 | void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, | 587 | void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, |
| 630 | struct event_format *event, | 588 | struct tep_event_format *event, |
| 631 | struct tep_record *record); | 589 | struct tep_record *record); |
| 632 | void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, | 590 | void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, |
| 633 | struct event_format *event, | 591 | struct tep_event_format *event, |
| 634 | struct tep_record *record, | 592 | struct tep_record *record, |
| 635 | bool use_trace_clock); | 593 | bool use_trace_clock); |
| 636 | void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, | 594 | void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s, |
| 637 | struct event_format *event, | 595 | struct tep_event_format *event, |
| 638 | struct tep_record *record); | 596 | struct tep_record *record); |
| 639 | void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, | 597 | void tep_print_event(struct tep_handle *pevent, struct trace_seq *s, |
| 640 | struct tep_record *record, bool use_trace_clock); | 598 | struct tep_record *record, bool use_trace_clock); |
| @@ -645,32 +603,32 @@ int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long si | |||
| 645 | enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf, | 603 | enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf, |
| 646 | unsigned long size, const char *sys); | 604 | unsigned long size, const char *sys); |
| 647 | enum tep_errno tep_parse_format(struct tep_handle *pevent, | 605 | enum tep_errno tep_parse_format(struct tep_handle *pevent, |
| 648 | struct event_format **eventp, | 606 | struct tep_event_format **eventp, |
| 649 | const char *buf, | 607 | const char *buf, |
| 650 | unsigned long size, const char *sys); | 608 | unsigned long size, const char *sys); |
| 651 | void tep_free_format(struct event_format *event); | 609 | void tep_free_format(struct tep_event_format *event); |
| 652 | void tep_free_format_field(struct format_field *field); | 610 | void tep_free_format_field(struct tep_format_field *field); |
| 653 | 611 | ||
| 654 | void *tep_get_field_raw(struct trace_seq *s, struct event_format *event, | 612 | void *tep_get_field_raw(struct trace_seq *s, struct tep_event_format *event, |
| 655 | const char *name, struct tep_record *record, | 613 | const char *name, struct tep_record *record, |
| 656 | int *len, int err); | 614 | int *len, int err); |
| 657 | 615 | ||
| 658 | int tep_get_field_val(struct trace_seq *s, struct event_format *event, | 616 | int tep_get_field_val(struct trace_seq *s, struct tep_event_format *event, |
| 659 | const char *name, struct tep_record *record, | 617 | const char *name, struct tep_record *record, |
| 660 | unsigned long long *val, int err); | 618 | unsigned long long *val, int err); |
| 661 | int tep_get_common_field_val(struct trace_seq *s, struct event_format *event, | 619 | int tep_get_common_field_val(struct trace_seq *s, struct tep_event_format *event, |
| 662 | const char *name, struct tep_record *record, | 620 | const char *name, struct tep_record *record, |
| 663 | unsigned long long *val, int err); | 621 | unsigned long long *val, int err); |
| 664 | int tep_get_any_field_val(struct trace_seq *s, struct event_format *event, | 622 | int tep_get_any_field_val(struct trace_seq *s, struct tep_event_format *event, |
| 665 | const char *name, struct tep_record *record, | 623 | const char *name, struct tep_record *record, |
| 666 | unsigned long long *val, int err); | 624 | unsigned long long *val, int err); |
| 667 | 625 | ||
| 668 | int tep_print_num_field(struct trace_seq *s, const char *fmt, | 626 | int tep_print_num_field(struct trace_seq *s, const char *fmt, |
| 669 | struct event_format *event, const char *name, | 627 | struct tep_event_format *event, const char *name, |
| 670 | struct tep_record *record, int err); | 628 | struct tep_record *record, int err); |
| 671 | 629 | ||
| 672 | int tep_print_func_field(struct trace_seq *s, const char *fmt, | 630 | int tep_print_func_field(struct trace_seq *s, const char *fmt, |
| 673 | struct event_format *event, const char *name, | 631 | struct tep_event_format *event, const char *name, |
| 674 | struct tep_record *record, int err); | 632 | struct tep_record *record, int err); |
| 675 | 633 | ||
| 676 | int tep_register_event_handler(struct tep_handle *pevent, int id, | 634 | int tep_register_event_handler(struct tep_handle *pevent, int id, |
| @@ -686,29 +644,29 @@ int tep_register_print_function(struct tep_handle *pevent, | |||
| 686 | int tep_unregister_print_function(struct tep_handle *pevent, | 644 | int tep_unregister_print_function(struct tep_handle *pevent, |
| 687 | tep_func_handler func, char *name); | 645 | tep_func_handler func, char *name); |
| 688 | 646 | ||
| 689 | struct format_field *tep_find_common_field(struct event_format *event, const char *name); | 647 | struct tep_format_field *tep_find_common_field(struct tep_event_format *event, const char *name); |
| 690 | struct format_field *tep_find_field(struct event_format *event, const char *name); | 648 | struct tep_format_field *tep_find_field(struct tep_event_format *event, const char *name); |
| 691 | struct format_field *tep_find_any_field(struct event_format *event, const char *name); | 649 | struct tep_format_field *tep_find_any_field(struct tep_event_format *event, const char *name); |
| 692 | 650 | ||
| 693 | const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr); | 651 | const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr); |
| 694 | unsigned long long | 652 | unsigned long long |
| 695 | tep_find_function_address(struct tep_handle *pevent, unsigned long long addr); | 653 | tep_find_function_address(struct tep_handle *pevent, unsigned long long addr); |
| 696 | unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size); | 654 | unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size); |
| 697 | int tep_read_number_field(struct format_field *field, const void *data, | 655 | int tep_read_number_field(struct tep_format_field *field, const void *data, |
| 698 | unsigned long long *value); | 656 | unsigned long long *value); |
| 699 | 657 | ||
| 700 | struct event_format *tep_find_event(struct tep_handle *pevent, int id); | 658 | struct tep_event_format *tep_find_event(struct tep_handle *pevent, int id); |
| 701 | 659 | ||
| 702 | struct event_format * | 660 | struct tep_event_format * |
| 703 | tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name); | 661 | tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name); |
| 704 | 662 | ||
| 705 | struct event_format * | 663 | struct tep_event_format * |
| 706 | tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); | 664 | tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); |
| 707 | 665 | ||
| 708 | void tep_data_lat_fmt(struct tep_handle *pevent, | 666 | void tep_data_lat_fmt(struct tep_handle *pevent, |
| 709 | struct trace_seq *s, struct tep_record *record); | 667 | struct trace_seq *s, struct tep_record *record); |
| 710 | int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); | 668 | int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); |
| 711 | struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type); | 669 | struct tep_event_format *tep_data_event_from_type(struct tep_handle *pevent, int type); |
| 712 | int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); | 670 | int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); |
| 713 | int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); | 671 | int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); |
| 714 | int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); | 672 | int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); |
| @@ -719,17 +677,17 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co | |||
| 719 | int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); | 677 | int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); |
| 720 | 678 | ||
| 721 | void tep_print_field(struct trace_seq *s, void *data, | 679 | void tep_print_field(struct trace_seq *s, void *data, |
| 722 | struct format_field *field); | 680 | struct tep_format_field *field); |
| 723 | void tep_print_fields(struct trace_seq *s, void *data, | 681 | void tep_print_fields(struct trace_seq *s, void *data, |
| 724 | int size __maybe_unused, struct event_format *event); | 682 | int size __maybe_unused, struct tep_event_format *event); |
| 725 | void tep_event_info(struct trace_seq *s, struct event_format *event, | 683 | void tep_event_info(struct trace_seq *s, struct tep_event_format *event, |
| 726 | struct tep_record *record); | 684 | struct tep_record *record); |
| 727 | int tep_strerror(struct tep_handle *pevent, enum tep_errno errnum, | 685 | int tep_strerror(struct tep_handle *pevent, enum tep_errno errnum, |
| 728 | char *buf, size_t buflen); | 686 | char *buf, size_t buflen); |
| 729 | 687 | ||
| 730 | struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type); | 688 | struct tep_event_format **tep_list_events(struct tep_handle *pevent, enum tep_event_sort_type); |
| 731 | struct format_field **tep_event_common_fields(struct event_format *event); | 689 | struct tep_format_field **tep_event_common_fields(struct tep_event_format *event); |
| 732 | struct format_field **tep_event_fields(struct event_format *event); | 690 | struct tep_format_field **tep_event_fields(struct tep_event_format *event); |
| 733 | 691 | ||
| 734 | static inline int tep_get_cpus(struct tep_handle *pevent) | 692 | static inline int tep_get_cpus(struct tep_handle *pevent) |
| 735 | { | 693 | { |
| @@ -798,7 +756,7 @@ void tep_unref(struct tep_handle *pevent); | |||
| 798 | 756 | ||
| 799 | /* access to the internal parser */ | 757 | /* access to the internal parser */ |
| 800 | void tep_buffer_init(const char *buf, unsigned long long size); | 758 | void tep_buffer_init(const char *buf, unsigned long long size); |
| 801 | enum event_type tep_read_token(char **tok); | 759 | enum tep_event_type tep_read_token(char **tok); |
| 802 | void tep_free_token(char *token); | 760 | void tep_free_token(char *token); |
| 803 | int tep_peek_char(void); | 761 | int tep_peek_char(void); |
| 804 | const char *tep_get_input_buf(void); | 762 | const char *tep_get_input_buf(void); |
| @@ -810,136 +768,136 @@ void tep_print_printk(struct tep_handle *pevent); | |||
| 810 | 768 | ||
| 811 | /* ----------------------- filtering ----------------------- */ | 769 | /* ----------------------- filtering ----------------------- */ |
| 812 | 770 | ||
| 813 | enum filter_boolean_type { | 771 | enum tep_filter_boolean_type { |
| 814 | FILTER_FALSE, | 772 | TEP_FILTER_FALSE, |
| 815 | FILTER_TRUE, | 773 | TEP_FILTER_TRUE, |
| 816 | }; | 774 | }; |
| 817 | 775 | ||
| 818 | enum filter_op_type { | 776 | enum tep_filter_op_type { |
| 819 | FILTER_OP_AND = 1, | 777 | TEP_FILTER_OP_AND = 1, |
| 820 | FILTER_OP_OR, | 778 | TEP_FILTER_OP_OR, |
| 821 | FILTER_OP_NOT, | 779 | TEP_FILTER_OP_NOT, |
| 822 | }; | 780 | }; |
| 823 | 781 | ||
| 824 | enum filter_cmp_type { | 782 | enum tep_filter_cmp_type { |
| 825 | FILTER_CMP_NONE, | 783 | TEP_FILTER_CMP_NONE, |
| 826 | FILTER_CMP_EQ, | 784 | TEP_FILTER_CMP_EQ, |
| 827 | FILTER_CMP_NE, | 785 | TEP_FILTER_CMP_NE, |
| 828 | FILTER_CMP_GT, | 786 | TEP_FILTER_CMP_GT, |
| 829 | FILTER_CMP_LT, | 787 | TEP_FILTER_CMP_LT, |
| 830 | FILTER_CMP_GE, | 788 | TEP_FILTER_CMP_GE, |
| 831 | FILTER_CMP_LE, | 789 | TEP_FILTER_CMP_LE, |
| 832 | FILTER_CMP_MATCH, | 790 | TEP_FILTER_CMP_MATCH, |
| 833 | FILTER_CMP_NOT_MATCH, | 791 | TEP_FILTER_CMP_NOT_MATCH, |
| 834 | FILTER_CMP_REGEX, | 792 | TEP_FILTER_CMP_REGEX, |
| 835 | FILTER_CMP_NOT_REGEX, | 793 | TEP_FILTER_CMP_NOT_REGEX, |
| 836 | }; | 794 | }; |
| 837 | 795 | ||
| 838 | enum filter_exp_type { | 796 | enum tep_filter_exp_type { |
| 839 | FILTER_EXP_NONE, | 797 | TEP_FILTER_EXP_NONE, |
| 840 | FILTER_EXP_ADD, | 798 | TEP_FILTER_EXP_ADD, |
| 841 | FILTER_EXP_SUB, | 799 | TEP_FILTER_EXP_SUB, |
| 842 | FILTER_EXP_MUL, | 800 | TEP_FILTER_EXP_MUL, |
| 843 | FILTER_EXP_DIV, | 801 | TEP_FILTER_EXP_DIV, |
| 844 | FILTER_EXP_MOD, | 802 | TEP_FILTER_EXP_MOD, |
| 845 | FILTER_EXP_RSHIFT, | 803 | TEP_FILTER_EXP_RSHIFT, |
| 846 | FILTER_EXP_LSHIFT, | 804 | TEP_FILTER_EXP_LSHIFT, |
| 847 | FILTER_EXP_AND, | 805 | TEP_FILTER_EXP_AND, |
| 848 | FILTER_EXP_OR, | 806 | TEP_FILTER_EXP_OR, |
| 849 | FILTER_EXP_XOR, | 807 | TEP_FILTER_EXP_XOR, |
| 850 | FILTER_EXP_NOT, | 808 | TEP_FILTER_EXP_NOT, |
| 851 | }; | 809 | }; |
| 852 | 810 | ||
| 853 | enum filter_arg_type { | 811 | enum tep_filter_arg_type { |
| 854 | FILTER_ARG_NONE, | 812 | TEP_FILTER_ARG_NONE, |
| 855 | FILTER_ARG_BOOLEAN, | 813 | TEP_FILTER_ARG_BOOLEAN, |
| 856 | FILTER_ARG_VALUE, | 814 | TEP_FILTER_ARG_VALUE, |
| 857 | FILTER_ARG_FIELD, | 815 | TEP_FILTER_ARG_FIELD, |
| 858 | FILTER_ARG_EXP, | 816 | TEP_FILTER_ARG_EXP, |
| 859 | FILTER_ARG_OP, | 817 | TEP_FILTER_ARG_OP, |
| 860 | FILTER_ARG_NUM, | 818 | TEP_FILTER_ARG_NUM, |
| 861 | FILTER_ARG_STR, | 819 | TEP_FILTER_ARG_STR, |
| 862 | }; | 820 | }; |
| 863 | 821 | ||
| 864 | enum filter_value_type { | 822 | enum tep_filter_value_type { |
| 865 | FILTER_NUMBER, | 823 | TEP_FILTER_NUMBER, |
| 866 | FILTER_STRING, | 824 | TEP_FILTER_STRING, |
| 867 | FILTER_CHAR | 825 | TEP_FILTER_CHAR |
| 868 | }; | 826 | }; |
| 869 | 827 | ||
| 870 | struct fliter_arg; | 828 | struct tep_filter_arg; |
| 871 | 829 | ||
| 872 | struct filter_arg_boolean { | 830 | struct tep_filter_arg_boolean { |
| 873 | enum filter_boolean_type value; | 831 | enum tep_filter_boolean_type value; |
| 874 | }; | 832 | }; |
| 875 | 833 | ||
| 876 | struct filter_arg_field { | 834 | struct tep_filter_arg_field { |
| 877 | struct format_field *field; | 835 | struct tep_format_field *field; |
| 878 | }; | 836 | }; |
| 879 | 837 | ||
| 880 | struct filter_arg_value { | 838 | struct tep_filter_arg_value { |
| 881 | enum filter_value_type type; | 839 | enum tep_filter_value_type type; |
| 882 | union { | 840 | union { |
| 883 | char *str; | 841 | char *str; |
| 884 | unsigned long long val; | 842 | unsigned long long val; |
| 885 | }; | 843 | }; |
| 886 | }; | 844 | }; |
| 887 | 845 | ||
| 888 | struct filter_arg_op { | 846 | struct tep_filter_arg_op { |
| 889 | enum filter_op_type type; | 847 | enum tep_filter_op_type type; |
| 890 | struct filter_arg *left; | 848 | struct tep_filter_arg *left; |
| 891 | struct filter_arg *right; | 849 | struct tep_filter_arg *right; |
| 892 | }; | 850 | }; |
| 893 | 851 | ||
| 894 | struct filter_arg_exp { | 852 | struct tep_filter_arg_exp { |
| 895 | enum filter_exp_type type; | 853 | enum tep_filter_exp_type type; |
| 896 | struct filter_arg *left; | 854 | struct tep_filter_arg *left; |
| 897 | struct filter_arg *right; | 855 | struct tep_filter_arg *right; |
| 898 | }; | 856 | }; |
| 899 | 857 | ||
| 900 | struct filter_arg_num { | 858 | struct tep_filter_arg_num { |
| 901 | enum filter_cmp_type type; | 859 | enum tep_filter_cmp_type type; |
| 902 | struct filter_arg *left; | 860 | struct tep_filter_arg *left; |
| 903 | struct filter_arg *right; | 861 | struct tep_filter_arg *right; |
| 904 | }; | 862 | }; |
| 905 | 863 | ||
| 906 | struct filter_arg_str { | 864 | struct tep_filter_arg_str { |
| 907 | enum filter_cmp_type type; | 865 | enum tep_filter_cmp_type type; |
| 908 | struct format_field *field; | 866 | struct tep_format_field *field; |
| 909 | char *val; | 867 | char *val; |
| 910 | char *buffer; | 868 | char *buffer; |
| 911 | regex_t reg; | 869 | regex_t reg; |
| 912 | }; | 870 | }; |
| 913 | 871 | ||
| 914 | struct filter_arg { | 872 | struct tep_filter_arg { |
| 915 | enum filter_arg_type type; | 873 | enum tep_filter_arg_type type; |
| 916 | union { | 874 | union { |
| 917 | struct filter_arg_boolean boolean; | 875 | struct tep_filter_arg_boolean boolean; |
| 918 | struct filter_arg_field field; | 876 | struct tep_filter_arg_field field; |
| 919 | struct filter_arg_value value; | 877 | struct tep_filter_arg_value value; |
| 920 | struct filter_arg_op op; | 878 | struct tep_filter_arg_op op; |
| 921 | struct filter_arg_exp exp; | 879 | struct tep_filter_arg_exp exp; |
| 922 | struct filter_arg_num num; | 880 | struct tep_filter_arg_num num; |
| 923 | struct filter_arg_str str; | 881 | struct tep_filter_arg_str str; |
| 924 | }; | 882 | }; |
| 925 | }; | 883 | }; |
| 926 | 884 | ||
| 927 | struct filter_type { | 885 | struct tep_filter_type { |
| 928 | int event_id; | 886 | int event_id; |
| 929 | struct event_format *event; | 887 | struct tep_event_format *event; |
| 930 | struct filter_arg *filter; | 888 | struct tep_filter_arg *filter; |
| 931 | }; | 889 | }; |
| 932 | 890 | ||
| 933 | #define TEP_FILTER_ERROR_BUFSZ 1024 | 891 | #define TEP_FILTER_ERROR_BUFSZ 1024 |
| 934 | 892 | ||
| 935 | struct event_filter { | 893 | struct tep_event_filter { |
| 936 | struct tep_handle *pevent; | 894 | struct tep_handle *pevent; |
| 937 | int filters; | 895 | int filters; |
| 938 | struct filter_type *event_filters; | 896 | struct tep_filter_type *event_filters; |
| 939 | char error_buffer[TEP_FILTER_ERROR_BUFSZ]; | 897 | char error_buffer[TEP_FILTER_ERROR_BUFSZ]; |
| 940 | }; | 898 | }; |
| 941 | 899 | ||
| 942 | struct event_filter *tep_filter_alloc(struct tep_handle *pevent); | 900 | struct tep_event_filter *tep_filter_alloc(struct tep_handle *pevent); |
| 943 | 901 | ||
| 944 | /* for backward compatibility */ | 902 | /* for backward compatibility */ |
| 945 | #define FILTER_NONE TEP_ERRNO__NO_FILTER | 903 | #define FILTER_NONE TEP_ERRNO__NO_FILTER |
| @@ -947,45 +905,45 @@ struct event_filter *tep_filter_alloc(struct tep_handle *pevent); | |||
| 947 | #define FILTER_MISS TEP_ERRNO__FILTER_MISS | 905 | #define FILTER_MISS TEP_ERRNO__FILTER_MISS |
| 948 | #define FILTER_MATCH TEP_ERRNO__FILTER_MATCH | 906 | #define FILTER_MATCH TEP_ERRNO__FILTER_MATCH |
| 949 | 907 | ||
| 950 | enum filter_trivial_type { | 908 | enum tep_filter_trivial_type { |
| 951 | FILTER_TRIVIAL_FALSE, | 909 | TEP_FILTER_TRIVIAL_FALSE, |
| 952 | FILTER_TRIVIAL_TRUE, | 910 | TEP_FILTER_TRIVIAL_TRUE, |
| 953 | FILTER_TRIVIAL_BOTH, | 911 | TEP_FILTER_TRIVIAL_BOTH, |
| 954 | }; | 912 | }; |
| 955 | 913 | ||
| 956 | enum tep_errno tep_filter_add_filter_str(struct event_filter *filter, | 914 | enum tep_errno tep_filter_add_filter_str(struct tep_event_filter *filter, |
| 957 | const char *filter_str); | 915 | const char *filter_str); |
| 958 | 916 | ||
| 959 | enum tep_errno tep_filter_match(struct event_filter *filter, | 917 | enum tep_errno tep_filter_match(struct tep_event_filter *filter, |
| 960 | struct tep_record *record); | 918 | struct tep_record *record); |
| 961 | 919 | ||
| 962 | int tep_filter_strerror(struct event_filter *filter, enum tep_errno err, | 920 | int tep_filter_strerror(struct tep_event_filter *filter, enum tep_errno err, |
| 963 | char *buf, size_t buflen); | 921 | char *buf, size_t buflen); |
| 964 | 922 | ||
| 965 | int tep_event_filtered(struct event_filter *filter, | 923 | int tep_event_filtered(struct tep_event_filter *filter, |
| 966 | int event_id); | 924 | int event_id); |
| 967 | 925 | ||
| 968 | void tep_filter_reset(struct event_filter *filter); | 926 | void tep_filter_reset(struct tep_event_filter *filter); |
| 969 | 927 | ||
| 970 | int tep_filter_clear_trivial(struct event_filter *filter, | 928 | int tep_filter_clear_trivial(struct tep_event_filter *filter, |
| 971 | enum filter_trivial_type type); | 929 | enum tep_filter_trivial_type type); |
| 972 | 930 | ||
| 973 | void tep_filter_free(struct event_filter *filter); | 931 | void tep_filter_free(struct tep_event_filter *filter); |
| 974 | 932 | ||
| 975 | char *tep_filter_make_string(struct event_filter *filter, int event_id); | 933 | char *tep_filter_make_string(struct tep_event_filter *filter, int event_id); |
| 976 | 934 | ||
| 977 | int tep_filter_remove_event(struct event_filter *filter, | 935 | int tep_filter_remove_event(struct tep_event_filter *filter, |
| 978 | int event_id); | 936 | int event_id); |
| 979 | 937 | ||
| 980 | int tep_filter_event_has_trivial(struct event_filter *filter, | 938 | int tep_filter_event_has_trivial(struct tep_event_filter *filter, |
| 981 | int event_id, | 939 | int event_id, |
| 982 | enum filter_trivial_type type); | 940 | enum tep_filter_trivial_type type); |
| 983 | 941 | ||
| 984 | int tep_filter_copy(struct event_filter *dest, struct event_filter *source); | 942 | int tep_filter_copy(struct tep_event_filter *dest, struct tep_event_filter *source); |
| 985 | 943 | ||
| 986 | int tep_update_trivial(struct event_filter *dest, struct event_filter *source, | 944 | int tep_update_trivial(struct tep_event_filter *dest, struct tep_event_filter *source, |
| 987 | enum filter_trivial_type type); | 945 | enum tep_filter_trivial_type type); |
| 988 | 946 | ||
| 989 | int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2); | 947 | int tep_filter_compare(struct tep_event_filter *filter1, struct tep_event_filter *filter2); |
| 990 | 948 | ||
| 991 | #endif /* _PARSE_EVENTS_H */ | 949 | #endif /* _PARSE_EVENTS_H */ |
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index f17e25097e1e..46eb64eb0c2e 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <dirent.h> | 15 | #include <dirent.h> |
| 16 | #include "event-parse.h" | 16 | #include "event-parse.h" |
| 17 | #include "event-utils.h" | 17 | #include "event-utils.h" |
| 18 | #include "trace-seq.h" | ||
| 18 | 19 | ||
| 19 | #define LOCAL_PLUGIN_DIR ".traceevent/plugins" | 20 | #define LOCAL_PLUGIN_DIR ".traceevent/plugins" |
| 20 | 21 | ||
| @@ -30,8 +31,8 @@ static struct trace_plugin_options { | |||
| 30 | char *value; | 31 | char *value; |
| 31 | } *trace_plugin_options; | 32 | } *trace_plugin_options; |
| 32 | 33 | ||
| 33 | struct plugin_list { | 34 | struct tep_plugin_list { |
| 34 | struct plugin_list *next; | 35 | struct tep_plugin_list *next; |
| 35 | char *name; | 36 | char *name; |
| 36 | void *handle; | 37 | void *handle; |
| 37 | }; | 38 | }; |
| @@ -258,7 +259,7 @@ void tep_plugin_remove_options(struct tep_plugin_option *options) | |||
| 258 | */ | 259 | */ |
| 259 | void tep_print_plugins(struct trace_seq *s, | 260 | void tep_print_plugins(struct trace_seq *s, |
| 260 | const char *prefix, const char *suffix, | 261 | const char *prefix, const char *suffix, |
| 261 | const struct plugin_list *list) | 262 | const struct tep_plugin_list *list) |
| 262 | { | 263 | { |
| 263 | while (list) { | 264 | while (list) { |
| 264 | trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix); | 265 | trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix); |
| @@ -270,9 +271,9 @@ static void | |||
| 270 | load_plugin(struct tep_handle *pevent, const char *path, | 271 | load_plugin(struct tep_handle *pevent, const char *path, |
| 271 | const char *file, void *data) | 272 | const char *file, void *data) |
| 272 | { | 273 | { |
| 273 | struct plugin_list **plugin_list = data; | 274 | struct tep_plugin_list **plugin_list = data; |
| 274 | tep_plugin_load_func func; | 275 | tep_plugin_load_func func; |
| 275 | struct plugin_list *list; | 276 | struct tep_plugin_list *list; |
| 276 | const char *alias; | 277 | const char *alias; |
| 277 | char *plugin; | 278 | char *plugin; |
| 278 | void *handle; | 279 | void *handle; |
| @@ -416,20 +417,20 @@ load_plugins(struct tep_handle *pevent, const char *suffix, | |||
| 416 | free(path); | 417 | free(path); |
| 417 | } | 418 | } |
| 418 | 419 | ||
| 419 | struct plugin_list* | 420 | struct tep_plugin_list* |
| 420 | tep_load_plugins(struct tep_handle *pevent) | 421 | tep_load_plugins(struct tep_handle *pevent) |
| 421 | { | 422 | { |
| 422 | struct plugin_list *list = NULL; | 423 | struct tep_plugin_list *list = NULL; |
| 423 | 424 | ||
| 424 | load_plugins(pevent, ".so", load_plugin, &list); | 425 | load_plugins(pevent, ".so", load_plugin, &list); |
| 425 | return list; | 426 | return list; |
| 426 | } | 427 | } |
| 427 | 428 | ||
| 428 | void | 429 | void |
| 429 | tep_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent) | 430 | tep_unload_plugins(struct tep_plugin_list *plugin_list, struct tep_handle *pevent) |
| 430 | { | 431 | { |
| 431 | tep_plugin_unload_func func; | 432 | tep_plugin_unload_func func; |
| 432 | struct plugin_list *list; | 433 | struct tep_plugin_list *list; |
| 433 | 434 | ||
| 434 | while (plugin_list) { | 435 | while (plugin_list) { |
| 435 | list = plugin_list; | 436 | list = plugin_list; |
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index e76154c02ee7..d64b6128fa7d 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c | |||
| @@ -16,17 +16,17 @@ | |||
| 16 | #define COMM "COMM" | 16 | #define COMM "COMM" |
| 17 | #define CPU "CPU" | 17 | #define CPU "CPU" |
| 18 | 18 | ||
| 19 | static struct format_field comm = { | 19 | static struct tep_format_field comm = { |
| 20 | .name = "COMM", | 20 | .name = "COMM", |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | static struct format_field cpu = { | 23 | static struct tep_format_field cpu = { |
| 24 | .name = "CPU", | 24 | .name = "CPU", |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | struct event_list { | 27 | struct event_list { |
| 28 | struct event_list *next; | 28 | struct event_list *next; |
| 29 | struct event_format *event; | 29 | struct tep_event_format *event; |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | static void show_error(char *error_buf, const char *fmt, ...) | 32 | static void show_error(char *error_buf, const char *fmt, ...) |
| @@ -61,15 +61,15 @@ static void free_token(char *token) | |||
| 61 | tep_free_token(token); | 61 | tep_free_token(token); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static enum event_type read_token(char **tok) | 64 | static enum tep_event_type read_token(char **tok) |
| 65 | { | 65 | { |
| 66 | enum event_type type; | 66 | enum tep_event_type type; |
| 67 | char *token = NULL; | 67 | char *token = NULL; |
| 68 | 68 | ||
| 69 | do { | 69 | do { |
| 70 | free_token(token); | 70 | free_token(token); |
| 71 | type = tep_read_token(&token); | 71 | type = tep_read_token(&token); |
| 72 | } while (type == EVENT_NEWLINE || type == EVENT_SPACE); | 72 | } while (type == TEP_EVENT_NEWLINE || type == TEP_EVENT_SPACE); |
| 73 | 73 | ||
| 74 | /* If token is = or ! check to see if the next char is ~ */ | 74 | /* If token is = or ! check to see if the next char is ~ */ |
| 75 | if (token && | 75 | if (token && |
| @@ -79,7 +79,7 @@ static enum event_type read_token(char **tok) | |||
| 79 | *tok = malloc(3); | 79 | *tok = malloc(3); |
| 80 | if (*tok == NULL) { | 80 | if (*tok == NULL) { |
| 81 | free_token(token); | 81 | free_token(token); |
| 82 | return EVENT_ERROR; | 82 | return TEP_EVENT_ERROR; |
| 83 | } | 83 | } |
| 84 | sprintf(*tok, "%c%c", *token, '~'); | 84 | sprintf(*tok, "%c%c", *token, '~'); |
| 85 | free_token(token); | 85 | free_token(token); |
| @@ -94,8 +94,8 @@ static enum event_type read_token(char **tok) | |||
| 94 | 94 | ||
| 95 | static int filter_cmp(const void *a, const void *b) | 95 | static int filter_cmp(const void *a, const void *b) |
| 96 | { | 96 | { |
| 97 | const struct filter_type *ea = a; | 97 | const struct tep_filter_type *ea = a; |
| 98 | const struct filter_type *eb = b; | 98 | const struct tep_filter_type *eb = b; |
| 99 | 99 | ||
| 100 | if (ea->event_id < eb->event_id) | 100 | if (ea->event_id < eb->event_id) |
| 101 | return -1; | 101 | return -1; |
| @@ -106,11 +106,11 @@ static int filter_cmp(const void *a, const void *b) | |||
| 106 | return 0; | 106 | return 0; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | static struct filter_type * | 109 | static struct tep_filter_type * |
| 110 | find_filter_type(struct event_filter *filter, int id) | 110 | find_filter_type(struct tep_event_filter *filter, int id) |
| 111 | { | 111 | { |
| 112 | struct filter_type *filter_type; | 112 | struct tep_filter_type *filter_type; |
| 113 | struct filter_type key; | 113 | struct tep_filter_type key; |
| 114 | 114 | ||
| 115 | key.event_id = id; | 115 | key.event_id = id; |
| 116 | 116 | ||
| @@ -122,10 +122,10 @@ find_filter_type(struct event_filter *filter, int id) | |||
| 122 | return filter_type; | 122 | return filter_type; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | static struct filter_type * | 125 | static struct tep_filter_type * |
| 126 | add_filter_type(struct event_filter *filter, int id) | 126 | add_filter_type(struct tep_event_filter *filter, int id) |
| 127 | { | 127 | { |
| 128 | struct filter_type *filter_type; | 128 | struct tep_filter_type *filter_type; |
| 129 | int i; | 129 | int i; |
| 130 | 130 | ||
| 131 | filter_type = find_filter_type(filter, id); | 131 | filter_type = find_filter_type(filter, id); |
| @@ -165,9 +165,9 @@ add_filter_type(struct event_filter *filter, int id) | |||
| 165 | * tep_filter_alloc - create a new event filter | 165 | * tep_filter_alloc - create a new event filter |
| 166 | * @pevent: The pevent that this filter is associated with | 166 | * @pevent: The pevent that this filter is associated with |
| 167 | */ | 167 | */ |
| 168 | struct event_filter *tep_filter_alloc(struct tep_handle *pevent) | 168 | struct tep_event_filter *tep_filter_alloc(struct tep_handle *pevent) |
| 169 | { | 169 | { |
| 170 | struct event_filter *filter; | 170 | struct tep_event_filter *filter; |
| 171 | 171 | ||
| 172 | filter = malloc(sizeof(*filter)); | 172 | filter = malloc(sizeof(*filter)); |
| 173 | if (filter == NULL) | 173 | if (filter == NULL) |
| @@ -180,44 +180,44 @@ struct event_filter *tep_filter_alloc(struct tep_handle *pevent) | |||
| 180 | return filter; | 180 | return filter; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | static struct filter_arg *allocate_arg(void) | 183 | static struct tep_filter_arg *allocate_arg(void) |
| 184 | { | 184 | { |
| 185 | return calloc(1, sizeof(struct filter_arg)); | 185 | return calloc(1, sizeof(struct tep_filter_arg)); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | static void free_arg(struct filter_arg *arg) | 188 | static void free_arg(struct tep_filter_arg *arg) |
| 189 | { | 189 | { |
| 190 | if (!arg) | 190 | if (!arg) |
| 191 | return; | 191 | return; |
| 192 | 192 | ||
| 193 | switch (arg->type) { | 193 | switch (arg->type) { |
| 194 | case FILTER_ARG_NONE: | 194 | case TEP_FILTER_ARG_NONE: |
| 195 | case FILTER_ARG_BOOLEAN: | 195 | case TEP_FILTER_ARG_BOOLEAN: |
| 196 | break; | 196 | break; |
| 197 | 197 | ||
| 198 | case FILTER_ARG_NUM: | 198 | case TEP_FILTER_ARG_NUM: |
| 199 | free_arg(arg->num.left); | 199 | free_arg(arg->num.left); |
| 200 | free_arg(arg->num.right); | 200 | free_arg(arg->num.right); |
| 201 | break; | 201 | break; |
| 202 | 202 | ||
| 203 | case FILTER_ARG_EXP: | 203 | case TEP_FILTER_ARG_EXP: |
| 204 | free_arg(arg->exp.left); | 204 | free_arg(arg->exp.left); |
| 205 | free_arg(arg->exp.right); | 205 | free_arg(arg->exp.right); |
| 206 | break; | 206 | break; |
| 207 | 207 | ||
| 208 | case FILTER_ARG_STR: | 208 | case TEP_FILTER_ARG_STR: |
| 209 | free(arg->str.val); | 209 | free(arg->str.val); |
| 210 | regfree(&arg->str.reg); | 210 | regfree(&arg->str.reg); |
| 211 | free(arg->str.buffer); | 211 | free(arg->str.buffer); |
| 212 | break; | 212 | break; |
| 213 | 213 | ||
| 214 | case FILTER_ARG_VALUE: | 214 | case TEP_FILTER_ARG_VALUE: |
| 215 | if (arg->value.type == FILTER_STRING || | 215 | if (arg->value.type == TEP_FILTER_STRING || |
| 216 | arg->value.type == FILTER_CHAR) | 216 | arg->value.type == TEP_FILTER_CHAR) |
| 217 | free(arg->value.str); | 217 | free(arg->value.str); |
| 218 | break; | 218 | break; |
| 219 | 219 | ||
| 220 | case FILTER_ARG_OP: | 220 | case TEP_FILTER_ARG_OP: |
| 221 | free_arg(arg->op.left); | 221 | free_arg(arg->op.left); |
| 222 | free_arg(arg->op.right); | 222 | free_arg(arg->op.right); |
| 223 | default: | 223 | default: |
| @@ -228,7 +228,7 @@ static void free_arg(struct filter_arg *arg) | |||
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | static int add_event(struct event_list **events, | 230 | static int add_event(struct event_list **events, |
| 231 | struct event_format *event) | 231 | struct tep_event_format *event) |
| 232 | { | 232 | { |
| 233 | struct event_list *list; | 233 | struct event_list *list; |
| 234 | 234 | ||
| @@ -242,7 +242,7 @@ static int add_event(struct event_list **events, | |||
| 242 | return 0; | 242 | return 0; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | static int event_match(struct event_format *event, | 245 | static int event_match(struct tep_event_format *event, |
| 246 | regex_t *sreg, regex_t *ereg) | 246 | regex_t *sreg, regex_t *ereg) |
| 247 | { | 247 | { |
| 248 | if (sreg) { | 248 | if (sreg) { |
| @@ -258,7 +258,7 @@ static enum tep_errno | |||
| 258 | find_event(struct tep_handle *pevent, struct event_list **events, | 258 | find_event(struct tep_handle *pevent, struct event_list **events, |
| 259 | char *sys_name, char *event_name) | 259 | char *sys_name, char *event_name) |
| 260 | { | 260 | { |
| 261 | struct event_format *event; | 261 | struct tep_event_format *event; |
| 262 | regex_t ereg; | 262 | regex_t ereg; |
| 263 | regex_t sreg; | 263 | regex_t sreg; |
| 264 | int match = 0; | 264 | int match = 0; |
| @@ -333,11 +333,11 @@ static void free_events(struct event_list *events) | |||
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | static enum tep_errno | 335 | static enum tep_errno |
| 336 | create_arg_item(struct event_format *event, const char *token, | 336 | create_arg_item(struct tep_event_format *event, const char *token, |
| 337 | enum event_type type, struct filter_arg **parg, char *error_str) | 337 | enum tep_event_type type, struct tep_filter_arg **parg, char *error_str) |
| 338 | { | 338 | { |
| 339 | struct format_field *field; | 339 | struct tep_format_field *field; |
| 340 | struct filter_arg *arg; | 340 | struct tep_filter_arg *arg; |
| 341 | 341 | ||
| 342 | arg = allocate_arg(); | 342 | arg = allocate_arg(); |
| 343 | if (arg == NULL) { | 343 | if (arg == NULL) { |
| @@ -347,11 +347,11 @@ create_arg_item(struct event_format *event, const char *token, | |||
| 347 | 347 | ||
| 348 | switch (type) { | 348 | switch (type) { |
| 349 | 349 | ||
| 350 | case EVENT_SQUOTE: | 350 | case TEP_EVENT_SQUOTE: |
| 351 | case EVENT_DQUOTE: | 351 | case TEP_EVENT_DQUOTE: |
| 352 | arg->type = FILTER_ARG_VALUE; | 352 | arg->type = TEP_FILTER_ARG_VALUE; |
| 353 | arg->value.type = | 353 | arg->value.type = |
| 354 | type == EVENT_DQUOTE ? FILTER_STRING : FILTER_CHAR; | 354 | type == TEP_EVENT_DQUOTE ? TEP_FILTER_STRING : TEP_FILTER_CHAR; |
| 355 | arg->value.str = strdup(token); | 355 | arg->value.str = strdup(token); |
| 356 | if (!arg->value.str) { | 356 | if (!arg->value.str) { |
| 357 | free_arg(arg); | 357 | free_arg(arg); |
| @@ -359,11 +359,11 @@ create_arg_item(struct event_format *event, const char *token, | |||
| 359 | return TEP_ERRNO__MEM_ALLOC_FAILED; | 359 | return TEP_ERRNO__MEM_ALLOC_FAILED; |
| 360 | } | 360 | } |
| 361 | break; | 361 | break; |
| 362 | case EVENT_ITEM: | 362 | case TEP_EVENT_ITEM: |
| 363 | /* if it is a number, then convert it */ | 363 | /* if it is a number, then convert it */ |
| 364 | if (isdigit(token[0])) { | 364 | if (isdigit(token[0])) { |
| 365 | arg->type = FILTER_ARG_VALUE; | 365 | arg->type = TEP_FILTER_ARG_VALUE; |
| 366 | arg->value.type = FILTER_NUMBER; | 366 | arg->value.type = TEP_FILTER_NUMBER; |
| 367 | arg->value.val = strtoull(token, NULL, 0); | 367 | arg->value.val = strtoull(token, NULL, 0); |
| 368 | break; | 368 | break; |
| 369 | } | 369 | } |
| @@ -377,12 +377,12 @@ create_arg_item(struct event_format *event, const char *token, | |||
| 377 | field = &cpu; | 377 | field = &cpu; |
| 378 | } else { | 378 | } else { |
| 379 | /* not a field, Make it false */ | 379 | /* not a field, Make it false */ |
| 380 | arg->type = FILTER_ARG_BOOLEAN; | 380 | arg->type = TEP_FILTER_ARG_BOOLEAN; |
| 381 | arg->boolean.value = FILTER_FALSE; | 381 | arg->boolean.value = TEP_FILTER_FALSE; |
| 382 | break; | 382 | break; |
| 383 | } | 383 | } |
| 384 | } | 384 | } |
| 385 | arg->type = FILTER_ARG_FIELD; | 385 | arg->type = TEP_FILTER_ARG_FIELD; |
| 386 | arg->field.field = field; | 386 | arg->field.field = field; |
| 387 | break; | 387 | break; |
| 388 | default: | 388 | default: |
| @@ -394,82 +394,82 @@ create_arg_item(struct event_format *event, const char *token, | |||
| 394 | return 0; | 394 | return 0; |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | static struct filter_arg * | 397 | static struct tep_filter_arg * |
| 398 | create_arg_op(enum filter_op_type btype) | 398 | create_arg_op(enum tep_filter_op_type btype) |
| 399 | { | 399 | { |
| 400 | struct filter_arg *arg; | 400 | struct tep_filter_arg *arg; |
| 401 | 401 | ||
| 402 | arg = allocate_arg(); | 402 | arg = allocate_arg(); |
| 403 | if (!arg) | 403 | if (!arg) |
| 404 | return NULL; | 404 | return NULL; |
| 405 | 405 | ||
| 406 | arg->type = FILTER_ARG_OP; | 406 | arg->type = TEP_FILTER_ARG_OP; |
| 407 | arg->op.type = btype; | 407 | arg->op.type = btype; |
| 408 | 408 | ||
| 409 | return arg; | 409 | return arg; |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | static struct filter_arg * | 412 | static struct tep_filter_arg * |
| 413 | create_arg_exp(enum filter_exp_type etype) | 413 | create_arg_exp(enum tep_filter_exp_type etype) |
| 414 | { | 414 | { |
| 415 | struct filter_arg *arg; | 415 | struct tep_filter_arg *arg; |
| 416 | 416 | ||
| 417 | arg = allocate_arg(); | 417 | arg = allocate_arg(); |
| 418 | if (!arg) | 418 | if (!arg) |
| 419 | return NULL; | 419 | return NULL; |
| 420 | 420 | ||
| 421 | arg->type = FILTER_ARG_EXP; | 421 | arg->type = TEP_FILTER_ARG_EXP; |
| 422 | arg->exp.type = etype; | 422 | arg->exp.type = etype; |
| 423 | 423 | ||
| 424 | return arg; | 424 | return arg; |
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | static struct filter_arg * | 427 | static struct tep_filter_arg * |
| 428 | create_arg_cmp(enum filter_cmp_type ctype) | 428 | create_arg_cmp(enum tep_filter_cmp_type ctype) |
| 429 | { | 429 | { |
| 430 | struct filter_arg *arg; | 430 | struct tep_filter_arg *arg; |
| 431 | 431 | ||
| 432 | arg = allocate_arg(); | 432 | arg = allocate_arg(); |
| 433 | if (!arg) | 433 | if (!arg) |
| 434 | return NULL; | 434 | return NULL; |
| 435 | 435 | ||
| 436 | /* Use NUM and change if necessary */ | 436 | /* Use NUM and change if necessary */ |
| 437 | arg->type = FILTER_ARG_NUM; | 437 | arg->type = TEP_FILTER_ARG_NUM; |
| 438 | arg->num.type = ctype; | 438 | arg->num.type = ctype; |
| 439 | 439 | ||
| 440 | return arg; | 440 | return arg; |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | static enum tep_errno | 443 | static enum tep_errno |
| 444 | add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | 444 | add_right(struct tep_filter_arg *op, struct tep_filter_arg *arg, char *error_str) |
| 445 | { | 445 | { |
| 446 | struct filter_arg *left; | 446 | struct tep_filter_arg *left; |
| 447 | char *str; | 447 | char *str; |
| 448 | int op_type; | 448 | int op_type; |
| 449 | int ret; | 449 | int ret; |
| 450 | 450 | ||
| 451 | switch (op->type) { | 451 | switch (op->type) { |
| 452 | case FILTER_ARG_EXP: | 452 | case TEP_FILTER_ARG_EXP: |
| 453 | if (op->exp.right) | 453 | if (op->exp.right) |
| 454 | goto out_fail; | 454 | goto out_fail; |
| 455 | op->exp.right = arg; | 455 | op->exp.right = arg; |
| 456 | break; | 456 | break; |
| 457 | 457 | ||
| 458 | case FILTER_ARG_OP: | 458 | case TEP_FILTER_ARG_OP: |
| 459 | if (op->op.right) | 459 | if (op->op.right) |
| 460 | goto out_fail; | 460 | goto out_fail; |
| 461 | op->op.right = arg; | 461 | op->op.right = arg; |
| 462 | break; | 462 | break; |
| 463 | 463 | ||
| 464 | case FILTER_ARG_NUM: | 464 | case TEP_FILTER_ARG_NUM: |
| 465 | if (op->op.right) | 465 | if (op->op.right) |
| 466 | goto out_fail; | 466 | goto out_fail; |
| 467 | /* | 467 | /* |
| 468 | * The arg must be num, str, or field | 468 | * The arg must be num, str, or field |
| 469 | */ | 469 | */ |
| 470 | switch (arg->type) { | 470 | switch (arg->type) { |
| 471 | case FILTER_ARG_VALUE: | 471 | case TEP_FILTER_ARG_VALUE: |
| 472 | case FILTER_ARG_FIELD: | 472 | case TEP_FILTER_ARG_FIELD: |
| 473 | break; | 473 | break; |
| 474 | default: | 474 | default: |
| 475 | show_error(error_str, "Illegal rvalue"); | 475 | show_error(error_str, "Illegal rvalue"); |
| @@ -481,20 +481,20 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | |||
| 481 | * convert this to a string or regex. | 481 | * convert this to a string or regex. |
| 482 | */ | 482 | */ |
| 483 | switch (arg->value.type) { | 483 | switch (arg->value.type) { |
| 484 | case FILTER_CHAR: | 484 | case TEP_FILTER_CHAR: |
| 485 | /* | 485 | /* |
| 486 | * A char should be converted to number if | 486 | * A char should be converted to number if |
| 487 | * the string is 1 byte, and the compare | 487 | * the string is 1 byte, and the compare |
| 488 | * is not a REGEX. | 488 | * is not a REGEX. |
| 489 | */ | 489 | */ |
| 490 | if (strlen(arg->value.str) == 1 && | 490 | if (strlen(arg->value.str) == 1 && |
| 491 | op->num.type != FILTER_CMP_REGEX && | 491 | op->num.type != TEP_FILTER_CMP_REGEX && |
| 492 | op->num.type != FILTER_CMP_NOT_REGEX) { | 492 | op->num.type != TEP_FILTER_CMP_NOT_REGEX) { |
| 493 | arg->value.type = FILTER_NUMBER; | 493 | arg->value.type = TEP_FILTER_NUMBER; |
| 494 | goto do_int; | 494 | goto do_int; |
| 495 | } | 495 | } |
| 496 | /* fall through */ | 496 | /* fall through */ |
| 497 | case FILTER_STRING: | 497 | case TEP_FILTER_STRING: |
| 498 | 498 | ||
| 499 | /* convert op to a string arg */ | 499 | /* convert op to a string arg */ |
| 500 | op_type = op->num.type; | 500 | op_type = op->num.type; |
| @@ -508,16 +508,16 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | |||
| 508 | * If left arg was a field not found then | 508 | * If left arg was a field not found then |
| 509 | * NULL the entire op. | 509 | * NULL the entire op. |
| 510 | */ | 510 | */ |
| 511 | if (left->type == FILTER_ARG_BOOLEAN) { | 511 | if (left->type == TEP_FILTER_ARG_BOOLEAN) { |
| 512 | free_arg(left); | 512 | free_arg(left); |
| 513 | free_arg(arg); | 513 | free_arg(arg); |
| 514 | op->type = FILTER_ARG_BOOLEAN; | 514 | op->type = TEP_FILTER_ARG_BOOLEAN; |
| 515 | op->boolean.value = FILTER_FALSE; | 515 | op->boolean.value = TEP_FILTER_FALSE; |
| 516 | break; | 516 | break; |
| 517 | } | 517 | } |
| 518 | 518 | ||
| 519 | /* Left arg must be a field */ | 519 | /* Left arg must be a field */ |
| 520 | if (left->type != FILTER_ARG_FIELD) { | 520 | if (left->type != TEP_FILTER_ARG_FIELD) { |
| 521 | show_error(error_str, | 521 | show_error(error_str, |
| 522 | "Illegal lvalue for string comparison"); | 522 | "Illegal lvalue for string comparison"); |
| 523 | return TEP_ERRNO__ILLEGAL_LVALUE; | 523 | return TEP_ERRNO__ILLEGAL_LVALUE; |
| @@ -525,15 +525,15 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | |||
| 525 | 525 | ||
| 526 | /* Make sure this is a valid string compare */ | 526 | /* Make sure this is a valid string compare */ |
| 527 | switch (op_type) { | 527 | switch (op_type) { |
| 528 | case FILTER_CMP_EQ: | 528 | case TEP_FILTER_CMP_EQ: |
| 529 | op_type = FILTER_CMP_MATCH; | 529 | op_type = TEP_FILTER_CMP_MATCH; |
| 530 | break; | 530 | break; |
| 531 | case FILTER_CMP_NE: | 531 | case TEP_FILTER_CMP_NE: |
| 532 | op_type = FILTER_CMP_NOT_MATCH; | 532 | op_type = TEP_FILTER_CMP_NOT_MATCH; |
| 533 | break; | 533 | break; |
| 534 | 534 | ||
| 535 | case FILTER_CMP_REGEX: | 535 | case TEP_FILTER_CMP_REGEX: |
| 536 | case FILTER_CMP_NOT_REGEX: | 536 | case TEP_FILTER_CMP_NOT_REGEX: |
| 537 | ret = regcomp(&op->str.reg, str, REG_ICASE|REG_NOSUB); | 537 | ret = regcomp(&op->str.reg, str, REG_ICASE|REG_NOSUB); |
| 538 | if (ret) { | 538 | if (ret) { |
| 539 | show_error(error_str, | 539 | show_error(error_str, |
| @@ -548,7 +548,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | |||
| 548 | return TEP_ERRNO__ILLEGAL_STRING_CMP; | 548 | return TEP_ERRNO__ILLEGAL_STRING_CMP; |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | op->type = FILTER_ARG_STR; | 551 | op->type = TEP_FILTER_ARG_STR; |
| 552 | op->str.type = op_type; | 552 | op->str.type = op_type; |
| 553 | op->str.field = left->field.field; | 553 | op->str.field = left->field.field; |
| 554 | op->str.val = strdup(str); | 554 | op->str.val = strdup(str); |
| @@ -573,12 +573,12 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | |||
| 573 | 573 | ||
| 574 | break; | 574 | break; |
| 575 | 575 | ||
| 576 | case FILTER_NUMBER: | 576 | case TEP_FILTER_NUMBER: |
| 577 | 577 | ||
| 578 | do_int: | 578 | do_int: |
| 579 | switch (op->num.type) { | 579 | switch (op->num.type) { |
| 580 | case FILTER_CMP_REGEX: | 580 | case TEP_FILTER_CMP_REGEX: |
| 581 | case FILTER_CMP_NOT_REGEX: | 581 | case TEP_FILTER_CMP_NOT_REGEX: |
| 582 | show_error(error_str, | 582 | show_error(error_str, |
| 583 | "Op not allowed with integers"); | 583 | "Op not allowed with integers"); |
| 584 | return TEP_ERRNO__ILLEGAL_INTEGER_CMP; | 584 | return TEP_ERRNO__ILLEGAL_INTEGER_CMP; |
| @@ -605,35 +605,35 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) | |||
| 605 | return TEP_ERRNO__SYNTAX_ERROR; | 605 | return TEP_ERRNO__SYNTAX_ERROR; |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | static struct filter_arg * | 608 | static struct tep_filter_arg * |
| 609 | rotate_op_right(struct filter_arg *a, struct filter_arg *b) | 609 | rotate_op_right(struct tep_filter_arg *a, struct tep_filter_arg *b) |
| 610 | { | 610 | { |
| 611 | struct filter_arg *arg; | 611 | struct tep_filter_arg *arg; |
| 612 | 612 | ||
| 613 | arg = a->op.right; | 613 | arg = a->op.right; |
| 614 | a->op.right = b; | 614 | a->op.right = b; |
| 615 | return arg; | 615 | return arg; |
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | static enum tep_errno add_left(struct filter_arg *op, struct filter_arg *arg) | 618 | static enum tep_errno add_left(struct tep_filter_arg *op, struct tep_filter_arg *arg) |
| 619 | { | 619 | { |
| 620 | switch (op->type) { | 620 | switch (op->type) { |
| 621 | case FILTER_ARG_EXP: | 621 | case TEP_FILTER_ARG_EXP: |
| 622 | if (arg->type == FILTER_ARG_OP) | 622 | if (arg->type == TEP_FILTER_ARG_OP) |
| 623 | arg = rotate_op_right(arg, op); | 623 | arg = rotate_op_right(arg, op); |
| 624 | op->exp.left = arg; | 624 | op->exp.left = arg; |
| 625 | break; | 625 | break; |
| 626 | 626 | ||
| 627 | case FILTER_ARG_OP: | 627 | case TEP_FILTER_ARG_OP: |
| 628 | op->op.left = arg; | 628 | op->op.left = arg; |
| 629 | break; | 629 | break; |
| 630 | case FILTER_ARG_NUM: | 630 | case TEP_FILTER_ARG_NUM: |
| 631 | if (arg->type == FILTER_ARG_OP) | 631 | if (arg->type == TEP_FILTER_ARG_OP) |
| 632 | arg = rotate_op_right(arg, op); | 632 | arg = rotate_op_right(arg, op); |
| 633 | 633 | ||
| 634 | /* left arg of compares must be a field */ | 634 | /* left arg of compares must be a field */ |
| 635 | if (arg->type != FILTER_ARG_FIELD && | 635 | if (arg->type != TEP_FILTER_ARG_FIELD && |
| 636 | arg->type != FILTER_ARG_BOOLEAN) | 636 | arg->type != TEP_FILTER_ARG_BOOLEAN) |
| 637 | return TEP_ERRNO__INVALID_ARG_TYPE; | 637 | return TEP_ERRNO__INVALID_ARG_TYPE; |
| 638 | op->num.left = arg; | 638 | op->num.left = arg; |
| 639 | break; | 639 | break; |
| @@ -652,91 +652,91 @@ enum op_type { | |||
| 652 | }; | 652 | }; |
| 653 | 653 | ||
| 654 | static enum op_type process_op(const char *token, | 654 | static enum op_type process_op(const char *token, |
| 655 | enum filter_op_type *btype, | 655 | enum tep_filter_op_type *btype, |
| 656 | enum filter_cmp_type *ctype, | 656 | enum tep_filter_cmp_type *ctype, |
| 657 | enum filter_exp_type *etype) | 657 | enum tep_filter_exp_type *etype) |
| 658 | { | 658 | { |
| 659 | *btype = FILTER_OP_NOT; | 659 | *btype = TEP_FILTER_OP_NOT; |
| 660 | *etype = FILTER_EXP_NONE; | 660 | *etype = TEP_FILTER_EXP_NONE; |
| 661 | *ctype = FILTER_CMP_NONE; | 661 | *ctype = TEP_FILTER_CMP_NONE; |
| 662 | 662 | ||
| 663 | if (strcmp(token, "&&") == 0) | 663 | if (strcmp(token, "&&") == 0) |
| 664 | *btype = FILTER_OP_AND; | 664 | *btype = TEP_FILTER_OP_AND; |
| 665 | else if (strcmp(token, "||") == 0) | 665 | else if (strcmp(token, "||") == 0) |
| 666 | *btype = FILTER_OP_OR; | 666 | *btype = TEP_FILTER_OP_OR; |
| 667 | else if (strcmp(token, "!") == 0) | 667 | else if (strcmp(token, "!") == 0) |
| 668 | return OP_NOT; | 668 | return OP_NOT; |
| 669 | 669 | ||
| 670 | if (*btype != FILTER_OP_NOT) | 670 | if (*btype != TEP_FILTER_OP_NOT) |
| 671 | return OP_BOOL; | 671 | return OP_BOOL; |
| 672 | 672 | ||
| 673 | /* Check for value expressions */ | 673 | /* Check for value expressions */ |
| 674 | if (strcmp(token, "+") == 0) { | 674 | if (strcmp(token, "+") == 0) { |
| 675 | *etype = FILTER_EXP_ADD; | 675 | *etype = TEP_FILTER_EXP_ADD; |
| 676 | } else if (strcmp(token, "-") == 0) { | 676 | } else if (strcmp(token, "-") == 0) { |
| 677 | *etype = FILTER_EXP_SUB; | 677 | *etype = TEP_FILTER_EXP_SUB; |
| 678 | } else if (strcmp(token, "*") == 0) { | 678 | } else if (strcmp(token, "*") == 0) { |
| 679 | *etype = FILTER_EXP_MUL; | 679 | *etype = TEP_FILTER_EXP_MUL; |
| 680 | } else if (strcmp(token, "/") == 0) { | 680 | } else if (strcmp(token, "/") == 0) { |
| 681 | *etype = FILTER_EXP_DIV; | 681 | *etype = TEP_FILTER_EXP_DIV; |
| 682 | } else if (strcmp(token, "%") == 0) { | 682 | } else if (strcmp(token, "%") == 0) { |
| 683 | *etype = FILTER_EXP_MOD; | 683 | *etype = TEP_FILTER_EXP_MOD; |
| 684 | } else if (strcmp(token, ">>") == 0) { | 684 | } else if (strcmp(token, ">>") == 0) { |
| 685 | *etype = FILTER_EXP_RSHIFT; | 685 | *etype = TEP_FILTER_EXP_RSHIFT; |
| 686 | } else if (strcmp(token, "<<") == 0) { | 686 | } else if (strcmp(token, "<<") == 0) { |
| 687 | *etype = FILTER_EXP_LSHIFT; | 687 | *etype = TEP_FILTER_EXP_LSHIFT; |
| 688 | } else if (strcmp(token, "&") == 0) { | 688 | } else if (strcmp(token, "&") == 0) { |
| 689 | *etype = FILTER_EXP_AND; | 689 | *etype = TEP_FILTER_EXP_AND; |
| 690 | } else if (strcmp(token, "|") == 0) { | 690 | } else if (strcmp(token, "|") == 0) { |
| 691 | *etype = FILTER_EXP_OR; | 691 | *etype = TEP_FILTER_EXP_OR; |
| 692 | } else if (strcmp(token, "^") == 0) { | 692 | } else if (strcmp(token, "^") == 0) { |
| 693 | *etype = FILTER_EXP_XOR; | 693 | *etype = TEP_FILTER_EXP_XOR; |
| 694 | } else if (strcmp(token, "~") == 0) | 694 | } else if (strcmp(token, "~") == 0) |
| 695 | *etype = FILTER_EXP_NOT; | 695 | *etype = TEP_FILTER_EXP_NOT; |
| 696 | 696 | ||
| 697 | if (*etype != FILTER_EXP_NONE) | 697 | if (*etype != TEP_FILTER_EXP_NONE) |
| 698 | return OP_EXP; | 698 | return OP_EXP; |
| 699 | 699 | ||
| 700 | /* Check for compares */ | 700 | /* Check for compares */ |
| 701 | if (strcmp(token, "==") == 0) | 701 | if (strcmp(token, "==") == 0) |
| 702 | *ctype = FILTER_CMP_EQ; | 702 | *ctype = TEP_FILTER_CMP_EQ; |
| 703 | else if (strcmp(token, "!=") == 0) | 703 | else if (strcmp(token, "!=") == 0) |
| 704 | *ctype = FILTER_CMP_NE; | 704 | *ctype = TEP_FILTER_CMP_NE; |
| 705 | else if (strcmp(token, "<") == 0) | 705 | else if (strcmp(token, "<") == 0) |
| 706 | *ctype = FILTER_CMP_LT; | 706 | *ctype = TEP_FILTER_CMP_LT; |
| 707 | else if (strcmp(token, ">") == 0) | 707 | else if (strcmp(token, ">") == 0) |
| 708 | *ctype = FILTER_CMP_GT; | 708 | *ctype = TEP_FILTER_CMP_GT; |
| 709 | else if (strcmp(token, "<=") == 0) | 709 | else if (strcmp(token, "<=") == 0) |
| 710 | *ctype = FILTER_CMP_LE; | 710 | *ctype = TEP_FILTER_CMP_LE; |
| 711 | else if (strcmp(token, ">=") == 0) | 711 | else if (strcmp(token, ">=") == 0) |
| 712 | *ctype = FILTER_CMP_GE; | 712 | *ctype = TEP_FILTER_CMP_GE; |
| 713 | else if (strcmp(token, "=~") == 0) | 713 | else if (strcmp(token, "=~") == 0) |
| 714 | *ctype = FILTER_CMP_REGEX; | 714 | *ctype = TEP_FILTER_CMP_REGEX; |
| 715 | else if (strcmp(token, "!~") == 0) | 715 | else if (strcmp(token, "!~") == 0) |
| 716 | *ctype = FILTER_CMP_NOT_REGEX; | 716 | *ctype = TEP_FILTER_CMP_NOT_REGEX; |
| 717 | else | 717 | else |
| 718 | return OP_NONE; | 718 | return OP_NONE; |
| 719 | 719 | ||
| 720 | return OP_CMP; | 720 | return OP_CMP; |
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | static int check_op_done(struct filter_arg *arg) | 723 | static int check_op_done(struct tep_filter_arg *arg) |
| 724 | { | 724 | { |
| 725 | switch (arg->type) { | 725 | switch (arg->type) { |
| 726 | case FILTER_ARG_EXP: | 726 | case TEP_FILTER_ARG_EXP: |
| 727 | return arg->exp.right != NULL; | 727 | return arg->exp.right != NULL; |
| 728 | 728 | ||
| 729 | case FILTER_ARG_OP: | 729 | case TEP_FILTER_ARG_OP: |
| 730 | return arg->op.right != NULL; | 730 | return arg->op.right != NULL; |
| 731 | 731 | ||
| 732 | case FILTER_ARG_NUM: | 732 | case TEP_FILTER_ARG_NUM: |
| 733 | return arg->num.right != NULL; | 733 | return arg->num.right != NULL; |
| 734 | 734 | ||
| 735 | case FILTER_ARG_STR: | 735 | case TEP_FILTER_ARG_STR: |
| 736 | /* A string conversion is always done */ | 736 | /* A string conversion is always done */ |
| 737 | return 1; | 737 | return 1; |
| 738 | 738 | ||
| 739 | case FILTER_ARG_BOOLEAN: | 739 | case TEP_FILTER_ARG_BOOLEAN: |
| 740 | /* field not found, is ok */ | 740 | /* field not found, is ok */ |
| 741 | return 1; | 741 | return 1; |
| 742 | 742 | ||
| @@ -752,14 +752,14 @@ enum filter_vals { | |||
| 752 | }; | 752 | }; |
| 753 | 753 | ||
| 754 | static enum tep_errno | 754 | static enum tep_errno |
| 755 | reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, | 755 | reparent_op_arg(struct tep_filter_arg *parent, struct tep_filter_arg *old_child, |
| 756 | struct filter_arg *arg, char *error_str) | 756 | struct tep_filter_arg *arg, char *error_str) |
| 757 | { | 757 | { |
| 758 | struct filter_arg *other_child; | 758 | struct tep_filter_arg *other_child; |
| 759 | struct filter_arg **ptr; | 759 | struct tep_filter_arg **ptr; |
| 760 | 760 | ||
| 761 | if (parent->type != FILTER_ARG_OP && | 761 | if (parent->type != TEP_FILTER_ARG_OP && |
| 762 | arg->type != FILTER_ARG_OP) { | 762 | arg->type != TEP_FILTER_ARG_OP) { |
| 763 | show_error(error_str, "can not reparent other than OP"); | 763 | show_error(error_str, "can not reparent other than OP"); |
| 764 | return TEP_ERRNO__REPARENT_NOT_OP; | 764 | return TEP_ERRNO__REPARENT_NOT_OP; |
| 765 | } | 765 | } |
| @@ -804,7 +804,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, | |||
| 804 | } | 804 | } |
| 805 | 805 | ||
| 806 | /* Returns either filter_vals (success) or tep_errno (failfure) */ | 806 | /* Returns either filter_vals (success) or tep_errno (failfure) */ |
| 807 | static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | 807 | static int test_arg(struct tep_filter_arg *parent, struct tep_filter_arg *arg, |
| 808 | char *error_str) | 808 | char *error_str) |
| 809 | { | 809 | { |
| 810 | int lval, rval; | 810 | int lval, rval; |
| @@ -812,16 +812,16 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | |||
| 812 | switch (arg->type) { | 812 | switch (arg->type) { |
| 813 | 813 | ||
| 814 | /* bad case */ | 814 | /* bad case */ |
| 815 | case FILTER_ARG_BOOLEAN: | 815 | case TEP_FILTER_ARG_BOOLEAN: |
| 816 | return FILTER_VAL_FALSE + arg->boolean.value; | 816 | return FILTER_VAL_FALSE + arg->boolean.value; |
| 817 | 817 | ||
| 818 | /* good cases: */ | 818 | /* good cases: */ |
| 819 | case FILTER_ARG_STR: | 819 | case TEP_FILTER_ARG_STR: |
| 820 | case FILTER_ARG_VALUE: | 820 | case TEP_FILTER_ARG_VALUE: |
| 821 | case FILTER_ARG_FIELD: | 821 | case TEP_FILTER_ARG_FIELD: |
| 822 | return FILTER_VAL_NORM; | 822 | return FILTER_VAL_NORM; |
| 823 | 823 | ||
| 824 | case FILTER_ARG_EXP: | 824 | case TEP_FILTER_ARG_EXP: |
| 825 | lval = test_arg(arg, arg->exp.left, error_str); | 825 | lval = test_arg(arg, arg->exp.left, error_str); |
| 826 | if (lval != FILTER_VAL_NORM) | 826 | if (lval != FILTER_VAL_NORM) |
| 827 | return lval; | 827 | return lval; |
| @@ -830,7 +830,7 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | |||
| 830 | return rval; | 830 | return rval; |
| 831 | return FILTER_VAL_NORM; | 831 | return FILTER_VAL_NORM; |
| 832 | 832 | ||
| 833 | case FILTER_ARG_NUM: | 833 | case TEP_FILTER_ARG_NUM: |
| 834 | lval = test_arg(arg, arg->num.left, error_str); | 834 | lval = test_arg(arg, arg->num.left, error_str); |
| 835 | if (lval != FILTER_VAL_NORM) | 835 | if (lval != FILTER_VAL_NORM) |
| 836 | return lval; | 836 | return lval; |
| @@ -839,14 +839,14 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | |||
| 839 | return rval; | 839 | return rval; |
| 840 | return FILTER_VAL_NORM; | 840 | return FILTER_VAL_NORM; |
| 841 | 841 | ||
| 842 | case FILTER_ARG_OP: | 842 | case TEP_FILTER_ARG_OP: |
| 843 | if (arg->op.type != FILTER_OP_NOT) { | 843 | if (arg->op.type != TEP_FILTER_OP_NOT) { |
| 844 | lval = test_arg(arg, arg->op.left, error_str); | 844 | lval = test_arg(arg, arg->op.left, error_str); |
| 845 | switch (lval) { | 845 | switch (lval) { |
| 846 | case FILTER_VAL_NORM: | 846 | case FILTER_VAL_NORM: |
| 847 | break; | 847 | break; |
| 848 | case FILTER_VAL_TRUE: | 848 | case FILTER_VAL_TRUE: |
| 849 | if (arg->op.type == FILTER_OP_OR) | 849 | if (arg->op.type == TEP_FILTER_OP_OR) |
| 850 | return FILTER_VAL_TRUE; | 850 | return FILTER_VAL_TRUE; |
| 851 | rval = test_arg(arg, arg->op.right, error_str); | 851 | rval = test_arg(arg, arg->op.right, error_str); |
| 852 | if (rval != FILTER_VAL_NORM) | 852 | if (rval != FILTER_VAL_NORM) |
| @@ -856,7 +856,7 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | |||
| 856 | error_str); | 856 | error_str); |
| 857 | 857 | ||
| 858 | case FILTER_VAL_FALSE: | 858 | case FILTER_VAL_FALSE: |
| 859 | if (arg->op.type == FILTER_OP_AND) | 859 | if (arg->op.type == TEP_FILTER_OP_AND) |
| 860 | return FILTER_VAL_FALSE; | 860 | return FILTER_VAL_FALSE; |
| 861 | rval = test_arg(arg, arg->op.right, error_str); | 861 | rval = test_arg(arg, arg->op.right, error_str); |
| 862 | if (rval != FILTER_VAL_NORM) | 862 | if (rval != FILTER_VAL_NORM) |
| @@ -877,18 +877,18 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | |||
| 877 | break; | 877 | break; |
| 878 | 878 | ||
| 879 | case FILTER_VAL_TRUE: | 879 | case FILTER_VAL_TRUE: |
| 880 | if (arg->op.type == FILTER_OP_OR) | 880 | if (arg->op.type == TEP_FILTER_OP_OR) |
| 881 | return FILTER_VAL_TRUE; | 881 | return FILTER_VAL_TRUE; |
| 882 | if (arg->op.type == FILTER_OP_NOT) | 882 | if (arg->op.type == TEP_FILTER_OP_NOT) |
| 883 | return FILTER_VAL_FALSE; | 883 | return FILTER_VAL_FALSE; |
| 884 | 884 | ||
| 885 | return reparent_op_arg(parent, arg, arg->op.left, | 885 | return reparent_op_arg(parent, arg, arg->op.left, |
| 886 | error_str); | 886 | error_str); |
| 887 | 887 | ||
| 888 | case FILTER_VAL_FALSE: | 888 | case FILTER_VAL_FALSE: |
| 889 | if (arg->op.type == FILTER_OP_AND) | 889 | if (arg->op.type == TEP_FILTER_OP_AND) |
| 890 | return FILTER_VAL_FALSE; | 890 | return FILTER_VAL_FALSE; |
| 891 | if (arg->op.type == FILTER_OP_NOT) | 891 | if (arg->op.type == TEP_FILTER_OP_NOT) |
| 892 | return FILTER_VAL_TRUE; | 892 | return FILTER_VAL_TRUE; |
| 893 | 893 | ||
| 894 | return reparent_op_arg(parent, arg, arg->op.left, | 894 | return reparent_op_arg(parent, arg, arg->op.left, |
| @@ -904,8 +904,8 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, | |||
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | /* Remove any unknown event fields */ | 906 | /* Remove any unknown event fields */ |
| 907 | static int collapse_tree(struct filter_arg *arg, | 907 | static int collapse_tree(struct tep_filter_arg *arg, |
| 908 | struct filter_arg **arg_collapsed, char *error_str) | 908 | struct tep_filter_arg **arg_collapsed, char *error_str) |
| 909 | { | 909 | { |
| 910 | int ret; | 910 | int ret; |
| 911 | 911 | ||
| @@ -919,7 +919,7 @@ static int collapse_tree(struct filter_arg *arg, | |||
| 919 | free_arg(arg); | 919 | free_arg(arg); |
| 920 | arg = allocate_arg(); | 920 | arg = allocate_arg(); |
| 921 | if (arg) { | 921 | if (arg) { |
| 922 | arg->type = FILTER_ARG_BOOLEAN; | 922 | arg->type = TEP_FILTER_ARG_BOOLEAN; |
| 923 | arg->boolean.value = ret == FILTER_VAL_TRUE; | 923 | arg->boolean.value = ret == FILTER_VAL_TRUE; |
| 924 | } else { | 924 | } else { |
| 925 | show_error(error_str, "Failed to allocate filter arg"); | 925 | show_error(error_str, "Failed to allocate filter arg"); |
| @@ -939,19 +939,19 @@ static int collapse_tree(struct filter_arg *arg, | |||
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | static enum tep_errno | 941 | static enum tep_errno |
| 942 | process_filter(struct event_format *event, struct filter_arg **parg, | 942 | process_filter(struct tep_event_format *event, struct tep_filter_arg **parg, |
| 943 | char *error_str, int not) | 943 | char *error_str, int not) |
| 944 | { | 944 | { |
| 945 | enum event_type type; | 945 | enum tep_event_type type; |
| 946 | char *token = NULL; | 946 | char *token = NULL; |
| 947 | struct filter_arg *current_op = NULL; | 947 | struct tep_filter_arg *current_op = NULL; |
| 948 | struct filter_arg *current_exp = NULL; | 948 | struct tep_filter_arg *current_exp = NULL; |
| 949 | struct filter_arg *left_item = NULL; | 949 | struct tep_filter_arg *left_item = NULL; |
| 950 | struct filter_arg *arg = NULL; | 950 | struct tep_filter_arg *arg = NULL; |
| 951 | enum op_type op_type; | 951 | enum op_type op_type; |
| 952 | enum filter_op_type btype; | 952 | enum tep_filter_op_type btype; |
| 953 | enum filter_exp_type etype; | 953 | enum tep_filter_exp_type etype; |
| 954 | enum filter_cmp_type ctype; | 954 | enum tep_filter_cmp_type ctype; |
| 955 | enum tep_errno ret; | 955 | enum tep_errno ret; |
| 956 | 956 | ||
| 957 | *parg = NULL; | 957 | *parg = NULL; |
| @@ -960,9 +960,9 @@ process_filter(struct event_format *event, struct filter_arg **parg, | |||
| 960 | free(token); | 960 | free(token); |
| 961 | type = read_token(&token); | 961 | type = read_token(&token); |
| 962 | switch (type) { | 962 | switch (type) { |
| 963 | case EVENT_SQUOTE: | 963 | case TEP_EVENT_SQUOTE: |
| 964 | case EVENT_DQUOTE: | 964 | case TEP_EVENT_DQUOTE: |
| 965 | case EVENT_ITEM: | 965 | case TEP_EVENT_ITEM: |
| 966 | ret = create_arg_item(event, token, type, &arg, error_str); | 966 | ret = create_arg_item(event, token, type, &arg, error_str); |
| 967 | if (ret < 0) | 967 | if (ret < 0) |
| 968 | goto fail; | 968 | goto fail; |
| @@ -987,7 +987,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, | |||
| 987 | arg = NULL; | 987 | arg = NULL; |
| 988 | break; | 988 | break; |
| 989 | 989 | ||
| 990 | case EVENT_DELIM: | 990 | case TEP_EVENT_DELIM: |
| 991 | if (*token == ',') { | 991 | if (*token == ',') { |
| 992 | show_error(error_str, "Illegal token ','"); | 992 | show_error(error_str, "Illegal token ','"); |
| 993 | ret = TEP_ERRNO__ILLEGAL_TOKEN; | 993 | ret = TEP_ERRNO__ILLEGAL_TOKEN; |
| @@ -1054,7 +1054,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, | |||
| 1054 | } | 1054 | } |
| 1055 | break; | 1055 | break; |
| 1056 | 1056 | ||
| 1057 | case EVENT_OP: | 1057 | case TEP_EVENT_OP: |
| 1058 | op_type = process_op(token, &btype, &ctype, &etype); | 1058 | op_type = process_op(token, &btype, &ctype, &etype); |
| 1059 | 1059 | ||
| 1060 | /* All expect a left arg except for NOT */ | 1060 | /* All expect a left arg except for NOT */ |
| @@ -1139,14 +1139,14 @@ process_filter(struct event_format *event, struct filter_arg **parg, | |||
| 1139 | if (ret < 0) | 1139 | if (ret < 0) |
| 1140 | goto fail_syntax; | 1140 | goto fail_syntax; |
| 1141 | break; | 1141 | break; |
| 1142 | case EVENT_NONE: | 1142 | case TEP_EVENT_NONE: |
| 1143 | break; | 1143 | break; |
| 1144 | case EVENT_ERROR: | 1144 | case TEP_EVENT_ERROR: |
| 1145 | goto fail_alloc; | 1145 | goto fail_alloc; |
| 1146 | default: | 1146 | default: |
| 1147 | goto fail_syntax; | 1147 | goto fail_syntax; |
| 1148 | } | 1148 | } |
| 1149 | } while (type != EVENT_NONE); | 1149 | } while (type != TEP_EVENT_NONE); |
| 1150 | 1150 | ||
| 1151 | if (!current_op && !current_exp) | 1151 | if (!current_op && !current_exp) |
| 1152 | goto fail_syntax; | 1152 | goto fail_syntax; |
| @@ -1179,8 +1179,8 @@ process_filter(struct event_format *event, struct filter_arg **parg, | |||
| 1179 | } | 1179 | } |
| 1180 | 1180 | ||
| 1181 | static enum tep_errno | 1181 | static enum tep_errno |
| 1182 | process_event(struct event_format *event, const char *filter_str, | 1182 | process_event(struct tep_event_format *event, const char *filter_str, |
| 1183 | struct filter_arg **parg, char *error_str) | 1183 | struct tep_filter_arg **parg, char *error_str) |
| 1184 | { | 1184 | { |
| 1185 | int ret; | 1185 | int ret; |
| 1186 | 1186 | ||
| @@ -1196,19 +1196,19 @@ process_event(struct event_format *event, const char *filter_str, | |||
| 1196 | if (*parg == NULL) | 1196 | if (*parg == NULL) |
| 1197 | return TEP_ERRNO__MEM_ALLOC_FAILED; | 1197 | return TEP_ERRNO__MEM_ALLOC_FAILED; |
| 1198 | 1198 | ||
| 1199 | (*parg)->type = FILTER_ARG_BOOLEAN; | 1199 | (*parg)->type = TEP_FILTER_ARG_BOOLEAN; |
| 1200 | (*parg)->boolean.value = FILTER_FALSE; | 1200 | (*parg)->boolean.value = TEP_FILTER_FALSE; |
| 1201 | } | 1201 | } |
| 1202 | 1202 | ||
| 1203 | return 0; | 1203 | return 0; |
| 1204 | } | 1204 | } |
| 1205 | 1205 | ||
| 1206 | static enum tep_errno | 1206 | static enum tep_errno |
| 1207 | filter_event(struct event_filter *filter, struct event_format *event, | 1207 | filter_event(struct tep_event_filter *filter, struct tep_event_format *event, |
| 1208 | const char *filter_str, char *error_str) | 1208 | const char *filter_str, char *error_str) |
| 1209 | { | 1209 | { |
| 1210 | struct filter_type *filter_type; | 1210 | struct tep_filter_type *filter_type; |
| 1211 | struct filter_arg *arg; | 1211 | struct tep_filter_arg *arg; |
| 1212 | enum tep_errno ret; | 1212 | enum tep_errno ret; |
| 1213 | 1213 | ||
| 1214 | if (filter_str) { | 1214 | if (filter_str) { |
| @@ -1222,8 +1222,8 @@ filter_event(struct event_filter *filter, struct event_format *event, | |||
| 1222 | if (arg == NULL) | 1222 | if (arg == NULL) |
| 1223 | return TEP_ERRNO__MEM_ALLOC_FAILED; | 1223 | return TEP_ERRNO__MEM_ALLOC_FAILED; |
| 1224 | 1224 | ||
| 1225 | arg->type = FILTER_ARG_BOOLEAN; | 1225 | arg->type = TEP_FILTER_ARG_BOOLEAN; |
| 1226 | arg->boolean.value = FILTER_TRUE; | 1226 | arg->boolean.value = TEP_FILTER_TRUE; |
| 1227 | } | 1227 | } |
| 1228 | 1228 | ||
| 1229 | filter_type = add_filter_type(filter, event->id); | 1229 | filter_type = add_filter_type(filter, event->id); |
| @@ -1237,7 +1237,7 @@ filter_event(struct event_filter *filter, struct event_format *event, | |||
| 1237 | return 0; | 1237 | return 0; |
| 1238 | } | 1238 | } |
| 1239 | 1239 | ||
| 1240 | static void filter_init_error_buf(struct event_filter *filter) | 1240 | static void filter_init_error_buf(struct tep_event_filter *filter) |
| 1241 | { | 1241 | { |
| 1242 | /* clear buffer to reset show error */ | 1242 | /* clear buffer to reset show error */ |
| 1243 | tep_buffer_init("", 0); | 1243 | tep_buffer_init("", 0); |
| @@ -1253,7 +1253,7 @@ static void filter_init_error_buf(struct event_filter *filter) | |||
| 1253 | * negative error code. Use tep_filter_strerror() to see | 1253 | * negative error code. Use tep_filter_strerror() to see |
| 1254 | * actual error message in case of error. | 1254 | * actual error message in case of error. |
| 1255 | */ | 1255 | */ |
| 1256 | enum tep_errno tep_filter_add_filter_str(struct event_filter *filter, | 1256 | enum tep_errno tep_filter_add_filter_str(struct tep_event_filter *filter, |
| 1257 | const char *filter_str) | 1257 | const char *filter_str) |
| 1258 | { | 1258 | { |
| 1259 | struct tep_handle *pevent = filter->pevent; | 1259 | struct tep_handle *pevent = filter->pevent; |
| @@ -1351,7 +1351,7 @@ enum tep_errno tep_filter_add_filter_str(struct event_filter *filter, | |||
| 1351 | return rtn; | 1351 | return rtn; |
| 1352 | } | 1352 | } |
| 1353 | 1353 | ||
| 1354 | static void free_filter_type(struct filter_type *filter_type) | 1354 | static void free_filter_type(struct tep_filter_type *filter_type) |
| 1355 | { | 1355 | { |
| 1356 | free_arg(filter_type->filter); | 1356 | free_arg(filter_type->filter); |
| 1357 | } | 1357 | } |
| @@ -1365,7 +1365,7 @@ static void free_filter_type(struct filter_type *filter_type) | |||
| 1365 | * | 1365 | * |
| 1366 | * Returns 0 if message was filled successfully, -1 if error | 1366 | * Returns 0 if message was filled successfully, -1 if error |
| 1367 | */ | 1367 | */ |
| 1368 | int tep_filter_strerror(struct event_filter *filter, enum tep_errno err, | 1368 | int tep_filter_strerror(struct tep_event_filter *filter, enum tep_errno err, |
| 1369 | char *buf, size_t buflen) | 1369 | char *buf, size_t buflen) |
| 1370 | { | 1370 | { |
| 1371 | if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END) | 1371 | if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END) |
| @@ -1393,10 +1393,10 @@ int tep_filter_strerror(struct event_filter *filter, enum tep_errno err, | |||
| 1393 | * Returns 1: if an event was removed | 1393 | * Returns 1: if an event was removed |
| 1394 | * 0: if the event was not found | 1394 | * 0: if the event was not found |
| 1395 | */ | 1395 | */ |
| 1396 | int tep_filter_remove_event(struct event_filter *filter, | 1396 | int tep_filter_remove_event(struct tep_event_filter *filter, |
| 1397 | int event_id) | 1397 | int event_id) |
| 1398 | { | 1398 | { |
| 1399 | struct filter_type *filter_type; | 1399 | struct tep_filter_type *filter_type; |
| 1400 | unsigned long len; | 1400 | unsigned long len; |
| 1401 | 1401 | ||
| 1402 | if (!filter->filters) | 1402 | if (!filter->filters) |
| @@ -1428,7 +1428,7 @@ int tep_filter_remove_event(struct event_filter *filter, | |||
| 1428 | * | 1428 | * |
| 1429 | * Removes all filters from a filter and resets it. | 1429 | * Removes all filters from a filter and resets it. |
| 1430 | */ | 1430 | */ |
| 1431 | void tep_filter_reset(struct event_filter *filter) | 1431 | void tep_filter_reset(struct tep_event_filter *filter) |
| 1432 | { | 1432 | { |
| 1433 | int i; | 1433 | int i; |
| 1434 | 1434 | ||
| @@ -1440,7 +1440,7 @@ void tep_filter_reset(struct event_filter *filter) | |||
| 1440 | filter->event_filters = NULL; | 1440 | filter->event_filters = NULL; |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | void tep_filter_free(struct event_filter *filter) | 1443 | void tep_filter_free(struct tep_event_filter *filter) |
| 1444 | { | 1444 | { |
| 1445 | tep_unref(filter->pevent); | 1445 | tep_unref(filter->pevent); |
| 1446 | 1446 | ||
| @@ -1449,14 +1449,14 @@ void tep_filter_free(struct event_filter *filter) | |||
| 1449 | free(filter); | 1449 | free(filter); |
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg); | 1452 | static char *arg_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg); |
| 1453 | 1453 | ||
| 1454 | static int copy_filter_type(struct event_filter *filter, | 1454 | static int copy_filter_type(struct tep_event_filter *filter, |
| 1455 | struct event_filter *source, | 1455 | struct tep_event_filter *source, |
| 1456 | struct filter_type *filter_type) | 1456 | struct tep_filter_type *filter_type) |
| 1457 | { | 1457 | { |
| 1458 | struct filter_arg *arg; | 1458 | struct tep_filter_arg *arg; |
| 1459 | struct event_format *event; | 1459 | struct tep_event_format *event; |
| 1460 | const char *sys; | 1460 | const char *sys; |
| 1461 | const char *name; | 1461 | const char *name; |
| 1462 | char *str; | 1462 | char *str; |
| @@ -1478,7 +1478,7 @@ static int copy_filter_type(struct event_filter *filter, | |||
| 1478 | if (arg == NULL) | 1478 | if (arg == NULL) |
| 1479 | return -1; | 1479 | return -1; |
| 1480 | 1480 | ||
| 1481 | arg->type = FILTER_ARG_BOOLEAN; | 1481 | arg->type = TEP_FILTER_ARG_BOOLEAN; |
| 1482 | if (strcmp(str, "TRUE") == 0) | 1482 | if (strcmp(str, "TRUE") == 0) |
| 1483 | arg->boolean.value = 1; | 1483 | arg->boolean.value = 1; |
| 1484 | else | 1484 | else |
| @@ -1507,7 +1507,7 @@ static int copy_filter_type(struct event_filter *filter, | |||
| 1507 | * | 1507 | * |
| 1508 | * Returns 0 on success and -1 if not all filters were copied | 1508 | * Returns 0 on success and -1 if not all filters were copied |
| 1509 | */ | 1509 | */ |
| 1510 | int tep_filter_copy(struct event_filter *dest, struct event_filter *source) | 1510 | int tep_filter_copy(struct tep_event_filter *dest, struct tep_event_filter *source) |
| 1511 | { | 1511 | { |
| 1512 | int ret = 0; | 1512 | int ret = 0; |
| 1513 | int i; | 1513 | int i; |
| @@ -1533,14 +1533,14 @@ int tep_filter_copy(struct event_filter *dest, struct event_filter *source) | |||
| 1533 | * Returns 0 on success and -1 if there was a problem updating, but | 1533 | * Returns 0 on success and -1 if there was a problem updating, but |
| 1534 | * events may have still been updated on error. | 1534 | * events may have still been updated on error. |
| 1535 | */ | 1535 | */ |
| 1536 | int tep_update_trivial(struct event_filter *dest, struct event_filter *source, | 1536 | int tep_update_trivial(struct tep_event_filter *dest, struct tep_event_filter *source, |
| 1537 | enum filter_trivial_type type) | 1537 | enum tep_filter_trivial_type type) |
| 1538 | { | 1538 | { |
| 1539 | struct tep_handle *src_pevent; | 1539 | struct tep_handle *src_pevent; |
| 1540 | struct tep_handle *dest_pevent; | 1540 | struct tep_handle *dest_pevent; |
| 1541 | struct event_format *event; | 1541 | struct tep_event_format *event; |
| 1542 | struct filter_type *filter_type; | 1542 | struct tep_filter_type *filter_type; |
| 1543 | struct filter_arg *arg; | 1543 | struct tep_filter_arg *arg; |
| 1544 | char *str; | 1544 | char *str; |
| 1545 | int i; | 1545 | int i; |
| 1546 | 1546 | ||
| @@ -1554,10 +1554,10 @@ int tep_update_trivial(struct event_filter *dest, struct event_filter *source, | |||
| 1554 | for (i = 0; i < dest->filters; i++) { | 1554 | for (i = 0; i < dest->filters; i++) { |
| 1555 | filter_type = &dest->event_filters[i]; | 1555 | filter_type = &dest->event_filters[i]; |
| 1556 | arg = filter_type->filter; | 1556 | arg = filter_type->filter; |
| 1557 | if (arg->type != FILTER_ARG_BOOLEAN) | 1557 | if (arg->type != TEP_FILTER_ARG_BOOLEAN) |
| 1558 | continue; | 1558 | continue; |
| 1559 | if ((arg->boolean.value && type == FILTER_TRIVIAL_FALSE) || | 1559 | if ((arg->boolean.value && type == TEP_FILTER_TRIVIAL_FALSE) || |
| 1560 | (!arg->boolean.value && type == FILTER_TRIVIAL_TRUE)) | 1560 | (!arg->boolean.value && type == TEP_FILTER_TRIVIAL_TRUE)) |
| 1561 | continue; | 1561 | continue; |
| 1562 | 1562 | ||
| 1563 | event = filter_type->event; | 1563 | event = filter_type->event; |
| @@ -1592,10 +1592,10 @@ int tep_update_trivial(struct event_filter *dest, struct event_filter *source, | |||
| 1592 | * | 1592 | * |
| 1593 | * Returns 0 on success and -1 if there was a problem. | 1593 | * Returns 0 on success and -1 if there was a problem. |
| 1594 | */ | 1594 | */ |
| 1595 | int tep_filter_clear_trivial(struct event_filter *filter, | 1595 | int tep_filter_clear_trivial(struct tep_event_filter *filter, |
| 1596 | enum filter_trivial_type type) | 1596 | enum tep_filter_trivial_type type) |
| 1597 | { | 1597 | { |
| 1598 | struct filter_type *filter_type; | 1598 | struct tep_filter_type *filter_type; |
| 1599 | int count = 0; | 1599 | int count = 0; |
| 1600 | int *ids = NULL; | 1600 | int *ids = NULL; |
| 1601 | int i; | 1601 | int i; |
| @@ -1611,14 +1611,14 @@ int tep_filter_clear_trivial(struct event_filter *filter, | |||
| 1611 | int *new_ids; | 1611 | int *new_ids; |
| 1612 | 1612 | ||
| 1613 | filter_type = &filter->event_filters[i]; | 1613 | filter_type = &filter->event_filters[i]; |
| 1614 | if (filter_type->filter->type != FILTER_ARG_BOOLEAN) | 1614 | if (filter_type->filter->type != TEP_FILTER_ARG_BOOLEAN) |
| 1615 | continue; | 1615 | continue; |
| 1616 | switch (type) { | 1616 | switch (type) { |
| 1617 | case FILTER_TRIVIAL_FALSE: | 1617 | case TEP_FILTER_TRIVIAL_FALSE: |
| 1618 | if (filter_type->filter->boolean.value) | 1618 | if (filter_type->filter->boolean.value) |
| 1619 | continue; | 1619 | continue; |
| 1620 | break; | 1620 | break; |
| 1621 | case FILTER_TRIVIAL_TRUE: | 1621 | case TEP_FILTER_TRIVIAL_TRUE: |
| 1622 | if (!filter_type->filter->boolean.value) | 1622 | if (!filter_type->filter->boolean.value) |
| 1623 | continue; | 1623 | continue; |
| 1624 | default: | 1624 | default: |
| @@ -1654,11 +1654,11 @@ int tep_filter_clear_trivial(struct event_filter *filter, | |||
| 1654 | * Returns 1 if the event contains a matching trivial type | 1654 | * Returns 1 if the event contains a matching trivial type |
| 1655 | * otherwise 0. | 1655 | * otherwise 0. |
| 1656 | */ | 1656 | */ |
| 1657 | int tep_filter_event_has_trivial(struct event_filter *filter, | 1657 | int tep_filter_event_has_trivial(struct tep_event_filter *filter, |
| 1658 | int event_id, | 1658 | int event_id, |
| 1659 | enum filter_trivial_type type) | 1659 | enum tep_filter_trivial_type type) |
| 1660 | { | 1660 | { |
| 1661 | struct filter_type *filter_type; | 1661 | struct tep_filter_type *filter_type; |
| 1662 | 1662 | ||
| 1663 | if (!filter->filters) | 1663 | if (!filter->filters) |
| 1664 | return 0; | 1664 | return 0; |
| @@ -1668,25 +1668,25 @@ int tep_filter_event_has_trivial(struct event_filter *filter, | |||
| 1668 | if (!filter_type) | 1668 | if (!filter_type) |
| 1669 | return 0; | 1669 | return 0; |
| 1670 | 1670 | ||
| 1671 | if (filter_type->filter->type != FILTER_ARG_BOOLEAN) | 1671 | if (filter_type->filter->type != TEP_FILTER_ARG_BOOLEAN) |
| 1672 | return 0; | 1672 | return 0; |
| 1673 | 1673 | ||
| 1674 | switch (type) { | 1674 | switch (type) { |
| 1675 | case FILTER_TRIVIAL_FALSE: | 1675 | case TEP_FILTER_TRIVIAL_FALSE: |
| 1676 | return !filter_type->filter->boolean.value; | 1676 | return !filter_type->filter->boolean.value; |
| 1677 | 1677 | ||
| 1678 | case FILTER_TRIVIAL_TRUE: | 1678 | case TEP_FILTER_TRIVIAL_TRUE: |
| 1679 | return filter_type->filter->boolean.value; | 1679 | return filter_type->filter->boolean.value; |
| 1680 | default: | 1680 | default: |
| 1681 | return 1; | 1681 | return 1; |
| 1682 | } | 1682 | } |
| 1683 | } | 1683 | } |
| 1684 | 1684 | ||
| 1685 | static int test_filter(struct event_format *event, struct filter_arg *arg, | 1685 | static int test_filter(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1686 | struct tep_record *record, enum tep_errno *err); | 1686 | struct tep_record *record, enum tep_errno *err); |
| 1687 | 1687 | ||
| 1688 | static const char * | 1688 | static const char * |
| 1689 | get_comm(struct event_format *event, struct tep_record *record) | 1689 | get_comm(struct tep_event_format *event, struct tep_record *record) |
| 1690 | { | 1690 | { |
| 1691 | const char *comm; | 1691 | const char *comm; |
| 1692 | int pid; | 1692 | int pid; |
| @@ -1697,8 +1697,8 @@ get_comm(struct event_format *event, struct tep_record *record) | |||
| 1697 | } | 1697 | } |
| 1698 | 1698 | ||
| 1699 | static unsigned long long | 1699 | static unsigned long long |
| 1700 | get_value(struct event_format *event, | 1700 | get_value(struct tep_event_format *event, |
| 1701 | struct format_field *field, struct tep_record *record) | 1701 | struct tep_format_field *field, struct tep_record *record) |
| 1702 | { | 1702 | { |
| 1703 | unsigned long long val; | 1703 | unsigned long long val; |
| 1704 | 1704 | ||
| @@ -1716,7 +1716,7 @@ get_value(struct event_format *event, | |||
| 1716 | 1716 | ||
| 1717 | tep_read_number_field(field, record->data, &val); | 1717 | tep_read_number_field(field, record->data, &val); |
| 1718 | 1718 | ||
| 1719 | if (!(field->flags & FIELD_IS_SIGNED)) | 1719 | if (!(field->flags & TEP_FIELD_IS_SIGNED)) |
| 1720 | return val; | 1720 | return val; |
| 1721 | 1721 | ||
| 1722 | switch (field->size) { | 1722 | switch (field->size) { |
| @@ -1733,11 +1733,11 @@ get_value(struct event_format *event, | |||
| 1733 | } | 1733 | } |
| 1734 | 1734 | ||
| 1735 | static unsigned long long | 1735 | static unsigned long long |
| 1736 | get_arg_value(struct event_format *event, struct filter_arg *arg, | 1736 | get_arg_value(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1737 | struct tep_record *record, enum tep_errno *err); | 1737 | struct tep_record *record, enum tep_errno *err); |
| 1738 | 1738 | ||
| 1739 | static unsigned long long | 1739 | static unsigned long long |
| 1740 | get_exp_value(struct event_format *event, struct filter_arg *arg, | 1740 | get_exp_value(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1741 | struct tep_record *record, enum tep_errno *err) | 1741 | struct tep_record *record, enum tep_errno *err) |
| 1742 | { | 1742 | { |
| 1743 | unsigned long long lval, rval; | 1743 | unsigned long long lval, rval; |
| @@ -1753,37 +1753,37 @@ get_exp_value(struct event_format *event, struct filter_arg *arg, | |||
| 1753 | } | 1753 | } |
| 1754 | 1754 | ||
| 1755 | switch (arg->exp.type) { | 1755 | switch (arg->exp.type) { |
| 1756 | case FILTER_EXP_ADD: | 1756 | case TEP_FILTER_EXP_ADD: |
| 1757 | return lval + rval; | 1757 | return lval + rval; |
| 1758 | 1758 | ||
| 1759 | case FILTER_EXP_SUB: | 1759 | case TEP_FILTER_EXP_SUB: |
| 1760 | return lval - rval; | 1760 | return lval - rval; |
| 1761 | 1761 | ||
| 1762 | case FILTER_EXP_MUL: | 1762 | case TEP_FILTER_EXP_MUL: |
| 1763 | return lval * rval; | 1763 | return lval * rval; |
| 1764 | 1764 | ||
| 1765 | case FILTER_EXP_DIV: | 1765 | case TEP_FILTER_EXP_DIV: |
| 1766 | return lval / rval; | 1766 | return lval / rval; |
| 1767 | 1767 | ||
| 1768 | case FILTER_EXP_MOD: | 1768 | case TEP_FILTER_EXP_MOD: |
| 1769 | return lval % rval; | 1769 | return lval % rval; |
| 1770 | 1770 | ||
| 1771 | case FILTER_EXP_RSHIFT: | 1771 | case TEP_FILTER_EXP_RSHIFT: |
| 1772 | return lval >> rval; | 1772 | return lval >> rval; |
| 1773 | 1773 | ||
| 1774 | case FILTER_EXP_LSHIFT: | 1774 | case TEP_FILTER_EXP_LSHIFT: |
| 1775 | return lval << rval; | 1775 | return lval << rval; |
| 1776 | 1776 | ||
| 1777 | case FILTER_EXP_AND: | 1777 | case TEP_FILTER_EXP_AND: |
| 1778 | return lval & rval; | 1778 | return lval & rval; |
| 1779 | 1779 | ||
| 1780 | case FILTER_EXP_OR: | 1780 | case TEP_FILTER_EXP_OR: |
| 1781 | return lval | rval; | 1781 | return lval | rval; |
| 1782 | 1782 | ||
| 1783 | case FILTER_EXP_XOR: | 1783 | case TEP_FILTER_EXP_XOR: |
| 1784 | return lval ^ rval; | 1784 | return lval ^ rval; |
| 1785 | 1785 | ||
| 1786 | case FILTER_EXP_NOT: | 1786 | case TEP_FILTER_EXP_NOT: |
| 1787 | default: | 1787 | default: |
| 1788 | if (!*err) | 1788 | if (!*err) |
| 1789 | *err = TEP_ERRNO__INVALID_EXP_TYPE; | 1789 | *err = TEP_ERRNO__INVALID_EXP_TYPE; |
| @@ -1792,21 +1792,21 @@ get_exp_value(struct event_format *event, struct filter_arg *arg, | |||
| 1792 | } | 1792 | } |
| 1793 | 1793 | ||
| 1794 | static unsigned long long | 1794 | static unsigned long long |
| 1795 | get_arg_value(struct event_format *event, struct filter_arg *arg, | 1795 | get_arg_value(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1796 | struct tep_record *record, enum tep_errno *err) | 1796 | struct tep_record *record, enum tep_errno *err) |
| 1797 | { | 1797 | { |
| 1798 | switch (arg->type) { | 1798 | switch (arg->type) { |
| 1799 | case FILTER_ARG_FIELD: | 1799 | case TEP_FILTER_ARG_FIELD: |
| 1800 | return get_value(event, arg->field.field, record); | 1800 | return get_value(event, arg->field.field, record); |
| 1801 | 1801 | ||
| 1802 | case FILTER_ARG_VALUE: | 1802 | case TEP_FILTER_ARG_VALUE: |
| 1803 | if (arg->value.type != FILTER_NUMBER) { | 1803 | if (arg->value.type != TEP_FILTER_NUMBER) { |
| 1804 | if (!*err) | 1804 | if (!*err) |
| 1805 | *err = TEP_ERRNO__NOT_A_NUMBER; | 1805 | *err = TEP_ERRNO__NOT_A_NUMBER; |
| 1806 | } | 1806 | } |
| 1807 | return arg->value.val; | 1807 | return arg->value.val; |
| 1808 | 1808 | ||
| 1809 | case FILTER_ARG_EXP: | 1809 | case TEP_FILTER_ARG_EXP: |
| 1810 | return get_exp_value(event, arg, record, err); | 1810 | return get_exp_value(event, arg, record, err); |
| 1811 | 1811 | ||
| 1812 | default: | 1812 | default: |
| @@ -1816,7 +1816,7 @@ get_arg_value(struct event_format *event, struct filter_arg *arg, | |||
| 1816 | return 0; | 1816 | return 0; |
| 1817 | } | 1817 | } |
| 1818 | 1818 | ||
| 1819 | static int test_num(struct event_format *event, struct filter_arg *arg, | 1819 | static int test_num(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1820 | struct tep_record *record, enum tep_errno *err) | 1820 | struct tep_record *record, enum tep_errno *err) |
| 1821 | { | 1821 | { |
| 1822 | unsigned long long lval, rval; | 1822 | unsigned long long lval, rval; |
| @@ -1832,22 +1832,22 @@ static int test_num(struct event_format *event, struct filter_arg *arg, | |||
| 1832 | } | 1832 | } |
| 1833 | 1833 | ||
| 1834 | switch (arg->num.type) { | 1834 | switch (arg->num.type) { |
| 1835 | case FILTER_CMP_EQ: | 1835 | case TEP_FILTER_CMP_EQ: |
| 1836 | return lval == rval; | 1836 | return lval == rval; |
| 1837 | 1837 | ||
| 1838 | case FILTER_CMP_NE: | 1838 | case TEP_FILTER_CMP_NE: |
| 1839 | return lval != rval; | 1839 | return lval != rval; |
| 1840 | 1840 | ||
| 1841 | case FILTER_CMP_GT: | 1841 | case TEP_FILTER_CMP_GT: |
| 1842 | return lval > rval; | 1842 | return lval > rval; |
| 1843 | 1843 | ||
| 1844 | case FILTER_CMP_LT: | 1844 | case TEP_FILTER_CMP_LT: |
| 1845 | return lval < rval; | 1845 | return lval < rval; |
| 1846 | 1846 | ||
| 1847 | case FILTER_CMP_GE: | 1847 | case TEP_FILTER_CMP_GE: |
| 1848 | return lval >= rval; | 1848 | return lval >= rval; |
| 1849 | 1849 | ||
| 1850 | case FILTER_CMP_LE: | 1850 | case TEP_FILTER_CMP_LE: |
| 1851 | return lval <= rval; | 1851 | return lval <= rval; |
| 1852 | 1852 | ||
| 1853 | default: | 1853 | default: |
| @@ -1857,9 +1857,9 @@ static int test_num(struct event_format *event, struct filter_arg *arg, | |||
| 1857 | } | 1857 | } |
| 1858 | } | 1858 | } |
| 1859 | 1859 | ||
| 1860 | static const char *get_field_str(struct filter_arg *arg, struct tep_record *record) | 1860 | static const char *get_field_str(struct tep_filter_arg *arg, struct tep_record *record) |
| 1861 | { | 1861 | { |
| 1862 | struct event_format *event; | 1862 | struct tep_event_format *event; |
| 1863 | struct tep_handle *pevent; | 1863 | struct tep_handle *pevent; |
| 1864 | unsigned long long addr; | 1864 | unsigned long long addr; |
| 1865 | const char *val = NULL; | 1865 | const char *val = NULL; |
| @@ -1867,11 +1867,11 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco | |||
| 1867 | char hex[64]; | 1867 | char hex[64]; |
| 1868 | 1868 | ||
| 1869 | /* If the field is not a string convert it */ | 1869 | /* If the field is not a string convert it */ |
| 1870 | if (arg->str.field->flags & FIELD_IS_STRING) { | 1870 | if (arg->str.field->flags & TEP_FIELD_IS_STRING) { |
| 1871 | val = record->data + arg->str.field->offset; | 1871 | val = record->data + arg->str.field->offset; |
| 1872 | size = arg->str.field->size; | 1872 | size = arg->str.field->size; |
| 1873 | 1873 | ||
| 1874 | if (arg->str.field->flags & FIELD_IS_DYNAMIC) { | 1874 | if (arg->str.field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 1875 | addr = *(unsigned int *)val; | 1875 | addr = *(unsigned int *)val; |
| 1876 | val = record->data + (addr & 0xffff); | 1876 | val = record->data + (addr & 0xffff); |
| 1877 | size = addr >> 16; | 1877 | size = addr >> 16; |
| @@ -1893,7 +1893,7 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco | |||
| 1893 | pevent = event->pevent; | 1893 | pevent = event->pevent; |
| 1894 | addr = get_value(event, arg->str.field, record); | 1894 | addr = get_value(event, arg->str.field, record); |
| 1895 | 1895 | ||
| 1896 | if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG)) | 1896 | if (arg->str.field->flags & (TEP_FIELD_IS_POINTER | TEP_FIELD_IS_LONG)) |
| 1897 | /* convert to a kernel symbol */ | 1897 | /* convert to a kernel symbol */ |
| 1898 | val = tep_find_function(pevent, addr); | 1898 | val = tep_find_function(pevent, addr); |
| 1899 | 1899 | ||
| @@ -1907,7 +1907,7 @@ static const char *get_field_str(struct filter_arg *arg, struct tep_record *reco | |||
| 1907 | return val; | 1907 | return val; |
| 1908 | } | 1908 | } |
| 1909 | 1909 | ||
| 1910 | static int test_str(struct event_format *event, struct filter_arg *arg, | 1910 | static int test_str(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1911 | struct tep_record *record, enum tep_errno *err) | 1911 | struct tep_record *record, enum tep_errno *err) |
| 1912 | { | 1912 | { |
| 1913 | const char *val; | 1913 | const char *val; |
| @@ -1918,17 +1918,17 @@ static int test_str(struct event_format *event, struct filter_arg *arg, | |||
| 1918 | val = get_field_str(arg, record); | 1918 | val = get_field_str(arg, record); |
| 1919 | 1919 | ||
| 1920 | switch (arg->str.type) { | 1920 | switch (arg->str.type) { |
| 1921 | case FILTER_CMP_MATCH: | 1921 | case TEP_FILTER_CMP_MATCH: |
| 1922 | return strcmp(val, arg->str.val) == 0; | 1922 | return strcmp(val, arg->str.val) == 0; |
| 1923 | 1923 | ||
| 1924 | case FILTER_CMP_NOT_MATCH: | 1924 | case TEP_FILTER_CMP_NOT_MATCH: |
| 1925 | return strcmp(val, arg->str.val) != 0; | 1925 | return strcmp(val, arg->str.val) != 0; |
| 1926 | 1926 | ||
| 1927 | case FILTER_CMP_REGEX: | 1927 | case TEP_FILTER_CMP_REGEX: |
| 1928 | /* Returns zero on match */ | 1928 | /* Returns zero on match */ |
| 1929 | return !regexec(&arg->str.reg, val, 0, NULL, 0); | 1929 | return !regexec(&arg->str.reg, val, 0, NULL, 0); |
| 1930 | 1930 | ||
| 1931 | case FILTER_CMP_NOT_REGEX: | 1931 | case TEP_FILTER_CMP_NOT_REGEX: |
| 1932 | return regexec(&arg->str.reg, val, 0, NULL, 0); | 1932 | return regexec(&arg->str.reg, val, 0, NULL, 0); |
| 1933 | 1933 | ||
| 1934 | default: | 1934 | default: |
| @@ -1938,19 +1938,19 @@ static int test_str(struct event_format *event, struct filter_arg *arg, | |||
| 1938 | } | 1938 | } |
| 1939 | } | 1939 | } |
| 1940 | 1940 | ||
| 1941 | static int test_op(struct event_format *event, struct filter_arg *arg, | 1941 | static int test_op(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1942 | struct tep_record *record, enum tep_errno *err) | 1942 | struct tep_record *record, enum tep_errno *err) |
| 1943 | { | 1943 | { |
| 1944 | switch (arg->op.type) { | 1944 | switch (arg->op.type) { |
| 1945 | case FILTER_OP_AND: | 1945 | case TEP_FILTER_OP_AND: |
| 1946 | return test_filter(event, arg->op.left, record, err) && | 1946 | return test_filter(event, arg->op.left, record, err) && |
| 1947 | test_filter(event, arg->op.right, record, err); | 1947 | test_filter(event, arg->op.right, record, err); |
| 1948 | 1948 | ||
| 1949 | case FILTER_OP_OR: | 1949 | case TEP_FILTER_OP_OR: |
| 1950 | return test_filter(event, arg->op.left, record, err) || | 1950 | return test_filter(event, arg->op.left, record, err) || |
| 1951 | test_filter(event, arg->op.right, record, err); | 1951 | test_filter(event, arg->op.right, record, err); |
| 1952 | 1952 | ||
| 1953 | case FILTER_OP_NOT: | 1953 | case TEP_FILTER_OP_NOT: |
| 1954 | return !test_filter(event, arg->op.right, record, err); | 1954 | return !test_filter(event, arg->op.right, record, err); |
| 1955 | 1955 | ||
| 1956 | default: | 1956 | default: |
| @@ -1960,7 +1960,7 @@ static int test_op(struct event_format *event, struct filter_arg *arg, | |||
| 1960 | } | 1960 | } |
| 1961 | } | 1961 | } |
| 1962 | 1962 | ||
| 1963 | static int test_filter(struct event_format *event, struct filter_arg *arg, | 1963 | static int test_filter(struct tep_event_format *event, struct tep_filter_arg *arg, |
| 1964 | struct tep_record *record, enum tep_errno *err) | 1964 | struct tep_record *record, enum tep_errno *err) |
| 1965 | { | 1965 | { |
| 1966 | if (*err) { | 1966 | if (*err) { |
| @@ -1971,22 +1971,22 @@ static int test_filter(struct event_format *event, struct filter_arg *arg, | |||
| 1971 | } | 1971 | } |
| 1972 | 1972 | ||
| 1973 | switch (arg->type) { | 1973 | switch (arg->type) { |
| 1974 | case FILTER_ARG_BOOLEAN: | 1974 | case TEP_FILTER_ARG_BOOLEAN: |
| 1975 | /* easy case */ | 1975 | /* easy case */ |
| 1976 | return arg->boolean.value; | 1976 | return arg->boolean.value; |
| 1977 | 1977 | ||
| 1978 | case FILTER_ARG_OP: | 1978 | case TEP_FILTER_ARG_OP: |
| 1979 | return test_op(event, arg, record, err); | 1979 | return test_op(event, arg, record, err); |
| 1980 | 1980 | ||
| 1981 | case FILTER_ARG_NUM: | 1981 | case TEP_FILTER_ARG_NUM: |
| 1982 | return test_num(event, arg, record, err); | 1982 | return test_num(event, arg, record, err); |
| 1983 | 1983 | ||
| 1984 | case FILTER_ARG_STR: | 1984 | case TEP_FILTER_ARG_STR: |
| 1985 | return test_str(event, arg, record, err); | 1985 | return test_str(event, arg, record, err); |
| 1986 | 1986 | ||
| 1987 | case FILTER_ARG_EXP: | 1987 | case TEP_FILTER_ARG_EXP: |
| 1988 | case FILTER_ARG_VALUE: | 1988 | case TEP_FILTER_ARG_VALUE: |
| 1989 | case FILTER_ARG_FIELD: | 1989 | case TEP_FILTER_ARG_FIELD: |
| 1990 | /* | 1990 | /* |
| 1991 | * Expressions, fields and values evaluate | 1991 | * Expressions, fields and values evaluate |
| 1992 | * to true if they return non zero | 1992 | * to true if they return non zero |
| @@ -2008,9 +2008,9 @@ static int test_filter(struct event_format *event, struct filter_arg *arg, | |||
| 2008 | * Returns 1 if filter found for @event_id | 2008 | * Returns 1 if filter found for @event_id |
| 2009 | * otherwise 0; | 2009 | * otherwise 0; |
| 2010 | */ | 2010 | */ |
| 2011 | int tep_event_filtered(struct event_filter *filter, int event_id) | 2011 | int tep_event_filtered(struct tep_event_filter *filter, int event_id) |
| 2012 | { | 2012 | { |
| 2013 | struct filter_type *filter_type; | 2013 | struct tep_filter_type *filter_type; |
| 2014 | 2014 | ||
| 2015 | if (!filter->filters) | 2015 | if (!filter->filters) |
| 2016 | return 0; | 2016 | return 0; |
| @@ -2032,11 +2032,11 @@ int tep_event_filtered(struct event_filter *filter, int event_id) | |||
| 2032 | * NO_FILTER - if no filters exist | 2032 | * NO_FILTER - if no filters exist |
| 2033 | * otherwise - error occurred during test | 2033 | * otherwise - error occurred during test |
| 2034 | */ | 2034 | */ |
| 2035 | enum tep_errno tep_filter_match(struct event_filter *filter, | 2035 | enum tep_errno tep_filter_match(struct tep_event_filter *filter, |
| 2036 | struct tep_record *record) | 2036 | struct tep_record *record) |
| 2037 | { | 2037 | { |
| 2038 | struct tep_handle *pevent = filter->pevent; | 2038 | struct tep_handle *pevent = filter->pevent; |
| 2039 | struct filter_type *filter_type; | 2039 | struct tep_filter_type *filter_type; |
| 2040 | int event_id; | 2040 | int event_id; |
| 2041 | int ret; | 2041 | int ret; |
| 2042 | enum tep_errno err = 0; | 2042 | enum tep_errno err = 0; |
| @@ -2059,7 +2059,7 @@ enum tep_errno tep_filter_match(struct event_filter *filter, | |||
| 2059 | return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS; | 2059 | return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS; |
| 2060 | } | 2060 | } |
| 2061 | 2061 | ||
| 2062 | static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | 2062 | static char *op_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2063 | { | 2063 | { |
| 2064 | char *str = NULL; | 2064 | char *str = NULL; |
| 2065 | char *left = NULL; | 2065 | char *left = NULL; |
| @@ -2070,10 +2070,10 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2070 | int val; | 2070 | int val; |
| 2071 | 2071 | ||
| 2072 | switch (arg->op.type) { | 2072 | switch (arg->op.type) { |
| 2073 | case FILTER_OP_AND: | 2073 | case TEP_FILTER_OP_AND: |
| 2074 | op = "&&"; | 2074 | op = "&&"; |
| 2075 | /* fall through */ | 2075 | /* fall through */ |
| 2076 | case FILTER_OP_OR: | 2076 | case TEP_FILTER_OP_OR: |
| 2077 | if (!op) | 2077 | if (!op) |
| 2078 | op = "||"; | 2078 | op = "||"; |
| 2079 | 2079 | ||
| @@ -2094,8 +2094,8 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2094 | right_val = 0; | 2094 | right_val = 0; |
| 2095 | 2095 | ||
| 2096 | if (left_val >= 0) { | 2096 | if (left_val >= 0) { |
| 2097 | if ((arg->op.type == FILTER_OP_AND && !left_val) || | 2097 | if ((arg->op.type == TEP_FILTER_OP_AND && !left_val) || |
| 2098 | (arg->op.type == FILTER_OP_OR && left_val)) { | 2098 | (arg->op.type == TEP_FILTER_OP_OR && left_val)) { |
| 2099 | /* Just return left value */ | 2099 | /* Just return left value */ |
| 2100 | str = left; | 2100 | str = left; |
| 2101 | left = NULL; | 2101 | left = NULL; |
| @@ -2105,10 +2105,10 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2105 | /* just evaluate this. */ | 2105 | /* just evaluate this. */ |
| 2106 | val = 0; | 2106 | val = 0; |
| 2107 | switch (arg->op.type) { | 2107 | switch (arg->op.type) { |
| 2108 | case FILTER_OP_AND: | 2108 | case TEP_FILTER_OP_AND: |
| 2109 | val = left_val && right_val; | 2109 | val = left_val && right_val; |
| 2110 | break; | 2110 | break; |
| 2111 | case FILTER_OP_OR: | 2111 | case TEP_FILTER_OP_OR: |
| 2112 | val = left_val || right_val; | 2112 | val = left_val || right_val; |
| 2113 | break; | 2113 | break; |
| 2114 | default: | 2114 | default: |
| @@ -2119,8 +2119,8 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2119 | } | 2119 | } |
| 2120 | } | 2120 | } |
| 2121 | if (right_val >= 0) { | 2121 | if (right_val >= 0) { |
| 2122 | if ((arg->op.type == FILTER_OP_AND && !right_val) || | 2122 | if ((arg->op.type == TEP_FILTER_OP_AND && !right_val) || |
| 2123 | (arg->op.type == FILTER_OP_OR && right_val)) { | 2123 | (arg->op.type == TEP_FILTER_OP_OR && right_val)) { |
| 2124 | /* Just return right value */ | 2124 | /* Just return right value */ |
| 2125 | str = right; | 2125 | str = right; |
| 2126 | right = NULL; | 2126 | right = NULL; |
| @@ -2135,7 +2135,7 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2135 | asprintf(&str, "(%s) %s (%s)", left, op, right); | 2135 | asprintf(&str, "(%s) %s (%s)", left, op, right); |
| 2136 | break; | 2136 | break; |
| 2137 | 2137 | ||
| 2138 | case FILTER_OP_NOT: | 2138 | case TEP_FILTER_OP_NOT: |
| 2139 | op = "!"; | 2139 | op = "!"; |
| 2140 | right = arg_to_str(filter, arg->op.right); | 2140 | right = arg_to_str(filter, arg->op.right); |
| 2141 | if (!right) | 2141 | if (!right) |
| @@ -2163,7 +2163,7 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2163 | return str; | 2163 | return str; |
| 2164 | } | 2164 | } |
| 2165 | 2165 | ||
| 2166 | static char *val_to_str(struct event_filter *filter, struct filter_arg *arg) | 2166 | static char *val_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2167 | { | 2167 | { |
| 2168 | char *str = NULL; | 2168 | char *str = NULL; |
| 2169 | 2169 | ||
| @@ -2172,12 +2172,12 @@ static char *val_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2172 | return str; | 2172 | return str; |
| 2173 | } | 2173 | } |
| 2174 | 2174 | ||
| 2175 | static char *field_to_str(struct event_filter *filter, struct filter_arg *arg) | 2175 | static char *field_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2176 | { | 2176 | { |
| 2177 | return strdup(arg->field.field->name); | 2177 | return strdup(arg->field.field->name); |
| 2178 | } | 2178 | } |
| 2179 | 2179 | ||
| 2180 | static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg) | 2180 | static char *exp_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2181 | { | 2181 | { |
| 2182 | char *lstr; | 2182 | char *lstr; |
| 2183 | char *rstr; | 2183 | char *rstr; |
| @@ -2190,34 +2190,34 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2190 | goto out; | 2190 | goto out; |
| 2191 | 2191 | ||
| 2192 | switch (arg->exp.type) { | 2192 | switch (arg->exp.type) { |
| 2193 | case FILTER_EXP_ADD: | 2193 | case TEP_FILTER_EXP_ADD: |
| 2194 | op = "+"; | 2194 | op = "+"; |
| 2195 | break; | 2195 | break; |
| 2196 | case FILTER_EXP_SUB: | 2196 | case TEP_FILTER_EXP_SUB: |
| 2197 | op = "-"; | 2197 | op = "-"; |
| 2198 | break; | 2198 | break; |
| 2199 | case FILTER_EXP_MUL: | 2199 | case TEP_FILTER_EXP_MUL: |
| 2200 | op = "*"; | 2200 | op = "*"; |
| 2201 | break; | 2201 | break; |
| 2202 | case FILTER_EXP_DIV: | 2202 | case TEP_FILTER_EXP_DIV: |
| 2203 | op = "/"; | 2203 | op = "/"; |
| 2204 | break; | 2204 | break; |
| 2205 | case FILTER_EXP_MOD: | 2205 | case TEP_FILTER_EXP_MOD: |
| 2206 | op = "%"; | 2206 | op = "%"; |
| 2207 | break; | 2207 | break; |
| 2208 | case FILTER_EXP_RSHIFT: | 2208 | case TEP_FILTER_EXP_RSHIFT: |
| 2209 | op = ">>"; | 2209 | op = ">>"; |
| 2210 | break; | 2210 | break; |
| 2211 | case FILTER_EXP_LSHIFT: | 2211 | case TEP_FILTER_EXP_LSHIFT: |
| 2212 | op = "<<"; | 2212 | op = "<<"; |
| 2213 | break; | 2213 | break; |
| 2214 | case FILTER_EXP_AND: | 2214 | case TEP_FILTER_EXP_AND: |
| 2215 | op = "&"; | 2215 | op = "&"; |
| 2216 | break; | 2216 | break; |
| 2217 | case FILTER_EXP_OR: | 2217 | case TEP_FILTER_EXP_OR: |
| 2218 | op = "|"; | 2218 | op = "|"; |
| 2219 | break; | 2219 | break; |
| 2220 | case FILTER_EXP_XOR: | 2220 | case TEP_FILTER_EXP_XOR: |
| 2221 | op = "^"; | 2221 | op = "^"; |
| 2222 | break; | 2222 | break; |
| 2223 | default: | 2223 | default: |
| @@ -2233,7 +2233,7 @@ out: | |||
| 2233 | return str; | 2233 | return str; |
| 2234 | } | 2234 | } |
| 2235 | 2235 | ||
| 2236 | static char *num_to_str(struct event_filter *filter, struct filter_arg *arg) | 2236 | static char *num_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2237 | { | 2237 | { |
| 2238 | char *lstr; | 2238 | char *lstr; |
| 2239 | char *rstr; | 2239 | char *rstr; |
| @@ -2246,26 +2246,26 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2246 | goto out; | 2246 | goto out; |
| 2247 | 2247 | ||
| 2248 | switch (arg->num.type) { | 2248 | switch (arg->num.type) { |
| 2249 | case FILTER_CMP_EQ: | 2249 | case TEP_FILTER_CMP_EQ: |
| 2250 | op = "=="; | 2250 | op = "=="; |
| 2251 | /* fall through */ | 2251 | /* fall through */ |
| 2252 | case FILTER_CMP_NE: | 2252 | case TEP_FILTER_CMP_NE: |
| 2253 | if (!op) | 2253 | if (!op) |
| 2254 | op = "!="; | 2254 | op = "!="; |
| 2255 | /* fall through */ | 2255 | /* fall through */ |
| 2256 | case FILTER_CMP_GT: | 2256 | case TEP_FILTER_CMP_GT: |
| 2257 | if (!op) | 2257 | if (!op) |
| 2258 | op = ">"; | 2258 | op = ">"; |
| 2259 | /* fall through */ | 2259 | /* fall through */ |
| 2260 | case FILTER_CMP_LT: | 2260 | case TEP_FILTER_CMP_LT: |
| 2261 | if (!op) | 2261 | if (!op) |
| 2262 | op = "<"; | 2262 | op = "<"; |
| 2263 | /* fall through */ | 2263 | /* fall through */ |
| 2264 | case FILTER_CMP_GE: | 2264 | case TEP_FILTER_CMP_GE: |
| 2265 | if (!op) | 2265 | if (!op) |
| 2266 | op = ">="; | 2266 | op = ">="; |
| 2267 | /* fall through */ | 2267 | /* fall through */ |
| 2268 | case FILTER_CMP_LE: | 2268 | case TEP_FILTER_CMP_LE: |
| 2269 | if (!op) | 2269 | if (!op) |
| 2270 | op = "<="; | 2270 | op = "<="; |
| 2271 | 2271 | ||
| @@ -2283,24 +2283,24 @@ out: | |||
| 2283 | return str; | 2283 | return str; |
| 2284 | } | 2284 | } |
| 2285 | 2285 | ||
| 2286 | static char *str_to_str(struct event_filter *filter, struct filter_arg *arg) | 2286 | static char *str_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2287 | { | 2287 | { |
| 2288 | char *str = NULL; | 2288 | char *str = NULL; |
| 2289 | char *op = NULL; | 2289 | char *op = NULL; |
| 2290 | 2290 | ||
| 2291 | switch (arg->str.type) { | 2291 | switch (arg->str.type) { |
| 2292 | case FILTER_CMP_MATCH: | 2292 | case TEP_FILTER_CMP_MATCH: |
| 2293 | op = "=="; | 2293 | op = "=="; |
| 2294 | /* fall through */ | 2294 | /* fall through */ |
| 2295 | case FILTER_CMP_NOT_MATCH: | 2295 | case TEP_FILTER_CMP_NOT_MATCH: |
| 2296 | if (!op) | 2296 | if (!op) |
| 2297 | op = "!="; | 2297 | op = "!="; |
| 2298 | /* fall through */ | 2298 | /* fall through */ |
| 2299 | case FILTER_CMP_REGEX: | 2299 | case TEP_FILTER_CMP_REGEX: |
| 2300 | if (!op) | 2300 | if (!op) |
| 2301 | op = "=~"; | 2301 | op = "=~"; |
| 2302 | /* fall through */ | 2302 | /* fall through */ |
| 2303 | case FILTER_CMP_NOT_REGEX: | 2303 | case TEP_FILTER_CMP_NOT_REGEX: |
| 2304 | if (!op) | 2304 | if (!op) |
| 2305 | op = "!~"; | 2305 | op = "!~"; |
| 2306 | 2306 | ||
| @@ -2315,31 +2315,31 @@ static char *str_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2315 | return str; | 2315 | return str; |
| 2316 | } | 2316 | } |
| 2317 | 2317 | ||
| 2318 | static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) | 2318 | static char *arg_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg) |
| 2319 | { | 2319 | { |
| 2320 | char *str = NULL; | 2320 | char *str = NULL; |
| 2321 | 2321 | ||
| 2322 | switch (arg->type) { | 2322 | switch (arg->type) { |
| 2323 | case FILTER_ARG_BOOLEAN: | 2323 | case TEP_FILTER_ARG_BOOLEAN: |
| 2324 | asprintf(&str, arg->boolean.value ? "TRUE" : "FALSE"); | 2324 | asprintf(&str, arg->boolean.value ? "TRUE" : "FALSE"); |
| 2325 | return str; | 2325 | return str; |
| 2326 | 2326 | ||
| 2327 | case FILTER_ARG_OP: | 2327 | case TEP_FILTER_ARG_OP: |
| 2328 | return op_to_str(filter, arg); | 2328 | return op_to_str(filter, arg); |
| 2329 | 2329 | ||
| 2330 | case FILTER_ARG_NUM: | 2330 | case TEP_FILTER_ARG_NUM: |
| 2331 | return num_to_str(filter, arg); | 2331 | return num_to_str(filter, arg); |
| 2332 | 2332 | ||
| 2333 | case FILTER_ARG_STR: | 2333 | case TEP_FILTER_ARG_STR: |
| 2334 | return str_to_str(filter, arg); | 2334 | return str_to_str(filter, arg); |
| 2335 | 2335 | ||
| 2336 | case FILTER_ARG_VALUE: | 2336 | case TEP_FILTER_ARG_VALUE: |
| 2337 | return val_to_str(filter, arg); | 2337 | return val_to_str(filter, arg); |
| 2338 | 2338 | ||
| 2339 | case FILTER_ARG_FIELD: | 2339 | case TEP_FILTER_ARG_FIELD: |
| 2340 | return field_to_str(filter, arg); | 2340 | return field_to_str(filter, arg); |
| 2341 | 2341 | ||
| 2342 | case FILTER_ARG_EXP: | 2342 | case TEP_FILTER_ARG_EXP: |
| 2343 | return exp_to_str(filter, arg); | 2343 | return exp_to_str(filter, arg); |
| 2344 | 2344 | ||
| 2345 | default: | 2345 | default: |
| @@ -2359,9 +2359,9 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) | |||
| 2359 | * NULL is returned if no filter is found or allocation failed. | 2359 | * NULL is returned if no filter is found or allocation failed. |
| 2360 | */ | 2360 | */ |
| 2361 | char * | 2361 | char * |
| 2362 | tep_filter_make_string(struct event_filter *filter, int event_id) | 2362 | tep_filter_make_string(struct tep_event_filter *filter, int event_id) |
| 2363 | { | 2363 | { |
| 2364 | struct filter_type *filter_type; | 2364 | struct tep_filter_type *filter_type; |
| 2365 | 2365 | ||
| 2366 | if (!filter->filters) | 2366 | if (!filter->filters) |
| 2367 | return NULL; | 2367 | return NULL; |
| @@ -2383,10 +2383,10 @@ tep_filter_make_string(struct event_filter *filter, int event_id) | |||
| 2383 | * 1 if the two filters hold the same content. | 2383 | * 1 if the two filters hold the same content. |
| 2384 | * 0 if they do not. | 2384 | * 0 if they do not. |
| 2385 | */ | 2385 | */ |
| 2386 | int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2) | 2386 | int tep_filter_compare(struct tep_event_filter *filter1, struct tep_event_filter *filter2) |
| 2387 | { | 2387 | { |
| 2388 | struct filter_type *filter_type1; | 2388 | struct tep_filter_type *filter_type1; |
| 2389 | struct filter_type *filter_type2; | 2389 | struct tep_filter_type *filter_type2; |
| 2390 | char *str1, *str2; | 2390 | char *str1, *str2; |
| 2391 | int result; | 2391 | int result; |
| 2392 | int i; | 2392 | int i; |
| @@ -2409,8 +2409,8 @@ int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter | |||
| 2409 | if (filter_type1->filter->type != filter_type2->filter->type) | 2409 | if (filter_type1->filter->type != filter_type2->filter->type) |
| 2410 | break; | 2410 | break; |
| 2411 | switch (filter_type1->filter->type) { | 2411 | switch (filter_type1->filter->type) { |
| 2412 | case FILTER_TRIVIAL_FALSE: | 2412 | case TEP_FILTER_TRIVIAL_FALSE: |
| 2413 | case FILTER_TRIVIAL_TRUE: | 2413 | case TEP_FILTER_TRIVIAL_TRUE: |
| 2414 | /* trivial types just need the type compared */ | 2414 | /* trivial types just need the type compared */ |
| 2415 | continue; | 2415 | continue; |
| 2416 | default: | 2416 | default: |
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 424747475d37..528acc75d81a 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | #include "event-parse.h" | 24 | #include "event-parse.h" |
| 25 | #include "event-utils.h" | 25 | #include "event-utils.h" |
| 26 | #include "trace-seq.h" | ||
| 26 | 27 | ||
| 27 | static struct func_stack { | 28 | static struct func_stack { |
| 28 | int size; | 29 | int size; |
| @@ -123,7 +124,7 @@ static int add_and_get_index(const char *parent, const char *child, int cpu) | |||
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | static int function_handler(struct trace_seq *s, struct tep_record *record, | 126 | static int function_handler(struct trace_seq *s, struct tep_record *record, |
| 126 | struct event_format *event, void *context) | 127 | struct tep_event_format *event, void *context) |
| 127 | { | 128 | { |
| 128 | struct tep_handle *pevent = event->pevent; | 129 | struct tep_handle *pevent = event->pevent; |
| 129 | unsigned long long function; | 130 | unsigned long long function; |
diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c index b43bfec565d8..9aa05b4ca811 100644 --- a/tools/lib/traceevent/plugin_hrtimer.c +++ b/tools/lib/traceevent/plugin_hrtimer.c | |||
| @@ -23,10 +23,11 @@ | |||
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | 24 | ||
| 25 | #include "event-parse.h" | 25 | #include "event-parse.h" |
| 26 | #include "trace-seq.h" | ||
| 26 | 27 | ||
| 27 | static int timer_expire_handler(struct trace_seq *s, | 28 | static int timer_expire_handler(struct trace_seq *s, |
| 28 | struct tep_record *record, | 29 | struct tep_record *record, |
| 29 | struct event_format *event, void *context) | 30 | struct tep_event_format *event, void *context) |
| 30 | { | 31 | { |
| 31 | trace_seq_printf(s, "hrtimer="); | 32 | trace_seq_printf(s, "hrtimer="); |
| 32 | 33 | ||
| @@ -46,7 +47,7 @@ static int timer_expire_handler(struct trace_seq *s, | |||
| 46 | 47 | ||
| 47 | static int timer_start_handler(struct trace_seq *s, | 48 | static int timer_start_handler(struct trace_seq *s, |
| 48 | struct tep_record *record, | 49 | struct tep_record *record, |
| 49 | struct event_format *event, void *context) | 50 | struct tep_event_format *event, void *context) |
| 50 | { | 51 | { |
| 51 | trace_seq_printf(s, "hrtimer="); | 52 | trace_seq_printf(s, "hrtimer="); |
| 52 | 53 | ||
diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c index 45a9acd19640..a5e34135dd6a 100644 --- a/tools/lib/traceevent/plugin_jbd2.c +++ b/tools/lib/traceevent/plugin_jbd2.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <string.h> | 22 | #include <string.h> |
| 23 | 23 | ||
| 24 | #include "event-parse.h" | 24 | #include "event-parse.h" |
| 25 | #include "trace-seq.h" | ||
| 25 | 26 | ||
| 26 | #define MINORBITS 20 | 27 | #define MINORBITS 20 |
| 27 | #define MINORMASK ((1U << MINORBITS) - 1) | 28 | #define MINORMASK ((1U << MINORBITS) - 1) |
diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index 73966b05abce..1beb4eaddfdf 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c | |||
| @@ -22,11 +22,12 @@ | |||
| 22 | #include <string.h> | 22 | #include <string.h> |
| 23 | 23 | ||
| 24 | #include "event-parse.h" | 24 | #include "event-parse.h" |
| 25 | #include "trace-seq.h" | ||
| 25 | 26 | ||
| 26 | static int call_site_handler(struct trace_seq *s, struct tep_record *record, | 27 | static int call_site_handler(struct trace_seq *s, struct tep_record *record, |
| 27 | struct event_format *event, void *context) | 28 | struct tep_event_format *event, void *context) |
| 28 | { | 29 | { |
| 29 | struct format_field *field; | 30 | struct tep_format_field *field; |
| 30 | unsigned long long val, addr; | 31 | unsigned long long val, addr; |
| 31 | void *data = record->data; | 32 | void *data = record->data; |
| 32 | const char *func; | 33 | const char *func; |
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 1d0d15906225..d13c22846fa9 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <stdint.h> | 23 | #include <stdint.h> |
| 24 | 24 | ||
| 25 | #include "event-parse.h" | 25 | #include "event-parse.h" |
| 26 | #include "trace-seq.h" | ||
| 26 | 27 | ||
| 27 | #ifdef HAVE_UDIS86 | 28 | #ifdef HAVE_UDIS86 |
| 28 | 29 | ||
| @@ -248,7 +249,7 @@ static const char *find_exit_reason(unsigned isa, int val) | |||
| 248 | } | 249 | } |
| 249 | 250 | ||
| 250 | static int print_exit_reason(struct trace_seq *s, struct tep_record *record, | 251 | static int print_exit_reason(struct trace_seq *s, struct tep_record *record, |
| 251 | struct event_format *event, const char *field) | 252 | struct tep_event_format *event, const char *field) |
| 252 | { | 253 | { |
| 253 | unsigned long long isa; | 254 | unsigned long long isa; |
| 254 | unsigned long long val; | 255 | unsigned long long val; |
| @@ -269,7 +270,7 @@ static int print_exit_reason(struct trace_seq *s, struct tep_record *record, | |||
| 269 | } | 270 | } |
| 270 | 271 | ||
| 271 | static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record, | 272 | static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record, |
| 272 | struct event_format *event, void *context) | 273 | struct tep_event_format *event, void *context) |
| 273 | { | 274 | { |
| 274 | unsigned long long info1 = 0, info2 = 0; | 275 | unsigned long long info1 = 0, info2 = 0; |
| 275 | 276 | ||
| @@ -292,7 +293,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record, | |||
| 292 | 293 | ||
| 293 | static int kvm_emulate_insn_handler(struct trace_seq *s, | 294 | static int kvm_emulate_insn_handler(struct trace_seq *s, |
| 294 | struct tep_record *record, | 295 | struct tep_record *record, |
| 295 | struct event_format *event, void *context) | 296 | struct tep_event_format *event, void *context) |
| 296 | { | 297 | { |
| 297 | unsigned long long rip, csbase, len, flags, failed; | 298 | unsigned long long rip, csbase, len, flags, failed; |
| 298 | int llen; | 299 | int llen; |
| @@ -331,7 +332,7 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, | |||
| 331 | 332 | ||
| 332 | 333 | ||
| 333 | static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_record *record, | 334 | static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_record *record, |
| 334 | struct event_format *event, void *context) | 335 | struct tep_event_format *event, void *context) |
| 335 | { | 336 | { |
| 336 | if (print_exit_reason(s, record, event, "exit_code") < 0) | 337 | if (print_exit_reason(s, record, event, "exit_code") < 0) |
| 337 | return -1; | 338 | return -1; |
| @@ -345,7 +346,7 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_reco | |||
| 345 | } | 346 | } |
| 346 | 347 | ||
| 347 | static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record, | 348 | static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record, |
| 348 | struct event_format *event, void *context) | 349 | struct tep_event_format *event, void *context) |
| 349 | { | 350 | { |
| 350 | tep_print_num_field(s, "rip %llx ", event, "rip", record, 1); | 351 | tep_print_num_field(s, "rip %llx ", event, "rip", record, 1); |
| 351 | 352 | ||
| @@ -371,7 +372,7 @@ union kvm_mmu_page_role { | |||
| 371 | }; | 372 | }; |
| 372 | 373 | ||
| 373 | static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, | 374 | static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, |
| 374 | struct event_format *event, void *context) | 375 | struct tep_event_format *event, void *context) |
| 375 | { | 376 | { |
| 376 | unsigned long long val; | 377 | unsigned long long val; |
| 377 | static const char *access_str[] = { | 378 | static const char *access_str[] = { |
| @@ -418,7 +419,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, | |||
| 418 | 419 | ||
| 419 | static int kvm_mmu_get_page_handler(struct trace_seq *s, | 420 | static int kvm_mmu_get_page_handler(struct trace_seq *s, |
| 420 | struct tep_record *record, | 421 | struct tep_record *record, |
| 421 | struct event_format *event, void *context) | 422 | struct tep_event_format *event, void *context) |
| 422 | { | 423 | { |
| 423 | unsigned long long val; | 424 | unsigned long long val; |
| 424 | 425 | ||
diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index de50a5316203..da3855e7b86f 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c | |||
| @@ -22,13 +22,14 @@ | |||
| 22 | #include <string.h> | 22 | #include <string.h> |
| 23 | 23 | ||
| 24 | #include "event-parse.h" | 24 | #include "event-parse.h" |
| 25 | #include "trace-seq.h" | ||
| 25 | 26 | ||
| 26 | #define INDENT 65 | 27 | #define INDENT 65 |
| 27 | 28 | ||
| 28 | static void print_string(struct trace_seq *s, struct event_format *event, | 29 | static void print_string(struct trace_seq *s, struct tep_event_format *event, |
| 29 | const char *name, const void *data) | 30 | const char *name, const void *data) |
| 30 | { | 31 | { |
| 31 | struct format_field *f = tep_find_field(event, name); | 32 | struct tep_format_field *f = tep_find_field(event, name); |
| 32 | int offset; | 33 | int offset; |
| 33 | int length; | 34 | int length; |
| 34 | 35 | ||
| @@ -59,7 +60,7 @@ static void print_string(struct trace_seq *s, struct event_format *event, | |||
| 59 | 60 | ||
| 60 | static int drv_bss_info_changed(struct trace_seq *s, | 61 | static int drv_bss_info_changed(struct trace_seq *s, |
| 61 | struct tep_record *record, | 62 | struct tep_record *record, |
| 62 | struct event_format *event, void *context) | 63 | struct tep_event_format *event, void *context) |
| 63 | { | 64 | { |
| 64 | void *data = record->data; | 65 | void *data = record->data; |
| 65 | 66 | ||
diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index eecb4bd95c11..77882272672f 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <string.h> | 22 | #include <string.h> |
| 23 | 23 | ||
| 24 | #include "event-parse.h" | 24 | #include "event-parse.h" |
| 25 | #include "trace-seq.h" | ||
| 25 | 26 | ||
| 26 | static void write_state(struct trace_seq *s, int val) | 27 | static void write_state(struct trace_seq *s, int val) |
| 27 | { | 28 | { |
| @@ -44,7 +45,7 @@ static void write_state(struct trace_seq *s, int val) | |||
| 44 | trace_seq_putc(s, 'R'); | 45 | trace_seq_putc(s, 'R'); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | static void write_and_save_comm(struct format_field *field, | 48 | static void write_and_save_comm(struct tep_format_field *field, |
| 48 | struct tep_record *record, | 49 | struct tep_record *record, |
| 49 | struct trace_seq *s, int pid) | 50 | struct trace_seq *s, int pid) |
| 50 | { | 51 | { |
| @@ -66,9 +67,9 @@ static void write_and_save_comm(struct format_field *field, | |||
| 66 | 67 | ||
| 67 | static int sched_wakeup_handler(struct trace_seq *s, | 68 | static int sched_wakeup_handler(struct trace_seq *s, |
| 68 | struct tep_record *record, | 69 | struct tep_record *record, |
| 69 | struct event_format *event, void *context) | 70 | struct tep_event_format *event, void *context) |
| 70 | { | 71 | { |
| 71 | struct format_field *field; | 72 | struct tep_format_field *field; |
| 72 | unsigned long long val; | 73 | unsigned long long val; |
| 73 | 74 | ||
| 74 | if (tep_get_field_val(s, event, "pid", record, &val, 1)) | 75 | if (tep_get_field_val(s, event, "pid", record, &val, 1)) |
| @@ -95,9 +96,9 @@ static int sched_wakeup_handler(struct trace_seq *s, | |||
| 95 | 96 | ||
| 96 | static int sched_switch_handler(struct trace_seq *s, | 97 | static int sched_switch_handler(struct trace_seq *s, |
| 97 | struct tep_record *record, | 98 | struct tep_record *record, |
| 98 | struct event_format *event, void *context) | 99 | struct tep_event_format *event, void *context) |
| 99 | { | 100 | { |
| 100 | struct format_field *field; | 101 | struct tep_format_field *field; |
| 101 | unsigned long long val; | 102 | unsigned long long val; |
| 102 | 103 | ||
| 103 | if (tep_get_field_val(s, event, "prev_pid", record, &val, 1)) | 104 | if (tep_get_field_val(s, event, "prev_pid", record, &val, 1)) |
diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index 5ec346f6b842..4eba25cc1431 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <string.h> | 3 | #include <string.h> |
| 4 | #include <inttypes.h> | 4 | #include <inttypes.h> |
| 5 | #include "event-parse.h" | 5 | #include "event-parse.h" |
| 6 | #include "trace-seq.h" | ||
| 6 | 7 | ||
| 7 | typedef unsigned long sector_t; | 8 | typedef unsigned long sector_t; |
| 8 | typedef uint64_t u64; | 9 | typedef uint64_t u64; |
diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c index b2acbd6e9c86..bc0496e4c296 100644 --- a/tools/lib/traceevent/plugin_xen.c +++ b/tools/lib/traceevent/plugin_xen.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | #include <string.h> | 4 | #include <string.h> |
| 5 | #include "event-parse.h" | 5 | #include "event-parse.h" |
| 6 | #include "trace-seq.h" | ||
| 6 | 7 | ||
| 7 | #define __HYPERVISOR_set_trap_table 0 | 8 | #define __HYPERVISOR_set_trap_table 0 |
| 8 | #define __HYPERVISOR_mmu_update 1 | 9 | #define __HYPERVISOR_mmu_update 1 |
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c index e3bac4543d3b..8ff1d55954d1 100644 --- a/tools/lib/traceevent/trace-seq.c +++ b/tools/lib/traceevent/trace-seq.c | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> | 3 | * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> |
| 4 | * | 4 | * |
| 5 | */ | 5 | */ |
| 6 | #include "trace-seq.h" | ||
| 7 | |||
| 6 | #include <stdio.h> | 8 | #include <stdio.h> |
| 7 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| 8 | #include <string.h> | 10 | #include <string.h> |
diff --git a/tools/lib/traceevent/trace-seq.h b/tools/lib/traceevent/trace-seq.h new file mode 100644 index 000000000000..d68ec69f8d1a --- /dev/null +++ b/tools/lib/traceevent/trace-seq.h | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | // SPDX-License-Identifier: LGPL-2.1 | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> | ||
| 4 | * | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef _TRACE_SEQ_H | ||
| 8 | #define _TRACE_SEQ_H | ||
| 9 | |||
| 10 | #include <stdarg.h> | ||
| 11 | #include <stdio.h> | ||
| 12 | |||
| 13 | /* ----------------------- trace_seq ----------------------- */ | ||
| 14 | |||
| 15 | #ifndef TRACE_SEQ_BUF_SIZE | ||
| 16 | #define TRACE_SEQ_BUF_SIZE 4096 | ||
| 17 | #endif | ||
| 18 | |||
| 19 | enum trace_seq_fail { | ||
| 20 | TRACE_SEQ__GOOD, | ||
| 21 | TRACE_SEQ__BUFFER_POISONED, | ||
| 22 | TRACE_SEQ__MEM_ALLOC_FAILED, | ||
| 23 | }; | ||
| 24 | |||
| 25 | /* | ||
| 26 | * Trace sequences are used to allow a function to call several other functions | ||
| 27 | * to create a string of data to use (up to a max of PAGE_SIZE). | ||
| 28 | */ | ||
| 29 | |||
| 30 | struct trace_seq { | ||
| 31 | char *buffer; | ||
| 32 | unsigned int buffer_size; | ||
| 33 | unsigned int len; | ||
| 34 | unsigned int readpos; | ||
| 35 | enum trace_seq_fail state; | ||
| 36 | }; | ||
| 37 | |||
| 38 | void trace_seq_init(struct trace_seq *s); | ||
| 39 | void trace_seq_reset(struct trace_seq *s); | ||
| 40 | void trace_seq_destroy(struct trace_seq *s); | ||
| 41 | |||
| 42 | extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | ||
| 43 | __attribute__ ((format (printf, 2, 3))); | ||
| 44 | extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | ||
| 45 | __attribute__ ((format (printf, 2, 0))); | ||
| 46 | |||
| 47 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | ||
| 48 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | ||
| 49 | |||
| 50 | extern void trace_seq_terminate(struct trace_seq *s); | ||
| 51 | |||
| 52 | extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp); | ||
| 53 | extern int trace_seq_do_printf(struct trace_seq *s); | ||
| 54 | |||
| 55 | #endif /* _TRACE_SEQ_H */ | ||
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 5224ade3d5af..92514fb3689f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
| @@ -779,7 +779,9 @@ endif | |||
| 779 | ifndef NO_LIBBPF | 779 | ifndef NO_LIBBPF |
| 780 | $(call QUIET_INSTALL, bpf-headers) \ | 780 | $(call QUIET_INSTALL, bpf-headers) \ |
| 781 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \ | 781 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \ |
| 782 | $(INSTALL) include/bpf/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf' | 782 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'; \ |
| 783 | $(INSTALL) include/bpf/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \ | ||
| 784 | $(INSTALL) include/bpf/linux/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux' | ||
| 783 | $(call QUIET_INSTALL, bpf-examples) \ | 785 | $(call QUIET_INSTALL, bpf-examples) \ |
| 784 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \ | 786 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \ |
| 785 | $(INSTALL) examples/bpf/*.c -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf' | 787 | $(INSTALL) examples/bpf/*.c -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf' |
diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c index 6688977e4ac7..76c6345a57d5 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c | |||
| @@ -8,6 +8,63 @@ struct arm64_annotate { | |||
| 8 | jump_insn; | 8 | jump_insn; |
| 9 | }; | 9 | }; |
| 10 | 10 | ||
| 11 | static int arm64_mov__parse(struct arch *arch __maybe_unused, | ||
| 12 | struct ins_operands *ops, | ||
| 13 | struct map_symbol *ms __maybe_unused) | ||
| 14 | { | ||
| 15 | char *s = strchr(ops->raw, ','), *target, *endptr; | ||
| 16 | |||
| 17 | if (s == NULL) | ||
| 18 | return -1; | ||
| 19 | |||
| 20 | *s = '\0'; | ||
| 21 | ops->source.raw = strdup(ops->raw); | ||
| 22 | *s = ','; | ||
| 23 | |||
| 24 | if (ops->source.raw == NULL) | ||
| 25 | return -1; | ||
| 26 | |||
| 27 | target = ++s; | ||
| 28 | ops->target.raw = strdup(target); | ||
| 29 | if (ops->target.raw == NULL) | ||
| 30 | goto out_free_source; | ||
| 31 | |||
| 32 | ops->target.addr = strtoull(target, &endptr, 16); | ||
| 33 | if (endptr == target) | ||
| 34 | goto out_free_target; | ||
| 35 | |||
| 36 | s = strchr(endptr, '<'); | ||
| 37 | if (s == NULL) | ||
| 38 | goto out_free_target; | ||
| 39 | endptr = strchr(s + 1, '>'); | ||
| 40 | if (endptr == NULL) | ||
| 41 | goto out_free_target; | ||
| 42 | |||
| 43 | *endptr = '\0'; | ||
| 44 | *s = ' '; | ||
| 45 | ops->target.name = strdup(s); | ||
| 46 | *s = '<'; | ||
| 47 | *endptr = '>'; | ||
| 48 | if (ops->target.name == NULL) | ||
| 49 | goto out_free_target; | ||
| 50 | |||
| 51 | return 0; | ||
| 52 | |||
| 53 | out_free_target: | ||
| 54 | zfree(&ops->target.raw); | ||
| 55 | out_free_source: | ||
| 56 | zfree(&ops->source.raw); | ||
| 57 | return -1; | ||
| 58 | } | ||
| 59 | |||
| 60 | static int mov__scnprintf(struct ins *ins, char *bf, size_t size, | ||
| 61 | struct ins_operands *ops); | ||
| 62 | |||
| 63 | static struct ins_ops arm64_mov_ops = { | ||
| 64 | .parse = arm64_mov__parse, | ||
| 65 | .scnprintf = mov__scnprintf, | ||
| 66 | }; | ||
| 67 | |||
| 11 | static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch, const char *name) | 68 | static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch, const char *name) |
| 12 | { | 69 | { |
| 13 | struct arm64_annotate *arm = arch->priv; | 70 | struct arm64_annotate *arm = arch->priv; |
| @@ -21,7 +78,7 @@ static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch, const | |||
| 21 | else if (!strcmp(name, "ret")) | 78 | else if (!strcmp(name, "ret")) |
| 22 | ops = &ret_ops; | 79 | ops = &ret_ops; |
| 23 | else | 80 | else |
| 24 | return NULL; | 81 | ops = &arm64_mov_ops; |
| 25 | 82 | ||
| 26 | arch__associate_ins_ops(arch, name, ops); | 83 | arch__associate_ins_ops(arch, name, ops); |
| 27 | return ops; | 84 | return ops; |
diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c index cee4e2f7c057..de0dd66dbb48 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c | |||
| @@ -100,8 +100,6 @@ out_free_source: | |||
| 100 | return -1; | 100 | return -1; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | static int mov__scnprintf(struct ins *ins, char *bf, size_t size, | ||
| 104 | struct ins_operands *ops); | ||
| 105 | 103 | ||
| 106 | static struct ins_ops s390_mov_ops = { | 104 | static struct ins_ops s390_mov_ops = { |
| 107 | .parse = s390_mov__parse, | 105 | .parse = s390_mov__parse, |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 830481b8db26..93d679eaf1f4 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
| @@ -283,12 +283,11 @@ out_put: | |||
| 283 | return ret; | 283 | return ret; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | static int process_feature_event(struct perf_tool *tool, | 286 | static int process_feature_event(struct perf_session *session, |
| 287 | union perf_event *event, | 287 | union perf_event *event) |
| 288 | struct perf_session *session) | ||
| 289 | { | 288 | { |
| 290 | if (event->feat.feat_id < HEADER_LAST_FEATURE) | 289 | if (event->feat.feat_id < HEADER_LAST_FEATURE) |
| 291 | return perf_event__process_feature(tool, event, session); | 290 | return perf_event__process_feature(session, event); |
| 292 | return 0; | 291 | return 0; |
| 293 | } | 292 | } |
| 294 | 293 | ||
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index a3b346359ba0..eda41673c4f3 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
| @@ -86,12 +86,10 @@ static int perf_event__drop_oe(struct perf_tool *tool __maybe_unused, | |||
| 86 | } | 86 | } |
| 87 | #endif | 87 | #endif |
| 88 | 88 | ||
| 89 | static int perf_event__repipe_op2_synth(struct perf_tool *tool, | 89 | static int perf_event__repipe_op2_synth(struct perf_session *session, |
| 90 | union perf_event *event, | 90 | union perf_event *event) |
| 91 | struct perf_session *session | ||
| 92 | __maybe_unused) | ||
| 93 | { | 91 | { |
| 94 | return perf_event__repipe_synth(tool, event); | 92 | return perf_event__repipe_synth(session->tool, event); |
| 95 | } | 93 | } |
| 96 | 94 | ||
| 97 | static int perf_event__repipe_attr(struct perf_tool *tool, | 95 | static int perf_event__repipe_attr(struct perf_tool *tool, |
| @@ -133,10 +131,10 @@ static int copy_bytes(struct perf_inject *inject, int fd, off_t size) | |||
| 133 | return 0; | 131 | return 0; |
| 134 | } | 132 | } |
| 135 | 133 | ||
| 136 | static s64 perf_event__repipe_auxtrace(struct perf_tool *tool, | 134 | static s64 perf_event__repipe_auxtrace(struct perf_session *session, |
| 137 | union perf_event *event, | 135 | union perf_event *event) |
| 138 | struct perf_session *session) | ||
| 139 | { | 136 | { |
| 137 | struct perf_tool *tool = session->tool; | ||
| 140 | struct perf_inject *inject = container_of(tool, struct perf_inject, | 138 | struct perf_inject *inject = container_of(tool, struct perf_inject, |
| 141 | tool); | 139 | tool); |
| 142 | int ret; | 140 | int ret; |
| @@ -174,9 +172,8 @@ static s64 perf_event__repipe_auxtrace(struct perf_tool *tool, | |||
| 174 | #else | 172 | #else |
| 175 | 173 | ||
| 176 | static s64 | 174 | static s64 |
| 177 | perf_event__repipe_auxtrace(struct perf_tool *tool __maybe_unused, | 175 | perf_event__repipe_auxtrace(struct perf_session *session __maybe_unused, |
| 178 | union perf_event *event __maybe_unused, | 176 | union perf_event *event __maybe_unused) |
| 179 | struct perf_session *session __maybe_unused) | ||
| 180 | { | 177 | { |
| 181 | pr_err("AUX area tracing not supported\n"); | 178 | pr_err("AUX area tracing not supported\n"); |
| 182 | return -EINVAL; | 179 | return -EINVAL; |
| @@ -362,26 +359,24 @@ static int perf_event__repipe_exit(struct perf_tool *tool, | |||
| 362 | return err; | 359 | return err; |
| 363 | } | 360 | } |
| 364 | 361 | ||
| 365 | static int perf_event__repipe_tracing_data(struct perf_tool *tool, | 362 | static int perf_event__repipe_tracing_data(struct perf_session *session, |
| 366 | union perf_event *event, | 363 | union perf_event *event) |
| 367 | struct perf_session *session) | ||
| 368 | { | 364 | { |
| 369 | int err; | 365 | int err; |
| 370 | 366 | ||
| 371 | perf_event__repipe_synth(tool, event); | 367 | perf_event__repipe_synth(session->tool, event); |
| 372 | err = perf_event__process_tracing_data(tool, event, session); | 368 | err = perf_event__process_tracing_data(session, event); |
| 373 | 369 | ||
| 374 | return err; | 370 | return err; |
| 375 | } | 371 | } |
| 376 | 372 | ||
| 377 | static int perf_event__repipe_id_index(struct perf_tool *tool, | 373 | static int perf_event__repipe_id_index(struct perf_session *session, |
| 378 | union perf_event *event, | 374 | union perf_event *event) |
| 379 | struct perf_session *session) | ||
| 380 | { | 375 | { |
| 381 | int err; | 376 | int err; |
| 382 | 377 | ||
| 383 | perf_event__repipe_synth(tool, event); | 378 | perf_event__repipe_synth(session->tool, event); |
| 384 | err = perf_event__process_id_index(tool, event, session); | 379 | err = perf_event__process_id_index(session, event); |
| 385 | 380 | ||
| 386 | return err; | 381 | return err; |
| 387 | } | 382 | } |
| @@ -803,7 +798,8 @@ int cmd_inject(int argc, const char **argv) | |||
| 803 | "kallsyms pathname"), | 798 | "kallsyms pathname"), |
| 804 | OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"), | 799 | OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"), |
| 805 | OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts, | 800 | OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts, |
| 806 | NULL, "opts", "Instruction Tracing options", | 801 | NULL, "opts", "Instruction Tracing options\n" |
| 802 | ITRACE_HELP, | ||
| 807 | itrace_parse_synth_opts), | 803 | itrace_parse_synth_opts), |
| 808 | OPT_BOOLEAN(0, "strip", &inject.strip, | 804 | OPT_BOOLEAN(0, "strip", &inject.strip, |
| 809 | "strip non-synthesized events (use with --itrace)"), | 805 | "strip non-synthesized events (use with --itrace)"), |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 22ebeb92ac51..0980dfe3396b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -106,9 +106,12 @@ static bool switch_output_time(struct record *rec) | |||
| 106 | trigger_is_ready(&switch_output_trigger); | 106 | trigger_is_ready(&switch_output_trigger); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | static int record__write(struct record *rec, void *bf, size_t size) | 109 | static int record__write(struct record *rec, struct perf_mmap *map __maybe_unused, |
| 110 | void *bf, size_t size) | ||
| 110 | { | 111 | { |
| 111 | if (perf_data__write(rec->session->data, bf, size) < 0) { | 112 | struct perf_data_file *file = &rec->session->data->file; |
| 113 | |||
| 114 | if (perf_data_file__write(file, bf, size) < 0) { | ||
| 112 | pr_err("failed to write perf data, error: %m\n"); | 115 | pr_err("failed to write perf data, error: %m\n"); |
| 113 | return -1; | 116 | return -1; |
| 114 | } | 117 | } |
| @@ -127,15 +130,15 @@ static int process_synthesized_event(struct perf_tool *tool, | |||
| 127 | struct machine *machine __maybe_unused) | 130 | struct machine *machine __maybe_unused) |
| 128 | { | 131 | { |
| 129 | struct record *rec = container_of(tool, struct record, tool); | 132 | struct record *rec = container_of(tool, struct record, tool); |
| 130 | return record__write(rec, event, event->header.size); | 133 | return record__write(rec, NULL, event, event->header.size); |
| 131 | } | 134 | } |
| 132 | 135 | ||
| 133 | static int record__pushfn(void *to, void *bf, size_t size) | 136 | static int record__pushfn(struct perf_mmap *map, void *to, void *bf, size_t size) |
| 134 | { | 137 | { |
| 135 | struct record *rec = to; | 138 | struct record *rec = to; |
| 136 | 139 | ||
| 137 | rec->samples++; | 140 | rec->samples++; |
| 138 | return record__write(rec, bf, size); | 141 | return record__write(rec, map, bf, size); |
| 139 | } | 142 | } |
| 140 | 143 | ||
| 141 | static volatile int done; | 144 | static volatile int done; |
| @@ -170,6 +173,7 @@ static void record__sig_exit(void) | |||
| 170 | #ifdef HAVE_AUXTRACE_SUPPORT | 173 | #ifdef HAVE_AUXTRACE_SUPPORT |
| 171 | 174 | ||
| 172 | static int record__process_auxtrace(struct perf_tool *tool, | 175 | static int record__process_auxtrace(struct perf_tool *tool, |
| 176 | struct perf_mmap *map, | ||
| 173 | union perf_event *event, void *data1, | 177 | union perf_event *event, void *data1, |
| 174 | size_t len1, void *data2, size_t len2) | 178 | size_t len1, void *data2, size_t len2) |
| 175 | { | 179 | { |
| @@ -197,21 +201,21 @@ static int record__process_auxtrace(struct perf_tool *tool, | |||
| 197 | if (padding) | 201 | if (padding) |
| 198 | padding = 8 - padding; | 202 | padding = 8 - padding; |
| 199 | 203 | ||
| 200 | record__write(rec, event, event->header.size); | 204 | record__write(rec, map, event, event->header.size); |
| 201 | record__write(rec, data1, len1); | 205 | record__write(rec, map, data1, len1); |
| 202 | if (len2) | 206 | if (len2) |
| 203 | record__write(rec, data2, len2); | 207 | record__write(rec, map, data2, len2); |
| 204 | record__write(rec, &pad, padding); | 208 | record__write(rec, map, &pad, padding); |
| 205 | 209 | ||
| 206 | return 0; | 210 | return 0; |
| 207 | } | 211 | } |
| 208 | 212 | ||
| 209 | static int record__auxtrace_mmap_read(struct record *rec, | 213 | static int record__auxtrace_mmap_read(struct record *rec, |
| 210 | struct auxtrace_mmap *mm) | 214 | struct perf_mmap *map) |
| 211 | { | 215 | { |
| 212 | int ret; | 216 | int ret; |
| 213 | 217 | ||
| 214 | ret = auxtrace_mmap__read(mm, rec->itr, &rec->tool, | 218 | ret = auxtrace_mmap__read(map, rec->itr, &rec->tool, |
| 215 | record__process_auxtrace); | 219 | record__process_auxtrace); |
| 216 | if (ret < 0) | 220 | if (ret < 0) |
| 217 | return ret; | 221 | return ret; |
| @@ -223,11 +227,11 @@ static int record__auxtrace_mmap_read(struct record *rec, | |||
| 223 | } | 227 | } |
| 224 | 228 | ||
| 225 | static int record__auxtrace_mmap_read_snapshot(struct record *rec, | 229 | static int record__auxtrace_mmap_read_snapshot(struct record *rec, |
| 226 | struct auxtrace_mmap *mm) | 230 | struct perf_mmap *map) |
| 227 | { | 231 | { |
| 228 | int ret; | 232 | int ret; |
| 229 | 233 | ||
| 230 | ret = auxtrace_mmap__read_snapshot(mm, rec->itr, &rec->tool, | 234 | ret = auxtrace_mmap__read_snapshot(map, rec->itr, &rec->tool, |
| 231 | record__process_auxtrace, | 235 | record__process_auxtrace, |
| 232 | rec->opts.auxtrace_snapshot_size); | 236 | rec->opts.auxtrace_snapshot_size); |
| 233 | if (ret < 0) | 237 | if (ret < 0) |
| @@ -245,13 +249,12 @@ static int record__auxtrace_read_snapshot_all(struct record *rec) | |||
| 245 | int rc = 0; | 249 | int rc = 0; |
| 246 | 250 | ||
| 247 | for (i = 0; i < rec->evlist->nr_mmaps; i++) { | 251 | for (i = 0; i < rec->evlist->nr_mmaps; i++) { |
| 248 | struct auxtrace_mmap *mm = | 252 | struct perf_mmap *map = &rec->evlist->mmap[i]; |
| 249 | &rec->evlist->mmap[i].auxtrace_mmap; | ||
| 250 | 253 | ||
| 251 | if (!mm->base) | 254 | if (!map->auxtrace_mmap.base) |
| 252 | continue; | 255 | continue; |
| 253 | 256 | ||
| 254 | if (record__auxtrace_mmap_read_snapshot(rec, mm) != 0) { | 257 | if (record__auxtrace_mmap_read_snapshot(rec, map) != 0) { |
| 255 | rc = -1; | 258 | rc = -1; |
| 256 | goto out; | 259 | goto out; |
| 257 | } | 260 | } |
| @@ -295,7 +298,7 @@ static int record__auxtrace_init(struct record *rec) | |||
| 295 | 298 | ||
| 296 | static inline | 299 | static inline |
| 297 | int record__auxtrace_mmap_read(struct record *rec __maybe_unused, | 300 | int record__auxtrace_mmap_read(struct record *rec __maybe_unused, |
| 298 | struct auxtrace_mmap *mm __maybe_unused) | 301 | struct perf_mmap *map __maybe_unused) |
| 299 | { | 302 | { |
| 300 | return 0; | 303 | return 0; |
| 301 | } | 304 | } |
| @@ -529,17 +532,17 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli | |||
| 529 | return 0; | 532 | return 0; |
| 530 | 533 | ||
| 531 | for (i = 0; i < evlist->nr_mmaps; i++) { | 534 | for (i = 0; i < evlist->nr_mmaps; i++) { |
| 532 | struct auxtrace_mmap *mm = &maps[i].auxtrace_mmap; | 535 | struct perf_mmap *map = &maps[i]; |
| 533 | 536 | ||
| 534 | if (maps[i].base) { | 537 | if (map->base) { |
| 535 | if (perf_mmap__push(&maps[i], rec, record__pushfn) != 0) { | 538 | if (perf_mmap__push(map, rec, record__pushfn) != 0) { |
| 536 | rc = -1; | 539 | rc = -1; |
| 537 | goto out; | 540 | goto out; |
| 538 | } | 541 | } |
| 539 | } | 542 | } |
| 540 | 543 | ||
| 541 | if (mm->base && !rec->opts.auxtrace_snapshot_mode && | 544 | if (map->auxtrace_mmap.base && !rec->opts.auxtrace_snapshot_mode && |
| 542 | record__auxtrace_mmap_read(rec, mm) != 0) { | 545 | record__auxtrace_mmap_read(rec, map) != 0) { |
| 543 | rc = -1; | 546 | rc = -1; |
| 544 | goto out; | 547 | goto out; |
| 545 | } | 548 | } |
| @@ -550,7 +553,7 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli | |||
| 550 | * at least one event. | 553 | * at least one event. |
| 551 | */ | 554 | */ |
| 552 | if (bytes_written != rec->bytes_written) | 555 | if (bytes_written != rec->bytes_written) |
| 553 | rc = record__write(rec, &finished_round_event, sizeof(finished_round_event)); | 556 | rc = record__write(rec, NULL, &finished_round_event, sizeof(finished_round_event)); |
| 554 | 557 | ||
| 555 | if (overwrite) | 558 | if (overwrite) |
| 556 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY); | 559 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY); |
| @@ -758,7 +761,7 @@ static int record__synthesize(struct record *rec, bool tail) | |||
| 758 | * We need to synthesize events first, because some | 761 | * We need to synthesize events first, because some |
| 759 | * features works on top of them (on report side). | 762 | * features works on top of them (on report side). |
| 760 | */ | 763 | */ |
| 761 | err = perf_event__synthesize_attrs(tool, session, | 764 | err = perf_event__synthesize_attrs(tool, rec->evlist, |
| 762 | process_synthesized_event); | 765 | process_synthesized_event); |
| 763 | if (err < 0) { | 766 | if (err < 0) { |
| 764 | pr_err("Couldn't synthesize attrs.\n"); | 767 | pr_err("Couldn't synthesize attrs.\n"); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 76e12bcd1765..c0703979c51d 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -201,14 +201,13 @@ static void setup_forced_leader(struct report *report, | |||
| 201 | perf_evlist__force_leader(evlist); | 201 | perf_evlist__force_leader(evlist); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | static int process_feature_event(struct perf_tool *tool, | 204 | static int process_feature_event(struct perf_session *session, |
| 205 | union perf_event *event, | 205 | union perf_event *event) |
| 206 | struct perf_session *session __maybe_unused) | ||
| 207 | { | 206 | { |
| 208 | struct report *rep = container_of(tool, struct report, tool); | 207 | struct report *rep = container_of(session->tool, struct report, tool); |
| 209 | 208 | ||
| 210 | if (event->feat.feat_id < HEADER_LAST_FEATURE) | 209 | if (event->feat.feat_id < HEADER_LAST_FEATURE) |
| 211 | return perf_event__process_feature(tool, event, session); | 210 | return perf_event__process_feature(session, event); |
| 212 | 211 | ||
| 213 | if (event->feat.feat_id != HEADER_LAST_FEATURE) { | 212 | if (event->feat.feat_id != HEADER_LAST_FEATURE) { |
| 214 | pr_err("failed: wrong feature ID: %" PRIu64 "\n", | 213 | pr_err("failed: wrong feature ID: %" PRIu64 "\n", |
| @@ -1105,7 +1104,7 @@ int cmd_report(int argc, const char **argv) | |||
| 1105 | OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", | 1104 | OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", |
| 1106 | "how to display percentage of filtered entries", parse_filter_percentage), | 1105 | "how to display percentage of filtered entries", parse_filter_percentage), |
| 1107 | OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", | 1106 | OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", |
| 1108 | "Instruction Tracing options", | 1107 | "Instruction Tracing options\n" ITRACE_HELP, |
| 1109 | itrace_parse_synth_opts), | 1108 | itrace_parse_synth_opts), |
| 1110 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, | 1109 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, |
| 1111 | "Show full source file name path for source lines"), | 1110 | "Show full source file name path for source lines"), |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index ba481d73f910..4da5e32b9e03 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -406,9 +406,10 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, | |||
| 406 | PERF_OUTPUT_WEIGHT)) | 406 | PERF_OUTPUT_WEIGHT)) |
| 407 | return -EINVAL; | 407 | return -EINVAL; |
| 408 | 408 | ||
| 409 | if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) { | 409 | if (PRINT_FIELD(SYM) && |
| 410 | !(evsel->attr.sample_type & (PERF_SAMPLE_IP|PERF_SAMPLE_ADDR))) { | ||
| 410 | pr_err("Display of symbols requested but neither sample IP nor " | 411 | pr_err("Display of symbols requested but neither sample IP nor " |
| 411 | "sample address\nis selected. Hence, no addresses to convert " | 412 | "sample address\navailable. Hence, no addresses to convert " |
| 412 | "to symbols.\n"); | 413 | "to symbols.\n"); |
| 413 | return -EINVAL; | 414 | return -EINVAL; |
| 414 | } | 415 | } |
| @@ -417,10 +418,9 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, | |||
| 417 | "selected.\n"); | 418 | "selected.\n"); |
| 418 | return -EINVAL; | 419 | return -EINVAL; |
| 419 | } | 420 | } |
| 420 | if (PRINT_FIELD(DSO) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR) && | 421 | if (PRINT_FIELD(DSO) && |
| 421 | !PRINT_FIELD(BRSTACK) && !PRINT_FIELD(BRSTACKSYM) && !PRINT_FIELD(BRSTACKOFF)) { | 422 | !(evsel->attr.sample_type & (PERF_SAMPLE_IP|PERF_SAMPLE_ADDR))) { |
| 422 | pr_err("Display of DSO requested but no address to convert. Select\n" | 423 | pr_err("Display of DSO requested but no address to convert.\n"); |
| 423 | "sample IP, sample address, brstack, brstacksym, or brstackoff.\n"); | ||
| 424 | return -EINVAL; | 424 | return -EINVAL; |
| 425 | } | 425 | } |
| 426 | if (PRINT_FIELD(SRCLINE) && !PRINT_FIELD(IP)) { | 426 | if (PRINT_FIELD(SRCLINE) && !PRINT_FIELD(IP)) { |
| @@ -1115,6 +1115,7 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample, | |||
| 1115 | const char *name = NULL; | 1115 | const char *name = NULL; |
| 1116 | static int spacing; | 1116 | static int spacing; |
| 1117 | int len = 0; | 1117 | int len = 0; |
| 1118 | int dlen = 0; | ||
| 1118 | u64 ip = 0; | 1119 | u64 ip = 0; |
| 1119 | 1120 | ||
| 1120 | /* | 1121 | /* |
| @@ -1141,6 +1142,12 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample, | |||
| 1141 | ip = sample->ip; | 1142 | ip = sample->ip; |
| 1142 | } | 1143 | } |
| 1143 | 1144 | ||
| 1145 | if (PRINT_FIELD(DSO) && !(PRINT_FIELD(IP) || PRINT_FIELD(ADDR))) { | ||
| 1146 | dlen += fprintf(fp, "("); | ||
| 1147 | dlen += map__fprintf_dsoname(al->map, fp); | ||
| 1148 | dlen += fprintf(fp, ")\t"); | ||
| 1149 | } | ||
| 1150 | |||
| 1144 | if (name) | 1151 | if (name) |
| 1145 | len = fprintf(fp, "%*s%s", (int)depth * 4, "", name); | 1152 | len = fprintf(fp, "%*s%s", (int)depth * 4, "", name); |
| 1146 | else if (ip) | 1153 | else if (ip) |
| @@ -1159,7 +1166,7 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample, | |||
| 1159 | if (len < spacing) | 1166 | if (len < spacing) |
| 1160 | len += fprintf(fp, "%*s", spacing - len, ""); | 1167 | len += fprintf(fp, "%*s", spacing - len, ""); |
| 1161 | 1168 | ||
| 1162 | return len; | 1169 | return len + dlen; |
| 1163 | } | 1170 | } |
| 1164 | 1171 | ||
| 1165 | static int perf_sample__fprintf_insn(struct perf_sample *sample, | 1172 | static int perf_sample__fprintf_insn(struct perf_sample *sample, |
| @@ -1255,6 +1262,18 @@ static struct { | |||
| 1255 | {0, NULL} | 1262 | {0, NULL} |
| 1256 | }; | 1263 | }; |
| 1257 | 1264 | ||
| 1265 | static const char *sample_flags_to_name(u32 flags) | ||
| 1266 | { | ||
| 1267 | int i; | ||
| 1268 | |||
| 1269 | for (i = 0; sample_flags[i].name ; i++) { | ||
| 1270 | if (sample_flags[i].flags == flags) | ||
| 1271 | return sample_flags[i].name; | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | return NULL; | ||
| 1275 | } | ||
| 1276 | |||
| 1258 | static int perf_sample__fprintf_flags(u32 flags, FILE *fp) | 1277 | static int perf_sample__fprintf_flags(u32 flags, FILE *fp) |
| 1259 | { | 1278 | { |
| 1260 | const char *chars = PERF_IP_FLAG_CHARS; | 1279 | const char *chars = PERF_IP_FLAG_CHARS; |
| @@ -1264,11 +1283,20 @@ static int perf_sample__fprintf_flags(u32 flags, FILE *fp) | |||
| 1264 | char str[33]; | 1283 | char str[33]; |
| 1265 | int i, pos = 0; | 1284 | int i, pos = 0; |
| 1266 | 1285 | ||
| 1267 | for (i = 0; sample_flags[i].name ; i++) { | 1286 | name = sample_flags_to_name(flags & ~PERF_IP_FLAG_IN_TX); |
| 1268 | if (sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) { | 1287 | if (name) |
| 1269 | name = sample_flags[i].name; | 1288 | return fprintf(fp, " %-15s%4s ", name, in_tx ? "(x)" : ""); |
| 1270 | break; | 1289 | |
| 1271 | } | 1290 | if (flags & PERF_IP_FLAG_TRACE_BEGIN) { |
| 1291 | name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_BEGIN)); | ||
| 1292 | if (name) | ||
| 1293 | return fprintf(fp, " tr strt %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | if (flags & PERF_IP_FLAG_TRACE_END) { | ||
| 1297 | name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_END)); | ||
| 1298 | if (name) | ||
| 1299 | return fprintf(fp, " tr end %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
| 1272 | } | 1300 | } |
| 1273 | 1301 | ||
| 1274 | for (i = 0; i < n; i++, flags >>= 1) { | 1302 | for (i = 0; i < n; i++, flags >>= 1) { |
| @@ -1281,10 +1309,7 @@ static int perf_sample__fprintf_flags(u32 flags, FILE *fp) | |||
| 1281 | } | 1309 | } |
| 1282 | str[pos] = 0; | 1310 | str[pos] = 0; |
| 1283 | 1311 | ||
| 1284 | if (name) | 1312 | return fprintf(fp, " %-19s ", str); |
| 1285 | return fprintf(fp, " %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
| 1286 | |||
| 1287 | return fprintf(fp, " %-11s ", str); | ||
| 1288 | } | 1313 | } |
| 1289 | 1314 | ||
| 1290 | struct printer_data { | 1315 | struct printer_data { |
| @@ -1544,7 +1569,8 @@ struct metric_ctx { | |||
| 1544 | FILE *fp; | 1569 | FILE *fp; |
| 1545 | }; | 1570 | }; |
| 1546 | 1571 | ||
| 1547 | static void script_print_metric(void *ctx, const char *color, | 1572 | static void script_print_metric(struct perf_stat_config *config __maybe_unused, |
| 1573 | void *ctx, const char *color, | ||
| 1548 | const char *fmt, | 1574 | const char *fmt, |
| 1549 | const char *unit, double val) | 1575 | const char *unit, double val) |
| 1550 | { | 1576 | { |
| @@ -1562,7 +1588,8 @@ static void script_print_metric(void *ctx, const char *color, | |||
| 1562 | fprintf(mctx->fp, " %s\n", unit); | 1588 | fprintf(mctx->fp, " %s\n", unit); |
| 1563 | } | 1589 | } |
| 1564 | 1590 | ||
| 1565 | static void script_new_line(void *ctx) | 1591 | static void script_new_line(struct perf_stat_config *config __maybe_unused, |
| 1592 | void *ctx) | ||
| 1566 | { | 1593 | { |
| 1567 | struct metric_ctx *mctx = ctx; | 1594 | struct metric_ctx *mctx = ctx; |
| 1568 | 1595 | ||
| @@ -1608,7 +1635,7 @@ static void perf_sample__fprint_metric(struct perf_script *script, | |||
| 1608 | evsel_script(evsel)->val = val; | 1635 | evsel_script(evsel)->val = val; |
| 1609 | if (evsel_script(evsel->leader)->gnum == evsel->leader->nr_members) { | 1636 | if (evsel_script(evsel->leader)->gnum == evsel->leader->nr_members) { |
| 1610 | for_each_group_member (ev2, evsel->leader) { | 1637 | for_each_group_member (ev2, evsel->leader) { |
| 1611 | perf_stat__print_shadow_stats(ev2, | 1638 | perf_stat__print_shadow_stats(&stat_config, ev2, |
| 1612 | evsel_script(ev2)->val, | 1639 | evsel_script(ev2)->val, |
| 1613 | sample->cpu, | 1640 | sample->cpu, |
| 1614 | &ctx, | 1641 | &ctx, |
| @@ -2489,6 +2516,8 @@ parse: | |||
| 2489 | output[j].fields &= ~all_output_options[i].field; | 2516 | output[j].fields &= ~all_output_options[i].field; |
| 2490 | else | 2517 | else |
| 2491 | output[j].fields |= all_output_options[i].field; | 2518 | output[j].fields |= all_output_options[i].field; |
| 2519 | output[j].user_set = true; | ||
| 2520 | output[j].wildcard_set = true; | ||
| 2492 | } | 2521 | } |
| 2493 | } | 2522 | } |
| 2494 | } else { | 2523 | } else { |
| @@ -2499,7 +2528,8 @@ parse: | |||
| 2499 | rc = -EINVAL; | 2528 | rc = -EINVAL; |
| 2500 | goto out; | 2529 | goto out; |
| 2501 | } | 2530 | } |
| 2502 | output[type].fields |= all_output_options[i].field; | 2531 | output[type].user_set = true; |
| 2532 | output[type].wildcard_set = true; | ||
| 2503 | } | 2533 | } |
| 2504 | } | 2534 | } |
| 2505 | 2535 | ||
| @@ -2963,9 +2993,8 @@ static void script__setup_sample_type(struct perf_script *script) | |||
| 2963 | } | 2993 | } |
| 2964 | } | 2994 | } |
| 2965 | 2995 | ||
| 2966 | static int process_stat_round_event(struct perf_tool *tool __maybe_unused, | 2996 | static int process_stat_round_event(struct perf_session *session, |
| 2967 | union perf_event *event, | 2997 | union perf_event *event) |
| 2968 | struct perf_session *session) | ||
| 2969 | { | 2998 | { |
| 2970 | struct stat_round_event *round = &event->stat_round; | 2999 | struct stat_round_event *round = &event->stat_round; |
| 2971 | struct perf_evsel *counter; | 3000 | struct perf_evsel *counter; |
| @@ -2979,9 +3008,8 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused, | |||
| 2979 | return 0; | 3008 | return 0; |
| 2980 | } | 3009 | } |
| 2981 | 3010 | ||
| 2982 | static int process_stat_config_event(struct perf_tool *tool __maybe_unused, | 3011 | static int process_stat_config_event(struct perf_session *session __maybe_unused, |
| 2983 | union perf_event *event, | 3012 | union perf_event *event) |
| 2984 | struct perf_session *session __maybe_unused) | ||
| 2985 | { | 3013 | { |
| 2986 | perf_event__read_stat_config(&stat_config, &event->stat_config); | 3014 | perf_event__read_stat_config(&stat_config, &event->stat_config); |
| 2987 | return 0; | 3015 | return 0; |
| @@ -3007,10 +3035,10 @@ static int set_maps(struct perf_script *script) | |||
| 3007 | } | 3035 | } |
| 3008 | 3036 | ||
| 3009 | static | 3037 | static |
| 3010 | int process_thread_map_event(struct perf_tool *tool, | 3038 | int process_thread_map_event(struct perf_session *session, |
| 3011 | union perf_event *event, | 3039 | union perf_event *event) |
| 3012 | struct perf_session *session __maybe_unused) | ||
| 3013 | { | 3040 | { |
| 3041 | struct perf_tool *tool = session->tool; | ||
| 3014 | struct perf_script *script = container_of(tool, struct perf_script, tool); | 3042 | struct perf_script *script = container_of(tool, struct perf_script, tool); |
| 3015 | 3043 | ||
| 3016 | if (script->threads) { | 3044 | if (script->threads) { |
| @@ -3026,10 +3054,10 @@ int process_thread_map_event(struct perf_tool *tool, | |||
| 3026 | } | 3054 | } |
| 3027 | 3055 | ||
| 3028 | static | 3056 | static |
| 3029 | int process_cpu_map_event(struct perf_tool *tool __maybe_unused, | 3057 | int process_cpu_map_event(struct perf_session *session, |
| 3030 | union perf_event *event, | 3058 | union perf_event *event) |
| 3031 | struct perf_session *session __maybe_unused) | ||
| 3032 | { | 3059 | { |
| 3060 | struct perf_tool *tool = session->tool; | ||
| 3033 | struct perf_script *script = container_of(tool, struct perf_script, tool); | 3061 | struct perf_script *script = container_of(tool, struct perf_script, tool); |
| 3034 | 3062 | ||
| 3035 | if (script->cpus) { | 3063 | if (script->cpus) { |
| @@ -3044,21 +3072,21 @@ int process_cpu_map_event(struct perf_tool *tool __maybe_unused, | |||
| 3044 | return set_maps(script); | 3072 | return set_maps(script); |
| 3045 | } | 3073 | } |
| 3046 | 3074 | ||
| 3047 | static int process_feature_event(struct perf_tool *tool, | 3075 | static int process_feature_event(struct perf_session *session, |
| 3048 | union perf_event *event, | 3076 | union perf_event *event) |
| 3049 | struct perf_session *session) | ||
| 3050 | { | 3077 | { |
| 3051 | if (event->feat.feat_id < HEADER_LAST_FEATURE) | 3078 | if (event->feat.feat_id < HEADER_LAST_FEATURE) |
| 3052 | return perf_event__process_feature(tool, event, session); | 3079 | return perf_event__process_feature(session, event); |
| 3053 | return 0; | 3080 | return 0; |
| 3054 | } | 3081 | } |
| 3055 | 3082 | ||
| 3056 | #ifdef HAVE_AUXTRACE_SUPPORT | 3083 | #ifdef HAVE_AUXTRACE_SUPPORT |
| 3057 | static int perf_script__process_auxtrace_info(struct perf_tool *tool, | 3084 | static int perf_script__process_auxtrace_info(struct perf_session *session, |
| 3058 | union perf_event *event, | 3085 | union perf_event *event) |
| 3059 | struct perf_session *session) | ||
| 3060 | { | 3086 | { |
| 3061 | int ret = perf_event__process_auxtrace_info(tool, event, session); | 3087 | struct perf_tool *tool = session->tool; |
| 3088 | |||
| 3089 | int ret = perf_event__process_auxtrace_info(session, event); | ||
| 3062 | 3090 | ||
| 3063 | if (ret == 0) { | 3091 | if (ret == 0) { |
| 3064 | struct perf_script *script = container_of(tool, struct perf_script, tool); | 3092 | struct perf_script *script = container_of(tool, struct perf_script, tool); |
| @@ -3193,7 +3221,7 @@ int cmd_script(int argc, const char **argv) | |||
| 3193 | OPT_BOOLEAN(0, "ns", &nanosecs, | 3221 | OPT_BOOLEAN(0, "ns", &nanosecs, |
| 3194 | "Use 9 decimal places when displaying time"), | 3222 | "Use 9 decimal places when displaying time"), |
| 3195 | OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", | 3223 | OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", |
| 3196 | "Instruction Tracing options", | 3224 | "Instruction Tracing options\n" ITRACE_HELP, |
| 3197 | itrace_parse_synth_opts), | 3225 | itrace_parse_synth_opts), |
| 3198 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, | 3226 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, |
| 3199 | "Show full source file name path for source lines"), | 3227 | "Show full source file name path for source lines"), |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d097b5b47eb8..b86aba1c8028 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
| @@ -88,8 +88,6 @@ | |||
| 88 | #include "sane_ctype.h" | 88 | #include "sane_ctype.h" |
| 89 | 89 | ||
| 90 | #define DEFAULT_SEPARATOR " " | 90 | #define DEFAULT_SEPARATOR " " |
| 91 | #define CNTR_NOT_SUPPORTED "<not supported>" | ||
| 92 | #define CNTR_NOT_COUNTED "<not counted>" | ||
| 93 | #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" | 91 | #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" |
| 94 | 92 | ||
| 95 | static void print_counters(struct timespec *ts, int argc, const char **argv); | 93 | static void print_counters(struct timespec *ts, int argc, const char **argv); |
| @@ -137,54 +135,30 @@ static const char *smi_cost_attrs = { | |||
| 137 | 135 | ||
| 138 | static struct perf_evlist *evsel_list; | 136 | static struct perf_evlist *evsel_list; |
| 139 | 137 | ||
| 140 | static struct rblist metric_events; | ||
| 141 | |||
| 142 | static struct target target = { | 138 | static struct target target = { |
| 143 | .uid = UINT_MAX, | 139 | .uid = UINT_MAX, |
| 144 | }; | 140 | }; |
| 145 | 141 | ||
| 146 | typedef int (*aggr_get_id_t)(struct cpu_map *m, int cpu); | ||
| 147 | |||
| 148 | #define METRIC_ONLY_LEN 20 | 142 | #define METRIC_ONLY_LEN 20 |
| 149 | 143 | ||
| 150 | static int run_count = 1; | ||
| 151 | static bool no_inherit = false; | ||
| 152 | static volatile pid_t child_pid = -1; | 144 | static volatile pid_t child_pid = -1; |
| 153 | static bool null_run = false; | ||
| 154 | static int detailed_run = 0; | 145 | static int detailed_run = 0; |
| 155 | static bool transaction_run; | 146 | static bool transaction_run; |
| 156 | static bool topdown_run = false; | 147 | static bool topdown_run = false; |
| 157 | static bool smi_cost = false; | 148 | static bool smi_cost = false; |
| 158 | static bool smi_reset = false; | 149 | static bool smi_reset = false; |
| 159 | static bool big_num = true; | ||
| 160 | static int big_num_opt = -1; | 150 | static int big_num_opt = -1; |
| 161 | static const char *csv_sep = NULL; | ||
| 162 | static bool csv_output = false; | ||
| 163 | static bool group = false; | 151 | static bool group = false; |
| 164 | static const char *pre_cmd = NULL; | 152 | static const char *pre_cmd = NULL; |
| 165 | static const char *post_cmd = NULL; | 153 | static const char *post_cmd = NULL; |
| 166 | static bool sync_run = false; | 154 | static bool sync_run = false; |
| 167 | static unsigned int initial_delay = 0; | ||
| 168 | static unsigned int unit_width = 4; /* strlen("unit") */ | ||
| 169 | static bool forever = false; | 155 | static bool forever = false; |
| 170 | static bool metric_only = false; | ||
| 171 | static bool force_metric_only = false; | 156 | static bool force_metric_only = false; |
| 172 | static bool no_merge = false; | ||
| 173 | static bool walltime_run_table = false; | ||
| 174 | static struct timespec ref_time; | 157 | static struct timespec ref_time; |
| 175 | static struct cpu_map *aggr_map; | ||
| 176 | static aggr_get_id_t aggr_get_id; | ||
| 177 | static bool append_file; | 158 | static bool append_file; |
| 178 | static bool interval_count; | 159 | static bool interval_count; |
| 179 | static bool interval_clear; | ||
| 180 | static const char *output_name; | 160 | static const char *output_name; |
| 181 | static int output_fd; | 161 | static int output_fd; |
| 182 | static int print_free_counters_hint; | ||
| 183 | static int print_mixed_hw_group_error; | ||
| 184 | static u64 *walltime_run; | ||
| 185 | static bool ru_display = false; | ||
| 186 | static struct rusage ru_data; | ||
| 187 | static unsigned int metric_only_len = METRIC_ONLY_LEN; | ||
| 188 | 162 | ||
| 189 | struct perf_stat { | 163 | struct perf_stat { |
| 190 | bool record; | 164 | bool record; |
| @@ -204,15 +178,15 @@ static struct perf_stat perf_stat; | |||
| 204 | static volatile int done = 0; | 178 | static volatile int done = 0; |
| 205 | 179 | ||
| 206 | static struct perf_stat_config stat_config = { | 180 | static struct perf_stat_config stat_config = { |
| 207 | .aggr_mode = AGGR_GLOBAL, | 181 | .aggr_mode = AGGR_GLOBAL, |
| 208 | .scale = true, | 182 | .scale = true, |
| 183 | .unit_width = 4, /* strlen("unit") */ | ||
| 184 | .run_count = 1, | ||
| 185 | .metric_only_len = METRIC_ONLY_LEN, | ||
| 186 | .walltime_nsecs_stats = &walltime_nsecs_stats, | ||
| 187 | .big_num = true, | ||
| 209 | }; | 188 | }; |
| 210 | 189 | ||
| 211 | static bool is_duration_time(struct perf_evsel *evsel) | ||
| 212 | { | ||
| 213 | return !strcmp(evsel->name, "duration_time"); | ||
| 214 | } | ||
| 215 | |||
| 216 | static inline void diff_timespec(struct timespec *r, struct timespec *a, | 190 | static inline void diff_timespec(struct timespec *r, struct timespec *a, |
| 217 | struct timespec *b) | 191 | struct timespec *b) |
| 218 | { | 192 | { |
| @@ -236,66 +210,6 @@ static void perf_stat__reset_stats(void) | |||
| 236 | perf_stat__reset_shadow_per_stat(&stat_config.stats[i]); | 210 | perf_stat__reset_shadow_per_stat(&stat_config.stats[i]); |
| 237 | } | 211 | } |
| 238 | 212 | ||
| 239 | static int create_perf_stat_counter(struct perf_evsel *evsel) | ||
| 240 | { | ||
| 241 | struct perf_event_attr *attr = &evsel->attr; | ||
| 242 | struct perf_evsel *leader = evsel->leader; | ||
| 243 | |||
| 244 | if (stat_config.scale) { | ||
| 245 | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | | ||
| 246 | PERF_FORMAT_TOTAL_TIME_RUNNING; | ||
| 247 | } | ||
| 248 | |||
| 249 | /* | ||
| 250 | * The event is part of non trivial group, let's enable | ||
| 251 | * the group read (for leader) and ID retrieval for all | ||
| 252 | * members. | ||
| 253 | */ | ||
| 254 | if (leader->nr_members > 1) | ||
| 255 | attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP; | ||
| 256 | |||
| 257 | attr->inherit = !no_inherit; | ||
| 258 | |||
| 259 | /* | ||
| 260 | * Some events get initialized with sample_(period/type) set, | ||
| 261 | * like tracepoints. Clear it up for counting. | ||
| 262 | */ | ||
| 263 | attr->sample_period = 0; | ||
| 264 | |||
| 265 | /* | ||
| 266 | * But set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless | ||
| 267 | * while avoiding that older tools show confusing messages. | ||
| 268 | * | ||
| 269 | * However for pipe sessions we need to keep it zero, | ||
| 270 | * because script's perf_evsel__check_attr is triggered | ||
| 271 | * by attr->sample_type != 0, and we can't run it on | ||
| 272 | * stat sessions. | ||
| 273 | */ | ||
| 274 | if (!(STAT_RECORD && perf_stat.data.is_pipe)) | ||
| 275 | attr->sample_type = PERF_SAMPLE_IDENTIFIER; | ||
| 276 | |||
| 277 | /* | ||
| 278 | * Disabling all counters initially, they will be enabled | ||
| 279 | * either manually by us or by kernel via enable_on_exec | ||
| 280 | * set later. | ||
| 281 | */ | ||
| 282 | if (perf_evsel__is_group_leader(evsel)) { | ||
| 283 | attr->disabled = 1; | ||
| 284 | |||
| 285 | /* | ||
| 286 | * In case of initial_delay we enable tracee | ||
| 287 | * events manually. | ||
| 288 | */ | ||
| 289 | if (target__none(&target) && !initial_delay) | ||
| 290 | attr->enable_on_exec = 1; | ||
| 291 | } | ||
| 292 | |||
| 293 | if (target__has_cpu(&target) && !target__has_per_thread(&target)) | ||
| 294 | return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel)); | ||
| 295 | |||
| 296 | return perf_evsel__open_per_thread(evsel, evsel_list->threads); | ||
| 297 | } | ||
| 298 | |||
| 299 | static int process_synthesized_event(struct perf_tool *tool __maybe_unused, | 213 | static int process_synthesized_event(struct perf_tool *tool __maybe_unused, |
| 300 | union perf_event *event, | 214 | union perf_event *event, |
| 301 | struct perf_sample *sample __maybe_unused, | 215 | struct perf_sample *sample __maybe_unused, |
| @@ -428,15 +342,15 @@ static void process_interval(void) | |||
| 428 | 342 | ||
| 429 | static void enable_counters(void) | 343 | static void enable_counters(void) |
| 430 | { | 344 | { |
| 431 | if (initial_delay) | 345 | if (stat_config.initial_delay) |
| 432 | usleep(initial_delay * USEC_PER_MSEC); | 346 | usleep(stat_config.initial_delay * USEC_PER_MSEC); |
| 433 | 347 | ||
| 434 | /* | 348 | /* |
| 435 | * We need to enable counters only if: | 349 | * We need to enable counters only if: |
| 436 | * - we don't have tracee (attaching to task or cpu) | 350 | * - we don't have tracee (attaching to task or cpu) |
| 437 | * - we have initial delay configured | 351 | * - we have initial delay configured |
| 438 | */ | 352 | */ |
| 439 | if (!target__none(&target) || initial_delay) | 353 | if (!target__none(&target) || stat_config.initial_delay) |
| 440 | perf_evlist__enable(evsel_list); | 354 | perf_evlist__enable(evsel_list); |
| 441 | } | 355 | } |
| 442 | 356 | ||
| @@ -464,80 +378,6 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf | |||
| 464 | workload_exec_errno = info->si_value.sival_int; | 378 | workload_exec_errno = info->si_value.sival_int; |
| 465 | } | 379 | } |
| 466 | 380 | ||
| 467 | static int perf_stat_synthesize_config(bool is_pipe) | ||
| 468 | { | ||
| 469 | int err; | ||
| 470 | |||
| 471 | if (is_pipe) { | ||
| 472 | err = perf_event__synthesize_attrs(NULL, perf_stat.session, | ||
| 473 | process_synthesized_event); | ||
| 474 | if (err < 0) { | ||
| 475 | pr_err("Couldn't synthesize attrs.\n"); | ||
| 476 | return err; | ||
| 477 | } | ||
| 478 | } | ||
| 479 | |||
| 480 | err = perf_event__synthesize_extra_attr(NULL, | ||
| 481 | evsel_list, | ||
| 482 | process_synthesized_event, | ||
| 483 | is_pipe); | ||
| 484 | |||
| 485 | err = perf_event__synthesize_thread_map2(NULL, evsel_list->threads, | ||
| 486 | process_synthesized_event, | ||
| 487 | NULL); | ||
| 488 | if (err < 0) { | ||
| 489 | pr_err("Couldn't synthesize thread map.\n"); | ||
| 490 | return err; | ||
| 491 | } | ||
| 492 | |||
| 493 | err = perf_event__synthesize_cpu_map(NULL, evsel_list->cpus, | ||
| 494 | process_synthesized_event, NULL); | ||
| 495 | if (err < 0) { | ||
| 496 | pr_err("Couldn't synthesize thread map.\n"); | ||
| 497 | return err; | ||
| 498 | } | ||
| 499 | |||
| 500 | err = perf_event__synthesize_stat_config(NULL, &stat_config, | ||
| 501 | process_synthesized_event, NULL); | ||
| 502 | if (err < 0) { | ||
| 503 | pr_err("Couldn't synthesize config.\n"); | ||
| 504 | return err; | ||
| 505 | } | ||
| 506 | |||
| 507 | return 0; | ||
| 508 | } | ||
| 509 | |||
| 510 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | ||
| 511 | |||
| 512 | static int __store_counter_ids(struct perf_evsel *counter) | ||
| 513 | { | ||
| 514 | int cpu, thread; | ||
| 515 | |||
| 516 | for (cpu = 0; cpu < xyarray__max_x(counter->fd); cpu++) { | ||
| 517 | for (thread = 0; thread < xyarray__max_y(counter->fd); | ||
| 518 | thread++) { | ||
| 519 | int fd = FD(counter, cpu, thread); | ||
| 520 | |||
| 521 | if (perf_evlist__id_add_fd(evsel_list, counter, | ||
| 522 | cpu, thread, fd) < 0) | ||
| 523 | return -1; | ||
| 524 | } | ||
| 525 | } | ||
| 526 | |||
| 527 | return 0; | ||
| 528 | } | ||
| 529 | |||
| 530 | static int store_counter_ids(struct perf_evsel *counter) | ||
| 531 | { | ||
| 532 | struct cpu_map *cpus = counter->cpus; | ||
| 533 | struct thread_map *threads = counter->threads; | ||
| 534 | |||
| 535 | if (perf_evsel__alloc_id(counter, cpus->nr, threads->nr)) | ||
| 536 | return -ENOMEM; | ||
| 537 | |||
| 538 | return __store_counter_ids(counter); | ||
| 539 | } | ||
| 540 | |||
| 541 | static bool perf_evsel__should_store_id(struct perf_evsel *counter) | 381 | static bool perf_evsel__should_store_id(struct perf_evsel *counter) |
| 542 | { | 382 | { |
| 543 | return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID; | 383 | return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID; |
| @@ -609,7 +449,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) | |||
| 609 | 449 | ||
| 610 | evlist__for_each_entry(evsel_list, counter) { | 450 | evlist__for_each_entry(evsel_list, counter) { |
| 611 | try_again: | 451 | try_again: |
| 612 | if (create_perf_stat_counter(counter) < 0) { | 452 | if (create_perf_stat_counter(counter, &stat_config, &target) < 0) { |
| 613 | 453 | ||
| 614 | /* Weak group failed. Reset the group. */ | 454 | /* Weak group failed. Reset the group. */ |
| 615 | if ((errno == EINVAL || errno == EBADF) && | 455 | if ((errno == EINVAL || errno == EBADF) && |
| @@ -664,11 +504,11 @@ try_again: | |||
| 664 | counter->supported = true; | 504 | counter->supported = true; |
| 665 | 505 | ||
| 666 | l = strlen(counter->unit); | 506 | l = strlen(counter->unit); |
| 667 | if (l > unit_width) | 507 | if (l > stat_config.unit_width) |
| 668 | unit_width = l; | 508 | stat_config.unit_width = l; |
| 669 | 509 | ||
| 670 | if (perf_evsel__should_store_id(counter) && | 510 | if (perf_evsel__should_store_id(counter) && |
| 671 | store_counter_ids(counter)) | 511 | perf_evsel__store_ids(counter, evsel_list)) |
| 672 | return -1; | 512 | return -1; |
| 673 | } | 513 | } |
| 674 | 514 | ||
| @@ -699,7 +539,8 @@ try_again: | |||
| 699 | if (err < 0) | 539 | if (err < 0) |
| 700 | return err; | 540 | return err; |
| 701 | 541 | ||
| 702 | err = perf_stat_synthesize_config(is_pipe); | 542 | err = perf_stat_synthesize_config(&stat_config, NULL, evsel_list, |
| 543 | process_synthesized_event, is_pipe); | ||
| 703 | if (err < 0) | 544 | if (err < 0) |
| 704 | return err; | 545 | return err; |
| 705 | } | 546 | } |
| @@ -724,7 +565,7 @@ try_again: | |||
| 724 | break; | 565 | break; |
| 725 | } | 566 | } |
| 726 | } | 567 | } |
| 727 | wait4(child_pid, &status, 0, &ru_data); | 568 | wait4(child_pid, &status, 0, &stat_config.ru_data); |
| 728 | 569 | ||
| 729 | if (workload_exec_errno) { | 570 | if (workload_exec_errno) { |
| 730 | const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); | 571 | const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); |
| @@ -752,8 +593,8 @@ try_again: | |||
| 752 | 593 | ||
| 753 | t1 = rdclock(); | 594 | t1 = rdclock(); |
| 754 | 595 | ||
| 755 | if (walltime_run_table) | 596 | if (stat_config.walltime_run_table) |
| 756 | walltime_run[run_idx] = t1 - t0; | 597 | stat_config.walltime_run[run_idx] = t1 - t0; |
| 757 | 598 | ||
| 758 | update_stats(&walltime_nsecs_stats, t1 - t0); | 599 | update_stats(&walltime_nsecs_stats, t1 - t0); |
| 759 | 600 | ||
| @@ -795,1105 +636,14 @@ static int run_perf_stat(int argc, const char **argv, int run_idx) | |||
| 795 | return ret; | 636 | return ret; |
| 796 | } | 637 | } |
| 797 | 638 | ||
| 798 | static void print_running(u64 run, u64 ena) | ||
| 799 | { | ||
| 800 | if (csv_output) { | ||
| 801 | fprintf(stat_config.output, "%s%" PRIu64 "%s%.2f", | ||
| 802 | csv_sep, | ||
| 803 | run, | ||
| 804 | csv_sep, | ||
| 805 | ena ? 100.0 * run / ena : 100.0); | ||
| 806 | } else if (run != ena) { | ||
| 807 | fprintf(stat_config.output, " (%.2f%%)", 100.0 * run / ena); | ||
| 808 | } | ||
| 809 | } | ||
| 810 | |||
| 811 | static void print_noise_pct(double total, double avg) | ||
| 812 | { | ||
| 813 | double pct = rel_stddev_stats(total, avg); | ||
| 814 | |||
| 815 | if (csv_output) | ||
| 816 | fprintf(stat_config.output, "%s%.2f%%", csv_sep, pct); | ||
| 817 | else if (pct) | ||
| 818 | fprintf(stat_config.output, " ( +-%6.2f%% )", pct); | ||
| 819 | } | ||
| 820 | |||
| 821 | static void print_noise(struct perf_evsel *evsel, double avg) | ||
| 822 | { | ||
| 823 | struct perf_stat_evsel *ps; | ||
| 824 | |||
| 825 | if (run_count == 1) | ||
| 826 | return; | ||
| 827 | |||
| 828 | ps = evsel->stats; | ||
| 829 | print_noise_pct(stddev_stats(&ps->res_stats[0]), avg); | ||
| 830 | } | ||
| 831 | |||
| 832 | static void aggr_printout(struct perf_evsel *evsel, int id, int nr) | ||
| 833 | { | ||
| 834 | switch (stat_config.aggr_mode) { | ||
| 835 | case AGGR_CORE: | ||
| 836 | fprintf(stat_config.output, "S%d-C%*d%s%*d%s", | ||
| 837 | cpu_map__id_to_socket(id), | ||
| 838 | csv_output ? 0 : -8, | ||
| 839 | cpu_map__id_to_cpu(id), | ||
| 840 | csv_sep, | ||
| 841 | csv_output ? 0 : 4, | ||
| 842 | nr, | ||
| 843 | csv_sep); | ||
| 844 | break; | ||
| 845 | case AGGR_SOCKET: | ||
| 846 | fprintf(stat_config.output, "S%*d%s%*d%s", | ||
| 847 | csv_output ? 0 : -5, | ||
| 848 | id, | ||
| 849 | csv_sep, | ||
| 850 | csv_output ? 0 : 4, | ||
| 851 | nr, | ||
| 852 | csv_sep); | ||
| 853 | break; | ||
| 854 | case AGGR_NONE: | ||
| 855 | fprintf(stat_config.output, "CPU%*d%s", | ||
| 856 | csv_output ? 0 : -4, | ||
| 857 | perf_evsel__cpus(evsel)->map[id], csv_sep); | ||
| 858 | break; | ||
| 859 | case AGGR_THREAD: | ||
| 860 | fprintf(stat_config.output, "%*s-%*d%s", | ||
| 861 | csv_output ? 0 : 16, | ||
| 862 | thread_map__comm(evsel->threads, id), | ||
| 863 | csv_output ? 0 : -8, | ||
| 864 | thread_map__pid(evsel->threads, id), | ||
| 865 | csv_sep); | ||
| 866 | break; | ||
| 867 | case AGGR_GLOBAL: | ||
| 868 | case AGGR_UNSET: | ||
| 869 | default: | ||
| 870 | break; | ||
| 871 | } | ||
| 872 | } | ||
| 873 | |||
| 874 | struct outstate { | ||
| 875 | FILE *fh; | ||
| 876 | bool newline; | ||
| 877 | const char *prefix; | ||
| 878 | int nfields; | ||
| 879 | int id, nr; | ||
| 880 | struct perf_evsel *evsel; | ||
| 881 | }; | ||
| 882 | |||
| 883 | #define METRIC_LEN 35 | ||
| 884 | |||
| 885 | static void new_line_std(void *ctx) | ||
| 886 | { | ||
| 887 | struct outstate *os = ctx; | ||
| 888 | |||
| 889 | os->newline = true; | ||
| 890 | } | ||
| 891 | |||
| 892 | static void do_new_line_std(struct outstate *os) | ||
| 893 | { | ||
| 894 | fputc('\n', os->fh); | ||
| 895 | fputs(os->prefix, os->fh); | ||
| 896 | aggr_printout(os->evsel, os->id, os->nr); | ||
| 897 | if (stat_config.aggr_mode == AGGR_NONE) | ||
| 898 | fprintf(os->fh, " "); | ||
| 899 | fprintf(os->fh, " "); | ||
| 900 | } | ||
| 901 | |||
| 902 | static void print_metric_std(void *ctx, const char *color, const char *fmt, | ||
| 903 | const char *unit, double val) | ||
| 904 | { | ||
| 905 | struct outstate *os = ctx; | ||
| 906 | FILE *out = os->fh; | ||
| 907 | int n; | ||
| 908 | bool newline = os->newline; | ||
| 909 | |||
| 910 | os->newline = false; | ||
| 911 | |||
| 912 | if (unit == NULL || fmt == NULL) { | ||
| 913 | fprintf(out, "%-*s", METRIC_LEN, ""); | ||
| 914 | return; | ||
| 915 | } | ||
| 916 | |||
| 917 | if (newline) | ||
| 918 | do_new_line_std(os); | ||
| 919 | |||
| 920 | n = fprintf(out, " # "); | ||
| 921 | if (color) | ||
| 922 | n += color_fprintf(out, color, fmt, val); | ||
| 923 | else | ||
| 924 | n += fprintf(out, fmt, val); | ||
| 925 | fprintf(out, " %-*s", METRIC_LEN - n - 1, unit); | ||
| 926 | } | ||
| 927 | |||
| 928 | static void new_line_csv(void *ctx) | ||
| 929 | { | ||
| 930 | struct outstate *os = ctx; | ||
| 931 | int i; | ||
| 932 | |||
| 933 | fputc('\n', os->fh); | ||
| 934 | if (os->prefix) | ||
| 935 | fprintf(os->fh, "%s%s", os->prefix, csv_sep); | ||
| 936 | aggr_printout(os->evsel, os->id, os->nr); | ||
| 937 | for (i = 0; i < os->nfields; i++) | ||
| 938 | fputs(csv_sep, os->fh); | ||
| 939 | } | ||
| 940 | |||
| 941 | static void print_metric_csv(void *ctx, | ||
| 942 | const char *color __maybe_unused, | ||
| 943 | const char *fmt, const char *unit, double val) | ||
| 944 | { | ||
| 945 | struct outstate *os = ctx; | ||
| 946 | FILE *out = os->fh; | ||
| 947 | char buf[64], *vals, *ends; | ||
| 948 | |||
| 949 | if (unit == NULL || fmt == NULL) { | ||
| 950 | fprintf(out, "%s%s", csv_sep, csv_sep); | ||
| 951 | return; | ||
| 952 | } | ||
| 953 | snprintf(buf, sizeof(buf), fmt, val); | ||
| 954 | ends = vals = ltrim(buf); | ||
| 955 | while (isdigit(*ends) || *ends == '.') | ||
| 956 | ends++; | ||
| 957 | *ends = 0; | ||
| 958 | while (isspace(*unit)) | ||
| 959 | unit++; | ||
| 960 | fprintf(out, "%s%s%s%s", csv_sep, vals, csv_sep, unit); | ||
| 961 | } | ||
| 962 | |||
| 963 | /* Filter out some columns that don't work well in metrics only mode */ | ||
| 964 | |||
| 965 | static bool valid_only_metric(const char *unit) | ||
| 966 | { | ||
| 967 | if (!unit) | ||
| 968 | return false; | ||
| 969 | if (strstr(unit, "/sec") || | ||
| 970 | strstr(unit, "hz") || | ||
| 971 | strstr(unit, "Hz") || | ||
| 972 | strstr(unit, "CPUs utilized")) | ||
| 973 | return false; | ||
| 974 | return true; | ||
| 975 | } | ||
| 976 | |||
| 977 | static const char *fixunit(char *buf, struct perf_evsel *evsel, | ||
| 978 | const char *unit) | ||
| 979 | { | ||
| 980 | if (!strncmp(unit, "of all", 6)) { | ||
| 981 | snprintf(buf, 1024, "%s %s", perf_evsel__name(evsel), | ||
| 982 | unit); | ||
| 983 | return buf; | ||
| 984 | } | ||
| 985 | return unit; | ||
| 986 | } | ||
| 987 | |||
| 988 | static void print_metric_only(void *ctx, const char *color, const char *fmt, | ||
| 989 | const char *unit, double val) | ||
| 990 | { | ||
| 991 | struct outstate *os = ctx; | ||
| 992 | FILE *out = os->fh; | ||
| 993 | char buf[1024], str[1024]; | ||
| 994 | unsigned mlen = metric_only_len; | ||
| 995 | |||
| 996 | if (!valid_only_metric(unit)) | ||
| 997 | return; | ||
| 998 | unit = fixunit(buf, os->evsel, unit); | ||
| 999 | if (mlen < strlen(unit)) | ||
| 1000 | mlen = strlen(unit) + 1; | ||
| 1001 | |||
| 1002 | if (color) | ||
| 1003 | mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1; | ||
| 1004 | |||
| 1005 | color_snprintf(str, sizeof(str), color ?: "", fmt, val); | ||
| 1006 | fprintf(out, "%*s ", mlen, str); | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | static void print_metric_only_csv(void *ctx, const char *color __maybe_unused, | ||
| 1010 | const char *fmt, | ||
| 1011 | const char *unit, double val) | ||
| 1012 | { | ||
| 1013 | struct outstate *os = ctx; | ||
| 1014 | FILE *out = os->fh; | ||
| 1015 | char buf[64], *vals, *ends; | ||
| 1016 | char tbuf[1024]; | ||
| 1017 | |||
| 1018 | if (!valid_only_metric(unit)) | ||
| 1019 | return; | ||
| 1020 | unit = fixunit(tbuf, os->evsel, unit); | ||
| 1021 | snprintf(buf, sizeof buf, fmt, val); | ||
| 1022 | ends = vals = ltrim(buf); | ||
| 1023 | while (isdigit(*ends) || *ends == '.') | ||
| 1024 | ends++; | ||
| 1025 | *ends = 0; | ||
| 1026 | fprintf(out, "%s%s", vals, csv_sep); | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | static void new_line_metric(void *ctx __maybe_unused) | ||
| 1030 | { | ||
| 1031 | } | ||
| 1032 | |||
| 1033 | static void print_metric_header(void *ctx, const char *color __maybe_unused, | ||
| 1034 | const char *fmt __maybe_unused, | ||
| 1035 | const char *unit, double val __maybe_unused) | ||
| 1036 | { | ||
| 1037 | struct outstate *os = ctx; | ||
| 1038 | char tbuf[1024]; | ||
| 1039 | |||
| 1040 | if (!valid_only_metric(unit)) | ||
| 1041 | return; | ||
| 1042 | unit = fixunit(tbuf, os->evsel, unit); | ||
| 1043 | if (csv_output) | ||
| 1044 | fprintf(os->fh, "%s%s", unit, csv_sep); | ||
| 1045 | else | ||
| 1046 | fprintf(os->fh, "%*s ", metric_only_len, unit); | ||
| 1047 | } | ||
| 1048 | |||
| 1049 | static int first_shadow_cpu(struct perf_evsel *evsel, int id) | ||
| 1050 | { | ||
| 1051 | int i; | ||
| 1052 | |||
| 1053 | if (!aggr_get_id) | ||
| 1054 | return 0; | ||
| 1055 | |||
| 1056 | if (stat_config.aggr_mode == AGGR_NONE) | ||
| 1057 | return id; | ||
| 1058 | |||
| 1059 | if (stat_config.aggr_mode == AGGR_GLOBAL) | ||
| 1060 | return 0; | ||
| 1061 | |||
| 1062 | for (i = 0; i < perf_evsel__nr_cpus(evsel); i++) { | ||
| 1063 | int cpu2 = perf_evsel__cpus(evsel)->map[i]; | ||
| 1064 | |||
| 1065 | if (aggr_get_id(evsel_list->cpus, cpu2) == id) | ||
| 1066 | return cpu2; | ||
| 1067 | } | ||
| 1068 | return 0; | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg) | ||
| 1072 | { | ||
| 1073 | FILE *output = stat_config.output; | ||
| 1074 | double sc = evsel->scale; | ||
| 1075 | const char *fmt; | ||
| 1076 | |||
| 1077 | if (csv_output) { | ||
| 1078 | fmt = floor(sc) != sc ? "%.2f%s" : "%.0f%s"; | ||
| 1079 | } else { | ||
| 1080 | if (big_num) | ||
| 1081 | fmt = floor(sc) != sc ? "%'18.2f%s" : "%'18.0f%s"; | ||
| 1082 | else | ||
| 1083 | fmt = floor(sc) != sc ? "%18.2f%s" : "%18.0f%s"; | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | aggr_printout(evsel, id, nr); | ||
| 1087 | |||
| 1088 | fprintf(output, fmt, avg, csv_sep); | ||
| 1089 | |||
| 1090 | if (evsel->unit) | ||
| 1091 | fprintf(output, "%-*s%s", | ||
| 1092 | csv_output ? 0 : unit_width, | ||
| 1093 | evsel->unit, csv_sep); | ||
| 1094 | |||
| 1095 | fprintf(output, "%-*s", csv_output ? 0 : 25, perf_evsel__name(evsel)); | ||
| 1096 | |||
| 1097 | if (evsel->cgrp) | ||
| 1098 | fprintf(output, "%s%s", csv_sep, evsel->cgrp->name); | ||
| 1099 | } | ||
| 1100 | |||
| 1101 | static bool is_mixed_hw_group(struct perf_evsel *counter) | ||
| 1102 | { | ||
| 1103 | struct perf_evlist *evlist = counter->evlist; | ||
| 1104 | u32 pmu_type = counter->attr.type; | ||
| 1105 | struct perf_evsel *pos; | ||
| 1106 | |||
| 1107 | if (counter->nr_members < 2) | ||
| 1108 | return false; | ||
| 1109 | |||
| 1110 | evlist__for_each_entry(evlist, pos) { | ||
| 1111 | /* software events can be part of any hardware group */ | ||
| 1112 | if (pos->attr.type == PERF_TYPE_SOFTWARE) | ||
| 1113 | continue; | ||
| 1114 | if (pmu_type == PERF_TYPE_SOFTWARE) { | ||
| 1115 | pmu_type = pos->attr.type; | ||
| 1116 | continue; | ||
| 1117 | } | ||
| 1118 | if (pmu_type != pos->attr.type) | ||
| 1119 | return true; | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | return false; | ||
| 1123 | } | ||
| 1124 | |||
| 1125 | static void printout(int id, int nr, struct perf_evsel *counter, double uval, | ||
| 1126 | char *prefix, u64 run, u64 ena, double noise, | ||
| 1127 | struct runtime_stat *st) | ||
| 1128 | { | ||
| 1129 | struct perf_stat_output_ctx out; | ||
| 1130 | struct outstate os = { | ||
| 1131 | .fh = stat_config.output, | ||
| 1132 | .prefix = prefix ? prefix : "", | ||
| 1133 | .id = id, | ||
| 1134 | .nr = nr, | ||
| 1135 | .evsel = counter, | ||
| 1136 | }; | ||
| 1137 | print_metric_t pm = print_metric_std; | ||
| 1138 | void (*nl)(void *); | ||
| 1139 | |||
| 1140 | if (metric_only) { | ||
| 1141 | nl = new_line_metric; | ||
| 1142 | if (csv_output) | ||
| 1143 | pm = print_metric_only_csv; | ||
| 1144 | else | ||
| 1145 | pm = print_metric_only; | ||
| 1146 | } else | ||
| 1147 | nl = new_line_std; | ||
| 1148 | |||
| 1149 | if (csv_output && !metric_only) { | ||
| 1150 | static int aggr_fields[] = { | ||
| 1151 | [AGGR_GLOBAL] = 0, | ||
| 1152 | [AGGR_THREAD] = 1, | ||
| 1153 | [AGGR_NONE] = 1, | ||
| 1154 | [AGGR_SOCKET] = 2, | ||
| 1155 | [AGGR_CORE] = 2, | ||
| 1156 | }; | ||
| 1157 | |||
| 1158 | pm = print_metric_csv; | ||
| 1159 | nl = new_line_csv; | ||
| 1160 | os.nfields = 3; | ||
| 1161 | os.nfields += aggr_fields[stat_config.aggr_mode]; | ||
| 1162 | if (counter->cgrp) | ||
| 1163 | os.nfields++; | ||
| 1164 | } | ||
| 1165 | if (run == 0 || ena == 0 || counter->counts->scaled == -1) { | ||
| 1166 | if (metric_only) { | ||
| 1167 | pm(&os, NULL, "", "", 0); | ||
| 1168 | return; | ||
| 1169 | } | ||
| 1170 | aggr_printout(counter, id, nr); | ||
| 1171 | |||
| 1172 | fprintf(stat_config.output, "%*s%s", | ||
| 1173 | csv_output ? 0 : 18, | ||
| 1174 | counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED, | ||
| 1175 | csv_sep); | ||
| 1176 | |||
| 1177 | if (counter->supported) { | ||
| 1178 | print_free_counters_hint = 1; | ||
| 1179 | if (is_mixed_hw_group(counter)) | ||
| 1180 | print_mixed_hw_group_error = 1; | ||
| 1181 | } | ||
| 1182 | |||
| 1183 | fprintf(stat_config.output, "%-*s%s", | ||
| 1184 | csv_output ? 0 : unit_width, | ||
| 1185 | counter->unit, csv_sep); | ||
| 1186 | |||
| 1187 | fprintf(stat_config.output, "%*s", | ||
| 1188 | csv_output ? 0 : -25, | ||
| 1189 | perf_evsel__name(counter)); | ||
| 1190 | |||
| 1191 | if (counter->cgrp) | ||
| 1192 | fprintf(stat_config.output, "%s%s", | ||
| 1193 | csv_sep, counter->cgrp->name); | ||
| 1194 | |||
| 1195 | if (!csv_output) | ||
| 1196 | pm(&os, NULL, NULL, "", 0); | ||
| 1197 | print_noise(counter, noise); | ||
| 1198 | print_running(run, ena); | ||
| 1199 | if (csv_output) | ||
| 1200 | pm(&os, NULL, NULL, "", 0); | ||
| 1201 | return; | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | if (!metric_only) | ||
| 1205 | abs_printout(id, nr, counter, uval); | ||
| 1206 | |||
| 1207 | out.print_metric = pm; | ||
| 1208 | out.new_line = nl; | ||
| 1209 | out.ctx = &os; | ||
| 1210 | out.force_header = false; | ||
| 1211 | |||
| 1212 | if (csv_output && !metric_only) { | ||
| 1213 | print_noise(counter, noise); | ||
| 1214 | print_running(run, ena); | ||
| 1215 | } | ||
| 1216 | |||
| 1217 | perf_stat__print_shadow_stats(counter, uval, | ||
| 1218 | first_shadow_cpu(counter, id), | ||
| 1219 | &out, &metric_events, st); | ||
| 1220 | if (!csv_output && !metric_only) { | ||
| 1221 | print_noise(counter, noise); | ||
| 1222 | print_running(run, ena); | ||
| 1223 | } | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | static void aggr_update_shadow(void) | ||
| 1227 | { | ||
| 1228 | int cpu, s2, id, s; | ||
| 1229 | u64 val; | ||
| 1230 | struct perf_evsel *counter; | ||
| 1231 | |||
| 1232 | for (s = 0; s < aggr_map->nr; s++) { | ||
| 1233 | id = aggr_map->map[s]; | ||
| 1234 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1235 | val = 0; | ||
| 1236 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | ||
| 1237 | s2 = aggr_get_id(evsel_list->cpus, cpu); | ||
| 1238 | if (s2 != id) | ||
| 1239 | continue; | ||
| 1240 | val += perf_counts(counter->counts, cpu, 0)->val; | ||
| 1241 | } | ||
| 1242 | perf_stat__update_shadow_stats(counter, val, | ||
| 1243 | first_shadow_cpu(counter, id), | ||
| 1244 | &rt_stat); | ||
| 1245 | } | ||
| 1246 | } | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | static void uniquify_event_name(struct perf_evsel *counter) | ||
| 1250 | { | ||
| 1251 | char *new_name; | ||
| 1252 | char *config; | ||
| 1253 | |||
| 1254 | if (counter->uniquified_name || | ||
| 1255 | !counter->pmu_name || !strncmp(counter->name, counter->pmu_name, | ||
| 1256 | strlen(counter->pmu_name))) | ||
| 1257 | return; | ||
| 1258 | |||
| 1259 | config = strchr(counter->name, '/'); | ||
| 1260 | if (config) { | ||
| 1261 | if (asprintf(&new_name, | ||
| 1262 | "%s%s", counter->pmu_name, config) > 0) { | ||
| 1263 | free(counter->name); | ||
| 1264 | counter->name = new_name; | ||
| 1265 | } | ||
| 1266 | } else { | ||
| 1267 | if (asprintf(&new_name, | ||
| 1268 | "%s [%s]", counter->name, counter->pmu_name) > 0) { | ||
| 1269 | free(counter->name); | ||
| 1270 | counter->name = new_name; | ||
| 1271 | } | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | counter->uniquified_name = true; | ||
| 1275 | } | ||
| 1276 | |||
| 1277 | static void collect_all_aliases(struct perf_evsel *counter, | ||
| 1278 | void (*cb)(struct perf_evsel *counter, void *data, | ||
| 1279 | bool first), | ||
| 1280 | void *data) | ||
| 1281 | { | ||
| 1282 | struct perf_evsel *alias; | ||
| 1283 | |||
| 1284 | alias = list_prepare_entry(counter, &(evsel_list->entries), node); | ||
| 1285 | list_for_each_entry_continue (alias, &evsel_list->entries, node) { | ||
| 1286 | if (strcmp(perf_evsel__name(alias), perf_evsel__name(counter)) || | ||
| 1287 | alias->scale != counter->scale || | ||
| 1288 | alias->cgrp != counter->cgrp || | ||
| 1289 | strcmp(alias->unit, counter->unit) || | ||
| 1290 | perf_evsel__is_clock(alias) != perf_evsel__is_clock(counter)) | ||
| 1291 | break; | ||
| 1292 | alias->merged_stat = true; | ||
| 1293 | cb(alias, data, false); | ||
| 1294 | } | ||
| 1295 | } | ||
| 1296 | |||
| 1297 | static bool collect_data(struct perf_evsel *counter, | ||
| 1298 | void (*cb)(struct perf_evsel *counter, void *data, | ||
| 1299 | bool first), | ||
| 1300 | void *data) | ||
| 1301 | { | ||
| 1302 | if (counter->merged_stat) | ||
| 1303 | return false; | ||
| 1304 | cb(counter, data, true); | ||
| 1305 | if (no_merge) | ||
| 1306 | uniquify_event_name(counter); | ||
| 1307 | else if (counter->auto_merge_stats) | ||
| 1308 | collect_all_aliases(counter, cb, data); | ||
| 1309 | return true; | ||
| 1310 | } | ||
| 1311 | |||
| 1312 | struct aggr_data { | ||
| 1313 | u64 ena, run, val; | ||
| 1314 | int id; | ||
| 1315 | int nr; | ||
| 1316 | int cpu; | ||
| 1317 | }; | ||
| 1318 | |||
| 1319 | static void aggr_cb(struct perf_evsel *counter, void *data, bool first) | ||
| 1320 | { | ||
| 1321 | struct aggr_data *ad = data; | ||
| 1322 | int cpu, s2; | ||
| 1323 | |||
| 1324 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | ||
| 1325 | struct perf_counts_values *counts; | ||
| 1326 | |||
| 1327 | s2 = aggr_get_id(perf_evsel__cpus(counter), cpu); | ||
| 1328 | if (s2 != ad->id) | ||
| 1329 | continue; | ||
| 1330 | if (first) | ||
| 1331 | ad->nr++; | ||
| 1332 | counts = perf_counts(counter->counts, cpu, 0); | ||
| 1333 | /* | ||
| 1334 | * When any result is bad, make them all to give | ||
| 1335 | * consistent output in interval mode. | ||
| 1336 | */ | ||
| 1337 | if (counts->ena == 0 || counts->run == 0 || | ||
| 1338 | counter->counts->scaled == -1) { | ||
| 1339 | ad->ena = 0; | ||
| 1340 | ad->run = 0; | ||
| 1341 | break; | ||
| 1342 | } | ||
| 1343 | ad->val += counts->val; | ||
| 1344 | ad->ena += counts->ena; | ||
| 1345 | ad->run += counts->run; | ||
| 1346 | } | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | static void print_aggr(char *prefix) | ||
| 1350 | { | ||
| 1351 | FILE *output = stat_config.output; | ||
| 1352 | struct perf_evsel *counter; | ||
| 1353 | int s, id, nr; | ||
| 1354 | double uval; | ||
| 1355 | u64 ena, run, val; | ||
| 1356 | bool first; | ||
| 1357 | |||
| 1358 | if (!(aggr_map || aggr_get_id)) | ||
| 1359 | return; | ||
| 1360 | |||
| 1361 | aggr_update_shadow(); | ||
| 1362 | |||
| 1363 | /* | ||
| 1364 | * With metric_only everything is on a single line. | ||
| 1365 | * Without each counter has its own line. | ||
| 1366 | */ | ||
| 1367 | for (s = 0; s < aggr_map->nr; s++) { | ||
| 1368 | struct aggr_data ad; | ||
| 1369 | if (prefix && metric_only) | ||
| 1370 | fprintf(output, "%s", prefix); | ||
| 1371 | |||
| 1372 | ad.id = id = aggr_map->map[s]; | ||
| 1373 | first = true; | ||
| 1374 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1375 | if (is_duration_time(counter)) | ||
| 1376 | continue; | ||
| 1377 | |||
| 1378 | ad.val = ad.ena = ad.run = 0; | ||
| 1379 | ad.nr = 0; | ||
| 1380 | if (!collect_data(counter, aggr_cb, &ad)) | ||
| 1381 | continue; | ||
| 1382 | nr = ad.nr; | ||
| 1383 | ena = ad.ena; | ||
| 1384 | run = ad.run; | ||
| 1385 | val = ad.val; | ||
| 1386 | if (first && metric_only) { | ||
| 1387 | first = false; | ||
| 1388 | aggr_printout(counter, id, nr); | ||
| 1389 | } | ||
| 1390 | if (prefix && !metric_only) | ||
| 1391 | fprintf(output, "%s", prefix); | ||
| 1392 | |||
| 1393 | uval = val * counter->scale; | ||
| 1394 | printout(id, nr, counter, uval, prefix, run, ena, 1.0, | ||
| 1395 | &rt_stat); | ||
| 1396 | if (!metric_only) | ||
| 1397 | fputc('\n', output); | ||
| 1398 | } | ||
| 1399 | if (metric_only) | ||
| 1400 | fputc('\n', output); | ||
| 1401 | } | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | static int cmp_val(const void *a, const void *b) | ||
| 1405 | { | ||
| 1406 | return ((struct perf_aggr_thread_value *)b)->val - | ||
| 1407 | ((struct perf_aggr_thread_value *)a)->val; | ||
| 1408 | } | ||
| 1409 | |||
| 1410 | static struct perf_aggr_thread_value *sort_aggr_thread( | ||
| 1411 | struct perf_evsel *counter, | ||
| 1412 | int nthreads, int ncpus, | ||
| 1413 | int *ret) | ||
| 1414 | { | ||
| 1415 | int cpu, thread, i = 0; | ||
| 1416 | double uval; | ||
| 1417 | struct perf_aggr_thread_value *buf; | ||
| 1418 | |||
| 1419 | buf = calloc(nthreads, sizeof(struct perf_aggr_thread_value)); | ||
| 1420 | if (!buf) | ||
| 1421 | return NULL; | ||
| 1422 | |||
| 1423 | for (thread = 0; thread < nthreads; thread++) { | ||
| 1424 | u64 ena = 0, run = 0, val = 0; | ||
| 1425 | |||
| 1426 | for (cpu = 0; cpu < ncpus; cpu++) { | ||
| 1427 | val += perf_counts(counter->counts, cpu, thread)->val; | ||
| 1428 | ena += perf_counts(counter->counts, cpu, thread)->ena; | ||
| 1429 | run += perf_counts(counter->counts, cpu, thread)->run; | ||
| 1430 | } | ||
| 1431 | |||
| 1432 | uval = val * counter->scale; | ||
| 1433 | |||
| 1434 | /* | ||
| 1435 | * Skip value 0 when enabling --per-thread globally, | ||
| 1436 | * otherwise too many 0 output. | ||
| 1437 | */ | ||
| 1438 | if (uval == 0.0 && target__has_per_thread(&target)) | ||
| 1439 | continue; | ||
| 1440 | |||
| 1441 | buf[i].counter = counter; | ||
| 1442 | buf[i].id = thread; | ||
| 1443 | buf[i].uval = uval; | ||
| 1444 | buf[i].val = val; | ||
| 1445 | buf[i].run = run; | ||
| 1446 | buf[i].ena = ena; | ||
| 1447 | i++; | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | qsort(buf, i, sizeof(struct perf_aggr_thread_value), cmp_val); | ||
| 1451 | |||
| 1452 | if (ret) | ||
| 1453 | *ret = i; | ||
| 1454 | |||
| 1455 | return buf; | ||
| 1456 | } | ||
| 1457 | |||
| 1458 | static void print_aggr_thread(struct perf_evsel *counter, char *prefix) | ||
| 1459 | { | ||
| 1460 | FILE *output = stat_config.output; | ||
| 1461 | int nthreads = thread_map__nr(counter->threads); | ||
| 1462 | int ncpus = cpu_map__nr(counter->cpus); | ||
| 1463 | int thread, sorted_threads, id; | ||
| 1464 | struct perf_aggr_thread_value *buf; | ||
| 1465 | |||
| 1466 | buf = sort_aggr_thread(counter, nthreads, ncpus, &sorted_threads); | ||
| 1467 | if (!buf) { | ||
| 1468 | perror("cannot sort aggr thread"); | ||
| 1469 | return; | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | for (thread = 0; thread < sorted_threads; thread++) { | ||
| 1473 | if (prefix) | ||
| 1474 | fprintf(output, "%s", prefix); | ||
| 1475 | |||
| 1476 | id = buf[thread].id; | ||
| 1477 | if (stat_config.stats) | ||
| 1478 | printout(id, 0, buf[thread].counter, buf[thread].uval, | ||
| 1479 | prefix, buf[thread].run, buf[thread].ena, 1.0, | ||
| 1480 | &stat_config.stats[id]); | ||
| 1481 | else | ||
| 1482 | printout(id, 0, buf[thread].counter, buf[thread].uval, | ||
| 1483 | prefix, buf[thread].run, buf[thread].ena, 1.0, | ||
| 1484 | &rt_stat); | ||
| 1485 | fputc('\n', output); | ||
| 1486 | } | ||
| 1487 | |||
| 1488 | free(buf); | ||
| 1489 | } | ||
| 1490 | |||
| 1491 | struct caggr_data { | ||
| 1492 | double avg, avg_enabled, avg_running; | ||
| 1493 | }; | ||
| 1494 | |||
| 1495 | static void counter_aggr_cb(struct perf_evsel *counter, void *data, | ||
| 1496 | bool first __maybe_unused) | ||
| 1497 | { | ||
| 1498 | struct caggr_data *cd = data; | ||
| 1499 | struct perf_stat_evsel *ps = counter->stats; | ||
| 1500 | |||
| 1501 | cd->avg += avg_stats(&ps->res_stats[0]); | ||
| 1502 | cd->avg_enabled += avg_stats(&ps->res_stats[1]); | ||
| 1503 | cd->avg_running += avg_stats(&ps->res_stats[2]); | ||
| 1504 | } | ||
| 1505 | |||
| 1506 | /* | ||
| 1507 | * Print out the results of a single counter: | ||
| 1508 | * aggregated counts in system-wide mode | ||
| 1509 | */ | ||
| 1510 | static void print_counter_aggr(struct perf_evsel *counter, char *prefix) | ||
| 1511 | { | ||
| 1512 | FILE *output = stat_config.output; | ||
| 1513 | double uval; | ||
| 1514 | struct caggr_data cd = { .avg = 0.0 }; | ||
| 1515 | |||
| 1516 | if (!collect_data(counter, counter_aggr_cb, &cd)) | ||
| 1517 | return; | ||
| 1518 | |||
| 1519 | if (prefix && !metric_only) | ||
| 1520 | fprintf(output, "%s", prefix); | ||
| 1521 | |||
| 1522 | uval = cd.avg * counter->scale; | ||
| 1523 | printout(-1, 0, counter, uval, prefix, cd.avg_running, cd.avg_enabled, | ||
| 1524 | cd.avg, &rt_stat); | ||
| 1525 | if (!metric_only) | ||
| 1526 | fprintf(output, "\n"); | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | static void counter_cb(struct perf_evsel *counter, void *data, | ||
| 1530 | bool first __maybe_unused) | ||
| 1531 | { | ||
| 1532 | struct aggr_data *ad = data; | ||
| 1533 | |||
| 1534 | ad->val += perf_counts(counter->counts, ad->cpu, 0)->val; | ||
| 1535 | ad->ena += perf_counts(counter->counts, ad->cpu, 0)->ena; | ||
| 1536 | ad->run += perf_counts(counter->counts, ad->cpu, 0)->run; | ||
| 1537 | } | ||
| 1538 | |||
| 1539 | /* | ||
| 1540 | * Print out the results of a single counter: | ||
| 1541 | * does not use aggregated count in system-wide | ||
| 1542 | */ | ||
| 1543 | static void print_counter(struct perf_evsel *counter, char *prefix) | ||
| 1544 | { | ||
| 1545 | FILE *output = stat_config.output; | ||
| 1546 | u64 ena, run, val; | ||
| 1547 | double uval; | ||
| 1548 | int cpu; | ||
| 1549 | |||
| 1550 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | ||
| 1551 | struct aggr_data ad = { .cpu = cpu }; | ||
| 1552 | |||
| 1553 | if (!collect_data(counter, counter_cb, &ad)) | ||
| 1554 | return; | ||
| 1555 | val = ad.val; | ||
| 1556 | ena = ad.ena; | ||
| 1557 | run = ad.run; | ||
| 1558 | |||
| 1559 | if (prefix) | ||
| 1560 | fprintf(output, "%s", prefix); | ||
| 1561 | |||
| 1562 | uval = val * counter->scale; | ||
| 1563 | printout(cpu, 0, counter, uval, prefix, run, ena, 1.0, | ||
| 1564 | &rt_stat); | ||
| 1565 | |||
| 1566 | fputc('\n', output); | ||
| 1567 | } | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | static void print_no_aggr_metric(char *prefix) | ||
| 1571 | { | ||
| 1572 | int cpu; | ||
| 1573 | int nrcpus = 0; | ||
| 1574 | struct perf_evsel *counter; | ||
| 1575 | u64 ena, run, val; | ||
| 1576 | double uval; | ||
| 1577 | |||
| 1578 | nrcpus = evsel_list->cpus->nr; | ||
| 1579 | for (cpu = 0; cpu < nrcpus; cpu++) { | ||
| 1580 | bool first = true; | ||
| 1581 | |||
| 1582 | if (prefix) | ||
| 1583 | fputs(prefix, stat_config.output); | ||
| 1584 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1585 | if (is_duration_time(counter)) | ||
| 1586 | continue; | ||
| 1587 | if (first) { | ||
| 1588 | aggr_printout(counter, cpu, 0); | ||
| 1589 | first = false; | ||
| 1590 | } | ||
| 1591 | val = perf_counts(counter->counts, cpu, 0)->val; | ||
| 1592 | ena = perf_counts(counter->counts, cpu, 0)->ena; | ||
| 1593 | run = perf_counts(counter->counts, cpu, 0)->run; | ||
| 1594 | |||
| 1595 | uval = val * counter->scale; | ||
| 1596 | printout(cpu, 0, counter, uval, prefix, run, ena, 1.0, | ||
| 1597 | &rt_stat); | ||
| 1598 | } | ||
| 1599 | fputc('\n', stat_config.output); | ||
| 1600 | } | ||
| 1601 | } | ||
| 1602 | |||
| 1603 | static int aggr_header_lens[] = { | ||
| 1604 | [AGGR_CORE] = 18, | ||
| 1605 | [AGGR_SOCKET] = 12, | ||
| 1606 | [AGGR_NONE] = 6, | ||
| 1607 | [AGGR_THREAD] = 24, | ||
| 1608 | [AGGR_GLOBAL] = 0, | ||
| 1609 | }; | ||
| 1610 | |||
| 1611 | static const char *aggr_header_csv[] = { | ||
| 1612 | [AGGR_CORE] = "core,cpus,", | ||
| 1613 | [AGGR_SOCKET] = "socket,cpus", | ||
| 1614 | [AGGR_NONE] = "cpu,", | ||
| 1615 | [AGGR_THREAD] = "comm-pid,", | ||
| 1616 | [AGGR_GLOBAL] = "" | ||
| 1617 | }; | ||
| 1618 | |||
| 1619 | static void print_metric_headers(const char *prefix, bool no_indent) | ||
| 1620 | { | ||
| 1621 | struct perf_stat_output_ctx out; | ||
| 1622 | struct perf_evsel *counter; | ||
| 1623 | struct outstate os = { | ||
| 1624 | .fh = stat_config.output | ||
| 1625 | }; | ||
| 1626 | |||
| 1627 | if (prefix) | ||
| 1628 | fprintf(stat_config.output, "%s", prefix); | ||
| 1629 | |||
| 1630 | if (!csv_output && !no_indent) | ||
| 1631 | fprintf(stat_config.output, "%*s", | ||
| 1632 | aggr_header_lens[stat_config.aggr_mode], ""); | ||
| 1633 | if (csv_output) { | ||
| 1634 | if (stat_config.interval) | ||
| 1635 | fputs("time,", stat_config.output); | ||
| 1636 | fputs(aggr_header_csv[stat_config.aggr_mode], | ||
| 1637 | stat_config.output); | ||
| 1638 | } | ||
| 1639 | |||
| 1640 | /* Print metrics headers only */ | ||
| 1641 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1642 | if (is_duration_time(counter)) | ||
| 1643 | continue; | ||
| 1644 | os.evsel = counter; | ||
| 1645 | out.ctx = &os; | ||
| 1646 | out.print_metric = print_metric_header; | ||
| 1647 | out.new_line = new_line_metric; | ||
| 1648 | out.force_header = true; | ||
| 1649 | os.evsel = counter; | ||
| 1650 | perf_stat__print_shadow_stats(counter, 0, | ||
| 1651 | 0, | ||
| 1652 | &out, | ||
| 1653 | &metric_events, | ||
| 1654 | &rt_stat); | ||
| 1655 | } | ||
| 1656 | fputc('\n', stat_config.output); | ||
| 1657 | } | ||
| 1658 | |||
| 1659 | static void print_interval(char *prefix, struct timespec *ts) | ||
| 1660 | { | ||
| 1661 | FILE *output = stat_config.output; | ||
| 1662 | static int num_print_interval; | ||
| 1663 | |||
| 1664 | if (interval_clear) | ||
| 1665 | puts(CONSOLE_CLEAR); | ||
| 1666 | |||
| 1667 | sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); | ||
| 1668 | |||
| 1669 | if ((num_print_interval == 0 && !csv_output) || interval_clear) { | ||
| 1670 | switch (stat_config.aggr_mode) { | ||
| 1671 | case AGGR_SOCKET: | ||
| 1672 | fprintf(output, "# time socket cpus"); | ||
| 1673 | if (!metric_only) | ||
| 1674 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 1675 | break; | ||
| 1676 | case AGGR_CORE: | ||
| 1677 | fprintf(output, "# time core cpus"); | ||
| 1678 | if (!metric_only) | ||
| 1679 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 1680 | break; | ||
| 1681 | case AGGR_NONE: | ||
| 1682 | fprintf(output, "# time CPU "); | ||
| 1683 | if (!metric_only) | ||
| 1684 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 1685 | break; | ||
| 1686 | case AGGR_THREAD: | ||
| 1687 | fprintf(output, "# time comm-pid"); | ||
| 1688 | if (!metric_only) | ||
| 1689 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 1690 | break; | ||
| 1691 | case AGGR_GLOBAL: | ||
| 1692 | default: | ||
| 1693 | fprintf(output, "# time"); | ||
| 1694 | if (!metric_only) | ||
| 1695 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 1696 | case AGGR_UNSET: | ||
| 1697 | break; | ||
| 1698 | } | ||
| 1699 | } | ||
| 1700 | |||
| 1701 | if ((num_print_interval == 0 || interval_clear) && metric_only) | ||
| 1702 | print_metric_headers(" ", true); | ||
| 1703 | if (++num_print_interval == 25) | ||
| 1704 | num_print_interval = 0; | ||
| 1705 | } | ||
| 1706 | |||
| 1707 | static void print_header(int argc, const char **argv) | ||
| 1708 | { | ||
| 1709 | FILE *output = stat_config.output; | ||
| 1710 | int i; | ||
| 1711 | |||
| 1712 | fflush(stdout); | ||
| 1713 | |||
| 1714 | if (!csv_output) { | ||
| 1715 | fprintf(output, "\n"); | ||
| 1716 | fprintf(output, " Performance counter stats for "); | ||
| 1717 | if (target.system_wide) | ||
| 1718 | fprintf(output, "\'system wide"); | ||
| 1719 | else if (target.cpu_list) | ||
| 1720 | fprintf(output, "\'CPU(s) %s", target.cpu_list); | ||
| 1721 | else if (!target__has_task(&target)) { | ||
| 1722 | fprintf(output, "\'%s", argv ? argv[0] : "pipe"); | ||
| 1723 | for (i = 1; argv && (i < argc); i++) | ||
| 1724 | fprintf(output, " %s", argv[i]); | ||
| 1725 | } else if (target.pid) | ||
| 1726 | fprintf(output, "process id \'%s", target.pid); | ||
| 1727 | else | ||
| 1728 | fprintf(output, "thread id \'%s", target.tid); | ||
| 1729 | |||
| 1730 | fprintf(output, "\'"); | ||
| 1731 | if (run_count > 1) | ||
| 1732 | fprintf(output, " (%d runs)", run_count); | ||
| 1733 | fprintf(output, ":\n\n"); | ||
| 1734 | } | ||
| 1735 | } | ||
| 1736 | |||
| 1737 | static int get_precision(double num) | ||
| 1738 | { | ||
| 1739 | if (num > 1) | ||
| 1740 | return 0; | ||
| 1741 | |||
| 1742 | return lround(ceil(-log10(num))); | ||
| 1743 | } | ||
| 1744 | |||
| 1745 | static void print_table(FILE *output, int precision, double avg) | ||
| 1746 | { | ||
| 1747 | char tmp[64]; | ||
| 1748 | int idx, indent = 0; | ||
| 1749 | |||
| 1750 | scnprintf(tmp, 64, " %17.*f", precision, avg); | ||
| 1751 | while (tmp[indent] == ' ') | ||
| 1752 | indent++; | ||
| 1753 | |||
| 1754 | fprintf(output, "%*s# Table of individual measurements:\n", indent, ""); | ||
| 1755 | |||
| 1756 | for (idx = 0; idx < run_count; idx++) { | ||
| 1757 | double run = (double) walltime_run[idx] / NSEC_PER_SEC; | ||
| 1758 | int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5); | ||
| 1759 | |||
| 1760 | fprintf(output, " %17.*f (%+.*f) ", | ||
| 1761 | precision, run, precision, run - avg); | ||
| 1762 | |||
| 1763 | for (h = 0; h < n; h++) | ||
| 1764 | fprintf(output, "#"); | ||
| 1765 | |||
| 1766 | fprintf(output, "\n"); | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | fprintf(output, "\n%*s# Final result:\n", indent, ""); | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | static double timeval2double(struct timeval *t) | ||
| 1773 | { | ||
| 1774 | return t->tv_sec + (double) t->tv_usec/USEC_PER_SEC; | ||
| 1775 | } | ||
| 1776 | |||
| 1777 | static void print_footer(void) | ||
| 1778 | { | ||
| 1779 | double avg = avg_stats(&walltime_nsecs_stats) / NSEC_PER_SEC; | ||
| 1780 | FILE *output = stat_config.output; | ||
| 1781 | int n; | ||
| 1782 | |||
| 1783 | if (!null_run) | ||
| 1784 | fprintf(output, "\n"); | ||
| 1785 | |||
| 1786 | if (run_count == 1) { | ||
| 1787 | fprintf(output, " %17.9f seconds time elapsed", avg); | ||
| 1788 | |||
| 1789 | if (ru_display) { | ||
| 1790 | double ru_utime = timeval2double(&ru_data.ru_utime); | ||
| 1791 | double ru_stime = timeval2double(&ru_data.ru_stime); | ||
| 1792 | |||
| 1793 | fprintf(output, "\n\n"); | ||
| 1794 | fprintf(output, " %17.9f seconds user\n", ru_utime); | ||
| 1795 | fprintf(output, " %17.9f seconds sys\n", ru_stime); | ||
| 1796 | } | ||
| 1797 | } else { | ||
| 1798 | double sd = stddev_stats(&walltime_nsecs_stats) / NSEC_PER_SEC; | ||
| 1799 | /* | ||
| 1800 | * Display at most 2 more significant | ||
| 1801 | * digits than the stddev inaccuracy. | ||
| 1802 | */ | ||
| 1803 | int precision = get_precision(sd) + 2; | ||
| 1804 | |||
| 1805 | if (walltime_run_table) | ||
| 1806 | print_table(output, precision, avg); | ||
| 1807 | |||
| 1808 | fprintf(output, " %17.*f +- %.*f seconds time elapsed", | ||
| 1809 | precision, avg, precision, sd); | ||
| 1810 | |||
| 1811 | print_noise_pct(sd, avg); | ||
| 1812 | } | ||
| 1813 | fprintf(output, "\n\n"); | ||
| 1814 | |||
| 1815 | if (print_free_counters_hint && | ||
| 1816 | sysctl__read_int("kernel/nmi_watchdog", &n) >= 0 && | ||
| 1817 | n > 0) | ||
| 1818 | fprintf(output, | ||
| 1819 | "Some events weren't counted. Try disabling the NMI watchdog:\n" | ||
| 1820 | " echo 0 > /proc/sys/kernel/nmi_watchdog\n" | ||
| 1821 | " perf stat ...\n" | ||
| 1822 | " echo 1 > /proc/sys/kernel/nmi_watchdog\n"); | ||
| 1823 | |||
| 1824 | if (print_mixed_hw_group_error) | ||
| 1825 | fprintf(output, | ||
| 1826 | "The events in group usually have to be from " | ||
| 1827 | "the same PMU. Try reorganizing the group.\n"); | ||
| 1828 | } | ||
| 1829 | |||
| 1830 | static void print_counters(struct timespec *ts, int argc, const char **argv) | 639 | static void print_counters(struct timespec *ts, int argc, const char **argv) |
| 1831 | { | 640 | { |
| 1832 | int interval = stat_config.interval; | ||
| 1833 | struct perf_evsel *counter; | ||
| 1834 | char buf[64], *prefix = NULL; | ||
| 1835 | |||
| 1836 | /* Do not print anything if we record to the pipe. */ | 641 | /* Do not print anything if we record to the pipe. */ |
| 1837 | if (STAT_RECORD && perf_stat.data.is_pipe) | 642 | if (STAT_RECORD && perf_stat.data.is_pipe) |
| 1838 | return; | 643 | return; |
| 1839 | 644 | ||
| 1840 | if (interval) | 645 | perf_evlist__print_counters(evsel_list, &stat_config, &target, |
| 1841 | print_interval(prefix = buf, ts); | 646 | ts, argc, argv); |
| 1842 | else | ||
| 1843 | print_header(argc, argv); | ||
| 1844 | |||
| 1845 | if (metric_only) { | ||
| 1846 | static int num_print_iv; | ||
| 1847 | |||
| 1848 | if (num_print_iv == 0 && !interval) | ||
| 1849 | print_metric_headers(prefix, false); | ||
| 1850 | if (num_print_iv++ == 25) | ||
| 1851 | num_print_iv = 0; | ||
| 1852 | if (stat_config.aggr_mode == AGGR_GLOBAL && prefix) | ||
| 1853 | fprintf(stat_config.output, "%s", prefix); | ||
| 1854 | } | ||
| 1855 | |||
| 1856 | switch (stat_config.aggr_mode) { | ||
| 1857 | case AGGR_CORE: | ||
| 1858 | case AGGR_SOCKET: | ||
| 1859 | print_aggr(prefix); | ||
| 1860 | break; | ||
| 1861 | case AGGR_THREAD: | ||
| 1862 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1863 | if (is_duration_time(counter)) | ||
| 1864 | continue; | ||
| 1865 | print_aggr_thread(counter, prefix); | ||
| 1866 | } | ||
| 1867 | break; | ||
| 1868 | case AGGR_GLOBAL: | ||
| 1869 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1870 | if (is_duration_time(counter)) | ||
| 1871 | continue; | ||
| 1872 | print_counter_aggr(counter, prefix); | ||
| 1873 | } | ||
| 1874 | if (metric_only) | ||
| 1875 | fputc('\n', stat_config.output); | ||
| 1876 | break; | ||
| 1877 | case AGGR_NONE: | ||
| 1878 | if (metric_only) | ||
| 1879 | print_no_aggr_metric(prefix); | ||
| 1880 | else { | ||
| 1881 | evlist__for_each_entry(evsel_list, counter) { | ||
| 1882 | if (is_duration_time(counter)) | ||
| 1883 | continue; | ||
| 1884 | print_counter(counter, prefix); | ||
| 1885 | } | ||
| 1886 | } | ||
| 1887 | break; | ||
| 1888 | case AGGR_UNSET: | ||
| 1889 | default: | ||
| 1890 | break; | ||
| 1891 | } | ||
| 1892 | |||
| 1893 | if (!interval && !csv_output) | ||
| 1894 | print_footer(); | ||
| 1895 | |||
| 1896 | fflush(stat_config.output); | ||
| 1897 | } | 647 | } |
| 1898 | 648 | ||
| 1899 | static volatile int signr = -1; | 649 | static volatile int signr = -1; |
| @@ -1950,7 +700,7 @@ static int enable_metric_only(const struct option *opt __maybe_unused, | |||
| 1950 | const char *s __maybe_unused, int unset) | 700 | const char *s __maybe_unused, int unset) |
| 1951 | { | 701 | { |
| 1952 | force_metric_only = true; | 702 | force_metric_only = true; |
| 1953 | metric_only = !unset; | 703 | stat_config.metric_only = !unset; |
| 1954 | return 0; | 704 | return 0; |
| 1955 | } | 705 | } |
| 1956 | 706 | ||
| @@ -1958,7 +708,7 @@ static int parse_metric_groups(const struct option *opt, | |||
| 1958 | const char *str, | 708 | const char *str, |
| 1959 | int unset __maybe_unused) | 709 | int unset __maybe_unused) |
| 1960 | { | 710 | { |
| 1961 | return metricgroup__parse_groups(opt, str, &metric_events); | 711 | return metricgroup__parse_groups(opt, str, &stat_config.metric_events); |
| 1962 | } | 712 | } |
| 1963 | 713 | ||
| 1964 | static const struct option stat_options[] = { | 714 | static const struct option stat_options[] = { |
| @@ -1969,7 +719,7 @@ static const struct option stat_options[] = { | |||
| 1969 | parse_events_option), | 719 | parse_events_option), |
| 1970 | OPT_CALLBACK(0, "filter", &evsel_list, "filter", | 720 | OPT_CALLBACK(0, "filter", &evsel_list, "filter", |
| 1971 | "event filter", parse_filter), | 721 | "event filter", parse_filter), |
| 1972 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, | 722 | OPT_BOOLEAN('i', "no-inherit", &stat_config.no_inherit, |
| 1973 | "child tasks do not inherit counters"), | 723 | "child tasks do not inherit counters"), |
| 1974 | OPT_STRING('p', "pid", &target.pid, "pid", | 724 | OPT_STRING('p', "pid", &target.pid, "pid", |
| 1975 | "stat events on existing process id"), | 725 | "stat events on existing process id"), |
| @@ -1982,11 +732,11 @@ static const struct option stat_options[] = { | |||
| 1982 | OPT_BOOLEAN('c', "scale", &stat_config.scale, "scale/normalize counters"), | 732 | OPT_BOOLEAN('c', "scale", &stat_config.scale, "scale/normalize counters"), |
| 1983 | OPT_INCR('v', "verbose", &verbose, | 733 | OPT_INCR('v', "verbose", &verbose, |
| 1984 | "be more verbose (show counter open errors, etc)"), | 734 | "be more verbose (show counter open errors, etc)"), |
| 1985 | OPT_INTEGER('r', "repeat", &run_count, | 735 | OPT_INTEGER('r', "repeat", &stat_config.run_count, |
| 1986 | "repeat command and print average + stddev (max: 100, forever: 0)"), | 736 | "repeat command and print average + stddev (max: 100, forever: 0)"), |
| 1987 | OPT_BOOLEAN(0, "table", &walltime_run_table, | 737 | OPT_BOOLEAN(0, "table", &stat_config.walltime_run_table, |
| 1988 | "display details about each run (only with -r option)"), | 738 | "display details about each run (only with -r option)"), |
| 1989 | OPT_BOOLEAN('n', "null", &null_run, | 739 | OPT_BOOLEAN('n', "null", &stat_config.null_run, |
| 1990 | "null run - dont start any counters"), | 740 | "null run - dont start any counters"), |
| 1991 | OPT_INCR('d', "detailed", &detailed_run, | 741 | OPT_INCR('d', "detailed", &detailed_run, |
| 1992 | "detailed run - start a lot of events"), | 742 | "detailed run - start a lot of events"), |
| @@ -1999,8 +749,8 @@ static const struct option stat_options[] = { | |||
| 1999 | "list of cpus to monitor in system-wide"), | 749 | "list of cpus to monitor in system-wide"), |
| 2000 | OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode, | 750 | OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode, |
| 2001 | "disable CPU count aggregation", AGGR_NONE), | 751 | "disable CPU count aggregation", AGGR_NONE), |
| 2002 | OPT_BOOLEAN(0, "no-merge", &no_merge, "Do not merge identical named events"), | 752 | OPT_BOOLEAN(0, "no-merge", &stat_config.no_merge, "Do not merge identical named events"), |
| 2003 | OPT_STRING('x', "field-separator", &csv_sep, "separator", | 753 | OPT_STRING('x', "field-separator", &stat_config.csv_sep, "separator", |
| 2004 | "print counts with custom separator"), | 754 | "print counts with custom separator"), |
| 2005 | OPT_CALLBACK('G', "cgroup", &evsel_list, "name", | 755 | OPT_CALLBACK('G', "cgroup", &evsel_list, "name", |
| 2006 | "monitor event in cgroup name only", parse_cgroups), | 756 | "monitor event in cgroup name only", parse_cgroups), |
| @@ -2017,7 +767,7 @@ static const struct option stat_options[] = { | |||
| 2017 | "(overhead is possible for values <= 100ms)"), | 767 | "(overhead is possible for values <= 100ms)"), |
| 2018 | OPT_INTEGER(0, "interval-count", &stat_config.times, | 768 | OPT_INTEGER(0, "interval-count", &stat_config.times, |
| 2019 | "print counts for fixed number of times"), | 769 | "print counts for fixed number of times"), |
| 2020 | OPT_BOOLEAN(0, "interval-clear", &interval_clear, | 770 | OPT_BOOLEAN(0, "interval-clear", &stat_config.interval_clear, |
| 2021 | "clear screen in between new interval"), | 771 | "clear screen in between new interval"), |
| 2022 | OPT_UINTEGER(0, "timeout", &stat_config.timeout, | 772 | OPT_UINTEGER(0, "timeout", &stat_config.timeout, |
| 2023 | "stop workload and print counts after a timeout period in ms (>= 10ms)"), | 773 | "stop workload and print counts after a timeout period in ms (>= 10ms)"), |
| @@ -2027,9 +777,9 @@ static const struct option stat_options[] = { | |||
| 2027 | "aggregate counts per physical processor core", AGGR_CORE), | 777 | "aggregate counts per physical processor core", AGGR_CORE), |
| 2028 | OPT_SET_UINT(0, "per-thread", &stat_config.aggr_mode, | 778 | OPT_SET_UINT(0, "per-thread", &stat_config.aggr_mode, |
| 2029 | "aggregate counts per thread", AGGR_THREAD), | 779 | "aggregate counts per thread", AGGR_THREAD), |
| 2030 | OPT_UINTEGER('D', "delay", &initial_delay, | 780 | OPT_UINTEGER('D', "delay", &stat_config.initial_delay, |
| 2031 | "ms to wait before starting measurement after program start"), | 781 | "ms to wait before starting measurement after program start"), |
| 2032 | OPT_CALLBACK_NOOPT(0, "metric-only", &metric_only, NULL, | 782 | OPT_CALLBACK_NOOPT(0, "metric-only", &stat_config.metric_only, NULL, |
| 2033 | "Only print computed metrics. No raw values", enable_metric_only), | 783 | "Only print computed metrics. No raw values", enable_metric_only), |
| 2034 | OPT_BOOLEAN(0, "topdown", &topdown_run, | 784 | OPT_BOOLEAN(0, "topdown", &topdown_run, |
| 2035 | "measure topdown level 1 statistics"), | 785 | "measure topdown level 1 statistics"), |
| @@ -2041,12 +791,14 @@ static const struct option stat_options[] = { | |||
| 2041 | OPT_END() | 791 | OPT_END() |
| 2042 | }; | 792 | }; |
| 2043 | 793 | ||
| 2044 | static int perf_stat__get_socket(struct cpu_map *map, int cpu) | 794 | static int perf_stat__get_socket(struct perf_stat_config *config __maybe_unused, |
| 795 | struct cpu_map *map, int cpu) | ||
| 2045 | { | 796 | { |
| 2046 | return cpu_map__get_socket(map, cpu, NULL); | 797 | return cpu_map__get_socket(map, cpu, NULL); |
| 2047 | } | 798 | } |
| 2048 | 799 | ||
| 2049 | static int perf_stat__get_core(struct cpu_map *map, int cpu) | 800 | static int perf_stat__get_core(struct perf_stat_config *config __maybe_unused, |
| 801 | struct cpu_map *map, int cpu) | ||
| 2050 | { | 802 | { |
| 2051 | return cpu_map__get_core(map, cpu, NULL); | 803 | return cpu_map__get_core(map, cpu, NULL); |
| 2052 | } | 804 | } |
| @@ -2063,9 +815,8 @@ static int cpu_map__get_max(struct cpu_map *map) | |||
| 2063 | return max; | 815 | return max; |
| 2064 | } | 816 | } |
| 2065 | 817 | ||
| 2066 | static struct cpu_map *cpus_aggr_map; | 818 | static int perf_stat__get_aggr(struct perf_stat_config *config, |
| 2067 | 819 | aggr_get_id_t get_id, struct cpu_map *map, int idx) | |
| 2068 | static int perf_stat__get_aggr(aggr_get_id_t get_id, struct cpu_map *map, int idx) | ||
| 2069 | { | 820 | { |
| 2070 | int cpu; | 821 | int cpu; |
| 2071 | 822 | ||
| @@ -2074,20 +825,22 @@ static int perf_stat__get_aggr(aggr_get_id_t get_id, struct cpu_map *map, int id | |||
| 2074 | 825 | ||
| 2075 | cpu = map->map[idx]; | 826 | cpu = map->map[idx]; |
| 2076 | 827 | ||
| 2077 | if (cpus_aggr_map->map[cpu] == -1) | 828 | if (config->cpus_aggr_map->map[cpu] == -1) |
| 2078 | cpus_aggr_map->map[cpu] = get_id(map, idx); | 829 | config->cpus_aggr_map->map[cpu] = get_id(config, map, idx); |
| 2079 | 830 | ||
| 2080 | return cpus_aggr_map->map[cpu]; | 831 | return config->cpus_aggr_map->map[cpu]; |
| 2081 | } | 832 | } |
| 2082 | 833 | ||
| 2083 | static int perf_stat__get_socket_cached(struct cpu_map *map, int idx) | 834 | static int perf_stat__get_socket_cached(struct perf_stat_config *config, |
| 835 | struct cpu_map *map, int idx) | ||
| 2084 | { | 836 | { |
| 2085 | return perf_stat__get_aggr(perf_stat__get_socket, map, idx); | 837 | return perf_stat__get_aggr(config, perf_stat__get_socket, map, idx); |
| 2086 | } | 838 | } |
| 2087 | 839 | ||
| 2088 | static int perf_stat__get_core_cached(struct cpu_map *map, int idx) | 840 | static int perf_stat__get_core_cached(struct perf_stat_config *config, |
| 841 | struct cpu_map *map, int idx) | ||
| 2089 | { | 842 | { |
| 2090 | return perf_stat__get_aggr(perf_stat__get_core, map, idx); | 843 | return perf_stat__get_aggr(config, perf_stat__get_core, map, idx); |
| 2091 | } | 844 | } |
| 2092 | 845 | ||
| 2093 | static int perf_stat_init_aggr_mode(void) | 846 | static int perf_stat_init_aggr_mode(void) |
| @@ -2096,18 +849,18 @@ static int perf_stat_init_aggr_mode(void) | |||
| 2096 | 849 | ||
| 2097 | switch (stat_config.aggr_mode) { | 850 | switch (stat_config.aggr_mode) { |
| 2098 | case AGGR_SOCKET: | 851 | case AGGR_SOCKET: |
| 2099 | if (cpu_map__build_socket_map(evsel_list->cpus, &aggr_map)) { | 852 | if (cpu_map__build_socket_map(evsel_list->cpus, &stat_config.aggr_map)) { |
| 2100 | perror("cannot build socket map"); | 853 | perror("cannot build socket map"); |
| 2101 | return -1; | 854 | return -1; |
| 2102 | } | 855 | } |
| 2103 | aggr_get_id = perf_stat__get_socket_cached; | 856 | stat_config.aggr_get_id = perf_stat__get_socket_cached; |
| 2104 | break; | 857 | break; |
| 2105 | case AGGR_CORE: | 858 | case AGGR_CORE: |
| 2106 | if (cpu_map__build_core_map(evsel_list->cpus, &aggr_map)) { | 859 | if (cpu_map__build_core_map(evsel_list->cpus, &stat_config.aggr_map)) { |
| 2107 | perror("cannot build core map"); | 860 | perror("cannot build core map"); |
| 2108 | return -1; | 861 | return -1; |
| 2109 | } | 862 | } |
| 2110 | aggr_get_id = perf_stat__get_core_cached; | 863 | stat_config.aggr_get_id = perf_stat__get_core_cached; |
| 2111 | break; | 864 | break; |
| 2112 | case AGGR_NONE: | 865 | case AGGR_NONE: |
| 2113 | case AGGR_GLOBAL: | 866 | case AGGR_GLOBAL: |
| @@ -2123,16 +876,16 @@ static int perf_stat_init_aggr_mode(void) | |||
| 2123 | * the aggregation translate cpumap. | 876 | * the aggregation translate cpumap. |
| 2124 | */ | 877 | */ |
| 2125 | nr = cpu_map__get_max(evsel_list->cpus); | 878 | nr = cpu_map__get_max(evsel_list->cpus); |
| 2126 | cpus_aggr_map = cpu_map__empty_new(nr + 1); | 879 | stat_config.cpus_aggr_map = cpu_map__empty_new(nr + 1); |
| 2127 | return cpus_aggr_map ? 0 : -ENOMEM; | 880 | return stat_config.cpus_aggr_map ? 0 : -ENOMEM; |
| 2128 | } | 881 | } |
| 2129 | 882 | ||
| 2130 | static void perf_stat__exit_aggr_mode(void) | 883 | static void perf_stat__exit_aggr_mode(void) |
| 2131 | { | 884 | { |
| 2132 | cpu_map__put(aggr_map); | 885 | cpu_map__put(stat_config.aggr_map); |
| 2133 | cpu_map__put(cpus_aggr_map); | 886 | cpu_map__put(stat_config.cpus_aggr_map); |
| 2134 | aggr_map = NULL; | 887 | stat_config.aggr_map = NULL; |
| 2135 | cpus_aggr_map = NULL; | 888 | stat_config.cpus_aggr_map = NULL; |
| 2136 | } | 889 | } |
| 2137 | 890 | ||
| 2138 | static inline int perf_env__get_cpu(struct perf_env *env, struct cpu_map *map, int idx) | 891 | static inline int perf_env__get_cpu(struct perf_env *env, struct cpu_map *map, int idx) |
| @@ -2190,12 +943,14 @@ static int perf_env__build_core_map(struct perf_env *env, struct cpu_map *cpus, | |||
| 2190 | return cpu_map__build_map(cpus, corep, perf_env__get_core, env); | 943 | return cpu_map__build_map(cpus, corep, perf_env__get_core, env); |
| 2191 | } | 944 | } |
| 2192 | 945 | ||
| 2193 | static int perf_stat__get_socket_file(struct cpu_map *map, int idx) | 946 | static int perf_stat__get_socket_file(struct perf_stat_config *config __maybe_unused, |
| 947 | struct cpu_map *map, int idx) | ||
| 2194 | { | 948 | { |
| 2195 | return perf_env__get_socket(map, idx, &perf_stat.session->header.env); | 949 | return perf_env__get_socket(map, idx, &perf_stat.session->header.env); |
| 2196 | } | 950 | } |
| 2197 | 951 | ||
| 2198 | static int perf_stat__get_core_file(struct cpu_map *map, int idx) | 952 | static int perf_stat__get_core_file(struct perf_stat_config *config __maybe_unused, |
| 953 | struct cpu_map *map, int idx) | ||
| 2199 | { | 954 | { |
| 2200 | return perf_env__get_core(map, idx, &perf_stat.session->header.env); | 955 | return perf_env__get_core(map, idx, &perf_stat.session->header.env); |
| 2201 | } | 956 | } |
| @@ -2206,18 +961,18 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st) | |||
| 2206 | 961 | ||
| 2207 | switch (stat_config.aggr_mode) { | 962 | switch (stat_config.aggr_mode) { |
| 2208 | case AGGR_SOCKET: | 963 | case AGGR_SOCKET: |
| 2209 | if (perf_env__build_socket_map(env, evsel_list->cpus, &aggr_map)) { | 964 | if (perf_env__build_socket_map(env, evsel_list->cpus, &stat_config.aggr_map)) { |
| 2210 | perror("cannot build socket map"); | 965 | perror("cannot build socket map"); |
| 2211 | return -1; | 966 | return -1; |
| 2212 | } | 967 | } |
| 2213 | aggr_get_id = perf_stat__get_socket_file; | 968 | stat_config.aggr_get_id = perf_stat__get_socket_file; |
| 2214 | break; | 969 | break; |
| 2215 | case AGGR_CORE: | 970 | case AGGR_CORE: |
| 2216 | if (perf_env__build_core_map(env, evsel_list->cpus, &aggr_map)) { | 971 | if (perf_env__build_core_map(env, evsel_list->cpus, &stat_config.aggr_map)) { |
| 2217 | perror("cannot build core map"); | 972 | perror("cannot build core map"); |
| 2218 | return -1; | 973 | return -1; |
| 2219 | } | 974 | } |
| 2220 | aggr_get_id = perf_stat__get_core_file; | 975 | stat_config.aggr_get_id = perf_stat__get_core_file; |
| 2221 | break; | 976 | break; |
| 2222 | case AGGR_NONE: | 977 | case AGGR_NONE: |
| 2223 | case AGGR_GLOBAL: | 978 | case AGGR_GLOBAL: |
| @@ -2401,7 +1156,7 @@ static int add_default_attributes(void) | |||
| 2401 | struct parse_events_error errinfo; | 1156 | struct parse_events_error errinfo; |
| 2402 | 1157 | ||
| 2403 | /* Set attrs if no event is selected and !null_run: */ | 1158 | /* Set attrs if no event is selected and !null_run: */ |
| 2404 | if (null_run) | 1159 | if (stat_config.null_run) |
| 2405 | return 0; | 1160 | return 0; |
| 2406 | 1161 | ||
| 2407 | if (transaction_run) { | 1162 | if (transaction_run) { |
| @@ -2414,7 +1169,7 @@ static int add_default_attributes(void) | |||
| 2414 | struct option opt = { .value = &evsel_list }; | 1169 | struct option opt = { .value = &evsel_list }; |
| 2415 | 1170 | ||
| 2416 | return metricgroup__parse_groups(&opt, "transaction", | 1171 | return metricgroup__parse_groups(&opt, "transaction", |
| 2417 | &metric_events); | 1172 | &stat_config.metric_events); |
| 2418 | } | 1173 | } |
| 2419 | 1174 | ||
| 2420 | if (pmu_have_event("cpu", "cycles-ct") && | 1175 | if (pmu_have_event("cpu", "cycles-ct") && |
| @@ -2452,7 +1207,7 @@ static int add_default_attributes(void) | |||
| 2452 | if (pmu_have_event("msr", "aperf") && | 1207 | if (pmu_have_event("msr", "aperf") && |
| 2453 | pmu_have_event("msr", "smi")) { | 1208 | pmu_have_event("msr", "smi")) { |
| 2454 | if (!force_metric_only) | 1209 | if (!force_metric_only) |
| 2455 | metric_only = true; | 1210 | stat_config.metric_only = true; |
| 2456 | err = parse_events(evsel_list, smi_cost_attrs, &errinfo); | 1211 | err = parse_events(evsel_list, smi_cost_attrs, &errinfo); |
| 2457 | } else { | 1212 | } else { |
| 2458 | fprintf(stderr, "To measure SMI cost, it needs " | 1213 | fprintf(stderr, "To measure SMI cost, it needs " |
| @@ -2483,7 +1238,7 @@ static int add_default_attributes(void) | |||
| 2483 | } | 1238 | } |
| 2484 | 1239 | ||
| 2485 | if (!force_metric_only) | 1240 | if (!force_metric_only) |
| 2486 | metric_only = true; | 1241 | stat_config.metric_only = true; |
| 2487 | if (topdown_filter_events(topdown_attrs, &str, | 1242 | if (topdown_filter_events(topdown_attrs, &str, |
| 2488 | arch_topdown_check_group(&warn)) < 0) { | 1243 | arch_topdown_check_group(&warn)) < 0) { |
| 2489 | pr_err("Out of memory\n"); | 1244 | pr_err("Out of memory\n"); |
| @@ -2580,7 +1335,7 @@ static int __cmd_record(int argc, const char **argv) | |||
| 2580 | if (output_name) | 1335 | if (output_name) |
| 2581 | data->file.path = output_name; | 1336 | data->file.path = output_name; |
| 2582 | 1337 | ||
| 2583 | if (run_count != 1 || forever) { | 1338 | if (stat_config.run_count != 1 || forever) { |
| 2584 | pr_err("Cannot use -r option with perf stat record.\n"); | 1339 | pr_err("Cannot use -r option with perf stat record.\n"); |
| 2585 | return -1; | 1340 | return -1; |
| 2586 | } | 1341 | } |
| @@ -2599,9 +1354,8 @@ static int __cmd_record(int argc, const char **argv) | |||
| 2599 | return argc; | 1354 | return argc; |
| 2600 | } | 1355 | } |
| 2601 | 1356 | ||
| 2602 | static int process_stat_round_event(struct perf_tool *tool __maybe_unused, | 1357 | static int process_stat_round_event(struct perf_session *session, |
| 2603 | union perf_event *event, | 1358 | union perf_event *event) |
| 2604 | struct perf_session *session) | ||
| 2605 | { | 1359 | { |
| 2606 | struct stat_round_event *stat_round = &event->stat_round; | 1360 | struct stat_round_event *stat_round = &event->stat_round; |
| 2607 | struct perf_evsel *counter; | 1361 | struct perf_evsel *counter; |
| @@ -2626,10 +1380,10 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused, | |||
| 2626 | } | 1380 | } |
| 2627 | 1381 | ||
| 2628 | static | 1382 | static |
| 2629 | int process_stat_config_event(struct perf_tool *tool, | 1383 | int process_stat_config_event(struct perf_session *session, |
| 2630 | union perf_event *event, | 1384 | union perf_event *event) |
| 2631 | struct perf_session *session __maybe_unused) | ||
| 2632 | { | 1385 | { |
| 1386 | struct perf_tool *tool = session->tool; | ||
| 2633 | struct perf_stat *st = container_of(tool, struct perf_stat, tool); | 1387 | struct perf_stat *st = container_of(tool, struct perf_stat, tool); |
| 2634 | 1388 | ||
| 2635 | perf_event__read_stat_config(&stat_config, &event->stat_config); | 1389 | perf_event__read_stat_config(&stat_config, &event->stat_config); |
| @@ -2669,10 +1423,10 @@ static int set_maps(struct perf_stat *st) | |||
| 2669 | } | 1423 | } |
| 2670 | 1424 | ||
| 2671 | static | 1425 | static |
| 2672 | int process_thread_map_event(struct perf_tool *tool, | 1426 | int process_thread_map_event(struct perf_session *session, |
| 2673 | union perf_event *event, | 1427 | union perf_event *event) |
| 2674 | struct perf_session *session __maybe_unused) | ||
| 2675 | { | 1428 | { |
| 1429 | struct perf_tool *tool = session->tool; | ||
| 2676 | struct perf_stat *st = container_of(tool, struct perf_stat, tool); | 1430 | struct perf_stat *st = container_of(tool, struct perf_stat, tool); |
| 2677 | 1431 | ||
| 2678 | if (st->threads) { | 1432 | if (st->threads) { |
| @@ -2688,10 +1442,10 @@ int process_thread_map_event(struct perf_tool *tool, | |||
| 2688 | } | 1442 | } |
| 2689 | 1443 | ||
| 2690 | static | 1444 | static |
| 2691 | int process_cpu_map_event(struct perf_tool *tool, | 1445 | int process_cpu_map_event(struct perf_session *session, |
| 2692 | union perf_event *event, | 1446 | union perf_event *event) |
| 2693 | struct perf_session *session __maybe_unused) | ||
| 2694 | { | 1447 | { |
| 1448 | struct perf_tool *tool = session->tool; | ||
| 2695 | struct perf_stat *st = container_of(tool, struct perf_stat, tool); | 1449 | struct perf_stat *st = container_of(tool, struct perf_stat, tool); |
| 2696 | struct cpu_map *cpus; | 1450 | struct cpu_map *cpus; |
| 2697 | 1451 | ||
| @@ -2853,12 +1607,12 @@ int cmd_stat(int argc, const char **argv) | |||
| 2853 | perf_stat__collect_metric_expr(evsel_list); | 1607 | perf_stat__collect_metric_expr(evsel_list); |
| 2854 | perf_stat__init_shadow_stats(); | 1608 | perf_stat__init_shadow_stats(); |
| 2855 | 1609 | ||
| 2856 | if (csv_sep) { | 1610 | if (stat_config.csv_sep) { |
| 2857 | csv_output = true; | 1611 | stat_config.csv_output = true; |
| 2858 | if (!strcmp(csv_sep, "\\t")) | 1612 | if (!strcmp(stat_config.csv_sep, "\\t")) |
| 2859 | csv_sep = "\t"; | 1613 | stat_config.csv_sep = "\t"; |
| 2860 | } else | 1614 | } else |
| 2861 | csv_sep = DEFAULT_SEPARATOR; | 1615 | stat_config.csv_sep = DEFAULT_SEPARATOR; |
| 2862 | 1616 | ||
| 2863 | if (argc && !strncmp(argv[0], "rec", 3)) { | 1617 | if (argc && !strncmp(argv[0], "rec", 3)) { |
| 2864 | argc = __cmd_record(argc, argv); | 1618 | argc = __cmd_record(argc, argv); |
| @@ -2883,17 +1637,17 @@ int cmd_stat(int argc, const char **argv) | |||
| 2883 | goto out; | 1637 | goto out; |
| 2884 | } | 1638 | } |
| 2885 | 1639 | ||
| 2886 | if (metric_only && stat_config.aggr_mode == AGGR_THREAD) { | 1640 | if (stat_config.metric_only && stat_config.aggr_mode == AGGR_THREAD) { |
| 2887 | fprintf(stderr, "--metric-only is not supported with --per-thread\n"); | 1641 | fprintf(stderr, "--metric-only is not supported with --per-thread\n"); |
| 2888 | goto out; | 1642 | goto out; |
| 2889 | } | 1643 | } |
| 2890 | 1644 | ||
| 2891 | if (metric_only && run_count > 1) { | 1645 | if (stat_config.metric_only && stat_config.run_count > 1) { |
| 2892 | fprintf(stderr, "--metric-only is not supported with -r\n"); | 1646 | fprintf(stderr, "--metric-only is not supported with -r\n"); |
| 2893 | goto out; | 1647 | goto out; |
| 2894 | } | 1648 | } |
| 2895 | 1649 | ||
| 2896 | if (walltime_run_table && run_count <= 1) { | 1650 | if (stat_config.walltime_run_table && stat_config.run_count <= 1) { |
| 2897 | fprintf(stderr, "--table is only supported with -r\n"); | 1651 | fprintf(stderr, "--table is only supported with -r\n"); |
| 2898 | parse_options_usage(stat_usage, stat_options, "r", 1); | 1652 | parse_options_usage(stat_usage, stat_options, "r", 1); |
| 2899 | parse_options_usage(NULL, stat_options, "table", 0); | 1653 | parse_options_usage(NULL, stat_options, "table", 0); |
| @@ -2931,7 +1685,7 @@ int cmd_stat(int argc, const char **argv) | |||
| 2931 | /* | 1685 | /* |
| 2932 | * let the spreadsheet do the pretty-printing | 1686 | * let the spreadsheet do the pretty-printing |
| 2933 | */ | 1687 | */ |
| 2934 | if (csv_output) { | 1688 | if (stat_config.csv_output) { |
| 2935 | /* User explicitly passed -B? */ | 1689 | /* User explicitly passed -B? */ |
| 2936 | if (big_num_opt == 1) { | 1690 | if (big_num_opt == 1) { |
| 2937 | fprintf(stderr, "-B option not supported with -x\n"); | 1691 | fprintf(stderr, "-B option not supported with -x\n"); |
| @@ -2939,9 +1693,9 @@ int cmd_stat(int argc, const char **argv) | |||
| 2939 | parse_options_usage(NULL, stat_options, "x", 1); | 1693 | parse_options_usage(NULL, stat_options, "x", 1); |
| 2940 | goto out; | 1694 | goto out; |
| 2941 | } else /* Nope, so disable big number formatting */ | 1695 | } else /* Nope, so disable big number formatting */ |
| 2942 | big_num = false; | 1696 | stat_config.big_num = false; |
| 2943 | } else if (big_num_opt == 0) /* User passed --no-big-num */ | 1697 | } else if (big_num_opt == 0) /* User passed --no-big-num */ |
| 2944 | big_num = false; | 1698 | stat_config.big_num = false; |
| 2945 | 1699 | ||
| 2946 | setup_system_wide(argc); | 1700 | setup_system_wide(argc); |
| 2947 | 1701 | ||
| @@ -2949,21 +1703,21 @@ int cmd_stat(int argc, const char **argv) | |||
| 2949 | * Display user/system times only for single | 1703 | * Display user/system times only for single |
| 2950 | * run and when there's specified tracee. | 1704 | * run and when there's specified tracee. |
| 2951 | */ | 1705 | */ |
| 2952 | if ((run_count == 1) && target__none(&target)) | 1706 | if ((stat_config.run_count == 1) && target__none(&target)) |
| 2953 | ru_display = true; | 1707 | stat_config.ru_display = true; |
| 2954 | 1708 | ||
| 2955 | if (run_count < 0) { | 1709 | if (stat_config.run_count < 0) { |
| 2956 | pr_err("Run count must be a positive number\n"); | 1710 | pr_err("Run count must be a positive number\n"); |
| 2957 | parse_options_usage(stat_usage, stat_options, "r", 1); | 1711 | parse_options_usage(stat_usage, stat_options, "r", 1); |
| 2958 | goto out; | 1712 | goto out; |
| 2959 | } else if (run_count == 0) { | 1713 | } else if (stat_config.run_count == 0) { |
| 2960 | forever = true; | 1714 | forever = true; |
| 2961 | run_count = 1; | 1715 | stat_config.run_count = 1; |
| 2962 | } | 1716 | } |
| 2963 | 1717 | ||
| 2964 | if (walltime_run_table) { | 1718 | if (stat_config.walltime_run_table) { |
| 2965 | walltime_run = zalloc(run_count * sizeof(walltime_run[0])); | 1719 | stat_config.walltime_run = zalloc(stat_config.run_count * sizeof(stat_config.walltime_run[0])); |
| 2966 | if (!walltime_run) { | 1720 | if (!stat_config.walltime_run) { |
| 2967 | pr_err("failed to setup -r option"); | 1721 | pr_err("failed to setup -r option"); |
| 2968 | goto out; | 1722 | goto out; |
| 2969 | } | 1723 | } |
| @@ -3066,6 +1820,17 @@ int cmd_stat(int argc, const char **argv) | |||
| 3066 | goto out; | 1820 | goto out; |
| 3067 | 1821 | ||
| 3068 | /* | 1822 | /* |
| 1823 | * Set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless | ||
| 1824 | * while avoiding that older tools show confusing messages. | ||
| 1825 | * | ||
| 1826 | * However for pipe sessions we need to keep it zero, | ||
| 1827 | * because script's perf_evsel__check_attr is triggered | ||
| 1828 | * by attr->sample_type != 0, and we can't run it on | ||
| 1829 | * stat sessions. | ||
| 1830 | */ | ||
| 1831 | stat_config.identifier = !(STAT_RECORD && perf_stat.data.is_pipe); | ||
| 1832 | |||
| 1833 | /* | ||
| 3069 | * We dont want to block the signals - that would cause | 1834 | * We dont want to block the signals - that would cause |
| 3070 | * child tasks to inherit that and Ctrl-C would not work. | 1835 | * child tasks to inherit that and Ctrl-C would not work. |
| 3071 | * What we want is for Ctrl-C to work in the exec()-ed | 1836 | * What we want is for Ctrl-C to work in the exec()-ed |
| @@ -3079,8 +1844,8 @@ int cmd_stat(int argc, const char **argv) | |||
| 3079 | signal(SIGABRT, skip_signal); | 1844 | signal(SIGABRT, skip_signal); |
| 3080 | 1845 | ||
| 3081 | status = 0; | 1846 | status = 0; |
| 3082 | for (run_idx = 0; forever || run_idx < run_count; run_idx++) { | 1847 | for (run_idx = 0; forever || run_idx < stat_config.run_count; run_idx++) { |
| 3083 | if (run_count != 1 && verbose > 0) | 1848 | if (stat_config.run_count != 1 && verbose > 0) |
| 3084 | fprintf(output, "[ perf stat: executing run #%d ... ]\n", | 1849 | fprintf(output, "[ perf stat: executing run #%d ... ]\n", |
| 3085 | run_idx + 1); | 1850 | run_idx + 1); |
| 3086 | 1851 | ||
| @@ -3132,7 +1897,7 @@ int cmd_stat(int argc, const char **argv) | |||
| 3132 | perf_stat__exit_aggr_mode(); | 1897 | perf_stat__exit_aggr_mode(); |
| 3133 | perf_evlist__free_stats(evsel_list); | 1898 | perf_evlist__free_stats(evsel_list); |
| 3134 | out: | 1899 | out: |
| 3135 | free(walltime_run); | 1900 | free(stat_config.walltime_run); |
| 3136 | 1901 | ||
| 3137 | if (smi_cost && smi_reset) | 1902 | if (smi_cost && smi_reset) |
| 3138 | sysfs__write_int(FREEZE_ON_SMI_PATH, 0); | 1903 | sysfs__write_int(FREEZE_ON_SMI_PATH, 0); |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 22ab8e67c760..90289f31dd87 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -181,7 +181,7 @@ static int __tp_field__init_uint(struct tp_field *field, int size, int offset, b | |||
| 181 | return 0; | 181 | return 0; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | static int tp_field__init_uint(struct tp_field *field, struct format_field *format_field, bool needs_swap) | 184 | static int tp_field__init_uint(struct tp_field *field, struct tep_format_field *format_field, bool needs_swap) |
| 185 | { | 185 | { |
| 186 | return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap); | 186 | return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap); |
| 187 | } | 187 | } |
| @@ -198,7 +198,7 @@ static int __tp_field__init_ptr(struct tp_field *field, int offset) | |||
| 198 | return 0; | 198 | return 0; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field) | 201 | static int tp_field__init_ptr(struct tp_field *field, struct tep_format_field *format_field) |
| 202 | { | 202 | { |
| 203 | return __tp_field__init_ptr(field, format_field->offset); | 203 | return __tp_field__init_ptr(field, format_field->offset); |
| 204 | } | 204 | } |
| @@ -214,7 +214,7 @@ static int perf_evsel__init_tp_uint_field(struct perf_evsel *evsel, | |||
| 214 | struct tp_field *field, | 214 | struct tp_field *field, |
| 215 | const char *name) | 215 | const char *name) |
| 216 | { | 216 | { |
| 217 | struct format_field *format_field = perf_evsel__field(evsel, name); | 217 | struct tep_format_field *format_field = perf_evsel__field(evsel, name); |
| 218 | 218 | ||
| 219 | if (format_field == NULL) | 219 | if (format_field == NULL) |
| 220 | return -1; | 220 | return -1; |
| @@ -230,7 +230,7 @@ static int perf_evsel__init_tp_ptr_field(struct perf_evsel *evsel, | |||
| 230 | struct tp_field *field, | 230 | struct tp_field *field, |
| 231 | const char *name) | 231 | const char *name) |
| 232 | { | 232 | { |
| 233 | struct format_field *format_field = perf_evsel__field(evsel, name); | 233 | struct tep_format_field *format_field = perf_evsel__field(evsel, name); |
| 234 | 234 | ||
| 235 | if (format_field == NULL) | 235 | if (format_field == NULL) |
| 236 | return -1; | 236 | return -1; |
| @@ -288,6 +288,13 @@ static int perf_evsel__init_augmented_syscall_tp_args(struct perf_evsel *evsel) | |||
| 288 | return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64)); | 288 | return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64)); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | static int perf_evsel__init_augmented_syscall_tp_ret(struct perf_evsel *evsel) | ||
| 292 | { | ||
| 293 | struct syscall_tp *sc = evsel->priv; | ||
| 294 | |||
| 295 | return __tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap); | ||
| 296 | } | ||
| 297 | |||
| 291 | static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) | 298 | static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) |
| 292 | { | 299 | { |
| 293 | evsel->priv = malloc(sizeof(struct syscall_tp)); | 300 | evsel->priv = malloc(sizeof(struct syscall_tp)); |
| @@ -498,16 +505,6 @@ static const char *clockid[] = { | |||
| 498 | }; | 505 | }; |
| 499 | static DEFINE_STRARRAY(clockid); | 506 | static DEFINE_STRARRAY(clockid); |
| 500 | 507 | ||
| 501 | static const char *socket_families[] = { | ||
| 502 | "UNSPEC", "LOCAL", "INET", "AX25", "IPX", "APPLETALK", "NETROM", | ||
| 503 | "BRIDGE", "ATMPVC", "X25", "INET6", "ROSE", "DECnet", "NETBEUI", | ||
| 504 | "SECURITY", "KEY", "NETLINK", "PACKET", "ASH", "ECONET", "ATMSVC", | ||
| 505 | "RDS", "SNA", "IRDA", "PPPOX", "WANPIPE", "LLC", "IB", "CAN", "TIPC", | ||
| 506 | "BLUETOOTH", "IUCV", "RXRPC", "ISDN", "PHONET", "IEEE802154", "CAIF", | ||
| 507 | "ALG", "NFC", "VSOCK", | ||
| 508 | }; | ||
| 509 | static DEFINE_STRARRAY(socket_families); | ||
| 510 | |||
| 511 | static size_t syscall_arg__scnprintf_access_mode(char *bf, size_t size, | 508 | static size_t syscall_arg__scnprintf_access_mode(char *bf, size_t size, |
| 512 | struct syscall_arg *arg) | 509 | struct syscall_arg *arg) |
| 513 | { | 510 | { |
| @@ -631,6 +628,8 @@ static struct syscall_fmt { | |||
| 631 | } syscall_fmts[] = { | 628 | } syscall_fmts[] = { |
| 632 | { .name = "access", | 629 | { .name = "access", |
| 633 | .arg = { [1] = { .scnprintf = SCA_ACCMODE, /* mode */ }, }, }, | 630 | .arg = { [1] = { .scnprintf = SCA_ACCMODE, /* mode */ }, }, }, |
| 631 | { .name = "bind", | ||
| 632 | .arg = { [1] = { .scnprintf = SCA_SOCKADDR, /* umyaddr */ }, }, }, | ||
| 634 | { .name = "bpf", | 633 | { .name = "bpf", |
| 635 | .arg = { [0] = STRARRAY(cmd, bpf_cmd), }, }, | 634 | .arg = { [0] = STRARRAY(cmd, bpf_cmd), }, }, |
| 636 | { .name = "brk", .hexret = true, | 635 | { .name = "brk", .hexret = true, |
| @@ -645,6 +644,8 @@ static struct syscall_fmt { | |||
| 645 | [4] = { .name = "tls", .scnprintf = SCA_HEX, }, }, }, | 644 | [4] = { .name = "tls", .scnprintf = SCA_HEX, }, }, }, |
| 646 | { .name = "close", | 645 | { .name = "close", |
| 647 | .arg = { [0] = { .scnprintf = SCA_CLOSE_FD, /* fd */ }, }, }, | 646 | .arg = { [0] = { .scnprintf = SCA_CLOSE_FD, /* fd */ }, }, }, |
| 647 | { .name = "connect", | ||
| 648 | .arg = { [1] = { .scnprintf = SCA_SOCKADDR, /* servaddr */ }, }, }, | ||
| 648 | { .name = "epoll_ctl", | 649 | { .name = "epoll_ctl", |
| 649 | .arg = { [1] = STRARRAY(op, epoll_ctl_ops), }, }, | 650 | .arg = { [1] = STRARRAY(op, epoll_ctl_ops), }, }, |
| 650 | { .name = "eventfd2", | 651 | { .name = "eventfd2", |
| @@ -801,7 +802,8 @@ static struct syscall_fmt { | |||
| 801 | { .name = "sendmsg", | 802 | { .name = "sendmsg", |
| 802 | .arg = { [2] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, }, | 803 | .arg = { [2] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, }, |
| 803 | { .name = "sendto", | 804 | { .name = "sendto", |
| 804 | .arg = { [3] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, }, }, | 805 | .arg = { [3] = { .scnprintf = SCA_MSG_FLAGS, /* flags */ }, |
| 806 | [4] = { .scnprintf = SCA_SOCKADDR, /* addr */ }, }, }, | ||
| 805 | { .name = "set_tid_address", .errpid = true, }, | 807 | { .name = "set_tid_address", .errpid = true, }, |
| 806 | { .name = "setitimer", | 808 | { .name = "setitimer", |
| 807 | .arg = { [0] = STRARRAY(which, itimers), }, }, | 809 | .arg = { [0] = STRARRAY(which, itimers), }, }, |
| @@ -830,6 +832,7 @@ static struct syscall_fmt { | |||
| 830 | .arg = { [2] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, }, | 832 | .arg = { [2] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, }, |
| 831 | { .name = "tkill", | 833 | { .name = "tkill", |
| 832 | .arg = { [1] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, }, | 834 | .arg = { [1] = { .scnprintf = SCA_SIGNUM, /* sig */ }, }, }, |
| 835 | { .name = "umount2", .alias = "umount", }, | ||
| 833 | { .name = "uname", .alias = "newuname", }, | 836 | { .name = "uname", .alias = "newuname", }, |
| 834 | { .name = "unlinkat", | 837 | { .name = "unlinkat", |
| 835 | .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, }, | 838 | .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, }, |
| @@ -856,13 +859,15 @@ static struct syscall_fmt *syscall_fmt__find(const char *name) | |||
| 856 | /* | 859 | /* |
| 857 | * is_exit: is this "exit" or "exit_group"? | 860 | * is_exit: is this "exit" or "exit_group"? |
| 858 | * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter. | 861 | * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter. |
| 862 | * args_size: sum of the sizes of the syscall arguments, anything after that is augmented stuff: pathname for openat, etc. | ||
| 859 | */ | 863 | */ |
| 860 | struct syscall { | 864 | struct syscall { |
| 861 | struct event_format *tp_format; | 865 | struct tep_event_format *tp_format; |
| 862 | int nr_args; | 866 | int nr_args; |
| 867 | int args_size; | ||
| 863 | bool is_exit; | 868 | bool is_exit; |
| 864 | bool is_open; | 869 | bool is_open; |
| 865 | struct format_field *args; | 870 | struct tep_format_field *args; |
| 866 | const char *name; | 871 | const char *name; |
| 867 | struct syscall_fmt *fmt; | 872 | struct syscall_fmt *fmt; |
| 868 | struct syscall_arg_fmt *arg_fmt; | 873 | struct syscall_arg_fmt *arg_fmt; |
| @@ -1095,11 +1100,21 @@ static void thread__set_filename_pos(struct thread *thread, const char *bf, | |||
| 1095 | ttrace->filename.entry_str_pos = bf - ttrace->entry_str; | 1100 | ttrace->filename.entry_str_pos = bf - ttrace->entry_str; |
| 1096 | } | 1101 | } |
| 1097 | 1102 | ||
| 1103 | static size_t syscall_arg__scnprintf_augmented_string(struct syscall_arg *arg, char *bf, size_t size) | ||
| 1104 | { | ||
| 1105 | struct augmented_arg *augmented_arg = arg->augmented.args; | ||
| 1106 | |||
| 1107 | return scnprintf(bf, size, "%.*s", augmented_arg->size, augmented_arg->value); | ||
| 1108 | } | ||
| 1109 | |||
| 1098 | static size_t syscall_arg__scnprintf_filename(char *bf, size_t size, | 1110 | static size_t syscall_arg__scnprintf_filename(char *bf, size_t size, |
| 1099 | struct syscall_arg *arg) | 1111 | struct syscall_arg *arg) |
| 1100 | { | 1112 | { |
| 1101 | unsigned long ptr = arg->val; | 1113 | unsigned long ptr = arg->val; |
| 1102 | 1114 | ||
| 1115 | if (arg->augmented.args) | ||
| 1116 | return syscall_arg__scnprintf_augmented_string(arg, bf, size); | ||
| 1117 | |||
| 1103 | if (!arg->trace->vfs_getname) | 1118 | if (!arg->trace->vfs_getname) |
| 1104 | return scnprintf(bf, size, "%#x", ptr); | 1119 | return scnprintf(bf, size, "%#x", ptr); |
| 1105 | 1120 | ||
| @@ -1142,11 +1157,9 @@ static void sig_handler(int sig) | |||
| 1142 | interrupted = sig == SIGINT; | 1157 | interrupted = sig == SIGINT; |
| 1143 | } | 1158 | } |
| 1144 | 1159 | ||
| 1145 | static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thread, | 1160 | static size_t trace__fprintf_comm_tid(struct trace *trace, struct thread *thread, FILE *fp) |
| 1146 | u64 duration, bool duration_calculated, u64 tstamp, FILE *fp) | ||
| 1147 | { | 1161 | { |
| 1148 | size_t printed = trace__fprintf_tstamp(trace, tstamp, fp); | 1162 | size_t printed = 0; |
| 1149 | printed += fprintf_duration(duration, duration_calculated, fp); | ||
| 1150 | 1163 | ||
| 1151 | if (trace->multiple_threads) { | 1164 | if (trace->multiple_threads) { |
| 1152 | if (trace->show_comm) | 1165 | if (trace->show_comm) |
| @@ -1157,6 +1170,14 @@ static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thre | |||
| 1157 | return printed; | 1170 | return printed; |
| 1158 | } | 1171 | } |
| 1159 | 1172 | ||
| 1173 | static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thread, | ||
| 1174 | u64 duration, bool duration_calculated, u64 tstamp, FILE *fp) | ||
| 1175 | { | ||
| 1176 | size_t printed = trace__fprintf_tstamp(trace, tstamp, fp); | ||
| 1177 | printed += fprintf_duration(duration, duration_calculated, fp); | ||
| 1178 | return printed + trace__fprintf_comm_tid(trace, thread, fp); | ||
| 1179 | } | ||
| 1180 | |||
| 1160 | static int trace__process_event(struct trace *trace, struct machine *machine, | 1181 | static int trace__process_event(struct trace *trace, struct machine *machine, |
| 1161 | union perf_event *event, struct perf_sample *sample) | 1182 | union perf_event *event, struct perf_sample *sample) |
| 1162 | { | 1183 | { |
| @@ -1258,10 +1279,12 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args) | |||
| 1258 | 1279 | ||
| 1259 | static int syscall__set_arg_fmts(struct syscall *sc) | 1280 | static int syscall__set_arg_fmts(struct syscall *sc) |
| 1260 | { | 1281 | { |
| 1261 | struct format_field *field; | 1282 | struct tep_format_field *field, *last_field = NULL; |
| 1262 | int idx = 0, len; | 1283 | int idx = 0, len; |
| 1263 | 1284 | ||
| 1264 | for (field = sc->args; field; field = field->next, ++idx) { | 1285 | for (field = sc->args; field; field = field->next, ++idx) { |
| 1286 | last_field = field; | ||
| 1287 | |||
| 1265 | if (sc->fmt && sc->fmt->arg[idx].scnprintf) | 1288 | if (sc->fmt && sc->fmt->arg[idx].scnprintf) |
| 1266 | continue; | 1289 | continue; |
| 1267 | 1290 | ||
| @@ -1270,7 +1293,7 @@ static int syscall__set_arg_fmts(struct syscall *sc) | |||
| 1270 | strcmp(field->name, "path") == 0 || | 1293 | strcmp(field->name, "path") == 0 || |
| 1271 | strcmp(field->name, "pathname") == 0)) | 1294 | strcmp(field->name, "pathname") == 0)) |
| 1272 | sc->arg_fmt[idx].scnprintf = SCA_FILENAME; | 1295 | sc->arg_fmt[idx].scnprintf = SCA_FILENAME; |
| 1273 | else if (field->flags & FIELD_IS_POINTER) | 1296 | else if (field->flags & TEP_FIELD_IS_POINTER) |
| 1274 | sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex; | 1297 | sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex; |
| 1275 | else if (strcmp(field->type, "pid_t") == 0) | 1298 | else if (strcmp(field->type, "pid_t") == 0) |
| 1276 | sc->arg_fmt[idx].scnprintf = SCA_PID; | 1299 | sc->arg_fmt[idx].scnprintf = SCA_PID; |
| @@ -1292,6 +1315,9 @@ static int syscall__set_arg_fmts(struct syscall *sc) | |||
| 1292 | } | 1315 | } |
| 1293 | } | 1316 | } |
| 1294 | 1317 | ||
| 1318 | if (last_field) | ||
| 1319 | sc->args_size = last_field->offset + last_field->size; | ||
| 1320 | |||
| 1295 | return 0; | 1321 | return 0; |
| 1296 | } | 1322 | } |
| 1297 | 1323 | ||
| @@ -1472,14 +1498,18 @@ static size_t syscall__scnprintf_val(struct syscall *sc, char *bf, size_t size, | |||
| 1472 | } | 1498 | } |
| 1473 | 1499 | ||
| 1474 | static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, | 1500 | static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, |
| 1475 | unsigned char *args, struct trace *trace, | 1501 | unsigned char *args, void *augmented_args, int augmented_args_size, |
| 1476 | struct thread *thread) | 1502 | struct trace *trace, struct thread *thread) |
| 1477 | { | 1503 | { |
| 1478 | size_t printed = 0; | 1504 | size_t printed = 0; |
| 1479 | unsigned long val; | 1505 | unsigned long val; |
| 1480 | u8 bit = 1; | 1506 | u8 bit = 1; |
| 1481 | struct syscall_arg arg = { | 1507 | struct syscall_arg arg = { |
| 1482 | .args = args, | 1508 | .args = args, |
| 1509 | .augmented = { | ||
| 1510 | .size = augmented_args_size, | ||
| 1511 | .args = augmented_args, | ||
| 1512 | }, | ||
| 1483 | .idx = 0, | 1513 | .idx = 0, |
| 1484 | .mask = 0, | 1514 | .mask = 0, |
| 1485 | .trace = trace, | 1515 | .trace = trace, |
| @@ -1495,7 +1525,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, | |||
| 1495 | ttrace->ret_scnprintf = NULL; | 1525 | ttrace->ret_scnprintf = NULL; |
| 1496 | 1526 | ||
| 1497 | if (sc->args != NULL) { | 1527 | if (sc->args != NULL) { |
| 1498 | struct format_field *field; | 1528 | struct tep_format_field *field; |
| 1499 | 1529 | ||
| 1500 | for (field = sc->args; field; | 1530 | for (field = sc->args; field; |
| 1501 | field = field->next, ++arg.idx, bit <<= 1) { | 1531 | field = field->next, ++arg.idx, bit <<= 1) { |
| @@ -1654,6 +1684,17 @@ static int trace__fprintf_sample(struct trace *trace, struct perf_evsel *evsel, | |||
| 1654 | return printed; | 1684 | return printed; |
| 1655 | } | 1685 | } |
| 1656 | 1686 | ||
| 1687 | static void *syscall__augmented_args(struct syscall *sc, struct perf_sample *sample, int *augmented_args_size) | ||
| 1688 | { | ||
| 1689 | void *augmented_args = NULL; | ||
| 1690 | |||
| 1691 | *augmented_args_size = sample->raw_size - sc->args_size; | ||
| 1692 | if (*augmented_args_size > 0) | ||
| 1693 | augmented_args = sample->raw_data + sc->args_size; | ||
| 1694 | |||
| 1695 | return augmented_args; | ||
| 1696 | } | ||
| 1697 | |||
| 1657 | static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, | 1698 | static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, |
| 1658 | union perf_event *event __maybe_unused, | 1699 | union perf_event *event __maybe_unused, |
| 1659 | struct perf_sample *sample) | 1700 | struct perf_sample *sample) |
| @@ -1663,6 +1704,8 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, | |||
| 1663 | size_t printed = 0; | 1704 | size_t printed = 0; |
| 1664 | struct thread *thread; | 1705 | struct thread *thread; |
| 1665 | int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; | 1706 | int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; |
| 1707 | int augmented_args_size = 0; | ||
| 1708 | void *augmented_args = NULL; | ||
| 1666 | struct syscall *sc = trace__syscall_info(trace, evsel, id); | 1709 | struct syscall *sc = trace__syscall_info(trace, evsel, id); |
| 1667 | struct thread_trace *ttrace; | 1710 | struct thread_trace *ttrace; |
| 1668 | 1711 | ||
| @@ -1686,13 +1729,24 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, | |||
| 1686 | 1729 | ||
| 1687 | if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) | 1730 | if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) |
| 1688 | trace__printf_interrupted_entry(trace); | 1731 | trace__printf_interrupted_entry(trace); |
| 1689 | 1732 | /* | |
| 1733 | * If this is raw_syscalls.sys_enter, then it always comes with the 6 possible | ||
| 1734 | * arguments, even if the syscall being handled, say "openat", uses only 4 arguments | ||
| 1735 | * this breaks syscall__augmented_args() check for augmented args, as we calculate | ||
| 1736 | * syscall->args_size using each syscalls:sys_enter_NAME tracefs format file, | ||
| 1737 | * so when handling, say the openat syscall, we end up getting 6 args for the | ||
| 1738 | * raw_syscalls:sys_enter event, when we expected just 4, we end up mistakenly | ||
| 1739 | * thinking that the extra 2 u64 args are the augmented filename, so just check | ||
| 1740 | * here and avoid using augmented syscalls when the evsel is the raw_syscalls one. | ||
| 1741 | */ | ||
| 1742 | if (evsel != trace->syscalls.events.sys_enter) | ||
| 1743 | augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size); | ||
| 1690 | ttrace->entry_time = sample->time; | 1744 | ttrace->entry_time = sample->time; |
| 1691 | msg = ttrace->entry_str; | 1745 | msg = ttrace->entry_str; |
| 1692 | printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name); | 1746 | printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name); |
| 1693 | 1747 | ||
| 1694 | printed += syscall__scnprintf_args(sc, msg + printed, trace__entry_str_size - printed, | 1748 | printed += syscall__scnprintf_args(sc, msg + printed, trace__entry_str_size - printed, |
| 1695 | args, trace, thread); | 1749 | args, augmented_args, augmented_args_size, trace, thread); |
| 1696 | 1750 | ||
| 1697 | if (sc->is_exit) { | 1751 | if (sc->is_exit) { |
| 1698 | if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) { | 1752 | if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) { |
| @@ -1723,7 +1777,8 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evse | |||
| 1723 | int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; | 1777 | int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; |
| 1724 | struct syscall *sc = trace__syscall_info(trace, evsel, id); | 1778 | struct syscall *sc = trace__syscall_info(trace, evsel, id); |
| 1725 | char msg[1024]; | 1779 | char msg[1024]; |
| 1726 | void *args; | 1780 | void *args, *augmented_args = NULL; |
| 1781 | int augmented_args_size; | ||
| 1727 | 1782 | ||
| 1728 | if (sc == NULL) | 1783 | if (sc == NULL) |
| 1729 | return -1; | 1784 | return -1; |
| @@ -1738,7 +1793,8 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evse | |||
| 1738 | goto out_put; | 1793 | goto out_put; |
| 1739 | 1794 | ||
| 1740 | args = perf_evsel__sc_tp_ptr(evsel, args, sample); | 1795 | args = perf_evsel__sc_tp_ptr(evsel, args, sample); |
| 1741 | syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread); | 1796 | augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size); |
| 1797 | syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmented_args, augmented_args_size, trace, thread); | ||
| 1742 | fprintf(trace->output, "%s", msg); | 1798 | fprintf(trace->output, "%s", msg); |
| 1743 | err = 0; | 1799 | err = 0; |
| 1744 | out_put: | 1800 | out_put: |
| @@ -2022,6 +2078,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, | |||
| 2022 | union perf_event *event __maybe_unused, | 2078 | union perf_event *event __maybe_unused, |
| 2023 | struct perf_sample *sample) | 2079 | struct perf_sample *sample) |
| 2024 | { | 2080 | { |
| 2081 | struct thread *thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); | ||
| 2025 | int callchain_ret = 0; | 2082 | int callchain_ret = 0; |
| 2026 | 2083 | ||
| 2027 | if (sample->callchain) { | 2084 | if (sample->callchain) { |
| @@ -2039,13 +2096,31 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, | |||
| 2039 | if (trace->trace_syscalls) | 2096 | if (trace->trace_syscalls) |
| 2040 | fprintf(trace->output, "( ): "); | 2097 | fprintf(trace->output, "( ): "); |
| 2041 | 2098 | ||
| 2099 | if (thread) | ||
| 2100 | trace__fprintf_comm_tid(trace, thread, trace->output); | ||
| 2101 | |||
| 2102 | if (evsel == trace->syscalls.events.augmented) { | ||
| 2103 | int id = perf_evsel__sc_tp_uint(evsel, id, sample); | ||
| 2104 | struct syscall *sc = trace__syscall_info(trace, evsel, id); | ||
| 2105 | |||
| 2106 | if (sc) { | ||
| 2107 | fprintf(trace->output, "%s(", sc->name); | ||
| 2108 | trace__fprintf_sys_enter(trace, evsel, sample); | ||
| 2109 | fputc(')', trace->output); | ||
| 2110 | goto newline; | ||
| 2111 | } | ||
| 2112 | |||
| 2113 | /* | ||
| 2114 | * XXX: Not having the associated syscall info or not finding/adding | ||
| 2115 | * the thread should never happen, but if it does... | ||
| 2116 | * fall thru and print it as a bpf_output event. | ||
| 2117 | */ | ||
| 2118 | } | ||
| 2119 | |||
| 2042 | fprintf(trace->output, "%s:", evsel->name); | 2120 | fprintf(trace->output, "%s:", evsel->name); |
| 2043 | 2121 | ||
| 2044 | if (perf_evsel__is_bpf_output(evsel)) { | 2122 | if (perf_evsel__is_bpf_output(evsel)) { |
| 2045 | if (evsel == trace->syscalls.events.augmented) | 2123 | bpf_output__fprintf(trace, sample); |
| 2046 | trace__fprintf_sys_enter(trace, evsel, sample); | ||
| 2047 | else | ||
| 2048 | bpf_output__fprintf(trace, sample); | ||
| 2049 | } else if (evsel->tp_format) { | 2124 | } else if (evsel->tp_format) { |
| 2050 | if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || | 2125 | if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || |
| 2051 | trace__fprintf_sys_enter(trace, evsel, sample)) { | 2126 | trace__fprintf_sys_enter(trace, evsel, sample)) { |
| @@ -2055,12 +2130,14 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, | |||
| 2055 | } | 2130 | } |
| 2056 | } | 2131 | } |
| 2057 | 2132 | ||
| 2133 | newline: | ||
| 2058 | fprintf(trace->output, "\n"); | 2134 | fprintf(trace->output, "\n"); |
| 2059 | 2135 | ||
| 2060 | if (callchain_ret > 0) | 2136 | if (callchain_ret > 0) |
| 2061 | trace__fprintf_callchain(trace, sample); | 2137 | trace__fprintf_callchain(trace, sample); |
| 2062 | else if (callchain_ret < 0) | 2138 | else if (callchain_ret < 0) |
| 2063 | pr_err("Problem processing %s callchain, skipping...\n", perf_evsel__name(evsel)); | 2139 | pr_err("Problem processing %s callchain, skipping...\n", perf_evsel__name(evsel)); |
| 2140 | thread__put(thread); | ||
| 2064 | out: | 2141 | out: |
| 2065 | return 0; | 2142 | return 0; |
| 2066 | } | 2143 | } |
| @@ -3276,12 +3353,8 @@ int cmd_trace(int argc, const char **argv) | |||
| 3276 | goto out; | 3353 | goto out; |
| 3277 | } | 3354 | } |
| 3278 | 3355 | ||
| 3279 | if (evsel) { | 3356 | if (evsel) |
| 3280 | if (perf_evsel__init_augmented_syscall_tp(evsel) || | ||
| 3281 | perf_evsel__init_augmented_syscall_tp_args(evsel)) | ||
| 3282 | goto out; | ||
| 3283 | trace.syscalls.events.augmented = evsel; | 3357 | trace.syscalls.events.augmented = evsel; |
| 3284 | } | ||
| 3285 | 3358 | ||
| 3286 | err = bpf__setup_stdout(trace.evlist); | 3359 | err = bpf__setup_stdout(trace.evlist); |
| 3287 | if (err) { | 3360 | if (err) { |
| @@ -3326,6 +3399,34 @@ int cmd_trace(int argc, const char **argv) | |||
| 3326 | } | 3399 | } |
| 3327 | } | 3400 | } |
| 3328 | 3401 | ||
| 3402 | /* | ||
| 3403 | * If we are augmenting syscalls, then combine what we put in the | ||
| 3404 | * __augmented_syscalls__ BPF map with what is in the | ||
| 3405 | * syscalls:sys_exit_FOO tracepoints, i.e. just like we do without BPF, | ||
| 3406 | * combining raw_syscalls:sys_enter with raw_syscalls:sys_exit. | ||
| 3407 | * | ||
| 3408 | * We'll switch to look at two BPF maps, one for sys_enter and the | ||
| 3409 | * other for sys_exit when we start augmenting the sys_exit paths with | ||
| 3410 | * buffers that are being copied from kernel to userspace, think 'read' | ||
| 3411 | * syscall. | ||
| 3412 | */ | ||
| 3413 | if (trace.syscalls.events.augmented) { | ||
| 3414 | evsel = trace.syscalls.events.augmented; | ||
| 3415 | |||
| 3416 | if (perf_evsel__init_augmented_syscall_tp(evsel) || | ||
| 3417 | perf_evsel__init_augmented_syscall_tp_args(evsel)) | ||
| 3418 | goto out; | ||
| 3419 | evsel->handler = trace__sys_enter; | ||
| 3420 | |||
| 3421 | evlist__for_each_entry(trace.evlist, evsel) { | ||
| 3422 | if (strstarts(perf_evsel__name(evsel), "syscalls:sys_exit_")) { | ||
| 3423 | perf_evsel__init_augmented_syscall_tp(evsel); | ||
| 3424 | perf_evsel__init_augmented_syscall_tp_ret(evsel); | ||
| 3425 | evsel->handler = trace__sys_exit; | ||
| 3426 | } | ||
| 3427 | } | ||
| 3428 | } | ||
| 3429 | |||
| 3329 | if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) | 3430 | if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) |
| 3330 | return trace__record(&trace, argc-1, &argv[1]); | 3431 | return trace__record(&trace, argc-1, &argv[1]); |
| 3331 | 3432 | ||
diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt index 2d0caf20ff3a..bc6c585f74fc 100644 --- a/tools/perf/command-list.txt +++ b/tools/perf/command-list.txt | |||
| @@ -30,3 +30,4 @@ perf-test mainporcelain common | |||
| 30 | perf-timechart mainporcelain common | 30 | perf-timechart mainporcelain common |
| 31 | perf-top mainporcelain common | 31 | perf-top mainporcelain common |
| 32 | perf-trace mainporcelain audit | 32 | perf-trace mainporcelain audit |
| 33 | perf-version mainporcelain common | ||
diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c index 69a31386d8cd..2ae44813ef2d 100644 --- a/tools/perf/examples/bpf/augmented_syscalls.c +++ b/tools/perf/examples/bpf/augmented_syscalls.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* | 2 | /* |
| 3 | * Augment the openat syscall with the contents of the filename pointer argument. | 3 | * Augment syscalls with the contents of the pointer arguments. |
| 4 | * | 4 | * |
| 5 | * Test it with: | 5 | * Test it with: |
| 6 | * | 6 | * |
| @@ -10,15 +10,14 @@ | |||
| 10 | * the last one should be the one for '/etc/passwd'. | 10 | * the last one should be the one for '/etc/passwd'. |
| 11 | * | 11 | * |
| 12 | * This matches what is marshalled into the raw_syscall:sys_enter payload | 12 | * This matches what is marshalled into the raw_syscall:sys_enter payload |
| 13 | * expected by the 'perf trace' beautifiers, and can be used by them unmodified, | 13 | * expected by the 'perf trace' beautifiers, and can be used by them, that will |
| 14 | * which will be done as that feature is implemented in the next csets, for now | 14 | * check if perf_sample->raw_data is more than what is expected for each |
| 15 | * it will appear in a dump done by the default tracepoint handler in 'perf trace', | 15 | * syscalls:sys_{enter,exit}_SYSCALL tracepoint, uing the extra data as the |
| 16 | * that uses bpf_output__fprintf() to just dump those contents, as done with | 16 | * contents of pointer arguments. |
| 17 | * the bpf-output event associated with the __bpf_output__ map declared in | ||
| 18 | * tools/perf/include/bpf/stdio.h. | ||
| 19 | */ | 17 | */ |
| 20 | 18 | ||
| 21 | #include <stdio.h> | 19 | #include <stdio.h> |
| 20 | #include <linux/socket.h> | ||
| 22 | 21 | ||
| 23 | struct bpf_map SEC("maps") __augmented_syscalls__ = { | 22 | struct bpf_map SEC("maps") __augmented_syscalls__ = { |
| 24 | .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, | 23 | .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, |
| @@ -27,6 +26,44 @@ struct bpf_map SEC("maps") __augmented_syscalls__ = { | |||
| 27 | .max_entries = __NR_CPUS__, | 26 | .max_entries = __NR_CPUS__, |
| 28 | }; | 27 | }; |
| 29 | 28 | ||
| 29 | struct syscall_exit_args { | ||
| 30 | unsigned long long common_tp_fields; | ||
| 31 | long syscall_nr; | ||
| 32 | long ret; | ||
| 33 | }; | ||
| 34 | |||
| 35 | struct augmented_filename { | ||
| 36 | unsigned int size; | ||
| 37 | int reserved; | ||
| 38 | char value[256]; | ||
| 39 | }; | ||
| 40 | |||
| 41 | #define augmented_filename_syscall(syscall) \ | ||
| 42 | struct augmented_enter_##syscall##_args { \ | ||
| 43 | struct syscall_enter_##syscall##_args args; \ | ||
| 44 | struct augmented_filename filename; \ | ||
| 45 | }; \ | ||
| 46 | int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \ | ||
| 47 | { \ | ||
| 48 | struct augmented_enter_##syscall##_args augmented_args = { .filename.reserved = 0, }; \ | ||
| 49 | unsigned int len = sizeof(augmented_args); \ | ||
| 50 | probe_read(&augmented_args.args, sizeof(augmented_args.args), args); \ | ||
| 51 | augmented_args.filename.size = probe_read_str(&augmented_args.filename.value, \ | ||
| 52 | sizeof(augmented_args.filename.value), \ | ||
| 53 | args->filename_ptr); \ | ||
| 54 | if (augmented_args.filename.size < sizeof(augmented_args.filename.value)) { \ | ||
| 55 | len -= sizeof(augmented_args.filename.value) - augmented_args.filename.size; \ | ||
| 56 | len &= sizeof(augmented_args.filename.value) - 1; \ | ||
| 57 | } \ | ||
| 58 | perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, \ | ||
| 59 | &augmented_args, len); \ | ||
| 60 | return 0; \ | ||
| 61 | } \ | ||
| 62 | int syscall_exit(syscall)(struct syscall_exit_args *args) \ | ||
| 63 | { \ | ||
| 64 | return 1; /* 0 as soon as we start copying data returned by the kernel, e.g. 'read' */ \ | ||
| 65 | } | ||
| 66 | |||
| 30 | struct syscall_enter_openat_args { | 67 | struct syscall_enter_openat_args { |
| 31 | unsigned long long common_tp_fields; | 68 | unsigned long long common_tp_fields; |
| 32 | long syscall_nr; | 69 | long syscall_nr; |
| @@ -36,20 +73,101 @@ struct syscall_enter_openat_args { | |||
| 36 | long mode; | 73 | long mode; |
| 37 | }; | 74 | }; |
| 38 | 75 | ||
| 39 | struct augmented_enter_openat_args { | 76 | augmented_filename_syscall(openat); |
| 40 | struct syscall_enter_openat_args args; | 77 | |
| 41 | char filename[64]; | 78 | struct syscall_enter_open_args { |
| 79 | unsigned long long common_tp_fields; | ||
| 80 | long syscall_nr; | ||
| 81 | char *filename_ptr; | ||
| 82 | long flags; | ||
| 83 | long mode; | ||
| 84 | }; | ||
| 85 | |||
| 86 | augmented_filename_syscall(open); | ||
| 87 | |||
| 88 | struct syscall_enter_inotify_add_watch_args { | ||
| 89 | unsigned long long common_tp_fields; | ||
| 90 | long syscall_nr; | ||
| 91 | long fd; | ||
| 92 | char *filename_ptr; | ||
| 93 | long mask; | ||
| 94 | }; | ||
| 95 | |||
| 96 | augmented_filename_syscall(inotify_add_watch); | ||
| 97 | |||
| 98 | struct statbuf; | ||
| 99 | |||
| 100 | struct syscall_enter_newstat_args { | ||
| 101 | unsigned long long common_tp_fields; | ||
| 102 | long syscall_nr; | ||
| 103 | char *filename_ptr; | ||
| 104 | struct stat *statbuf; | ||
| 42 | }; | 105 | }; |
| 43 | 106 | ||
| 44 | int syscall_enter(openat)(struct syscall_enter_openat_args *args) | 107 | augmented_filename_syscall(newstat); |
| 45 | { | 108 | |
| 46 | struct augmented_enter_openat_args augmented_args; | 109 | #ifndef _K_SS_MAXSIZE |
| 110 | #define _K_SS_MAXSIZE 128 | ||
| 111 | #endif | ||
| 47 | 112 | ||
| 48 | probe_read(&augmented_args.args, sizeof(augmented_args.args), args); | 113 | #define augmented_sockaddr_syscall(syscall) \ |
| 49 | probe_read_str(&augmented_args.filename, sizeof(augmented_args.filename), args->filename_ptr); | 114 | struct augmented_enter_##syscall##_args { \ |
| 50 | perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, | 115 | struct syscall_enter_##syscall##_args args; \ |
| 51 | &augmented_args, sizeof(augmented_args)); | 116 | struct sockaddr_storage addr; \ |
| 52 | return 1; | 117 | }; \ |
| 118 | int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \ | ||
| 119 | { \ | ||
| 120 | struct augmented_enter_##syscall##_args augmented_args; \ | ||
| 121 | unsigned long addrlen = sizeof(augmented_args.addr); \ | ||
| 122 | probe_read(&augmented_args.args, sizeof(augmented_args.args), args); \ | ||
| 123 | /* FIXME_CLANG_OPTIMIZATION_THAT_ACCESSES_USER_CONTROLLED_ADDRLEN_DESPITE_THIS_CHECK */ \ | ||
| 124 | /* if (addrlen > augmented_args.args.addrlen) */ \ | ||
| 125 | /* addrlen = augmented_args.args.addrlen; */ \ | ||
| 126 | /* */ \ | ||
| 127 | probe_read(&augmented_args.addr, addrlen, args->addr_ptr); \ | ||
| 128 | perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, \ | ||
| 129 | &augmented_args, \ | ||
| 130 | sizeof(augmented_args) - sizeof(augmented_args.addr) + addrlen); \ | ||
| 131 | return 0; \ | ||
| 132 | } \ | ||
| 133 | int syscall_exit(syscall)(struct syscall_exit_args *args) \ | ||
| 134 | { \ | ||
| 135 | return 1; /* 0 as soon as we start copying data returned by the kernel, e.g. 'read' */ \ | ||
| 53 | } | 136 | } |
| 54 | 137 | ||
| 138 | struct sockaddr; | ||
| 139 | |||
| 140 | struct syscall_enter_bind_args { | ||
| 141 | unsigned long long common_tp_fields; | ||
| 142 | long syscall_nr; | ||
| 143 | long fd; | ||
| 144 | struct sockaddr *addr_ptr; | ||
| 145 | unsigned long addrlen; | ||
| 146 | }; | ||
| 147 | |||
| 148 | augmented_sockaddr_syscall(bind); | ||
| 149 | |||
| 150 | struct syscall_enter_connect_args { | ||
| 151 | unsigned long long common_tp_fields; | ||
| 152 | long syscall_nr; | ||
| 153 | long fd; | ||
| 154 | struct sockaddr *addr_ptr; | ||
| 155 | unsigned long addrlen; | ||
| 156 | }; | ||
| 157 | |||
| 158 | augmented_sockaddr_syscall(connect); | ||
| 159 | |||
| 160 | struct syscall_enter_sendto_args { | ||
| 161 | unsigned long long common_tp_fields; | ||
| 162 | long syscall_nr; | ||
| 163 | long fd; | ||
| 164 | void *buff; | ||
| 165 | long len; | ||
| 166 | unsigned long flags; | ||
| 167 | struct sockaddr *addr_ptr; | ||
| 168 | long addr_len; | ||
| 169 | }; | ||
| 170 | |||
| 171 | augmented_sockaddr_syscall(sendto); | ||
| 172 | |||
| 55 | license(GPL); | 173 | license(GPL); |
diff --git a/tools/perf/examples/bpf/etcsnoop.c b/tools/perf/examples/bpf/etcsnoop.c new file mode 100644 index 000000000000..b59e8812ee8c --- /dev/null +++ b/tools/perf/examples/bpf/etcsnoop.c | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Augment the filename syscalls with the contents of the filename pointer argument | ||
| 4 | * filtering only those that do not start with /etc/. | ||
| 5 | * | ||
| 6 | * Test it with: | ||
| 7 | * | ||
| 8 | * perf trace -e tools/perf/examples/bpf/augmented_syscalls.c cat /etc/passwd > /dev/null | ||
| 9 | * | ||
| 10 | * It'll catch some openat syscalls related to the dynamic linked and | ||
| 11 | * the last one should be the one for '/etc/passwd'. | ||
| 12 | * | ||
| 13 | * This matches what is marshalled into the raw_syscall:sys_enter payload | ||
| 14 | * expected by the 'perf trace' beautifiers, and can be used by them unmodified, | ||
| 15 | * which will be done as that feature is implemented in the next csets, for now | ||
| 16 | * it will appear in a dump done by the default tracepoint handler in 'perf trace', | ||
| 17 | * that uses bpf_output__fprintf() to just dump those contents, as done with | ||
| 18 | * the bpf-output event associated with the __bpf_output__ map declared in | ||
| 19 | * tools/perf/include/bpf/stdio.h. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdio.h> | ||
| 23 | |||
| 24 | struct bpf_map SEC("maps") __augmented_syscalls__ = { | ||
| 25 | .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, | ||
| 26 | .key_size = sizeof(int), | ||
| 27 | .value_size = sizeof(u32), | ||
| 28 | .max_entries = __NR_CPUS__, | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct augmented_filename { | ||
| 32 | int size; | ||
| 33 | int reserved; | ||
| 34 | char value[64]; | ||
| 35 | }; | ||
| 36 | |||
| 37 | #define augmented_filename_syscall_enter(syscall) \ | ||
| 38 | struct augmented_enter_##syscall##_args { \ | ||
| 39 | struct syscall_enter_##syscall##_args args; \ | ||
| 40 | struct augmented_filename filename; \ | ||
| 41 | }; \ | ||
| 42 | int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \ | ||
| 43 | { \ | ||
| 44 | char etc[6] = "/etc/"; \ | ||
| 45 | struct augmented_enter_##syscall##_args augmented_args = { .filename.reserved = 0, }; \ | ||
| 46 | probe_read(&augmented_args.args, sizeof(augmented_args.args), args); \ | ||
| 47 | augmented_args.filename.size = probe_read_str(&augmented_args.filename.value, \ | ||
| 48 | sizeof(augmented_args.filename.value), \ | ||
| 49 | args->filename_ptr); \ | ||
| 50 | if (__builtin_memcmp(augmented_args.filename.value, etc, 4) != 0) \ | ||
| 51 | return 0; \ | ||
| 52 | perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, \ | ||
| 53 | &augmented_args, \ | ||
| 54 | (sizeof(augmented_args) - sizeof(augmented_args.filename.value) + \ | ||
| 55 | augmented_args.filename.size)); \ | ||
| 56 | return 0; \ | ||
| 57 | } | ||
| 58 | |||
| 59 | struct syscall_enter_openat_args { | ||
| 60 | unsigned long long common_tp_fields; | ||
| 61 | long syscall_nr; | ||
| 62 | long dfd; | ||
| 63 | char *filename_ptr; | ||
| 64 | long flags; | ||
| 65 | long mode; | ||
| 66 | }; | ||
| 67 | |||
| 68 | augmented_filename_syscall_enter(openat); | ||
| 69 | |||
| 70 | struct syscall_enter_open_args { | ||
| 71 | unsigned long long common_tp_fields; | ||
| 72 | long syscall_nr; | ||
| 73 | char *filename_ptr; | ||
| 74 | long flags; | ||
| 75 | long mode; | ||
| 76 | }; | ||
| 77 | |||
| 78 | augmented_filename_syscall_enter(open); | ||
| 79 | |||
| 80 | license(GPL); | ||
diff --git a/tools/perf/include/bpf/bpf.h b/tools/perf/include/bpf/bpf.h index 47897d65e799..52b6d87fe822 100644 --- a/tools/perf/include/bpf/bpf.h +++ b/tools/perf/include/bpf/bpf.h | |||
| @@ -26,6 +26,9 @@ struct bpf_map { | |||
| 26 | #define syscall_enter(name) \ | 26 | #define syscall_enter(name) \ |
| 27 | SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name | 27 | SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name |
| 28 | 28 | ||
| 29 | #define syscall_exit(name) \ | ||
| 30 | SEC("syscalls:sys_exit_" #name) syscall_exit_ ## name | ||
| 31 | |||
| 29 | #define license(name) \ | 32 | #define license(name) \ |
| 30 | char _license[] SEC("license") = #name; \ | 33 | char _license[] SEC("license") = #name; \ |
| 31 | int _version SEC("version") = LINUX_VERSION_CODE; | 34 | int _version SEC("version") = LINUX_VERSION_CODE; |
diff --git a/tools/perf/include/bpf/linux/socket.h b/tools/perf/include/bpf/linux/socket.h new file mode 100644 index 000000000000..7f844568dab8 --- /dev/null +++ b/tools/perf/include/bpf/linux/socket.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| 2 | #ifndef _UAPI_LINUX_SOCKET_H | ||
| 3 | #define _UAPI_LINUX_SOCKET_H | ||
| 4 | |||
| 5 | /* | ||
| 6 | * Desired design of maximum size and alignment (see RFC2553) | ||
| 7 | */ | ||
| 8 | #define _K_SS_MAXSIZE 128 /* Implementation specific max size */ | ||
| 9 | #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) | ||
| 10 | /* Implementation specific desired alignment */ | ||
| 11 | |||
| 12 | typedef unsigned short __kernel_sa_family_t; | ||
| 13 | |||
| 14 | struct __kernel_sockaddr_storage { | ||
| 15 | __kernel_sa_family_t ss_family; /* address family */ | ||
| 16 | /* Following field(s) are implementation specific */ | ||
| 17 | char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; | ||
| 18 | /* space to achieve desired size, */ | ||
| 19 | /* _SS_MAXSIZE value minus size of ss_family */ | ||
| 20 | } __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */ | ||
| 21 | |||
| 22 | #define sockaddr_storage __kernel_sockaddr_storage | ||
| 23 | |||
| 24 | #endif /* _UAPI_LINUX_SOCKET_H */ | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json new file mode 100644 index 000000000000..abc98b018446 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "BR_IMMED_SPEC", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "BR_RETURN_SPEC", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "BR_INDIRECT_SPEC", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "PublicDescription": "Mispredicted or not predicted branch speculatively executed", | ||
| 13 | "EventCode": "0x10", | ||
| 14 | "EventName": "BR_MIS_PRED", | ||
| 15 | "BriefDescription": "Branch mispredicted" | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "PublicDescription": "Predictable branch speculatively executed", | ||
| 19 | "EventCode": "0x12", | ||
| 20 | "EventName": "BR_PRED", | ||
| 21 | "BriefDescription": "Predictable branch" | ||
| 22 | }, | ||
| 23 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json new file mode 100644 index 000000000000..687b2629e1d1 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "BUS_ACCESS_RD", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "BUS_ACCESS_WR", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "BUS_ACCESS_SHARED", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "BUS_ACCESS_NOT_SHARED", | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "ArchStdEvent": "BUS_ACCESS_NORMAL", | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "ArchStdEvent": "BUS_ACCESS_PERIPH", | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | "PublicDescription": "Bus access", | ||
| 22 | "EventCode": "0x19", | ||
| 23 | "EventName": "BUS_ACCESS", | ||
| 24 | "BriefDescription": "Bus access" | ||
| 25 | }, | ||
| 26 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json new file mode 100644 index 000000000000..df9201434cb6 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json | |||
| @@ -0,0 +1,191 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "L1D_CACHE_RD", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "L1D_CACHE_WR", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "L1D_CACHE_REFILL_RD", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "L1D_CACHE_INVAL", | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "ArchStdEvent": "L1D_TLB_REFILL_RD", | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "ArchStdEvent": "L1D_TLB_REFILL_WR", | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | "ArchStdEvent": "L2D_CACHE_RD", | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | "ArchStdEvent": "L2D_CACHE_WR", | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | "ArchStdEvent": "L2D_CACHE_REFILL_RD", | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | "ArchStdEvent": "L2D_CACHE_REFILL_WR", | ||
| 31 | }, | ||
| 32 | { | ||
| 33 | "ArchStdEvent": "L2D_CACHE_WB_VICTIM", | ||
| 34 | }, | ||
| 35 | { | ||
| 36 | "ArchStdEvent": "L2D_CACHE_WB_CLEAN", | ||
| 37 | }, | ||
| 38 | { | ||
| 39 | "ArchStdEvent": "L2D_CACHE_INVAL", | ||
| 40 | }, | ||
| 41 | { | ||
| 42 | "PublicDescription": "Level 1 instruction cache refill", | ||
| 43 | "EventCode": "0x01", | ||
| 44 | "EventName": "L1I_CACHE_REFILL", | ||
| 45 | "BriefDescription": "L1I cache refill" | ||
| 46 | }, | ||
| 47 | { | ||
| 48 | "PublicDescription": "Level 1 instruction TLB refill", | ||
| 49 | "EventCode": "0x02", | ||
| 50 | "EventName": "L1I_TLB_REFILL", | ||
| 51 | "BriefDescription": "L1I TLB refill" | ||
| 52 | }, | ||
| 53 | { | ||
| 54 | "PublicDescription": "Level 1 data cache refill", | ||
| 55 | "EventCode": "0x03", | ||
| 56 | "EventName": "L1D_CACHE_REFILL", | ||
| 57 | "BriefDescription": "L1D cache refill" | ||
| 58 | }, | ||
| 59 | { | ||
| 60 | "PublicDescription": "Level 1 data cache access", | ||
| 61 | "EventCode": "0x04", | ||
| 62 | "EventName": "L1D_CACHE_ACCESS", | ||
| 63 | "BriefDescription": "L1D cache access" | ||
| 64 | }, | ||
| 65 | { | ||
| 66 | "PublicDescription": "Level 1 data TLB refill", | ||
| 67 | "EventCode": "0x05", | ||
| 68 | "EventName": "L1D_TLB_REFILL", | ||
| 69 | "BriefDescription": "L1D TLB refill" | ||
| 70 | }, | ||
| 71 | { | ||
| 72 | "PublicDescription": "Level 1 instruction cache access", | ||
| 73 | "EventCode": "0x14", | ||
| 74 | "EventName": "L1I_CACHE_ACCESS", | ||
| 75 | "BriefDescription": "L1I cache access" | ||
| 76 | }, | ||
| 77 | { | ||
| 78 | "PublicDescription": "Level 2 data cache access", | ||
| 79 | "EventCode": "0x16", | ||
| 80 | "EventName": "L2D_CACHE_ACCESS", | ||
| 81 | "BriefDescription": "L2D cache access" | ||
| 82 | }, | ||
| 83 | { | ||
| 84 | "PublicDescription": "Level 2 data refill", | ||
| 85 | "EventCode": "0x17", | ||
| 86 | "EventName": "L2D_CACHE_REFILL", | ||
| 87 | "BriefDescription": "L2D cache refill" | ||
| 88 | }, | ||
| 89 | { | ||
| 90 | "PublicDescription": "Level 2 data cache, Write-Back", | ||
| 91 | "EventCode": "0x18", | ||
| 92 | "EventName": "L2D_CACHE_WB", | ||
| 93 | "BriefDescription": "L2D cache Write-Back" | ||
| 94 | }, | ||
| 95 | { | ||
| 96 | "PublicDescription": "Level 1 data TLB access. This event counts any load or store operation which accesses the data L1 TLB", | ||
| 97 | "EventCode": "0x25", | ||
| 98 | "EventName": "L1D_TLB_ACCESS", | ||
| 99 | "BriefDescription": "L1D TLB access" | ||
| 100 | }, | ||
| 101 | { | ||
| 102 | "PublicDescription": "Level 1 instruction TLB access. This event counts any instruction fetch which accesses the instruction L1 TLB", | ||
| 103 | "EventCode": "0x26", | ||
| 104 | "EventName": "L1I_TLB_ACCESS", | ||
| 105 | "BriefDescription": "L1I TLB access" | ||
| 106 | }, | ||
| 107 | { | ||
| 108 | "PublicDescription": "Level 2 access to data TLB that caused a page table walk. This event counts on any data access which causes L2D_TLB_REFILL to count", | ||
| 109 | "EventCode": "0x34", | ||
| 110 | "EventName": "L2D_TLB_ACCESS", | ||
| 111 | "BriefDescription": "L2D TLB access" | ||
| 112 | }, | ||
| 113 | { | ||
| 114 | "PublicDescription": "Level 2 access to instruciton TLB that caused a page table walk. This event counts on any instruciton access which causes L2I_TLB_REFILL to count", | ||
| 115 | "EventCode": "0x35", | ||
| 116 | "EventName": "L2I_TLB_ACCESS", | ||
| 117 | "BriefDescription": "L2D TLB access" | ||
| 118 | }, | ||
| 119 | { | ||
| 120 | "PublicDescription": "Branch target buffer misprediction", | ||
| 121 | "EventCode": "0x102", | ||
| 122 | "EventName": "BTB_MIS_PRED", | ||
| 123 | "BriefDescription": "BTB misprediction" | ||
| 124 | }, | ||
| 125 | { | ||
| 126 | "PublicDescription": "ITB miss", | ||
| 127 | "EventCode": "0x103", | ||
| 128 | "EventName": "ITB_MISS", | ||
| 129 | "BriefDescription": "ITB miss" | ||
| 130 | }, | ||
| 131 | { | ||
| 132 | "PublicDescription": "DTB miss", | ||
| 133 | "EventCode": "0x104", | ||
| 134 | "EventName": "DTB_MISS", | ||
| 135 | "BriefDescription": "DTB miss" | ||
| 136 | }, | ||
| 137 | { | ||
| 138 | "PublicDescription": "Level 1 data cache late miss", | ||
| 139 | "EventCode": "0x105", | ||
| 140 | "EventName": "L1D_CACHE_LATE_MISS", | ||
| 141 | "BriefDescription": "L1D cache late miss" | ||
| 142 | }, | ||
| 143 | { | ||
| 144 | "PublicDescription": "Level 1 data cache prefetch request", | ||
| 145 | "EventCode": "0x106", | ||
| 146 | "EventName": "L1D_CACHE_PREFETCH", | ||
| 147 | "BriefDescription": "L1D cache prefetch" | ||
| 148 | }, | ||
| 149 | { | ||
| 150 | "PublicDescription": "Level 2 data cache prefetch request", | ||
| 151 | "EventCode": "0x107", | ||
| 152 | "EventName": "L2D_CACHE_PREFETCH", | ||
| 153 | "BriefDescription": "L2D cache prefetch" | ||
| 154 | }, | ||
| 155 | { | ||
| 156 | "PublicDescription": "Level 1 stage 2 TLB refill", | ||
| 157 | "EventCode": "0x111", | ||
| 158 | "EventName": "L1_STAGE2_TLB_REFILL", | ||
| 159 | "BriefDescription": "L1 stage 2 TLB refill" | ||
| 160 | }, | ||
| 161 | { | ||
| 162 | "PublicDescription": "Page walk cache level-0 stage-1 hit", | ||
| 163 | "EventCode": "0x112", | ||
| 164 | "EventName": "PAGE_WALK_L0_STAGE1_HIT", | ||
| 165 | "BriefDescription": "Page walk, L0 stage-1 hit" | ||
| 166 | }, | ||
| 167 | { | ||
| 168 | "PublicDescription": "Page walk cache level-1 stage-1 hit", | ||
| 169 | "EventCode": "0x113", | ||
| 170 | "EventName": "PAGE_WALK_L1_STAGE1_HIT", | ||
| 171 | "BriefDescription": "Page walk, L1 stage-1 hit" | ||
| 172 | }, | ||
| 173 | { | ||
| 174 | "PublicDescription": "Page walk cache level-2 stage-1 hit", | ||
| 175 | "EventCode": "0x114", | ||
| 176 | "EventName": "PAGE_WALK_L2_STAGE1_HIT", | ||
| 177 | "BriefDescription": "Page walk, L2 stage-1 hit" | ||
| 178 | }, | ||
| 179 | { | ||
| 180 | "PublicDescription": "Page walk cache level-1 stage-2 hit", | ||
| 181 | "EventCode": "0x115", | ||
| 182 | "EventName": "PAGE_WALK_L1_STAGE2_HIT", | ||
| 183 | "BriefDescription": "Page walk, L1 stage-2 hit" | ||
| 184 | }, | ||
| 185 | { | ||
| 186 | "PublicDescription": "Page walk cache level-2 stage-2 hit", | ||
| 187 | "EventCode": "0x116", | ||
| 188 | "EventName": "PAGE_WALK_L2_STAGE2_HIT", | ||
| 189 | "BriefDescription": "Page walk, L2 stage-2 hit" | ||
| 190 | }, | ||
| 191 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json new file mode 100644 index 000000000000..38cd1f1a70dc --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "PublicDescription": "The number of core clock cycles", | ||
| 4 | "EventCode": "0x11", | ||
| 5 | "EventName": "CPU_CYCLES", | ||
| 6 | "BriefDescription": "Clock cycles" | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "PublicDescription": "FSU clocking gated off cycle", | ||
| 10 | "EventCode": "0x101", | ||
| 11 | "EventName": "FSU_CLOCK_OFF_CYCLES", | ||
| 12 | "BriefDescription": "FSU clocking gated off cycle" | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "PublicDescription": "Wait state cycle", | ||
| 16 | "EventCode": "0x110", | ||
| 17 | "EventName": "Wait_CYCLES", | ||
| 18 | "BriefDescription": "Wait state cycle" | ||
| 19 | }, | ||
| 20 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json deleted file mode 100644 index bc03c06c3918..000000000000 --- a/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "L1D_CACHE_RD", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "L1D_CACHE_WR", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "L1D_CACHE_REFILL_RD", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "L1D_CACHE_REFILL_WR", | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "ArchStdEvent": "L1D_TLB_REFILL_RD", | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "ArchStdEvent": "L1D_TLB_REFILL_WR", | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | "ArchStdEvent": "L1D_TLB_RD", | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | "ArchStdEvent": "L1D_TLB_WR", | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | "ArchStdEvent": "BUS_ACCESS_RD", | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | "ArchStdEvent": "BUS_ACCESS_WR", | ||
| 31 | } | ||
| 32 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json new file mode 100644 index 000000000000..3720dc28a15f --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "EXC_UNDEF", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "EXC_SVC", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "EXC_PABORT", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "EXC_DABORT", | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "ArchStdEvent": "EXC_IRQ", | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "ArchStdEvent": "EXC_FIQ", | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | "ArchStdEvent": "EXC_HVC", | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | "ArchStdEvent": "EXC_TRAP_PABORT", | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | "ArchStdEvent": "EXC_TRAP_DABORT", | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | "ArchStdEvent": "EXC_TRAP_OTHER", | ||
| 31 | }, | ||
| 32 | { | ||
| 33 | "ArchStdEvent": "EXC_TRAP_IRQ", | ||
| 34 | }, | ||
| 35 | { | ||
| 36 | "ArchStdEvent": "EXC_TRAP_FIQ", | ||
| 37 | }, | ||
| 38 | { | ||
| 39 | "PublicDescription": "Exception taken", | ||
| 40 | "EventCode": "0x09", | ||
| 41 | "EventName": "EXC_TAKEN", | ||
| 42 | "BriefDescription": "Exception taken" | ||
| 43 | }, | ||
| 44 | { | ||
| 45 | "PublicDescription": "Instruction architecturally executed, condition check pass, exception return", | ||
| 46 | "EventCode": "0x0a", | ||
| 47 | "EventName": "EXC_RETURN", | ||
| 48 | "BriefDescription": "Exception return" | ||
| 49 | }, | ||
| 50 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json new file mode 100644 index 000000000000..82cf753e6472 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "LD_SPEC", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "ST_SPEC", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "LDST_SPEC", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "DP_SPEC", | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "ArchStdEvent": "ASE_SPEC", | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "ArchStdEvent": "VFP_SPEC", | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | "ArchStdEvent": "PC_WRITE_SPEC", | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | "ArchStdEvent": "CRYPTO_SPEC", | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | "ArchStdEvent": "ISB_SPEC", | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | "ArchStdEvent": "DSB_SPEC", | ||
| 31 | }, | ||
| 32 | { | ||
| 33 | "ArchStdEvent": "DMB_SPEC", | ||
| 34 | }, | ||
| 35 | { | ||
| 36 | "ArchStdEvent": "RC_LD_SPEC", | ||
| 37 | }, | ||
| 38 | { | ||
| 39 | "ArchStdEvent": "RC_ST_SPEC", | ||
| 40 | }, | ||
| 41 | { | ||
| 42 | "PublicDescription": "Instruction architecturally executed, software increment", | ||
| 43 | "EventCode": "0x00", | ||
| 44 | "EventName": "SW_INCR", | ||
| 45 | "BriefDescription": "Software increment" | ||
| 46 | }, | ||
| 47 | { | ||
| 48 | "PublicDescription": "Instruction architecturally executed", | ||
| 49 | "EventCode": "0x08", | ||
| 50 | "EventName": "INST_RETIRED", | ||
| 51 | "BriefDescription": "Instruction retired" | ||
| 52 | }, | ||
| 53 | { | ||
| 54 | "PublicDescription": "Instruction architecturally executed, condition code check pass, write to CONTEXTIDR", | ||
| 55 | "EventCode": "0x0b", | ||
| 56 | "EventName": "CID_WRITE_RETIRED", | ||
| 57 | "BriefDescription": "Write to CONTEXTIDR" | ||
| 58 | }, | ||
| 59 | { | ||
| 60 | "PublicDescription": "Operation speculatively executed", | ||
| 61 | "EventCode": "0x1b", | ||
| 62 | "EventName": "INST_SPEC", | ||
| 63 | "BriefDescription": "Speculatively executed" | ||
| 64 | }, | ||
| 65 | { | ||
| 66 | "PublicDescription": "Instruction architecturally executed (condition check pass), write to TTBR", | ||
| 67 | "EventCode": "0x1c", | ||
| 68 | "EventName": "TTBR_WRITE_RETIRED", | ||
| 69 | "BriefDescription": "Instruction executed, TTBR write" | ||
| 70 | }, | ||
| 71 | { | ||
| 72 | "PublicDescription": "Instruction architecturally executed, branch. This event counts all branches, taken or not. This excludes exception entries, debug entries and CCFAIL branches", | ||
| 73 | "EventCode": "0x21", | ||
| 74 | "EventName": "BR_RETIRED", | ||
| 75 | "BriefDescription": "Branch retired" | ||
| 76 | }, | ||
| 77 | { | ||
| 78 | "PublicDescription": "Instruction architecturally executed, mispredicted branch. This event counts any branch counted by BR_RETIRED which is not correctly predicted and causes a pipeline flush", | ||
| 79 | "EventCode": "0x22", | ||
| 80 | "EventName": "BR_MISPRED_RETIRED", | ||
| 81 | "BriefDescription": "Mispredicted branch retired" | ||
| 82 | }, | ||
| 83 | { | ||
| 84 | "PublicDescription": "Operation speculatively executed, NOP", | ||
| 85 | "EventCode": "0x100", | ||
| 86 | "EventName": "NOP_SPEC", | ||
| 87 | "BriefDescription": "Speculatively executed, NOP" | ||
| 88 | }, | ||
| 89 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json new file mode 100644 index 000000000000..2aecc5c2347d --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "LDREX_SPEC", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "STREX_PASS_SPEC", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "STREX_FAIL_SPEC", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "STREX_SPEC", | ||
| 13 | }, | ||
| 14 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json new file mode 100644 index 000000000000..08508697b318 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "ArchStdEvent": "MEM_ACCESS_RD", | ||
| 4 | }, | ||
| 5 | { | ||
| 6 | "ArchStdEvent": "MEM_ACCESS_WR", | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "ArchStdEvent": "UNALIGNED_LD_SPEC", | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | "ArchStdEvent": "UNALIGNED_ST_SPEC", | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "ArchStdEvent": "UNALIGNED_LDST_SPEC", | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "PublicDescription": "Data memory access", | ||
| 19 | "EventCode": "0x13", | ||
| 20 | "EventName": "MEM_ACCESS", | ||
| 21 | "BriefDescription": "Memory access" | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | "PublicDescription": "Local memory error. This event counts any correctable or uncorrectable memory error (ECC or parity) in the protected core RAMs", | ||
| 25 | "EventCode": "0x1a", | ||
| 26 | "EventName": "MEM_ERROR", | ||
| 27 | "BriefDescription": "Memory error" | ||
| 28 | }, | ||
| 29 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json new file mode 100644 index 000000000000..e2087de586bf --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "PublicDescription": "Decode starved for instruction cycle", | ||
| 4 | "EventCode": "0x108", | ||
| 5 | "EventName": "DECODE_STALL", | ||
| 6 | "BriefDescription": "Decode starved" | ||
| 7 | }, | ||
| 8 | { | ||
| 9 | "PublicDescription": "Op dispatch stalled cycle", | ||
| 10 | "EventCode": "0x109", | ||
| 11 | "EventName": "DISPATCH_STALL", | ||
| 12 | "BriefDescription": "Dispatch stalled" | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | "PublicDescription": "IXA Op non-issue", | ||
| 16 | "EventCode": "0x10a", | ||
| 17 | "EventName": "IXA_STALL", | ||
| 18 | "BriefDescription": "IXA stalled" | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | "PublicDescription": "IXB Op non-issue", | ||
| 22 | "EventCode": "0x10b", | ||
| 23 | "EventName": "IXB_STALL", | ||
| 24 | "BriefDescription": "IXB stalled" | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | "PublicDescription": "BX Op non-issue", | ||
| 28 | "EventCode": "0x10c", | ||
| 29 | "EventName": "BX_STALL", | ||
| 30 | "BriefDescription": "BX stalled" | ||
| 31 | }, | ||
| 32 | { | ||
| 33 | "PublicDescription": "LX Op non-issue", | ||
| 34 | "EventCode": "0x10d", | ||
| 35 | "EventName": "LX_STALL", | ||
| 36 | "BriefDescription": "LX stalled" | ||
| 37 | }, | ||
| 38 | { | ||
| 39 | "PublicDescription": "SX Op non-issue", | ||
| 40 | "EventCode": "0x10e", | ||
| 41 | "EventName": "SX_STALL", | ||
| 42 | "BriefDescription": "SX stalled" | ||
| 43 | }, | ||
| 44 | { | ||
| 45 | "PublicDescription": "FX Op non-issue", | ||
| 46 | "EventCode": "0x10f", | ||
| 47 | "EventName": "FX_STALL", | ||
| 48 | "BriefDescription": "FX stalled" | ||
| 49 | }, | ||
| 50 | ] | ||
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 6c108fa79ae3..0b2b8305c965 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build | |||
| @@ -21,6 +21,7 @@ perf-y += python-use.o | |||
| 21 | perf-y += bp_signal.o | 21 | perf-y += bp_signal.o |
| 22 | perf-y += bp_signal_overflow.o | 22 | perf-y += bp_signal_overflow.o |
| 23 | perf-y += bp_account.o | 23 | perf-y += bp_account.o |
| 24 | perf-y += wp.o | ||
| 24 | perf-y += task-exit.o | 25 | perf-y += task-exit.o |
| 25 | perf-y += sw-clock.o | 26 | perf-y += sw-clock.o |
| 26 | perf-y += mmap-thread-lookup.o | 27 | perf-y += mmap-thread-lookup.o |
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index d7a5e1b9aa6f..54ca7d87236f 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
| @@ -121,6 +121,15 @@ static struct test generic_tests[] = { | |||
| 121 | .is_supported = test__bp_signal_is_supported, | 121 | .is_supported = test__bp_signal_is_supported, |
| 122 | }, | 122 | }, |
| 123 | { | 123 | { |
| 124 | .desc = "Watchpoint", | ||
| 125 | .func = test__wp, | ||
| 126 | .subtest = { | ||
| 127 | .skip_if_fail = false, | ||
| 128 | .get_nr = test__wp_subtest_get_nr, | ||
| 129 | .get_desc = test__wp_subtest_get_desc, | ||
| 130 | }, | ||
| 131 | }, | ||
| 132 | { | ||
| 124 | .desc = "Number of exit events of a simple workload", | 133 | .desc = "Number of exit events of a simple workload", |
| 125 | .func = test__task_exit, | 134 | .func = test__task_exit, |
| 126 | }, | 135 | }, |
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c index 699561fa512c..5f8501c68da4 100644 --- a/tools/perf/tests/evsel-tp-sched.c +++ b/tools/perf/tests/evsel-tp-sched.c | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, | 8 | static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, |
| 9 | int size, bool should_be_signed) | 9 | int size, bool should_be_signed) |
| 10 | { | 10 | { |
| 11 | struct format_field *field = perf_evsel__field(evsel, name); | 11 | struct tep_format_field *field = perf_evsel__field(evsel, name); |
| 12 | int is_signed; | 12 | int is_signed; |
| 13 | int ret = 0; | 13 | int ret = 0; |
| 14 | 14 | ||
| @@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, | |||
| 17 | return -1; | 17 | return -1; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | is_signed = !!(field->flags | FIELD_IS_SIGNED); | 20 | is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED); |
| 21 | if (should_be_signed && !is_signed) { | 21 | if (should_be_signed && !is_signed) { |
| 22 | pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", | 22 | pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", |
| 23 | evsel->name, name, is_signed, should_be_signed); | 23 | evsel->name, name, is_signed, should_be_signed); |
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh index 3013ac8f83d0..cab7b0aea6ea 100755 --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh | |||
| @@ -48,7 +48,7 @@ trace_libc_inet_pton_backtrace() { | |||
| 48 | *) | 48 | *) |
| 49 | eventattr='max-stack=3' | 49 | eventattr='max-stack=3' |
| 50 | echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected | 50 | echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected |
| 51 | echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected | 51 | echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected |
| 52 | ;; | 52 | ;; |
| 53 | esac | 53 | esac |
| 54 | 54 | ||
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index a9760e790563..8e26a4148f30 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h | |||
| @@ -59,6 +59,9 @@ int test__python_use(struct test *test, int subtest); | |||
| 59 | int test__bp_signal(struct test *test, int subtest); | 59 | int test__bp_signal(struct test *test, int subtest); |
| 60 | int test__bp_signal_overflow(struct test *test, int subtest); | 60 | int test__bp_signal_overflow(struct test *test, int subtest); |
| 61 | int test__bp_accounting(struct test *test, int subtest); | 61 | int test__bp_accounting(struct test *test, int subtest); |
| 62 | int test__wp(struct test *test, int subtest); | ||
| 63 | const char *test__wp_subtest_get_desc(int subtest); | ||
| 64 | int test__wp_subtest_get_nr(void); | ||
| 62 | int test__task_exit(struct test *test, int subtest); | 65 | int test__task_exit(struct test *test, int subtest); |
| 63 | int test__mem(struct test *test, int subtest); | 66 | int test__mem(struct test *test, int subtest); |
| 64 | int test__sw_clock_freq(struct test *test, int subtest); | 67 | int test__sw_clock_freq(struct test *test, int subtest); |
diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c new file mode 100644 index 000000000000..017a99317f94 --- /dev/null +++ b/tools/perf/tests/wp.c | |||
| @@ -0,0 +1,229 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <sys/ioctl.h> | ||
| 4 | #include <linux/hw_breakpoint.h> | ||
| 5 | #include "tests.h" | ||
| 6 | #include "debug.h" | ||
| 7 | #include "cloexec.h" | ||
| 8 | |||
| 9 | #define WP_TEST_ASSERT_VAL(fd, text, val) \ | ||
| 10 | do { \ | ||
| 11 | long long count; \ | ||
| 12 | wp_read(fd, &count, sizeof(long long)); \ | ||
| 13 | TEST_ASSERT_VAL(text, count == val); \ | ||
| 14 | } while (0) | ||
| 15 | |||
| 16 | volatile u64 data1; | ||
| 17 | volatile u8 data2[3]; | ||
| 18 | |||
| 19 | static int wp_read(int fd, long long *count, int size) | ||
| 20 | { | ||
| 21 | int ret = read(fd, count, size); | ||
| 22 | |||
| 23 | if (ret != size) { | ||
| 24 | pr_debug("failed to read: %d\n", ret); | ||
| 25 | return -1; | ||
| 26 | } | ||
| 27 | return 0; | ||
| 28 | } | ||
| 29 | |||
| 30 | static void get__perf_event_attr(struct perf_event_attr *attr, int wp_type, | ||
| 31 | void *wp_addr, unsigned long wp_len) | ||
| 32 | { | ||
| 33 | memset(attr, 0, sizeof(struct perf_event_attr)); | ||
| 34 | attr->type = PERF_TYPE_BREAKPOINT; | ||
| 35 | attr->size = sizeof(struct perf_event_attr); | ||
| 36 | attr->config = 0; | ||
| 37 | attr->bp_type = wp_type; | ||
| 38 | attr->bp_addr = (unsigned long)wp_addr; | ||
| 39 | attr->bp_len = wp_len; | ||
| 40 | attr->sample_period = 1; | ||
| 41 | attr->sample_type = PERF_SAMPLE_IP; | ||
| 42 | attr->exclude_kernel = 1; | ||
| 43 | attr->exclude_hv = 1; | ||
| 44 | } | ||
| 45 | |||
| 46 | static int __event(int wp_type, void *wp_addr, unsigned long wp_len) | ||
| 47 | { | ||
| 48 | int fd; | ||
| 49 | struct perf_event_attr attr; | ||
| 50 | |||
| 51 | get__perf_event_attr(&attr, wp_type, wp_addr, wp_len); | ||
| 52 | fd = sys_perf_event_open(&attr, 0, -1, -1, | ||
| 53 | perf_event_open_cloexec_flag()); | ||
| 54 | if (fd < 0) | ||
| 55 | pr_debug("failed opening event %x\n", attr.bp_type); | ||
| 56 | |||
| 57 | return fd; | ||
| 58 | } | ||
| 59 | |||
| 60 | static int wp_ro_test(void) | ||
| 61 | { | ||
| 62 | int fd; | ||
| 63 | unsigned long tmp, tmp1 = rand(); | ||
| 64 | |||
| 65 | fd = __event(HW_BREAKPOINT_R, (void *)&data1, sizeof(data1)); | ||
| 66 | if (fd < 0) | ||
| 67 | return -1; | ||
| 68 | |||
| 69 | tmp = data1; | ||
| 70 | WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1); | ||
| 71 | |||
| 72 | data1 = tmp1 + tmp; | ||
| 73 | WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1); | ||
| 74 | |||
| 75 | close(fd); | ||
| 76 | return 0; | ||
| 77 | } | ||
| 78 | |||
| 79 | static int wp_wo_test(void) | ||
| 80 | { | ||
| 81 | int fd; | ||
| 82 | unsigned long tmp, tmp1 = rand(); | ||
| 83 | |||
| 84 | fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1)); | ||
| 85 | if (fd < 0) | ||
| 86 | return -1; | ||
| 87 | |||
| 88 | tmp = data1; | ||
| 89 | WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 0); | ||
| 90 | |||
| 91 | data1 = tmp1 + tmp; | ||
| 92 | WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 1); | ||
| 93 | |||
| 94 | close(fd); | ||
| 95 | return 0; | ||
| 96 | } | ||
| 97 | |||
| 98 | static int wp_rw_test(void) | ||
| 99 | { | ||
| 100 | int fd; | ||
| 101 | unsigned long tmp, tmp1 = rand(); | ||
| 102 | |||
| 103 | fd = __event(HW_BREAKPOINT_R | HW_BREAKPOINT_W, (void *)&data1, | ||
| 104 | sizeof(data1)); | ||
| 105 | if (fd < 0) | ||
| 106 | return -1; | ||
| 107 | |||
| 108 | tmp = data1; | ||
| 109 | WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 1); | ||
| 110 | |||
| 111 | data1 = tmp1 + tmp; | ||
| 112 | WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 2); | ||
| 113 | |||
| 114 | close(fd); | ||
| 115 | return 0; | ||
| 116 | } | ||
| 117 | |||
| 118 | static int wp_modify_test(void) | ||
| 119 | { | ||
| 120 | int fd, ret; | ||
| 121 | unsigned long tmp = rand(); | ||
| 122 | struct perf_event_attr new_attr; | ||
| 123 | |||
| 124 | fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1)); | ||
| 125 | if (fd < 0) | ||
| 126 | return -1; | ||
| 127 | |||
| 128 | data1 = tmp; | ||
| 129 | WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1); | ||
| 130 | |||
| 131 | /* Modify watchpoint with disabled = 1 */ | ||
| 132 | get__perf_event_attr(&new_attr, HW_BREAKPOINT_W, (void *)&data2[0], | ||
| 133 | sizeof(u8) * 2); | ||
| 134 | new_attr.disabled = 1; | ||
| 135 | ret = ioctl(fd, PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &new_attr); | ||
| 136 | if (ret < 0) { | ||
| 137 | pr_debug("ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) failed\n"); | ||
| 138 | close(fd); | ||
| 139 | return ret; | ||
| 140 | } | ||
| 141 | |||
| 142 | data2[1] = tmp; /* Not Counted */ | ||
| 143 | WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1); | ||
| 144 | |||
| 145 | /* Enable the event */ | ||
| 146 | ioctl(fd, PERF_EVENT_IOC_ENABLE, 0); | ||
| 147 | if (ret < 0) { | ||
| 148 | pr_debug("Failed to enable event\n"); | ||
| 149 | close(fd); | ||
| 150 | return ret; | ||
| 151 | } | ||
| 152 | |||
| 153 | data2[1] = tmp; /* Counted */ | ||
| 154 | WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 2); | ||
| 155 | |||
| 156 | data2[2] = tmp; /* Not Counted */ | ||
| 157 | WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 2); | ||
| 158 | |||
| 159 | close(fd); | ||
| 160 | return 0; | ||
| 161 | } | ||
| 162 | |||
| 163 | static bool wp_ro_supported(void) | ||
| 164 | { | ||
| 165 | #if defined (__x86_64__) || defined (__i386__) | ||
| 166 | return false; | ||
| 167 | #else | ||
| 168 | return true; | ||
| 169 | #endif | ||
| 170 | } | ||
| 171 | |||
| 172 | static void wp_ro_skip_msg(void) | ||
| 173 | { | ||
| 174 | #if defined (__x86_64__) || defined (__i386__) | ||
| 175 | pr_debug("Hardware does not support read only watchpoints.\n"); | ||
| 176 | #endif | ||
| 177 | } | ||
| 178 | |||
| 179 | static struct { | ||
| 180 | const char *desc; | ||
| 181 | int (*target_func)(void); | ||
| 182 | bool (*is_supported)(void); | ||
| 183 | void (*skip_msg)(void); | ||
| 184 | } wp_testcase_table[] = { | ||
| 185 | { | ||
| 186 | .desc = "Read Only Watchpoint", | ||
| 187 | .target_func = &wp_ro_test, | ||
| 188 | .is_supported = &wp_ro_supported, | ||
| 189 | .skip_msg = &wp_ro_skip_msg, | ||
| 190 | }, | ||
| 191 | { | ||
| 192 | .desc = "Write Only Watchpoint", | ||
| 193 | .target_func = &wp_wo_test, | ||
| 194 | }, | ||
| 195 | { | ||
| 196 | .desc = "Read / Write Watchpoint", | ||
| 197 | .target_func = &wp_rw_test, | ||
| 198 | }, | ||
| 199 | { | ||
| 200 | .desc = "Modify Watchpoint", | ||
| 201 | .target_func = &wp_modify_test, | ||
| 202 | }, | ||
| 203 | }; | ||
| 204 | |||
| 205 | int test__wp_subtest_get_nr(void) | ||
| 206 | { | ||
| 207 | return (int)ARRAY_SIZE(wp_testcase_table); | ||
| 208 | } | ||
| 209 | |||
| 210 | const char *test__wp_subtest_get_desc(int i) | ||
| 211 | { | ||
| 212 | if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table)) | ||
| 213 | return NULL; | ||
| 214 | return wp_testcase_table[i].desc; | ||
| 215 | } | ||
| 216 | |||
| 217 | int test__wp(struct test *test __maybe_unused, int i) | ||
| 218 | { | ||
| 219 | if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table)) | ||
| 220 | return TEST_FAIL; | ||
| 221 | |||
| 222 | if (wp_testcase_table[i].is_supported && | ||
| 223 | !wp_testcase_table[i].is_supported()) { | ||
| 224 | wp_testcase_table[i].skip_msg(); | ||
| 225 | return TEST_SKIP; | ||
| 226 | } | ||
| 227 | |||
| 228 | return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL; | ||
| 229 | } | ||
diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build index f528ba35e140..c3b0afd67760 100644 --- a/tools/perf/trace/beauty/Build +++ b/tools/perf/trace/beauty/Build | |||
| @@ -7,5 +7,6 @@ endif | |||
| 7 | libperf-y += kcmp.o | 7 | libperf-y += kcmp.o |
| 8 | libperf-y += pkey_alloc.o | 8 | libperf-y += pkey_alloc.o |
| 9 | libperf-y += prctl.o | 9 | libperf-y += prctl.o |
| 10 | libperf-y += sockaddr.o | ||
| 10 | libperf-y += socket.o | 11 | libperf-y += socket.o |
| 11 | libperf-y += statx.o | 12 | libperf-y += statx.o |
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index 9615af5d412b..2570152d3909 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h | |||
| @@ -30,9 +30,36 @@ struct thread; | |||
| 30 | 30 | ||
| 31 | size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size); | 31 | size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size); |
| 32 | 32 | ||
| 33 | extern struct strarray strarray__socket_families; | ||
| 34 | |||
| 35 | /** | ||
| 36 | * augmented_arg: extra payload for syscall pointer arguments | ||
| 37 | |||
| 38 | * If perf_sample->raw_size is more than what a syscall sys_enter_FOO puts, | ||
| 39 | * then its the arguments contents, so that we can show more than just a | ||
| 40 | * pointer. This will be done initially with eBPF, the start of that is at the | ||
| 41 | * tools/perf/examples/bpf/augmented_syscalls.c example for the openat, but | ||
| 42 | * will eventually be done automagically caching the running kernel tracefs | ||
| 43 | * events data into an eBPF C script, that then gets compiled and its .o file | ||
| 44 | * cached for subsequent use. For char pointers like the ones for 'open' like | ||
| 45 | * syscalls its easy, for the rest we should use DWARF or better, BTF, much | ||
| 46 | * more compact. | ||
| 47 | * | ||
| 48 | * @size: 8 if all we need is an integer, otherwise all of the augmented arg. | ||
| 49 | * @int_arg: will be used for integer like pointer contents, like 'accept's 'upeer_addrlen' | ||
| 50 | * @value: u64 aligned, for structs, pathnames | ||
| 51 | */ | ||
| 52 | struct augmented_arg { | ||
| 53 | int size; | ||
| 54 | int int_arg; | ||
| 55 | u64 value[]; | ||
| 56 | }; | ||
| 57 | |||
| 33 | /** | 58 | /** |
| 34 | * @val: value of syscall argument being formatted | 59 | * @val: value of syscall argument being formatted |
| 35 | * @args: All the args, use syscall_args__val(arg, nth) to access one | 60 | * @args: All the args, use syscall_args__val(arg, nth) to access one |
| 61 | * @augmented_args: Extra data that can be collected, for instance, with eBPF for expanding the pathname for open, etc | ||
| 62 | * @augmented_args_size: augmented_args total payload size | ||
| 36 | * @thread: tid state (maps, pid, tid, etc) | 63 | * @thread: tid state (maps, pid, tid, etc) |
| 37 | * @trace: 'perf trace' internals: all threads, etc | 64 | * @trace: 'perf trace' internals: all threads, etc |
| 38 | * @parm: private area, may be an strarray, for instance | 65 | * @parm: private area, may be an strarray, for instance |
| @@ -43,6 +70,10 @@ size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_ | |||
| 43 | struct syscall_arg { | 70 | struct syscall_arg { |
| 44 | unsigned long val; | 71 | unsigned long val; |
| 45 | unsigned char *args; | 72 | unsigned char *args; |
| 73 | struct { | ||
| 74 | struct augmented_arg *args; | ||
| 75 | int size; | ||
| 76 | } augmented; | ||
| 46 | struct thread *thread; | 77 | struct thread *thread; |
| 47 | struct trace *trace; | 78 | struct trace *trace; |
| 48 | void *parm; | 79 | void *parm; |
| @@ -106,6 +137,9 @@ size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_a | |||
| 106 | size_t syscall_arg__scnprintf_prctl_arg3(char *bf, size_t size, struct syscall_arg *arg); | 137 | size_t syscall_arg__scnprintf_prctl_arg3(char *bf, size_t size, struct syscall_arg *arg); |
| 107 | #define SCA_PRCTL_ARG3 syscall_arg__scnprintf_prctl_arg3 | 138 | #define SCA_PRCTL_ARG3 syscall_arg__scnprintf_prctl_arg3 |
| 108 | 139 | ||
| 140 | size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg *arg); | ||
| 141 | #define SCA_SOCKADDR syscall_arg__scnprintf_sockaddr | ||
| 142 | |||
| 109 | size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct syscall_arg *arg); | 143 | size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct syscall_arg *arg); |
| 110 | #define SCA_SK_PROTO syscall_arg__scnprintf_socket_protocol | 144 | #define SCA_SK_PROTO syscall_arg__scnprintf_socket_protocol |
| 111 | 145 | ||
diff --git a/tools/perf/trace/beauty/sockaddr.c b/tools/perf/trace/beauty/sockaddr.c new file mode 100644 index 000000000000..71a79f72d9d9 --- /dev/null +++ b/tools/perf/trace/beauty/sockaddr.c | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> | ||
| 3 | |||
| 4 | #include "trace/beauty/beauty.h" | ||
| 5 | #include <sys/socket.h> | ||
| 6 | #include <sys/types.h> | ||
| 7 | #include <sys/un.h> | ||
| 8 | #include <arpa/inet.h> | ||
| 9 | |||
| 10 | static const char *socket_families[] = { | ||
| 11 | "UNSPEC", "LOCAL", "INET", "AX25", "IPX", "APPLETALK", "NETROM", | ||
| 12 | "BRIDGE", "ATMPVC", "X25", "INET6", "ROSE", "DECnet", "NETBEUI", | ||
| 13 | "SECURITY", "KEY", "NETLINK", "PACKET", "ASH", "ECONET", "ATMSVC", | ||
| 14 | "RDS", "SNA", "IRDA", "PPPOX", "WANPIPE", "LLC", "IB", "CAN", "TIPC", | ||
| 15 | "BLUETOOTH", "IUCV", "RXRPC", "ISDN", "PHONET", "IEEE802154", "CAIF", | ||
| 16 | "ALG", "NFC", "VSOCK", | ||
| 17 | }; | ||
| 18 | DEFINE_STRARRAY(socket_families); | ||
| 19 | |||
| 20 | static size_t af_inet__scnprintf(struct sockaddr *sa, char *bf, size_t size) | ||
| 21 | { | ||
| 22 | struct sockaddr_in *sin = (struct sockaddr_in *)sa; | ||
| 23 | char tmp[16]; | ||
| 24 | return scnprintf(bf, size, ", port: %d, addr: %s", ntohs(sin->sin_port), | ||
| 25 | inet_ntop(sin->sin_family, &sin->sin_addr, tmp, sizeof(tmp))); | ||
| 26 | } | ||
| 27 | |||
| 28 | static size_t af_inet6__scnprintf(struct sockaddr *sa, char *bf, size_t size) | ||
| 29 | { | ||
| 30 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; | ||
| 31 | u32 flowinfo = ntohl(sin6->sin6_flowinfo); | ||
| 32 | char tmp[512]; | ||
| 33 | size_t printed = scnprintf(bf, size, ", port: %d, addr: %s", ntohs(sin6->sin6_port), | ||
| 34 | inet_ntop(sin6->sin6_family, &sin6->sin6_addr, tmp, sizeof(tmp))); | ||
| 35 | if (flowinfo != 0) | ||
| 36 | printed += scnprintf(bf + printed, size - printed, ", flowinfo: %lu", flowinfo); | ||
| 37 | if (sin6->sin6_scope_id != 0) | ||
| 38 | printed += scnprintf(bf + printed, size - printed, ", scope_id: %lu", sin6->sin6_scope_id); | ||
| 39 | |||
| 40 | return printed; | ||
| 41 | } | ||
| 42 | |||
| 43 | static size_t af_local__scnprintf(struct sockaddr *sa, char *bf, size_t size) | ||
| 44 | { | ||
| 45 | struct sockaddr_un *sun = (struct sockaddr_un *)sa; | ||
| 46 | return scnprintf(bf, size, ", path: %s", sun->sun_path); | ||
| 47 | } | ||
| 48 | |||
| 49 | static size_t (*af_scnprintfs[])(struct sockaddr *sa, char *bf, size_t size) = { | ||
| 50 | [AF_LOCAL] = af_local__scnprintf, | ||
| 51 | [AF_INET] = af_inet__scnprintf, | ||
| 52 | [AF_INET6] = af_inet6__scnprintf, | ||
| 53 | }; | ||
| 54 | |||
| 55 | static size_t syscall_arg__scnprintf_augmented_sockaddr(struct syscall_arg *arg, char *bf, size_t size) | ||
| 56 | { | ||
| 57 | struct sockaddr *sa = (struct sockaddr *)arg->augmented.args; | ||
| 58 | char family[32]; | ||
| 59 | size_t printed; | ||
| 60 | |||
| 61 | strarray__scnprintf(&strarray__socket_families, family, sizeof(family), "%d", sa->sa_family); | ||
| 62 | printed = scnprintf(bf, size, "{ .family: %s", family); | ||
| 63 | |||
| 64 | if (sa->sa_family < ARRAY_SIZE(af_scnprintfs) && af_scnprintfs[sa->sa_family]) | ||
| 65 | printed += af_scnprintfs[sa->sa_family](sa, bf + printed, size - printed); | ||
| 66 | |||
| 67 | return printed + scnprintf(bf + printed, size - printed, " }"); | ||
| 68 | } | ||
| 69 | |||
| 70 | size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg *arg) | ||
| 71 | { | ||
| 72 | if (arg->augmented.args) | ||
| 73 | return syscall_arg__scnprintf_augmented_sockaddr(arg, bf, size); | ||
| 74 | |||
| 75 | return scnprintf(bf, size, "%#x", arg->val); | ||
| 76 | } | ||
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 7efe15b9618d..ecd9f9ceda77 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
| @@ -73,6 +73,7 @@ libperf-y += vdso.o | |||
| 73 | libperf-y += counts.o | 73 | libperf-y += counts.o |
| 74 | libperf-y += stat.o | 74 | libperf-y += stat.o |
| 75 | libperf-y += stat-shadow.o | 75 | libperf-y += stat-shadow.o |
| 76 | libperf-y += stat-display.o | ||
| 76 | libperf-y += record.o | 77 | libperf-y += record.o |
| 77 | libperf-y += srcline.o | 78 | libperf-y += srcline.o |
| 78 | libperf-y += data.o | 79 | libperf-y += data.o |
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index db1511359c5e..c4617bcfd521 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c | |||
| @@ -906,9 +906,8 @@ out_free: | |||
| 906 | return err; | 906 | return err; |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, | 909 | int perf_event__process_auxtrace_info(struct perf_session *session, |
| 910 | union perf_event *event, | 910 | union perf_event *event) |
| 911 | struct perf_session *session) | ||
| 912 | { | 911 | { |
| 913 | enum auxtrace_type type = event->auxtrace_info.type; | 912 | enum auxtrace_type type = event->auxtrace_info.type; |
| 914 | 913 | ||
| @@ -932,9 +931,8 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, | |||
| 932 | } | 931 | } |
| 933 | } | 932 | } |
| 934 | 933 | ||
| 935 | s64 perf_event__process_auxtrace(struct perf_tool *tool, | 934 | s64 perf_event__process_auxtrace(struct perf_session *session, |
| 936 | union perf_event *event, | 935 | union perf_event *event) |
| 937 | struct perf_session *session) | ||
| 938 | { | 936 | { |
| 939 | s64 err; | 937 | s64 err; |
| 940 | 938 | ||
| @@ -950,7 +948,7 @@ s64 perf_event__process_auxtrace(struct perf_tool *tool, | |||
| 950 | if (!session->auxtrace || event->header.type != PERF_RECORD_AUXTRACE) | 948 | if (!session->auxtrace || event->header.type != PERF_RECORD_AUXTRACE) |
| 951 | return -EINVAL; | 949 | return -EINVAL; |
| 952 | 950 | ||
| 953 | err = session->auxtrace->process_auxtrace_event(session, event, tool); | 951 | err = session->auxtrace->process_auxtrace_event(session, event, session->tool); |
| 954 | if (err < 0) | 952 | if (err < 0) |
| 955 | return err; | 953 | return err; |
| 956 | 954 | ||
| @@ -1185,9 +1183,8 @@ void events_stats__auxtrace_error_warn(const struct events_stats *stats) | |||
| 1185 | } | 1183 | } |
| 1186 | } | 1184 | } |
| 1187 | 1185 | ||
| 1188 | int perf_event__process_auxtrace_error(struct perf_tool *tool __maybe_unused, | 1186 | int perf_event__process_auxtrace_error(struct perf_session *session, |
| 1189 | union perf_event *event, | 1187 | union perf_event *event) |
| 1190 | struct perf_session *session) | ||
| 1191 | { | 1188 | { |
| 1192 | if (auxtrace__dont_decode(session)) | 1189 | if (auxtrace__dont_decode(session)) |
| 1193 | return 0; | 1190 | return 0; |
| @@ -1196,11 +1193,12 @@ int perf_event__process_auxtrace_error(struct perf_tool *tool __maybe_unused, | |||
| 1196 | return 0; | 1193 | return 0; |
| 1197 | } | 1194 | } |
| 1198 | 1195 | ||
| 1199 | static int __auxtrace_mmap__read(struct auxtrace_mmap *mm, | 1196 | static int __auxtrace_mmap__read(struct perf_mmap *map, |
| 1200 | struct auxtrace_record *itr, | 1197 | struct auxtrace_record *itr, |
| 1201 | struct perf_tool *tool, process_auxtrace_t fn, | 1198 | struct perf_tool *tool, process_auxtrace_t fn, |
| 1202 | bool snapshot, size_t snapshot_size) | 1199 | bool snapshot, size_t snapshot_size) |
| 1203 | { | 1200 | { |
| 1201 | struct auxtrace_mmap *mm = &map->auxtrace_mmap; | ||
| 1204 | u64 head, old = mm->prev, offset, ref; | 1202 | u64 head, old = mm->prev, offset, ref; |
| 1205 | unsigned char *data = mm->base; | 1203 | unsigned char *data = mm->base; |
| 1206 | size_t size, head_off, old_off, len1, len2, padding; | 1204 | size_t size, head_off, old_off, len1, len2, padding; |
| @@ -1287,7 +1285,7 @@ static int __auxtrace_mmap__read(struct auxtrace_mmap *mm, | |||
| 1287 | ev.auxtrace.tid = mm->tid; | 1285 | ev.auxtrace.tid = mm->tid; |
| 1288 | ev.auxtrace.cpu = mm->cpu; | 1286 | ev.auxtrace.cpu = mm->cpu; |
| 1289 | 1287 | ||
| 1290 | if (fn(tool, &ev, data1, len1, data2, len2)) | 1288 | if (fn(tool, map, &ev, data1, len1, data2, len2)) |
| 1291 | return -1; | 1289 | return -1; |
| 1292 | 1290 | ||
| 1293 | mm->prev = head; | 1291 | mm->prev = head; |
| @@ -1306,18 +1304,18 @@ static int __auxtrace_mmap__read(struct auxtrace_mmap *mm, | |||
| 1306 | return 1; | 1304 | return 1; |
| 1307 | } | 1305 | } |
| 1308 | 1306 | ||
| 1309 | int auxtrace_mmap__read(struct auxtrace_mmap *mm, struct auxtrace_record *itr, | 1307 | int auxtrace_mmap__read(struct perf_mmap *map, struct auxtrace_record *itr, |
| 1310 | struct perf_tool *tool, process_auxtrace_t fn) | 1308 | struct perf_tool *tool, process_auxtrace_t fn) |
| 1311 | { | 1309 | { |
| 1312 | return __auxtrace_mmap__read(mm, itr, tool, fn, false, 0); | 1310 | return __auxtrace_mmap__read(map, itr, tool, fn, false, 0); |
| 1313 | } | 1311 | } |
| 1314 | 1312 | ||
| 1315 | int auxtrace_mmap__read_snapshot(struct auxtrace_mmap *mm, | 1313 | int auxtrace_mmap__read_snapshot(struct perf_mmap *map, |
| 1316 | struct auxtrace_record *itr, | 1314 | struct auxtrace_record *itr, |
| 1317 | struct perf_tool *tool, process_auxtrace_t fn, | 1315 | struct perf_tool *tool, process_auxtrace_t fn, |
| 1318 | size_t snapshot_size) | 1316 | size_t snapshot_size) |
| 1319 | { | 1317 | { |
| 1320 | return __auxtrace_mmap__read(mm, itr, tool, fn, true, snapshot_size); | 1318 | return __auxtrace_mmap__read(map, itr, tool, fn, true, snapshot_size); |
| 1321 | } | 1319 | } |
| 1322 | 1320 | ||
| 1323 | /** | 1321 | /** |
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 71fc3bd74299..0a6ce9c4fc11 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h | |||
| @@ -33,6 +33,7 @@ union perf_event; | |||
| 33 | struct perf_session; | 33 | struct perf_session; |
| 34 | struct perf_evlist; | 34 | struct perf_evlist; |
| 35 | struct perf_tool; | 35 | struct perf_tool; |
| 36 | struct perf_mmap; | ||
| 36 | struct option; | 37 | struct option; |
| 37 | struct record_opts; | 38 | struct record_opts; |
| 38 | struct auxtrace_info_event; | 39 | struct auxtrace_info_event; |
| @@ -434,13 +435,14 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, | |||
| 434 | bool per_cpu); | 435 | bool per_cpu); |
| 435 | 436 | ||
| 436 | typedef int (*process_auxtrace_t)(struct perf_tool *tool, | 437 | typedef int (*process_auxtrace_t)(struct perf_tool *tool, |
| 438 | struct perf_mmap *map, | ||
| 437 | union perf_event *event, void *data1, | 439 | union perf_event *event, void *data1, |
| 438 | size_t len1, void *data2, size_t len2); | 440 | size_t len1, void *data2, size_t len2); |
| 439 | 441 | ||
| 440 | int auxtrace_mmap__read(struct auxtrace_mmap *mm, struct auxtrace_record *itr, | 442 | int auxtrace_mmap__read(struct perf_mmap *map, struct auxtrace_record *itr, |
| 441 | struct perf_tool *tool, process_auxtrace_t fn); | 443 | struct perf_tool *tool, process_auxtrace_t fn); |
| 442 | 444 | ||
| 443 | int auxtrace_mmap__read_snapshot(struct auxtrace_mmap *mm, | 445 | int auxtrace_mmap__read_snapshot(struct perf_mmap *map, |
| 444 | struct auxtrace_record *itr, | 446 | struct auxtrace_record *itr, |
| 445 | struct perf_tool *tool, process_auxtrace_t fn, | 447 | struct perf_tool *tool, process_auxtrace_t fn, |
| 446 | size_t snapshot_size); | 448 | size_t snapshot_size); |
| @@ -517,15 +519,12 @@ int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, | |||
| 517 | struct perf_tool *tool, | 519 | struct perf_tool *tool, |
| 518 | struct perf_session *session, | 520 | struct perf_session *session, |
| 519 | perf_event__handler_t process); | 521 | perf_event__handler_t process); |
| 520 | int perf_event__process_auxtrace_info(struct perf_tool *tool, | 522 | int perf_event__process_auxtrace_info(struct perf_session *session, |
| 521 | union perf_event *event, | 523 | union perf_event *event); |
| 522 | struct perf_session *session); | 524 | s64 perf_event__process_auxtrace(struct perf_session *session, |
| 523 | s64 perf_event__process_auxtrace(struct perf_tool *tool, | 525 | union perf_event *event); |
| 524 | union perf_event *event, | 526 | int perf_event__process_auxtrace_error(struct perf_session *session, |
| 525 | struct perf_session *session); | 527 | union perf_event *event); |
| 526 | int perf_event__process_auxtrace_error(struct perf_tool *tool, | ||
| 527 | union perf_event *event, | ||
| 528 | struct perf_session *session); | ||
| 529 | int itrace_parse_synth_opts(const struct option *opt, const char *str, | 528 | int itrace_parse_synth_opts(const struct option *opt, const char *str, |
| 530 | int unset); | 529 | int unset); |
| 531 | void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts); | 530 | void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts); |
| @@ -577,6 +576,23 @@ static inline void auxtrace__free(struct perf_session *session) | |||
| 577 | return session->auxtrace->free(session); | 576 | return session->auxtrace->free(session); |
| 578 | } | 577 | } |
| 579 | 578 | ||
| 579 | #define ITRACE_HELP \ | ||
| 580 | " i: synthesize instructions events\n" \ | ||
| 581 | " b: synthesize branches events\n" \ | ||
| 582 | " c: synthesize branches events (calls only)\n" \ | ||
| 583 | " r: synthesize branches events (returns only)\n" \ | ||
| 584 | " x: synthesize transactions events\n" \ | ||
| 585 | " w: synthesize ptwrite events\n" \ | ||
| 586 | " p: synthesize power events\n" \ | ||
| 587 | " e: synthesize error events\n" \ | ||
| 588 | " d: create a debug log\n" \ | ||
| 589 | " g[len]: synthesize a call chain (use with i or x)\n" \ | ||
| 590 | " l[len]: synthesize last branch entries (use with i or x)\n" \ | ||
| 591 | " sNUMBER: skip initial number of events\n" \ | ||
| 592 | " PERIOD[ns|us|ms|i|t]: specify period to sample stream\n" \ | ||
| 593 | " concatenate multiple options. Default is ibxwpe or cewp\n" | ||
| 594 | |||
| 595 | |||
| 580 | #else | 596 | #else |
| 581 | 597 | ||
| 582 | static inline struct auxtrace_record * | 598 | static inline struct auxtrace_record * |
| @@ -717,6 +733,8 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, | |||
| 717 | struct perf_evlist *evlist, int idx, | 733 | struct perf_evlist *evlist, int idx, |
| 718 | bool per_cpu); | 734 | bool per_cpu); |
| 719 | 735 | ||
| 736 | #define ITRACE_HELP "" | ||
| 737 | |||
| 720 | #endif | 738 | #endif |
| 721 | 739 | ||
| 722 | #endif | 740 | #endif |
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 47aac41349a2..f9ae1a993806 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c | |||
| @@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const cha | |||
| 1615 | int bpf__setup_stdout(struct perf_evlist *evlist) | 1615 | int bpf__setup_stdout(struct perf_evlist *evlist) |
| 1616 | { | 1616 | { |
| 1617 | struct perf_evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__"); | 1617 | struct perf_evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__"); |
| 1618 | return IS_ERR(evsel) ? PTR_ERR(evsel) : 0; | 1618 | return PTR_ERR_OR_ZERO(evsel); |
| 1619 | } | 1619 | } |
| 1620 | 1620 | ||
| 1621 | #define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START) | 1621 | #define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START) |
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index abd38abf1d91..2a36fab76994 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c | |||
| @@ -182,20 +182,20 @@ err_put_field: | |||
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | static struct bt_ctf_field_type* | 184 | static struct bt_ctf_field_type* |
| 185 | get_tracepoint_field_type(struct ctf_writer *cw, struct format_field *field) | 185 | get_tracepoint_field_type(struct ctf_writer *cw, struct tep_format_field *field) |
| 186 | { | 186 | { |
| 187 | unsigned long flags = field->flags; | 187 | unsigned long flags = field->flags; |
| 188 | 188 | ||
| 189 | if (flags & FIELD_IS_STRING) | 189 | if (flags & TEP_FIELD_IS_STRING) |
| 190 | return cw->data.string; | 190 | return cw->data.string; |
| 191 | 191 | ||
| 192 | if (!(flags & FIELD_IS_SIGNED)) { | 192 | if (!(flags & TEP_FIELD_IS_SIGNED)) { |
| 193 | /* unsigned long are mostly pointers */ | 193 | /* unsigned long are mostly pointers */ |
| 194 | if (flags & FIELD_IS_LONG || flags & FIELD_IS_POINTER) | 194 | if (flags & TEP_FIELD_IS_LONG || flags & TEP_FIELD_IS_POINTER) |
| 195 | return cw->data.u64_hex; | 195 | return cw->data.u64_hex; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | if (flags & FIELD_IS_SIGNED) { | 198 | if (flags & TEP_FIELD_IS_SIGNED) { |
| 199 | if (field->size == 8) | 199 | if (field->size == 8) |
| 200 | return cw->data.s64; | 200 | return cw->data.s64; |
| 201 | else | 201 | else |
| @@ -287,7 +287,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 287 | struct bt_ctf_event_class *event_class, | 287 | struct bt_ctf_event_class *event_class, |
| 288 | struct bt_ctf_event *event, | 288 | struct bt_ctf_event *event, |
| 289 | struct perf_sample *sample, | 289 | struct perf_sample *sample, |
| 290 | struct format_field *fmtf) | 290 | struct tep_format_field *fmtf) |
| 291 | { | 291 | { |
| 292 | struct bt_ctf_field_type *type; | 292 | struct bt_ctf_field_type *type; |
| 293 | struct bt_ctf_field *array_field; | 293 | struct bt_ctf_field *array_field; |
| @@ -304,10 +304,10 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 304 | name = fmtf->alias; | 304 | name = fmtf->alias; |
| 305 | offset = fmtf->offset; | 305 | offset = fmtf->offset; |
| 306 | len = fmtf->size; | 306 | len = fmtf->size; |
| 307 | if (flags & FIELD_IS_STRING) | 307 | if (flags & TEP_FIELD_IS_STRING) |
| 308 | flags &= ~FIELD_IS_ARRAY; | 308 | flags &= ~TEP_FIELD_IS_ARRAY; |
| 309 | 309 | ||
| 310 | if (flags & FIELD_IS_DYNAMIC) { | 310 | if (flags & TEP_FIELD_IS_DYNAMIC) { |
| 311 | unsigned long long tmp_val; | 311 | unsigned long long tmp_val; |
| 312 | 312 | ||
| 313 | tmp_val = tep_read_number(fmtf->event->pevent, | 313 | tmp_val = tep_read_number(fmtf->event->pevent, |
| @@ -317,7 +317,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 317 | offset &= 0xffff; | 317 | offset &= 0xffff; |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | if (flags & FIELD_IS_ARRAY) { | 320 | if (flags & TEP_FIELD_IS_ARRAY) { |
| 321 | 321 | ||
| 322 | type = bt_ctf_event_class_get_field_by_name( | 322 | type = bt_ctf_event_class_get_field_by_name( |
| 323 | event_class, name); | 323 | event_class, name); |
| @@ -338,7 +338,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 338 | type = get_tracepoint_field_type(cw, fmtf); | 338 | type = get_tracepoint_field_type(cw, fmtf); |
| 339 | 339 | ||
| 340 | for (i = 0; i < n_items; i++) { | 340 | for (i = 0; i < n_items; i++) { |
| 341 | if (flags & FIELD_IS_ARRAY) | 341 | if (flags & TEP_FIELD_IS_ARRAY) |
| 342 | field = bt_ctf_field_array_get_field(array_field, i); | 342 | field = bt_ctf_field_array_get_field(array_field, i); |
| 343 | else | 343 | else |
| 344 | field = bt_ctf_field_create(type); | 344 | field = bt_ctf_field_create(type); |
| @@ -348,7 +348,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 348 | return -1; | 348 | return -1; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | if (flags & FIELD_IS_STRING) | 351 | if (flags & TEP_FIELD_IS_STRING) |
| 352 | ret = string_set_value(field, data + offset + i * len); | 352 | ret = string_set_value(field, data + offset + i * len); |
| 353 | else { | 353 | else { |
| 354 | unsigned long long value_int; | 354 | unsigned long long value_int; |
| @@ -357,7 +357,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 357 | fmtf->event->pevent, | 357 | fmtf->event->pevent, |
| 358 | data + offset + i * len, len); | 358 | data + offset + i * len, len); |
| 359 | 359 | ||
| 360 | if (!(flags & FIELD_IS_SIGNED)) | 360 | if (!(flags & TEP_FIELD_IS_SIGNED)) |
| 361 | ret = bt_ctf_field_unsigned_integer_set_value( | 361 | ret = bt_ctf_field_unsigned_integer_set_value( |
| 362 | field, value_int); | 362 | field, value_int); |
| 363 | else | 363 | else |
| @@ -369,7 +369,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 369 | pr_err("failed to set file value %s\n", name); | 369 | pr_err("failed to set file value %s\n", name); |
| 370 | goto err_put_field; | 370 | goto err_put_field; |
| 371 | } | 371 | } |
| 372 | if (!(flags & FIELD_IS_ARRAY)) { | 372 | if (!(flags & TEP_FIELD_IS_ARRAY)) { |
| 373 | ret = bt_ctf_event_set_payload(event, name, field); | 373 | ret = bt_ctf_event_set_payload(event, name, field); |
| 374 | if (ret) { | 374 | if (ret) { |
| 375 | pr_err("failed to set payload %s\n", name); | 375 | pr_err("failed to set payload %s\n", name); |
| @@ -378,7 +378,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
| 378 | } | 378 | } |
| 379 | bt_ctf_field_put(field); | 379 | bt_ctf_field_put(field); |
| 380 | } | 380 | } |
| 381 | if (flags & FIELD_IS_ARRAY) { | 381 | if (flags & TEP_FIELD_IS_ARRAY) { |
| 382 | ret = bt_ctf_event_set_payload(event, name, array_field); | 382 | ret = bt_ctf_event_set_payload(event, name, array_field); |
| 383 | if (ret) { | 383 | if (ret) { |
| 384 | pr_err("Failed add payload array %s\n", name); | 384 | pr_err("Failed add payload array %s\n", name); |
| @@ -396,10 +396,10 @@ err_put_field: | |||
| 396 | static int add_tracepoint_fields_values(struct ctf_writer *cw, | 396 | static int add_tracepoint_fields_values(struct ctf_writer *cw, |
| 397 | struct bt_ctf_event_class *event_class, | 397 | struct bt_ctf_event_class *event_class, |
| 398 | struct bt_ctf_event *event, | 398 | struct bt_ctf_event *event, |
| 399 | struct format_field *fields, | 399 | struct tep_format_field *fields, |
| 400 | struct perf_sample *sample) | 400 | struct perf_sample *sample) |
| 401 | { | 401 | { |
| 402 | struct format_field *field; | 402 | struct tep_format_field *field; |
| 403 | int ret; | 403 | int ret; |
| 404 | 404 | ||
| 405 | for (field = fields; field; field = field->next) { | 405 | for (field = fields; field; field = field->next) { |
| @@ -417,8 +417,8 @@ static int add_tracepoint_values(struct ctf_writer *cw, | |||
| 417 | struct perf_evsel *evsel, | 417 | struct perf_evsel *evsel, |
| 418 | struct perf_sample *sample) | 418 | struct perf_sample *sample) |
| 419 | { | 419 | { |
| 420 | struct format_field *common_fields = evsel->tp_format->format.common_fields; | 420 | struct tep_format_field *common_fields = evsel->tp_format->format.common_fields; |
| 421 | struct format_field *fields = evsel->tp_format->format.fields; | 421 | struct tep_format_field *fields = evsel->tp_format->format.fields; |
| 422 | int ret; | 422 | int ret; |
| 423 | 423 | ||
| 424 | ret = add_tracepoint_fields_values(cw, event_class, event, | 424 | ret = add_tracepoint_fields_values(cw, event_class, event, |
| @@ -970,7 +970,7 @@ out: | |||
| 970 | 970 | ||
| 971 | static int event_class_add_field(struct bt_ctf_event_class *event_class, | 971 | static int event_class_add_field(struct bt_ctf_event_class *event_class, |
| 972 | struct bt_ctf_field_type *type, | 972 | struct bt_ctf_field_type *type, |
| 973 | struct format_field *field) | 973 | struct tep_format_field *field) |
| 974 | { | 974 | { |
| 975 | struct bt_ctf_field_type *t = NULL; | 975 | struct bt_ctf_field_type *t = NULL; |
| 976 | char *name; | 976 | char *name; |
| @@ -1009,10 +1009,10 @@ static int event_class_add_field(struct bt_ctf_event_class *event_class, | |||
| 1009 | } | 1009 | } |
| 1010 | 1010 | ||
| 1011 | static int add_tracepoint_fields_types(struct ctf_writer *cw, | 1011 | static int add_tracepoint_fields_types(struct ctf_writer *cw, |
| 1012 | struct format_field *fields, | 1012 | struct tep_format_field *fields, |
| 1013 | struct bt_ctf_event_class *event_class) | 1013 | struct bt_ctf_event_class *event_class) |
| 1014 | { | 1014 | { |
| 1015 | struct format_field *field; | 1015 | struct tep_format_field *field; |
| 1016 | int ret; | 1016 | int ret; |
| 1017 | 1017 | ||
| 1018 | for (field = fields; field; field = field->next) { | 1018 | for (field = fields; field; field = field->next) { |
| @@ -1030,15 +1030,15 @@ static int add_tracepoint_fields_types(struct ctf_writer *cw, | |||
| 1030 | * type and don't care that it is an array. What we don't | 1030 | * type and don't care that it is an array. What we don't |
| 1031 | * support is an array of strings. | 1031 | * support is an array of strings. |
| 1032 | */ | 1032 | */ |
| 1033 | if (flags & FIELD_IS_STRING) | 1033 | if (flags & TEP_FIELD_IS_STRING) |
| 1034 | flags &= ~FIELD_IS_ARRAY; | 1034 | flags &= ~TEP_FIELD_IS_ARRAY; |
| 1035 | 1035 | ||
| 1036 | if (flags & FIELD_IS_ARRAY) | 1036 | if (flags & TEP_FIELD_IS_ARRAY) |
| 1037 | type = bt_ctf_field_type_array_create(type, field->arraylen); | 1037 | type = bt_ctf_field_type_array_create(type, field->arraylen); |
| 1038 | 1038 | ||
| 1039 | ret = event_class_add_field(event_class, type, field); | 1039 | ret = event_class_add_field(event_class, type, field); |
| 1040 | 1040 | ||
| 1041 | if (flags & FIELD_IS_ARRAY) | 1041 | if (flags & TEP_FIELD_IS_ARRAY) |
| 1042 | bt_ctf_field_type_put(type); | 1042 | bt_ctf_field_type_put(type); |
| 1043 | 1043 | ||
| 1044 | if (ret) { | 1044 | if (ret) { |
| @@ -1055,8 +1055,8 @@ static int add_tracepoint_types(struct ctf_writer *cw, | |||
| 1055 | struct perf_evsel *evsel, | 1055 | struct perf_evsel *evsel, |
| 1056 | struct bt_ctf_event_class *class) | 1056 | struct bt_ctf_event_class *class) |
| 1057 | { | 1057 | { |
| 1058 | struct format_field *common_fields = evsel->tp_format->format.common_fields; | 1058 | struct tep_format_field *common_fields = evsel->tp_format->format.common_fields; |
| 1059 | struct format_field *fields = evsel->tp_format->format.fields; | 1059 | struct tep_format_field *fields = evsel->tp_format->format.fields; |
| 1060 | int ret; | 1060 | int ret; |
| 1061 | 1061 | ||
| 1062 | ret = add_tracepoint_fields_types(cw, common_fields, class); | 1062 | ret = add_tracepoint_fields_types(cw, common_fields, class); |
| @@ -1578,7 +1578,7 @@ int bt_convert__perf2ctf(const char *input, const char *path, | |||
| 1578 | { | 1578 | { |
| 1579 | struct perf_session *session; | 1579 | struct perf_session *session; |
| 1580 | struct perf_data data = { | 1580 | struct perf_data data = { |
| 1581 | .file.path = input, | 1581 | .file = { .path = input, .fd = -1 }, |
| 1582 | .mode = PERF_DATA_MODE_READ, | 1582 | .mode = PERF_DATA_MODE_READ, |
| 1583 | .force = opts->force, | 1583 | .force = opts->force, |
| 1584 | }; | 1584 | }; |
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index 7123746edcf4..69fbb0a72d0c 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c | |||
| @@ -463,6 +463,28 @@ int db_export__branch_types(struct db_export *dbe) | |||
| 463 | if (err) | 463 | if (err) |
| 464 | break; | 464 | break; |
| 465 | } | 465 | } |
| 466 | |||
| 467 | /* Add trace begin / end variants */ | ||
| 468 | for (i = 0; branch_types[i].name ; i++) { | ||
| 469 | const char *name = branch_types[i].name; | ||
| 470 | u32 type = branch_types[i].branch_type; | ||
| 471 | char buf[64]; | ||
| 472 | |||
| 473 | if (type == PERF_IP_FLAG_BRANCH || | ||
| 474 | (type & (PERF_IP_FLAG_TRACE_BEGIN | PERF_IP_FLAG_TRACE_END))) | ||
| 475 | continue; | ||
| 476 | |||
| 477 | snprintf(buf, sizeof(buf), "trace begin / %s", name); | ||
| 478 | err = db_export__branch_type(dbe, type | PERF_IP_FLAG_TRACE_BEGIN, buf); | ||
| 479 | if (err) | ||
| 480 | break; | ||
| 481 | |||
| 482 | snprintf(buf, sizeof(buf), "%s / trace end", name); | ||
| 483 | err = db_export__branch_type(dbe, type | PERF_IP_FLAG_TRACE_END, buf); | ||
| 484 | if (err) | ||
| 485 | break; | ||
| 486 | } | ||
| 487 | |||
| 466 | return err; | 488 | return err; |
| 467 | } | 489 | } |
| 468 | 490 | ||
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1a61628a1c12..cb7f01059940 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -2682,7 +2682,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, | |||
| 2682 | return 0; | 2682 | return 0; |
| 2683 | } | 2683 | } |
| 2684 | 2684 | ||
| 2685 | struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name) | 2685 | struct tep_format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name) |
| 2686 | { | 2686 | { |
| 2687 | return tep_find_field(evsel->tp_format, name); | 2687 | return tep_find_field(evsel->tp_format, name); |
| 2688 | } | 2688 | } |
| @@ -2690,7 +2690,7 @@ struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *nam | |||
| 2690 | void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, | 2690 | void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, |
| 2691 | const char *name) | 2691 | const char *name) |
| 2692 | { | 2692 | { |
| 2693 | struct format_field *field = perf_evsel__field(evsel, name); | 2693 | struct tep_format_field *field = perf_evsel__field(evsel, name); |
| 2694 | int offset; | 2694 | int offset; |
| 2695 | 2695 | ||
| 2696 | if (!field) | 2696 | if (!field) |
| @@ -2698,7 +2698,7 @@ void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, | |||
| 2698 | 2698 | ||
| 2699 | offset = field->offset; | 2699 | offset = field->offset; |
| 2700 | 2700 | ||
| 2701 | if (field->flags & FIELD_IS_DYNAMIC) { | 2701 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 2702 | offset = *(int *)(sample->raw_data + field->offset); | 2702 | offset = *(int *)(sample->raw_data + field->offset); |
| 2703 | offset &= 0xffff; | 2703 | offset &= 0xffff; |
| 2704 | } | 2704 | } |
| @@ -2706,7 +2706,7 @@ void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, | |||
| 2706 | return sample->raw_data + offset; | 2706 | return sample->raw_data + offset; |
| 2707 | } | 2707 | } |
| 2708 | 2708 | ||
| 2709 | u64 format_field__intval(struct format_field *field, struct perf_sample *sample, | 2709 | u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample, |
| 2710 | bool needs_swap) | 2710 | bool needs_swap) |
| 2711 | { | 2711 | { |
| 2712 | u64 value; | 2712 | u64 value; |
| @@ -2748,7 +2748,7 @@ u64 format_field__intval(struct format_field *field, struct perf_sample *sample, | |||
| 2748 | u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample, | 2748 | u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample, |
| 2749 | const char *name) | 2749 | const char *name) |
| 2750 | { | 2750 | { |
| 2751 | struct format_field *field = perf_evsel__field(evsel, name); | 2751 | struct tep_format_field *field = perf_evsel__field(evsel, name); |
| 2752 | 2752 | ||
| 2753 | if (!field) | 2753 | if (!field) |
| 2754 | return 0; | 2754 | return 0; |
| @@ -2940,3 +2940,32 @@ struct perf_env *perf_evsel__env(struct perf_evsel *evsel) | |||
| 2940 | return evsel->evlist->env; | 2940 | return evsel->evlist->env; |
| 2941 | return NULL; | 2941 | return NULL; |
| 2942 | } | 2942 | } |
| 2943 | |||
| 2944 | static int store_evsel_ids(struct perf_evsel *evsel, struct perf_evlist *evlist) | ||
| 2945 | { | ||
| 2946 | int cpu, thread; | ||
| 2947 | |||
| 2948 | for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { | ||
| 2949 | for (thread = 0; thread < xyarray__max_y(evsel->fd); | ||
| 2950 | thread++) { | ||
| 2951 | int fd = FD(evsel, cpu, thread); | ||
| 2952 | |||
| 2953 | if (perf_evlist__id_add_fd(evlist, evsel, | ||
| 2954 | cpu, thread, fd) < 0) | ||
| 2955 | return -1; | ||
| 2956 | } | ||
| 2957 | } | ||
| 2958 | |||
| 2959 | return 0; | ||
| 2960 | } | ||
| 2961 | |||
| 2962 | int perf_evsel__store_ids(struct perf_evsel *evsel, struct perf_evlist *evlist) | ||
| 2963 | { | ||
| 2964 | struct cpu_map *cpus = evsel->cpus; | ||
| 2965 | struct thread_map *threads = evsel->threads; | ||
| 2966 | |||
| 2967 | if (perf_evsel__alloc_id(evsel, cpus->nr, threads->nr)) | ||
| 2968 | return -ENOMEM; | ||
| 2969 | |||
| 2970 | return store_evsel_ids(evsel, evlist); | ||
| 2971 | } | ||
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 163c960614d3..4107c39f4a54 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
| @@ -102,7 +102,7 @@ struct perf_evsel { | |||
| 102 | char *name; | 102 | char *name; |
| 103 | double scale; | 103 | double scale; |
| 104 | const char *unit; | 104 | const char *unit; |
| 105 | struct event_format *tp_format; | 105 | struct tep_event_format *tp_format; |
| 106 | off_t id_offset; | 106 | off_t id_offset; |
| 107 | struct perf_stat_evsel *stats; | 107 | struct perf_stat_evsel *stats; |
| 108 | void *priv; | 108 | void *priv; |
| @@ -211,7 +211,7 @@ static inline struct perf_evsel *perf_evsel__newtp(const char *sys, const char * | |||
| 211 | 211 | ||
| 212 | struct perf_evsel *perf_evsel__new_cycles(bool precise); | 212 | struct perf_evsel *perf_evsel__new_cycles(bool precise); |
| 213 | 213 | ||
| 214 | struct event_format *event_format__new(const char *sys, const char *name); | 214 | struct tep_event_format *event_format__new(const char *sys, const char *name); |
| 215 | 215 | ||
| 216 | void perf_evsel__init(struct perf_evsel *evsel, | 216 | void perf_evsel__init(struct perf_evsel *evsel, |
| 217 | struct perf_event_attr *attr, int idx); | 217 | struct perf_event_attr *attr, int idx); |
| @@ -296,11 +296,11 @@ static inline char *perf_evsel__strval(struct perf_evsel *evsel, | |||
| 296 | return perf_evsel__rawptr(evsel, sample, name); | 296 | return perf_evsel__rawptr(evsel, sample, name); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | struct format_field; | 299 | struct tep_format_field; |
| 300 | 300 | ||
| 301 | u64 format_field__intval(struct format_field *field, struct perf_sample *sample, bool needs_swap); | 301 | u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample, bool needs_swap); |
| 302 | 302 | ||
| 303 | struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name); | 303 | struct tep_format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name); |
| 304 | 304 | ||
| 305 | #define perf_evsel__match(evsel, t, c) \ | 305 | #define perf_evsel__match(evsel, t, c) \ |
| 306 | (evsel->attr.type == PERF_TYPE_##t && \ | 306 | (evsel->attr.type == PERF_TYPE_##t && \ |
| @@ -481,4 +481,5 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, | |||
| 481 | 481 | ||
| 482 | struct perf_env *perf_evsel__env(struct perf_evsel *evsel); | 482 | struct perf_env *perf_evsel__env(struct perf_evsel *evsel); |
| 483 | 483 | ||
| 484 | int perf_evsel__store_ids(struct perf_evsel *evsel, struct perf_evlist *evlist); | ||
| 484 | #endif /* __PERF_EVSEL_H */ | 485 | #endif /* __PERF_EVSEL_H */ |
diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c index 06dfb027879d..0d0a4c6f368b 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c | |||
| @@ -73,7 +73,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | if (details->trace_fields) { | 75 | if (details->trace_fields) { |
| 76 | struct format_field *field; | 76 | struct tep_format_field *field; |
| 77 | 77 | ||
| 78 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) { | 78 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) { |
| 79 | printed += comma_fprintf(fp, &first, " (not a tracepoint)"); | 79 | printed += comma_fprintf(fp, &first, " (not a tracepoint)"); |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 3cadc252dd89..1ec1d9bc2d63 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
| @@ -3206,7 +3206,7 @@ static int read_attr(int fd, struct perf_header *ph, | |||
| 3206 | static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, | 3206 | static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, |
| 3207 | struct tep_handle *pevent) | 3207 | struct tep_handle *pevent) |
| 3208 | { | 3208 | { |
| 3209 | struct event_format *event; | 3209 | struct tep_event_format *event; |
| 3210 | char bf[128]; | 3210 | char bf[128]; |
| 3211 | 3211 | ||
| 3212 | /* already prepared */ | 3212 | /* already prepared */ |
| @@ -3448,10 +3448,10 @@ int perf_event__synthesize_features(struct perf_tool *tool, | |||
| 3448 | return ret; | 3448 | return ret; |
| 3449 | } | 3449 | } |
| 3450 | 3450 | ||
| 3451 | int perf_event__process_feature(struct perf_tool *tool, | 3451 | int perf_event__process_feature(struct perf_session *session, |
| 3452 | union perf_event *event, | 3452 | union perf_event *event) |
| 3453 | struct perf_session *session __maybe_unused) | ||
| 3454 | { | 3453 | { |
| 3454 | struct perf_tool *tool = session->tool; | ||
| 3455 | struct feat_fd ff = { .fd = 0 }; | 3455 | struct feat_fd ff = { .fd = 0 }; |
| 3456 | struct feature_event *fe = (struct feature_event *)event; | 3456 | struct feature_event *fe = (struct feature_event *)event; |
| 3457 | int type = fe->header.type; | 3457 | int type = fe->header.type; |
| @@ -3637,13 +3637,13 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp) | |||
| 3637 | } | 3637 | } |
| 3638 | 3638 | ||
| 3639 | int perf_event__synthesize_attrs(struct perf_tool *tool, | 3639 | int perf_event__synthesize_attrs(struct perf_tool *tool, |
| 3640 | struct perf_session *session, | 3640 | struct perf_evlist *evlist, |
| 3641 | perf_event__handler_t process) | 3641 | perf_event__handler_t process) |
| 3642 | { | 3642 | { |
| 3643 | struct perf_evsel *evsel; | 3643 | struct perf_evsel *evsel; |
| 3644 | int err = 0; | 3644 | int err = 0; |
| 3645 | 3645 | ||
| 3646 | evlist__for_each_entry(session->evlist, evsel) { | 3646 | evlist__for_each_entry(evlist, evsel) { |
| 3647 | err = perf_event__synthesize_attr(tool, &evsel->attr, evsel->ids, | 3647 | err = perf_event__synthesize_attr(tool, &evsel->attr, evsel->ids, |
| 3648 | evsel->id, process); | 3648 | evsel->id, process); |
| 3649 | if (err) { | 3649 | if (err) { |
| @@ -3856,9 +3856,8 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, | |||
| 3856 | return aligned_size; | 3856 | return aligned_size; |
| 3857 | } | 3857 | } |
| 3858 | 3858 | ||
| 3859 | int perf_event__process_tracing_data(struct perf_tool *tool __maybe_unused, | 3859 | int perf_event__process_tracing_data(struct perf_session *session, |
| 3860 | union perf_event *event, | 3860 | union perf_event *event) |
| 3861 | struct perf_session *session) | ||
| 3862 | { | 3861 | { |
| 3863 | ssize_t size_read, padding, size = event->tracing_data.size; | 3862 | ssize_t size_read, padding, size = event->tracing_data.size; |
| 3864 | int fd = perf_data__fd(session->data); | 3863 | int fd = perf_data__fd(session->data); |
| @@ -3924,9 +3923,8 @@ int perf_event__synthesize_build_id(struct perf_tool *tool, | |||
| 3924 | return err; | 3923 | return err; |
| 3925 | } | 3924 | } |
| 3926 | 3925 | ||
| 3927 | int perf_event__process_build_id(struct perf_tool *tool __maybe_unused, | 3926 | int perf_event__process_build_id(struct perf_session *session, |
| 3928 | union perf_event *event, | 3927 | union perf_event *event) |
| 3929 | struct perf_session *session) | ||
| 3930 | { | 3928 | { |
| 3931 | __event_process_build_id(&event->build_id, | 3929 | __event_process_build_id(&event->build_id, |
| 3932 | event->build_id.filename, | 3930 | event->build_id.filename, |
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 6d7fe44aadc0..e17903caa71d 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h | |||
| @@ -116,15 +116,14 @@ int perf_event__synthesize_extra_attr(struct perf_tool *tool, | |||
| 116 | perf_event__handler_t process, | 116 | perf_event__handler_t process, |
| 117 | bool is_pipe); | 117 | bool is_pipe); |
| 118 | 118 | ||
| 119 | int perf_event__process_feature(struct perf_tool *tool, | 119 | int perf_event__process_feature(struct perf_session *session, |
| 120 | union perf_event *event, | 120 | union perf_event *event); |
| 121 | struct perf_session *session); | ||
| 122 | 121 | ||
| 123 | int perf_event__synthesize_attr(struct perf_tool *tool, | 122 | int perf_event__synthesize_attr(struct perf_tool *tool, |
| 124 | struct perf_event_attr *attr, u32 ids, u64 *id, | 123 | struct perf_event_attr *attr, u32 ids, u64 *id, |
| 125 | perf_event__handler_t process); | 124 | perf_event__handler_t process); |
| 126 | int perf_event__synthesize_attrs(struct perf_tool *tool, | 125 | int perf_event__synthesize_attrs(struct perf_tool *tool, |
| 127 | struct perf_session *session, | 126 | struct perf_evlist *evlist, |
| 128 | perf_event__handler_t process); | 127 | perf_event__handler_t process); |
| 129 | int perf_event__synthesize_event_update_unit(struct perf_tool *tool, | 128 | int perf_event__synthesize_event_update_unit(struct perf_tool *tool, |
| 130 | struct perf_evsel *evsel, | 129 | struct perf_evsel *evsel, |
| @@ -148,17 +147,15 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp); | |||
| 148 | int perf_event__synthesize_tracing_data(struct perf_tool *tool, | 147 | int perf_event__synthesize_tracing_data(struct perf_tool *tool, |
| 149 | int fd, struct perf_evlist *evlist, | 148 | int fd, struct perf_evlist *evlist, |
| 150 | perf_event__handler_t process); | 149 | perf_event__handler_t process); |
| 151 | int perf_event__process_tracing_data(struct perf_tool *tool, | 150 | int perf_event__process_tracing_data(struct perf_session *session, |
| 152 | union perf_event *event, | 151 | union perf_event *event); |
| 153 | struct perf_session *session); | ||
| 154 | 152 | ||
| 155 | int perf_event__synthesize_build_id(struct perf_tool *tool, | 153 | int perf_event__synthesize_build_id(struct perf_tool *tool, |
| 156 | struct dso *pos, u16 misc, | 154 | struct dso *pos, u16 misc, |
| 157 | perf_event__handler_t process, | 155 | perf_event__handler_t process, |
| 158 | struct machine *machine); | 156 | struct machine *machine); |
| 159 | int perf_event__process_build_id(struct perf_tool *tool, | 157 | int perf_event__process_build_id(struct perf_session *session, |
| 160 | union perf_event *event, | 158 | union perf_event *event); |
| 161 | struct perf_session *session); | ||
| 162 | bool is_perf_magic(u64 magic); | 159 | bool is_perf_magic(u64 magic); |
| 163 | 160 | ||
| 164 | #define NAME_ALIGN 64 | 161 | #define NAME_ALIGN 64 |
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c index d404bed7003a..58f6a9ceb590 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | |||
| @@ -1165,7 +1165,7 @@ static int intel_pt_walk_tip(struct intel_pt_decoder *decoder) | |||
| 1165 | decoder->pge = false; | 1165 | decoder->pge = false; |
| 1166 | decoder->continuous_period = false; | 1166 | decoder->continuous_period = false; |
| 1167 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; | 1167 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; |
| 1168 | decoder->state.to_ip = 0; | 1168 | decoder->state.type |= INTEL_PT_TRACE_END; |
| 1169 | return 0; | 1169 | return 0; |
| 1170 | } | 1170 | } |
| 1171 | if (err == INTEL_PT_RETURN) | 1171 | if (err == INTEL_PT_RETURN) |
| @@ -1179,9 +1179,13 @@ static int intel_pt_walk_tip(struct intel_pt_decoder *decoder) | |||
| 1179 | decoder->continuous_period = false; | 1179 | decoder->continuous_period = false; |
| 1180 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; | 1180 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; |
| 1181 | decoder->state.from_ip = decoder->ip; | 1181 | decoder->state.from_ip = decoder->ip; |
| 1182 | decoder->state.to_ip = 0; | 1182 | if (decoder->packet.count == 0) { |
| 1183 | if (decoder->packet.count != 0) | 1183 | decoder->state.to_ip = 0; |
| 1184 | } else { | ||
| 1185 | decoder->state.to_ip = decoder->last_ip; | ||
| 1184 | decoder->ip = decoder->last_ip; | 1186 | decoder->ip = decoder->last_ip; |
| 1187 | } | ||
| 1188 | decoder->state.type |= INTEL_PT_TRACE_END; | ||
| 1185 | } else { | 1189 | } else { |
| 1186 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; | 1190 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; |
| 1187 | decoder->state.from_ip = decoder->ip; | 1191 | decoder->state.from_ip = decoder->ip; |
| @@ -1208,7 +1212,8 @@ static int intel_pt_walk_tip(struct intel_pt_decoder *decoder) | |||
| 1208 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; | 1212 | decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; |
| 1209 | decoder->ip = to_ip; | 1213 | decoder->ip = to_ip; |
| 1210 | decoder->state.from_ip = decoder->ip; | 1214 | decoder->state.from_ip = decoder->ip; |
| 1211 | decoder->state.to_ip = 0; | 1215 | decoder->state.to_ip = to_ip; |
| 1216 | decoder->state.type |= INTEL_PT_TRACE_END; | ||
| 1212 | return 0; | 1217 | return 0; |
| 1213 | } | 1218 | } |
| 1214 | intel_pt_log_at("ERROR: Conditional branch when expecting indirect branch", | 1219 | intel_pt_log_at("ERROR: Conditional branch when expecting indirect branch", |
| @@ -1640,14 +1645,15 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder) | |||
| 1640 | 1645 | ||
| 1641 | case INTEL_PT_TIP_PGD: | 1646 | case INTEL_PT_TIP_PGD: |
| 1642 | decoder->state.from_ip = decoder->ip; | 1647 | decoder->state.from_ip = decoder->ip; |
| 1643 | decoder->state.to_ip = 0; | 1648 | if (decoder->packet.count == 0) { |
| 1644 | if (decoder->packet.count != 0) { | 1649 | decoder->state.to_ip = 0; |
| 1650 | } else { | ||
| 1645 | intel_pt_set_ip(decoder); | 1651 | intel_pt_set_ip(decoder); |
| 1646 | intel_pt_log("Omitting PGD ip " x64_fmt "\n", | 1652 | decoder->state.to_ip = decoder->ip; |
| 1647 | decoder->ip); | ||
| 1648 | } | 1653 | } |
| 1649 | decoder->pge = false; | 1654 | decoder->pge = false; |
| 1650 | decoder->continuous_period = false; | 1655 | decoder->continuous_period = false; |
| 1656 | decoder->state.type |= INTEL_PT_TRACE_END; | ||
| 1651 | return 0; | 1657 | return 0; |
| 1652 | 1658 | ||
| 1653 | case INTEL_PT_TIP_PGE: | 1659 | case INTEL_PT_TIP_PGE: |
| @@ -1661,6 +1667,7 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder) | |||
| 1661 | intel_pt_set_ip(decoder); | 1667 | intel_pt_set_ip(decoder); |
| 1662 | decoder->state.to_ip = decoder->ip; | 1668 | decoder->state.to_ip = decoder->ip; |
| 1663 | } | 1669 | } |
| 1670 | decoder->state.type |= INTEL_PT_TRACE_BEGIN; | ||
| 1664 | return 0; | 1671 | return 0; |
| 1665 | 1672 | ||
| 1666 | case INTEL_PT_TIP: | 1673 | case INTEL_PT_TIP: |
| @@ -1739,6 +1746,7 @@ next: | |||
| 1739 | intel_pt_set_ip(decoder); | 1746 | intel_pt_set_ip(decoder); |
| 1740 | decoder->state.from_ip = 0; | 1747 | decoder->state.from_ip = 0; |
| 1741 | decoder->state.to_ip = decoder->ip; | 1748 | decoder->state.to_ip = decoder->ip; |
| 1749 | decoder->state.type |= INTEL_PT_TRACE_BEGIN; | ||
| 1742 | return 0; | 1750 | return 0; |
| 1743 | } | 1751 | } |
| 1744 | 1752 | ||
| @@ -2077,9 +2085,13 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder) | |||
| 2077 | decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; | 2085 | decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; |
| 2078 | if (intel_pt_have_ip(decoder)) | 2086 | if (intel_pt_have_ip(decoder)) |
| 2079 | intel_pt_set_ip(decoder); | 2087 | intel_pt_set_ip(decoder); |
| 2080 | if (decoder->ip) | 2088 | if (!decoder->ip) |
| 2081 | return 0; | 2089 | break; |
| 2082 | break; | 2090 | if (decoder->packet.type == INTEL_PT_TIP_PGE) |
| 2091 | decoder->state.type |= INTEL_PT_TRACE_BEGIN; | ||
| 2092 | if (decoder->packet.type == INTEL_PT_TIP_PGD) | ||
| 2093 | decoder->state.type |= INTEL_PT_TRACE_END; | ||
| 2094 | return 0; | ||
| 2083 | 2095 | ||
| 2084 | case INTEL_PT_FUP: | 2096 | case INTEL_PT_FUP: |
| 2085 | if (intel_pt_have_ip(decoder)) | 2097 | if (intel_pt_have_ip(decoder)) |
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h index 51c18d67f4ca..ed088d4726ba 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h | |||
| @@ -37,6 +37,8 @@ enum intel_pt_sample_type { | |||
| 37 | INTEL_PT_EX_STOP = 1 << 6, | 37 | INTEL_PT_EX_STOP = 1 << 6, |
| 38 | INTEL_PT_PWR_EXIT = 1 << 7, | 38 | INTEL_PT_PWR_EXIT = 1 << 7, |
| 39 | INTEL_PT_CBR_CHG = 1 << 8, | 39 | INTEL_PT_CBR_CHG = 1 << 8, |
| 40 | INTEL_PT_TRACE_BEGIN = 1 << 9, | ||
| 41 | INTEL_PT_TRACE_END = 1 << 10, | ||
| 40 | }; | 42 | }; |
| 41 | 43 | ||
| 42 | enum intel_pt_period_type { | 44 | enum intel_pt_period_type { |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index aec68908d604..48c1d415c6b0 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
| @@ -908,6 +908,11 @@ static void intel_pt_sample_flags(struct intel_pt_queue *ptq) | |||
| 908 | ptq->insn_len = ptq->state->insn_len; | 908 | ptq->insn_len = ptq->state->insn_len; |
| 909 | memcpy(ptq->insn, ptq->state->insn, INTEL_PT_INSN_BUF_SZ); | 909 | memcpy(ptq->insn, ptq->state->insn, INTEL_PT_INSN_BUF_SZ); |
| 910 | } | 910 | } |
| 911 | |||
| 912 | if (ptq->state->type & INTEL_PT_TRACE_BEGIN) | ||
| 913 | ptq->flags |= PERF_IP_FLAG_TRACE_BEGIN; | ||
| 914 | if (ptq->state->type & INTEL_PT_TRACE_END) | ||
| 915 | ptq->flags |= PERF_IP_FLAG_TRACE_END; | ||
| 911 | } | 916 | } |
| 912 | 917 | ||
| 913 | static int intel_pt_setup_queue(struct intel_pt *pt, | 918 | static int intel_pt_setup_queue(struct intel_pt *pt, |
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c index 19262f98cd4e..5b0b60f00275 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ | 19 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ |
| 20 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ | 20 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ |
| 21 | "-DLINUX_VERSION_CODE=$LINUX_VERSION_CODE " \ | 21 | "-DLINUX_VERSION_CODE=$LINUX_VERSION_CODE " \ |
| 22 | "$CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS " \ | 22 | "$CLANG_OPTIONS $PERF_BPF_INC_OPTIONS $KERNEL_INC_OPTIONS " \ |
| 23 | "-Wno-unused-value -Wno-pointer-sign " \ | 23 | "-Wno-unused-value -Wno-pointer-sign " \ |
| 24 | "-working-directory $WORKING_DIR " \ | 24 | "-working-directory $WORKING_DIR " \ |
| 25 | "-c \"$CLANG_SOURCE\" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE" | 25 | "-c \"$CLANG_SOURCE\" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE" |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 6a6929f208b4..354e54550d2b 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
| @@ -320,12 +320,11 @@ int map__load(struct map *map) | |||
| 320 | build_id__sprintf(map->dso->build_id, | 320 | build_id__sprintf(map->dso->build_id, |
| 321 | sizeof(map->dso->build_id), | 321 | sizeof(map->dso->build_id), |
| 322 | sbuild_id); | 322 | sbuild_id); |
| 323 | pr_warning("%s with build id %s not found", | 323 | pr_debug("%s with build id %s not found", name, sbuild_id); |
| 324 | name, sbuild_id); | ||
| 325 | } else | 324 | } else |
| 326 | pr_warning("Failed to open %s", name); | 325 | pr_debug("Failed to open %s", name); |
| 327 | 326 | ||
| 328 | pr_warning(", continuing without symbols\n"); | 327 | pr_debug(", continuing without symbols\n"); |
| 329 | return -1; | 328 | return -1; |
| 330 | } else if (nr == 0) { | 329 | } else if (nr == 0) { |
| 331 | #ifdef HAVE_LIBELF_SUPPORT | 330 | #ifdef HAVE_LIBELF_SUPPORT |
| @@ -334,12 +333,11 @@ int map__load(struct map *map) | |||
| 334 | 333 | ||
| 335 | if (len > sizeof(DSO__DELETED) && | 334 | if (len > sizeof(DSO__DELETED) && |
| 336 | strcmp(name + real_len + 1, DSO__DELETED) == 0) { | 335 | strcmp(name + real_len + 1, DSO__DELETED) == 0) { |
| 337 | pr_warning("%.*s was updated (is prelink enabled?). " | 336 | pr_debug("%.*s was updated (is prelink enabled?). " |
| 338 | "Restart the long running apps that use it!\n", | 337 | "Restart the long running apps that use it!\n", |
| 339 | (int)real_len, name); | 338 | (int)real_len, name); |
| 340 | } else { | 339 | } else { |
| 341 | pr_warning("no symbols found in %s, maybe install " | 340 | pr_debug("no symbols found in %s, maybe install a debug package?\n", name); |
| 342 | "a debug package?\n", name); | ||
| 343 | } | 341 | } |
| 344 | #endif | 342 | #endif |
| 345 | return -1; | 343 | return -1; |
| @@ -712,8 +710,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp | |||
| 712 | if (verbose >= 2) { | 710 | if (verbose >= 2) { |
| 713 | 711 | ||
| 714 | if (use_browser) { | 712 | if (use_browser) { |
| 715 | pr_warning("overlapping maps in %s " | 713 | pr_debug("overlapping maps in %s (disable tui for more info)\n", |
| 716 | "(disable tui for more info)\n", | ||
| 717 | map->dso->name); | 714 | map->dso->name); |
| 718 | } else { | 715 | } else { |
| 719 | fputs("overlapping maps:\n", fp); | 716 | fputs("overlapping maps:\n", fp); |
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 215f69f41672..cdb95b3a1213 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c | |||
| @@ -281,7 +281,7 @@ int perf_mmap__read_init(struct perf_mmap *map) | |||
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | int perf_mmap__push(struct perf_mmap *md, void *to, | 283 | int perf_mmap__push(struct perf_mmap *md, void *to, |
| 284 | int push(void *to, void *buf, size_t size)) | 284 | int push(struct perf_mmap *map, void *to, void *buf, size_t size)) |
| 285 | { | 285 | { |
| 286 | u64 head = perf_mmap__read_head(md); | 286 | u64 head = perf_mmap__read_head(md); |
| 287 | unsigned char *data = md->base + page_size; | 287 | unsigned char *data = md->base + page_size; |
| @@ -300,7 +300,7 @@ int perf_mmap__push(struct perf_mmap *md, void *to, | |||
| 300 | size = md->mask + 1 - (md->start & md->mask); | 300 | size = md->mask + 1 - (md->start & md->mask); |
| 301 | md->start += size; | 301 | md->start += size; |
| 302 | 302 | ||
| 303 | if (push(to, buf, size) < 0) { | 303 | if (push(md, to, buf, size) < 0) { |
| 304 | rc = -1; | 304 | rc = -1; |
| 305 | goto out; | 305 | goto out; |
| 306 | } | 306 | } |
| @@ -310,7 +310,7 @@ int perf_mmap__push(struct perf_mmap *md, void *to, | |||
| 310 | size = md->end - md->start; | 310 | size = md->end - md->start; |
| 311 | md->start += size; | 311 | md->start += size; |
| 312 | 312 | ||
| 313 | if (push(to, buf, size) < 0) { | 313 | if (push(md, to, buf, size) < 0) { |
| 314 | rc = -1; | 314 | rc = -1; |
| 315 | goto out; | 315 | goto out; |
| 316 | } | 316 | } |
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 05a6d47c7956..e603314dc792 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h | |||
| @@ -93,7 +93,7 @@ union perf_event *perf_mmap__read_forward(struct perf_mmap *map); | |||
| 93 | union perf_event *perf_mmap__read_event(struct perf_mmap *map); | 93 | union perf_event *perf_mmap__read_event(struct perf_mmap *map); |
| 94 | 94 | ||
| 95 | int perf_mmap__push(struct perf_mmap *md, void *to, | 95 | int perf_mmap__push(struct perf_mmap *md, void *to, |
| 96 | int push(void *to, void *buf, size_t size)); | 96 | int push(struct perf_mmap *map, void *to, void *buf, size_t size)); |
| 97 | 97 | ||
| 98 | size_t perf_mmap__mmap_len(struct perf_mmap *map); | 98 | size_t perf_mmap__mmap_len(struct perf_mmap *map); |
| 99 | 99 | ||
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index bad9e0296e9a..1904e7f6ec84 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c | |||
| @@ -80,14 +80,20 @@ static union perf_event *dup_event(struct ordered_events *oe, | |||
| 80 | return oe->copy_on_queue ? __dup_event(oe, event) : event; | 80 | return oe->copy_on_queue ? __dup_event(oe, event) : event; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | static void free_dup_event(struct ordered_events *oe, union perf_event *event) | 83 | static void __free_dup_event(struct ordered_events *oe, union perf_event *event) |
| 84 | { | 84 | { |
| 85 | if (event && oe->copy_on_queue) { | 85 | if (event) { |
| 86 | oe->cur_alloc_size -= event->header.size; | 86 | oe->cur_alloc_size -= event->header.size; |
| 87 | free(event); | 87 | free(event); |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | static void free_dup_event(struct ordered_events *oe, union perf_event *event) | ||
| 92 | { | ||
| 93 | if (oe->copy_on_queue) | ||
| 94 | __free_dup_event(oe, event); | ||
| 95 | } | ||
| 96 | |||
| 91 | #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct ordered_event)) | 97 | #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct ordered_event)) |
| 92 | static struct ordered_event *alloc_event(struct ordered_events *oe, | 98 | static struct ordered_event *alloc_event(struct ordered_events *oe, |
| 93 | union perf_event *event) | 99 | union perf_event *event) |
| @@ -95,21 +101,49 @@ static struct ordered_event *alloc_event(struct ordered_events *oe, | |||
| 95 | struct list_head *cache = &oe->cache; | 101 | struct list_head *cache = &oe->cache; |
| 96 | struct ordered_event *new = NULL; | 102 | struct ordered_event *new = NULL; |
| 97 | union perf_event *new_event; | 103 | union perf_event *new_event; |
| 104 | size_t size; | ||
| 98 | 105 | ||
| 99 | new_event = dup_event(oe, event); | 106 | new_event = dup_event(oe, event); |
| 100 | if (!new_event) | 107 | if (!new_event) |
| 101 | return NULL; | 108 | return NULL; |
| 102 | 109 | ||
| 110 | /* | ||
| 111 | * We maintain the following scheme of buffers for ordered | ||
| 112 | * event allocation: | ||
| 113 | * | ||
| 114 | * to_free list -> buffer1 (64K) | ||
| 115 | * buffer2 (64K) | ||
| 116 | * ... | ||
| 117 | * | ||
| 118 | * Each buffer keeps an array of ordered events objects: | ||
| 119 | * buffer -> event[0] | ||
| 120 | * event[1] | ||
| 121 | * ... | ||
| 122 | * | ||
| 123 | * Each allocated ordered event is linked to one of | ||
| 124 | * following lists: | ||
| 125 | * - time ordered list 'events' | ||
| 126 | * - list of currently removed events 'cache' | ||
| 127 | * | ||
| 128 | * Allocation of the ordered event uses the following order | ||
| 129 | * to get the memory: | ||
| 130 | * - use recently removed object from 'cache' list | ||
| 131 | * - use available object in current allocation buffer | ||
| 132 | * - allocate new buffer if the current buffer is full | ||
| 133 | * | ||
| 134 | * Removal of ordered event object moves it from events to | ||
| 135 | * the cache list. | ||
| 136 | */ | ||
| 137 | size = sizeof(*oe->buffer) + MAX_SAMPLE_BUFFER * sizeof(*new); | ||
| 138 | |||
| 103 | if (!list_empty(cache)) { | 139 | if (!list_empty(cache)) { |
| 104 | new = list_entry(cache->next, struct ordered_event, list); | 140 | new = list_entry(cache->next, struct ordered_event, list); |
| 105 | list_del(&new->list); | 141 | list_del(&new->list); |
| 106 | } else if (oe->buffer) { | 142 | } else if (oe->buffer) { |
| 107 | new = oe->buffer + oe->buffer_idx; | 143 | new = &oe->buffer->event[oe->buffer_idx]; |
| 108 | if (++oe->buffer_idx == MAX_SAMPLE_BUFFER) | 144 | if (++oe->buffer_idx == MAX_SAMPLE_BUFFER) |
| 109 | oe->buffer = NULL; | 145 | oe->buffer = NULL; |
| 110 | } else if (oe->cur_alloc_size < oe->max_alloc_size) { | 146 | } else if ((oe->cur_alloc_size + size) < oe->max_alloc_size) { |
| 111 | size_t size = MAX_SAMPLE_BUFFER * sizeof(*new); | ||
| 112 | |||
| 113 | oe->buffer = malloc(size); | 147 | oe->buffer = malloc(size); |
| 114 | if (!oe->buffer) { | 148 | if (!oe->buffer) { |
| 115 | free_dup_event(oe, new_event); | 149 | free_dup_event(oe, new_event); |
| @@ -122,11 +156,11 @@ static struct ordered_event *alloc_event(struct ordered_events *oe, | |||
| 122 | oe->cur_alloc_size += size; | 156 | oe->cur_alloc_size += size; |
| 123 | list_add(&oe->buffer->list, &oe->to_free); | 157 | list_add(&oe->buffer->list, &oe->to_free); |
| 124 | 158 | ||
| 125 | /* First entry is abused to maintain the to_free list. */ | 159 | oe->buffer_idx = 1; |
| 126 | oe->buffer_idx = 2; | 160 | new = &oe->buffer->event[0]; |
| 127 | new = oe->buffer + 1; | ||
| 128 | } else { | 161 | } else { |
| 129 | pr("allocation limit reached %" PRIu64 "B\n", oe->max_alloc_size); | 162 | pr("allocation limit reached %" PRIu64 "B\n", oe->max_alloc_size); |
| 163 | return NULL; | ||
| 130 | } | 164 | } |
| 131 | 165 | ||
| 132 | new->event = new_event; | 166 | new->event = new_event; |
| @@ -300,15 +334,38 @@ void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t d | |||
| 300 | oe->deliver = deliver; | 334 | oe->deliver = deliver; |
| 301 | } | 335 | } |
| 302 | 336 | ||
| 337 | static void | ||
| 338 | ordered_events_buffer__free(struct ordered_events_buffer *buffer, | ||
| 339 | unsigned int max, struct ordered_events *oe) | ||
| 340 | { | ||
| 341 | if (oe->copy_on_queue) { | ||
| 342 | unsigned int i; | ||
| 343 | |||
| 344 | for (i = 0; i < max; i++) | ||
| 345 | __free_dup_event(oe, buffer->event[i].event); | ||
| 346 | } | ||
| 347 | |||
| 348 | free(buffer); | ||
| 349 | } | ||
| 350 | |||
| 303 | void ordered_events__free(struct ordered_events *oe) | 351 | void ordered_events__free(struct ordered_events *oe) |
| 304 | { | 352 | { |
| 305 | while (!list_empty(&oe->to_free)) { | 353 | struct ordered_events_buffer *buffer, *tmp; |
| 306 | struct ordered_event *event; | ||
| 307 | 354 | ||
| 308 | event = list_entry(oe->to_free.next, struct ordered_event, list); | 355 | if (list_empty(&oe->to_free)) |
| 309 | list_del(&event->list); | 356 | return; |
| 310 | free_dup_event(oe, event->event); | 357 | |
| 311 | free(event); | 358 | /* |
| 359 | * Current buffer might not have all the events allocated | ||
| 360 | * yet, we need to free only allocated ones ... | ||
| 361 | */ | ||
| 362 | list_del(&oe->buffer->list); | ||
| 363 | ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); | ||
| 364 | |||
| 365 | /* ... and continue with the rest */ | ||
| 366 | list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) { | ||
| 367 | list_del(&buffer->list); | ||
| 368 | ordered_events_buffer__free(buffer, MAX_SAMPLE_BUFFER, oe); | ||
| 312 | } | 369 | } |
| 313 | } | 370 | } |
| 314 | 371 | ||
diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h index 8c7a2948593e..1338d5c345dc 100644 --- a/tools/perf/util/ordered-events.h +++ b/tools/perf/util/ordered-events.h | |||
| @@ -25,23 +25,28 @@ struct ordered_events; | |||
| 25 | typedef int (*ordered_events__deliver_t)(struct ordered_events *oe, | 25 | typedef int (*ordered_events__deliver_t)(struct ordered_events *oe, |
| 26 | struct ordered_event *event); | 26 | struct ordered_event *event); |
| 27 | 27 | ||
| 28 | struct ordered_events_buffer { | ||
| 29 | struct list_head list; | ||
| 30 | struct ordered_event event[0]; | ||
| 31 | }; | ||
| 32 | |||
| 28 | struct ordered_events { | 33 | struct ordered_events { |
| 29 | u64 last_flush; | 34 | u64 last_flush; |
| 30 | u64 next_flush; | 35 | u64 next_flush; |
| 31 | u64 max_timestamp; | 36 | u64 max_timestamp; |
| 32 | u64 max_alloc_size; | 37 | u64 max_alloc_size; |
| 33 | u64 cur_alloc_size; | 38 | u64 cur_alloc_size; |
| 34 | struct list_head events; | 39 | struct list_head events; |
| 35 | struct list_head cache; | 40 | struct list_head cache; |
| 36 | struct list_head to_free; | 41 | struct list_head to_free; |
| 37 | struct ordered_event *buffer; | 42 | struct ordered_events_buffer *buffer; |
| 38 | struct ordered_event *last; | 43 | struct ordered_event *last; |
| 39 | ordered_events__deliver_t deliver; | 44 | ordered_events__deliver_t deliver; |
| 40 | int buffer_idx; | 45 | int buffer_idx; |
| 41 | unsigned int nr_events; | 46 | unsigned int nr_events; |
| 42 | enum oe_flush last_flush_type; | 47 | enum oe_flush last_flush_type; |
| 43 | u32 nr_unordered_events; | 48 | u32 nr_unordered_events; |
| 44 | bool copy_on_queue; | 49 | bool copy_on_queue; |
| 45 | }; | 50 | }; |
| 46 | 51 | ||
| 47 | int ordered_events__queue(struct ordered_events *oe, union perf_event *event, | 52 | int ordered_events__queue(struct ordered_events *oe, union perf_event *event, |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index ce501ba14b08..50150dfc0cdf 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
| @@ -340,7 +340,7 @@ static bool is_tracepoint(struct pyrf_event *pevent) | |||
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | static PyObject* | 342 | static PyObject* |
| 343 | tracepoint_field(struct pyrf_event *pe, struct format_field *field) | 343 | tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field) |
| 344 | { | 344 | { |
| 345 | struct tep_handle *pevent = field->event->pevent; | 345 | struct tep_handle *pevent = field->event->pevent; |
| 346 | void *data = pe->sample.raw_data; | 346 | void *data = pe->sample.raw_data; |
| @@ -348,28 +348,28 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) | |||
| 348 | unsigned long long val; | 348 | unsigned long long val; |
| 349 | unsigned int offset, len; | 349 | unsigned int offset, len; |
| 350 | 350 | ||
| 351 | if (field->flags & FIELD_IS_ARRAY) { | 351 | if (field->flags & TEP_FIELD_IS_ARRAY) { |
| 352 | offset = field->offset; | 352 | offset = field->offset; |
| 353 | len = field->size; | 353 | len = field->size; |
| 354 | if (field->flags & FIELD_IS_DYNAMIC) { | 354 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 355 | val = tep_read_number(pevent, data + offset, len); | 355 | val = tep_read_number(pevent, data + offset, len); |
| 356 | offset = val; | 356 | offset = val; |
| 357 | len = offset >> 16; | 357 | len = offset >> 16; |
| 358 | offset &= 0xffff; | 358 | offset &= 0xffff; |
| 359 | } | 359 | } |
| 360 | if (field->flags & FIELD_IS_STRING && | 360 | if (field->flags & TEP_FIELD_IS_STRING && |
| 361 | is_printable_array(data + offset, len)) { | 361 | is_printable_array(data + offset, len)) { |
| 362 | ret = _PyUnicode_FromString((char *)data + offset); | 362 | ret = _PyUnicode_FromString((char *)data + offset); |
| 363 | } else { | 363 | } else { |
| 364 | ret = PyByteArray_FromStringAndSize((const char *) data + offset, len); | 364 | ret = PyByteArray_FromStringAndSize((const char *) data + offset, len); |
| 365 | field->flags &= ~FIELD_IS_STRING; | 365 | field->flags &= ~TEP_FIELD_IS_STRING; |
| 366 | } | 366 | } |
| 367 | } else { | 367 | } else { |
| 368 | val = tep_read_number(pevent, data + field->offset, | 368 | val = tep_read_number(pevent, data + field->offset, |
| 369 | field->size); | 369 | field->size); |
| 370 | if (field->flags & FIELD_IS_POINTER) | 370 | if (field->flags & TEP_FIELD_IS_POINTER) |
| 371 | ret = PyLong_FromUnsignedLong((unsigned long) val); | 371 | ret = PyLong_FromUnsignedLong((unsigned long) val); |
| 372 | else if (field->flags & FIELD_IS_SIGNED) | 372 | else if (field->flags & TEP_FIELD_IS_SIGNED) |
| 373 | ret = PyLong_FromLong((long) val); | 373 | ret = PyLong_FromLong((long) val); |
| 374 | else | 374 | else |
| 375 | ret = PyLong_FromUnsignedLong((unsigned long) val); | 375 | ret = PyLong_FromUnsignedLong((unsigned long) val); |
| @@ -383,10 +383,10 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name) | |||
| 383 | { | 383 | { |
| 384 | const char *str = _PyUnicode_AsString(PyObject_Str(attr_name)); | 384 | const char *str = _PyUnicode_AsString(PyObject_Str(attr_name)); |
| 385 | struct perf_evsel *evsel = pevent->evsel; | 385 | struct perf_evsel *evsel = pevent->evsel; |
| 386 | struct format_field *field; | 386 | struct tep_format_field *field; |
| 387 | 387 | ||
| 388 | if (!evsel->tp_format) { | 388 | if (!evsel->tp_format) { |
| 389 | struct event_format *tp_format; | 389 | struct tep_event_format *tp_format; |
| 390 | 390 | ||
| 391 | tp_format = trace_event__tp_format_id(evsel->attr.config); | 391 | tp_format = trace_event__tp_format_id(evsel->attr.config); |
| 392 | if (!tp_format) | 392 | if (!tp_format) |
| @@ -1240,7 +1240,7 @@ static struct { | |||
| 1240 | static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel, | 1240 | static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel, |
| 1241 | PyObject *args, PyObject *kwargs) | 1241 | PyObject *args, PyObject *kwargs) |
| 1242 | { | 1242 | { |
| 1243 | struct event_format *tp_format; | 1243 | struct tep_event_format *tp_format; |
| 1244 | static char *kwlist[] = { "sys", "name", NULL }; | 1244 | static char *kwlist[] = { "sys", "name", NULL }; |
| 1245 | char *sys = NULL; | 1245 | char *sys = NULL; |
| 1246 | char *name = NULL; | 1246 | char *name = NULL; |
diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index d2c78ffd9fee..a2eeebbfb25f 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c | |||
| @@ -147,6 +147,9 @@ | |||
| 147 | #include <linux/bitops.h> | 147 | #include <linux/bitops.h> |
| 148 | #include <linux/log2.h> | 148 | #include <linux/log2.h> |
| 149 | 149 | ||
| 150 | #include <sys/stat.h> | ||
| 151 | #include <sys/types.h> | ||
| 152 | |||
| 150 | #include "cpumap.h" | 153 | #include "cpumap.h" |
| 151 | #include "color.h" | 154 | #include "color.h" |
| 152 | #include "evsel.h" | 155 | #include "evsel.h" |
| @@ -159,6 +162,7 @@ | |||
| 159 | #include "auxtrace.h" | 162 | #include "auxtrace.h" |
| 160 | #include "s390-cpumsf.h" | 163 | #include "s390-cpumsf.h" |
| 161 | #include "s390-cpumsf-kernel.h" | 164 | #include "s390-cpumsf-kernel.h" |
| 165 | #include "config.h" | ||
| 162 | 166 | ||
| 163 | struct s390_cpumsf { | 167 | struct s390_cpumsf { |
| 164 | struct auxtrace auxtrace; | 168 | struct auxtrace auxtrace; |
| @@ -170,6 +174,8 @@ struct s390_cpumsf { | |||
| 170 | u32 pmu_type; | 174 | u32 pmu_type; |
| 171 | u16 machine_type; | 175 | u16 machine_type; |
| 172 | bool data_queued; | 176 | bool data_queued; |
| 177 | bool use_logfile; | ||
| 178 | char *logdir; | ||
| 173 | }; | 179 | }; |
| 174 | 180 | ||
| 175 | struct s390_cpumsf_queue { | 181 | struct s390_cpumsf_queue { |
| @@ -177,6 +183,7 @@ struct s390_cpumsf_queue { | |||
| 177 | unsigned int queue_nr; | 183 | unsigned int queue_nr; |
| 178 | struct auxtrace_buffer *buffer; | 184 | struct auxtrace_buffer *buffer; |
| 179 | int cpu; | 185 | int cpu; |
| 186 | FILE *logfile; | ||
| 180 | }; | 187 | }; |
| 181 | 188 | ||
| 182 | /* Display s390 CPU measurement facility basic-sampling data entry */ | 189 | /* Display s390 CPU measurement facility basic-sampling data entry */ |
| @@ -595,6 +602,12 @@ static int s390_cpumsf_run_decoder(struct s390_cpumsf_queue *sfq, | |||
| 595 | buffer->use_size = buffer->size; | 602 | buffer->use_size = buffer->size; |
| 596 | buffer->use_data = buffer->data; | 603 | buffer->use_data = buffer->data; |
| 597 | } | 604 | } |
| 605 | if (sfq->logfile) { /* Write into log file */ | ||
| 606 | size_t rc = fwrite(buffer->data, buffer->size, 1, | ||
| 607 | sfq->logfile); | ||
| 608 | if (rc != 1) | ||
| 609 | pr_err("Failed to write auxiliary data\n"); | ||
| 610 | } | ||
| 598 | } else | 611 | } else |
| 599 | buffer = sfq->buffer; | 612 | buffer = sfq->buffer; |
| 600 | 613 | ||
| @@ -606,6 +619,13 @@ static int s390_cpumsf_run_decoder(struct s390_cpumsf_queue *sfq, | |||
| 606 | return -ENOMEM; | 619 | return -ENOMEM; |
| 607 | buffer->use_size = buffer->size; | 620 | buffer->use_size = buffer->size; |
| 608 | buffer->use_data = buffer->data; | 621 | buffer->use_data = buffer->data; |
| 622 | |||
| 623 | if (sfq->logfile) { /* Write into log file */ | ||
| 624 | size_t rc = fwrite(buffer->data, buffer->size, 1, | ||
| 625 | sfq->logfile); | ||
| 626 | if (rc != 1) | ||
| 627 | pr_err("Failed to write auxiliary data\n"); | ||
| 628 | } | ||
| 609 | } | 629 | } |
| 610 | pr_debug4("%s queue_nr:%d buffer:%" PRId64 " offset:%#" PRIx64 " size:%#zx rest:%#zx\n", | 630 | pr_debug4("%s queue_nr:%d buffer:%" PRId64 " offset:%#" PRIx64 " size:%#zx rest:%#zx\n", |
| 611 | __func__, sfq->queue_nr, buffer->buffer_nr, buffer->offset, | 631 | __func__, sfq->queue_nr, buffer->buffer_nr, buffer->offset, |
| @@ -640,6 +660,23 @@ s390_cpumsf_alloc_queue(struct s390_cpumsf *sf, unsigned int queue_nr) | |||
| 640 | sfq->sf = sf; | 660 | sfq->sf = sf; |
| 641 | sfq->queue_nr = queue_nr; | 661 | sfq->queue_nr = queue_nr; |
| 642 | sfq->cpu = -1; | 662 | sfq->cpu = -1; |
| 663 | if (sf->use_logfile) { | ||
| 664 | char *name; | ||
| 665 | int rc; | ||
| 666 | |||
| 667 | rc = (sf->logdir) | ||
| 668 | ? asprintf(&name, "%s/aux.smp.%02x", | ||
| 669 | sf->logdir, queue_nr) | ||
| 670 | : asprintf(&name, "aux.smp.%02x", queue_nr); | ||
| 671 | if (rc > 0) | ||
| 672 | sfq->logfile = fopen(name, "w"); | ||
| 673 | if (sfq->logfile == NULL) { | ||
| 674 | pr_err("Failed to open auxiliary log file %s," | ||
| 675 | "continue...\n", name); | ||
| 676 | sf->use_logfile = false; | ||
| 677 | } | ||
| 678 | free(name); | ||
| 679 | } | ||
| 643 | return sfq; | 680 | return sfq; |
| 644 | } | 681 | } |
| 645 | 682 | ||
| @@ -850,8 +887,16 @@ static void s390_cpumsf_free_queues(struct perf_session *session) | |||
| 850 | struct auxtrace_queues *queues = &sf->queues; | 887 | struct auxtrace_queues *queues = &sf->queues; |
| 851 | unsigned int i; | 888 | unsigned int i; |
| 852 | 889 | ||
| 853 | for (i = 0; i < queues->nr_queues; i++) | 890 | for (i = 0; i < queues->nr_queues; i++) { |
| 891 | struct s390_cpumsf_queue *sfq = (struct s390_cpumsf_queue *) | ||
| 892 | queues->queue_array[i].priv; | ||
| 893 | |||
| 894 | if (sfq != NULL && sfq->logfile) { | ||
| 895 | fclose(sfq->logfile); | ||
| 896 | sfq->logfile = NULL; | ||
| 897 | } | ||
| 854 | zfree(&queues->queue_array[i].priv); | 898 | zfree(&queues->queue_array[i].priv); |
| 899 | } | ||
| 855 | auxtrace_queues__free(queues); | 900 | auxtrace_queues__free(queues); |
| 856 | } | 901 | } |
| 857 | 902 | ||
| @@ -864,6 +909,7 @@ static void s390_cpumsf_free(struct perf_session *session) | |||
| 864 | auxtrace_heap__free(&sf->heap); | 909 | auxtrace_heap__free(&sf->heap); |
| 865 | s390_cpumsf_free_queues(session); | 910 | s390_cpumsf_free_queues(session); |
| 866 | session->auxtrace = NULL; | 911 | session->auxtrace = NULL; |
| 912 | free(sf->logdir); | ||
| 867 | free(sf); | 913 | free(sf); |
| 868 | } | 914 | } |
| 869 | 915 | ||
| @@ -877,17 +923,55 @@ static int s390_cpumsf_get_type(const char *cpuid) | |||
| 877 | 923 | ||
| 878 | /* Check itrace options set on perf report command. | 924 | /* Check itrace options set on perf report command. |
| 879 | * Return true, if none are set or all options specified can be | 925 | * Return true, if none are set or all options specified can be |
| 880 | * handled on s390. | 926 | * handled on s390 (currently only option 'd' for logging. |
| 881 | * Return false otherwise. | 927 | * Return false otherwise. |
| 882 | */ | 928 | */ |
| 883 | static bool check_auxtrace_itrace(struct itrace_synth_opts *itops) | 929 | static bool check_auxtrace_itrace(struct itrace_synth_opts *itops) |
| 884 | { | 930 | { |
| 931 | bool ison = false; | ||
| 932 | |||
| 885 | if (!itops || !itops->set) | 933 | if (!itops || !itops->set) |
| 886 | return true; | 934 | return true; |
| 887 | pr_err("No --itrace options supported\n"); | 935 | ison = itops->inject || itops->instructions || itops->branches || |
| 936 | itops->transactions || itops->ptwrites || | ||
| 937 | itops->pwr_events || itops->errors || | ||
| 938 | itops->dont_decode || itops->calls || itops->returns || | ||
| 939 | itops->callchain || itops->thread_stack || | ||
| 940 | itops->last_branch; | ||
| 941 | if (!ison) | ||
| 942 | return true; | ||
| 943 | pr_err("Unsupported --itrace options specified\n"); | ||
| 888 | return false; | 944 | return false; |
| 889 | } | 945 | } |
| 890 | 946 | ||
| 947 | /* Check for AUXTRACE dump directory if it is needed. | ||
| 948 | * On failure print an error message but continue. | ||
| 949 | * Return 0 on wrong keyword in config file and 1 otherwise. | ||
| 950 | */ | ||
| 951 | static int s390_cpumsf__config(const char *var, const char *value, void *cb) | ||
| 952 | { | ||
| 953 | struct s390_cpumsf *sf = cb; | ||
| 954 | struct stat stbuf; | ||
| 955 | int rc; | ||
| 956 | |||
| 957 | if (strcmp(var, "auxtrace.dumpdir")) | ||
| 958 | return 0; | ||
| 959 | sf->logdir = strdup(value); | ||
| 960 | if (sf->logdir == NULL) { | ||
| 961 | pr_err("Failed to find auxtrace log directory %s," | ||
| 962 | " continue with current directory...\n", value); | ||
| 963 | return 1; | ||
| 964 | } | ||
| 965 | rc = stat(sf->logdir, &stbuf); | ||
| 966 | if (rc == -1 || !S_ISDIR(stbuf.st_mode)) { | ||
| 967 | pr_err("Missing auxtrace log directory %s," | ||
| 968 | " continue with current directory...\n", value); | ||
| 969 | free(sf->logdir); | ||
| 970 | sf->logdir = NULL; | ||
| 971 | } | ||
| 972 | return 1; | ||
| 973 | } | ||
| 974 | |||
| 891 | int s390_cpumsf_process_auxtrace_info(union perf_event *event, | 975 | int s390_cpumsf_process_auxtrace_info(union perf_event *event, |
| 892 | struct perf_session *session) | 976 | struct perf_session *session) |
| 893 | { | 977 | { |
| @@ -906,6 +990,9 @@ int s390_cpumsf_process_auxtrace_info(union perf_event *event, | |||
| 906 | err = -EINVAL; | 990 | err = -EINVAL; |
| 907 | goto err_free; | 991 | goto err_free; |
| 908 | } | 992 | } |
| 993 | sf->use_logfile = session->itrace_synth_opts->log; | ||
| 994 | if (sf->use_logfile) | ||
| 995 | perf_config(s390_cpumsf__config, sf); | ||
| 909 | 996 | ||
| 910 | err = auxtrace_queues__init(&sf->queues); | 997 | err = auxtrace_queues__init(&sf->queues); |
| 911 | if (err) | 998 | if (err) |
| @@ -940,6 +1027,7 @@ err_free_queues: | |||
| 940 | auxtrace_queues__free(&sf->queues); | 1027 | auxtrace_queues__free(&sf->queues); |
| 941 | session->auxtrace = NULL; | 1028 | session->auxtrace = NULL; |
| 942 | err_free: | 1029 | err_free: |
| 1030 | free(sf->logdir); | ||
| 943 | free(sf); | 1031 | free(sf); |
| 944 | return err; | 1032 | return err; |
| 945 | } | 1033 | } |
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 45484f0f7292..89cb887648f9 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
| @@ -99,7 +99,7 @@ static void define_symbolic_value(const char *ev_name, | |||
| 99 | LEAVE; | 99 | LEAVE; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | static void define_symbolic_values(struct print_flag_sym *field, | 102 | static void define_symbolic_values(struct tep_print_flag_sym *field, |
| 103 | const char *ev_name, | 103 | const char *ev_name, |
| 104 | const char *field_name) | 104 | const char *field_name) |
| 105 | { | 105 | { |
| @@ -157,7 +157,7 @@ static void define_flag_value(const char *ev_name, | |||
| 157 | LEAVE; | 157 | LEAVE; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | static void define_flag_values(struct print_flag_sym *field, | 160 | static void define_flag_values(struct tep_print_flag_sym *field, |
| 161 | const char *ev_name, | 161 | const char *ev_name, |
| 162 | const char *field_name) | 162 | const char *field_name) |
| 163 | { | 163 | { |
| @@ -189,62 +189,62 @@ static void define_flag_field(const char *ev_name, | |||
| 189 | LEAVE; | 189 | LEAVE; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static void define_event_symbols(struct event_format *event, | 192 | static void define_event_symbols(struct tep_event_format *event, |
| 193 | const char *ev_name, | 193 | const char *ev_name, |
| 194 | struct print_arg *args) | 194 | struct tep_print_arg *args) |
| 195 | { | 195 | { |
| 196 | if (args == NULL) | 196 | if (args == NULL) |
| 197 | return; | 197 | return; |
| 198 | 198 | ||
| 199 | switch (args->type) { | 199 | switch (args->type) { |
| 200 | case PRINT_NULL: | 200 | case TEP_PRINT_NULL: |
| 201 | break; | 201 | break; |
| 202 | case PRINT_ATOM: | 202 | case TEP_PRINT_ATOM: |
| 203 | define_flag_value(ev_name, cur_field_name, "0", | 203 | define_flag_value(ev_name, cur_field_name, "0", |
| 204 | args->atom.atom); | 204 | args->atom.atom); |
| 205 | zero_flag_atom = 0; | 205 | zero_flag_atom = 0; |
| 206 | break; | 206 | break; |
| 207 | case PRINT_FIELD: | 207 | case TEP_PRINT_FIELD: |
| 208 | free(cur_field_name); | 208 | free(cur_field_name); |
| 209 | cur_field_name = strdup(args->field.name); | 209 | cur_field_name = strdup(args->field.name); |
| 210 | break; | 210 | break; |
| 211 | case PRINT_FLAGS: | 211 | case TEP_PRINT_FLAGS: |
| 212 | define_event_symbols(event, ev_name, args->flags.field); | 212 | define_event_symbols(event, ev_name, args->flags.field); |
| 213 | define_flag_field(ev_name, cur_field_name, args->flags.delim); | 213 | define_flag_field(ev_name, cur_field_name, args->flags.delim); |
| 214 | define_flag_values(args->flags.flags, ev_name, cur_field_name); | 214 | define_flag_values(args->flags.flags, ev_name, cur_field_name); |
| 215 | break; | 215 | break; |
| 216 | case PRINT_SYMBOL: | 216 | case TEP_PRINT_SYMBOL: |
| 217 | define_event_symbols(event, ev_name, args->symbol.field); | 217 | define_event_symbols(event, ev_name, args->symbol.field); |
| 218 | define_symbolic_field(ev_name, cur_field_name); | 218 | define_symbolic_field(ev_name, cur_field_name); |
| 219 | define_symbolic_values(args->symbol.symbols, ev_name, | 219 | define_symbolic_values(args->symbol.symbols, ev_name, |
| 220 | cur_field_name); | 220 | cur_field_name); |
| 221 | break; | 221 | break; |
| 222 | case PRINT_HEX: | 222 | case TEP_PRINT_HEX: |
| 223 | case PRINT_HEX_STR: | 223 | case TEP_PRINT_HEX_STR: |
| 224 | define_event_symbols(event, ev_name, args->hex.field); | 224 | define_event_symbols(event, ev_name, args->hex.field); |
| 225 | define_event_symbols(event, ev_name, args->hex.size); | 225 | define_event_symbols(event, ev_name, args->hex.size); |
| 226 | break; | 226 | break; |
| 227 | case PRINT_INT_ARRAY: | 227 | case TEP_PRINT_INT_ARRAY: |
| 228 | define_event_symbols(event, ev_name, args->int_array.field); | 228 | define_event_symbols(event, ev_name, args->int_array.field); |
| 229 | define_event_symbols(event, ev_name, args->int_array.count); | 229 | define_event_symbols(event, ev_name, args->int_array.count); |
| 230 | define_event_symbols(event, ev_name, args->int_array.el_size); | 230 | define_event_symbols(event, ev_name, args->int_array.el_size); |
| 231 | break; | 231 | break; |
| 232 | case PRINT_BSTRING: | 232 | case TEP_PRINT_BSTRING: |
| 233 | case PRINT_DYNAMIC_ARRAY: | 233 | case TEP_PRINT_DYNAMIC_ARRAY: |
| 234 | case PRINT_DYNAMIC_ARRAY_LEN: | 234 | case TEP_PRINT_DYNAMIC_ARRAY_LEN: |
| 235 | case PRINT_STRING: | 235 | case TEP_PRINT_STRING: |
| 236 | case PRINT_BITMASK: | 236 | case TEP_PRINT_BITMASK: |
| 237 | break; | 237 | break; |
| 238 | case PRINT_TYPE: | 238 | case TEP_PRINT_TYPE: |
| 239 | define_event_symbols(event, ev_name, args->typecast.item); | 239 | define_event_symbols(event, ev_name, args->typecast.item); |
| 240 | break; | 240 | break; |
| 241 | case PRINT_OP: | 241 | case TEP_PRINT_OP: |
| 242 | if (strcmp(args->op.op, ":") == 0) | 242 | if (strcmp(args->op.op, ":") == 0) |
| 243 | zero_flag_atom = 1; | 243 | zero_flag_atom = 1; |
| 244 | define_event_symbols(event, ev_name, args->op.left); | 244 | define_event_symbols(event, ev_name, args->op.left); |
| 245 | define_event_symbols(event, ev_name, args->op.right); | 245 | define_event_symbols(event, ev_name, args->op.right); |
| 246 | break; | 246 | break; |
| 247 | case PRINT_FUNC: | 247 | case TEP_PRINT_FUNC: |
| 248 | default: | 248 | default: |
| 249 | pr_err("Unsupported print arg type\n"); | 249 | pr_err("Unsupported print arg type\n"); |
| 250 | /* we should warn... */ | 250 | /* we should warn... */ |
| @@ -338,8 +338,8 @@ static void perl_process_tracepoint(struct perf_sample *sample, | |||
| 338 | struct addr_location *al) | 338 | struct addr_location *al) |
| 339 | { | 339 | { |
| 340 | struct thread *thread = al->thread; | 340 | struct thread *thread = al->thread; |
| 341 | struct event_format *event = evsel->tp_format; | 341 | struct tep_event_format *event = evsel->tp_format; |
| 342 | struct format_field *field; | 342 | struct tep_format_field *field; |
| 343 | static char handler[256]; | 343 | static char handler[256]; |
| 344 | unsigned long long val; | 344 | unsigned long long val; |
| 345 | unsigned long s, ns; | 345 | unsigned long s, ns; |
| @@ -388,9 +388,9 @@ static void perl_process_tracepoint(struct perf_sample *sample, | |||
| 388 | /* common fields other than pid can be accessed via xsub fns */ | 388 | /* common fields other than pid can be accessed via xsub fns */ |
| 389 | 389 | ||
| 390 | for (field = event->format.fields; field; field = field->next) { | 390 | for (field = event->format.fields; field; field = field->next) { |
| 391 | if (field->flags & FIELD_IS_STRING) { | 391 | if (field->flags & TEP_FIELD_IS_STRING) { |
| 392 | int offset; | 392 | int offset; |
| 393 | if (field->flags & FIELD_IS_DYNAMIC) { | 393 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 394 | offset = *(int *)(data + field->offset); | 394 | offset = *(int *)(data + field->offset); |
| 395 | offset &= 0xffff; | 395 | offset &= 0xffff; |
| 396 | } else | 396 | } else |
| @@ -399,7 +399,7 @@ static void perl_process_tracepoint(struct perf_sample *sample, | |||
| 399 | } else { /* FIELD_IS_NUMERIC */ | 399 | } else { /* FIELD_IS_NUMERIC */ |
| 400 | val = read_size(event, data + field->offset, | 400 | val = read_size(event, data + field->offset, |
| 401 | field->size); | 401 | field->size); |
| 402 | if (field->flags & FIELD_IS_SIGNED) { | 402 | if (field->flags & TEP_FIELD_IS_SIGNED) { |
| 403 | XPUSHs(sv_2mortal(newSViv(val))); | 403 | XPUSHs(sv_2mortal(newSViv(val))); |
| 404 | } else { | 404 | } else { |
| 405 | XPUSHs(sv_2mortal(newSVuv(val))); | 405 | XPUSHs(sv_2mortal(newSVuv(val))); |
| @@ -537,8 +537,8 @@ static int perl_stop_script(void) | |||
| 537 | 537 | ||
| 538 | static int perl_generate_script(struct tep_handle *pevent, const char *outfile) | 538 | static int perl_generate_script(struct tep_handle *pevent, const char *outfile) |
| 539 | { | 539 | { |
| 540 | struct event_format *event = NULL; | 540 | struct tep_event_format *event = NULL; |
| 541 | struct format_field *f; | 541 | struct tep_format_field *f; |
| 542 | char fname[PATH_MAX]; | 542 | char fname[PATH_MAX]; |
| 543 | int not_first, count; | 543 | int not_first, count; |
| 544 | FILE *ofp; | 544 | FILE *ofp; |
| @@ -646,11 +646,11 @@ sub print_backtrace\n\ | |||
| 646 | count++; | 646 | count++; |
| 647 | 647 | ||
| 648 | fprintf(ofp, "%s=", f->name); | 648 | fprintf(ofp, "%s=", f->name); |
| 649 | if (f->flags & FIELD_IS_STRING || | 649 | if (f->flags & TEP_FIELD_IS_STRING || |
| 650 | f->flags & FIELD_IS_FLAG || | 650 | f->flags & TEP_FIELD_IS_FLAG || |
| 651 | f->flags & FIELD_IS_SYMBOLIC) | 651 | f->flags & TEP_FIELD_IS_SYMBOLIC) |
| 652 | fprintf(ofp, "%%s"); | 652 | fprintf(ofp, "%%s"); |
| 653 | else if (f->flags & FIELD_IS_SIGNED) | 653 | else if (f->flags & TEP_FIELD_IS_SIGNED) |
| 654 | fprintf(ofp, "%%d"); | 654 | fprintf(ofp, "%%d"); |
| 655 | else | 655 | else |
| 656 | fprintf(ofp, "%%u"); | 656 | fprintf(ofp, "%%u"); |
| @@ -668,7 +668,7 @@ sub print_backtrace\n\ | |||
| 668 | if (++count % 5 == 0) | 668 | if (++count % 5 == 0) |
| 669 | fprintf(ofp, "\n\t "); | 669 | fprintf(ofp, "\n\t "); |
| 670 | 670 | ||
| 671 | if (f->flags & FIELD_IS_FLAG) { | 671 | if (f->flags & TEP_FIELD_IS_FLAG) { |
| 672 | if ((count - 1) % 5 != 0) { | 672 | if ((count - 1) % 5 != 0) { |
| 673 | fprintf(ofp, "\n\t "); | 673 | fprintf(ofp, "\n\t "); |
| 674 | count = 4; | 674 | count = 4; |
| @@ -678,7 +678,7 @@ sub print_backtrace\n\ | |||
| 678 | event->name); | 678 | event->name); |
| 679 | fprintf(ofp, "\"%s\", $%s)", f->name, | 679 | fprintf(ofp, "\"%s\", $%s)", f->name, |
| 680 | f->name); | 680 | f->name); |
| 681 | } else if (f->flags & FIELD_IS_SYMBOLIC) { | 681 | } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) { |
| 682 | if ((count - 1) % 5 != 0) { | 682 | if ((count - 1) % 5 != 0) { |
| 683 | fprintf(ofp, "\n\t "); | 683 | fprintf(ofp, "\n\t "); |
| 684 | count = 4; | 684 | count = 4; |
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index dfc6093f118c..69aa93d4ee99 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
| @@ -193,7 +193,7 @@ static void try_call_object(const char *handler_name, PyObject *args) | |||
| 193 | call_object(handler, args, handler_name); | 193 | call_object(handler, args, handler_name); |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | static void define_value(enum print_arg_type field_type, | 196 | static void define_value(enum tep_print_arg_type field_type, |
| 197 | const char *ev_name, | 197 | const char *ev_name, |
| 198 | const char *field_name, | 198 | const char *field_name, |
| 199 | const char *field_value, | 199 | const char *field_value, |
| @@ -204,7 +204,7 @@ static void define_value(enum print_arg_type field_type, | |||
| 204 | unsigned long long value; | 204 | unsigned long long value; |
| 205 | unsigned n = 0; | 205 | unsigned n = 0; |
| 206 | 206 | ||
| 207 | if (field_type == PRINT_SYMBOL) | 207 | if (field_type == TEP_PRINT_SYMBOL) |
| 208 | handler_name = "define_symbolic_value"; | 208 | handler_name = "define_symbolic_value"; |
| 209 | 209 | ||
| 210 | t = PyTuple_New(4); | 210 | t = PyTuple_New(4); |
| @@ -223,8 +223,8 @@ static void define_value(enum print_arg_type field_type, | |||
| 223 | Py_DECREF(t); | 223 | Py_DECREF(t); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | static void define_values(enum print_arg_type field_type, | 226 | static void define_values(enum tep_print_arg_type field_type, |
| 227 | struct print_flag_sym *field, | 227 | struct tep_print_flag_sym *field, |
| 228 | const char *ev_name, | 228 | const char *ev_name, |
| 229 | const char *field_name) | 229 | const char *field_name) |
| 230 | { | 230 | { |
| @@ -235,7 +235,7 @@ static void define_values(enum print_arg_type field_type, | |||
| 235 | define_values(field_type, field->next, ev_name, field_name); | 235 | define_values(field_type, field->next, ev_name, field_name); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | static void define_field(enum print_arg_type field_type, | 238 | static void define_field(enum tep_print_arg_type field_type, |
| 239 | const char *ev_name, | 239 | const char *ev_name, |
| 240 | const char *field_name, | 240 | const char *field_name, |
| 241 | const char *delim) | 241 | const char *delim) |
| @@ -244,10 +244,10 @@ static void define_field(enum print_arg_type field_type, | |||
| 244 | PyObject *t; | 244 | PyObject *t; |
| 245 | unsigned n = 0; | 245 | unsigned n = 0; |
| 246 | 246 | ||
| 247 | if (field_type == PRINT_SYMBOL) | 247 | if (field_type == TEP_PRINT_SYMBOL) |
| 248 | handler_name = "define_symbolic_field"; | 248 | handler_name = "define_symbolic_field"; |
| 249 | 249 | ||
| 250 | if (field_type == PRINT_FLAGS) | 250 | if (field_type == TEP_PRINT_FLAGS) |
| 251 | t = PyTuple_New(3); | 251 | t = PyTuple_New(3); |
| 252 | else | 252 | else |
| 253 | t = PyTuple_New(2); | 253 | t = PyTuple_New(2); |
| @@ -256,7 +256,7 @@ static void define_field(enum print_arg_type field_type, | |||
| 256 | 256 | ||
| 257 | PyTuple_SetItem(t, n++, _PyUnicode_FromString(ev_name)); | 257 | PyTuple_SetItem(t, n++, _PyUnicode_FromString(ev_name)); |
| 258 | PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_name)); | 258 | PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_name)); |
| 259 | if (field_type == PRINT_FLAGS) | 259 | if (field_type == TEP_PRINT_FLAGS) |
| 260 | PyTuple_SetItem(t, n++, _PyUnicode_FromString(delim)); | 260 | PyTuple_SetItem(t, n++, _PyUnicode_FromString(delim)); |
| 261 | 261 | ||
| 262 | try_call_object(handler_name, t); | 262 | try_call_object(handler_name, t); |
| @@ -264,54 +264,54 @@ static void define_field(enum print_arg_type field_type, | |||
| 264 | Py_DECREF(t); | 264 | Py_DECREF(t); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | static void define_event_symbols(struct event_format *event, | 267 | static void define_event_symbols(struct tep_event_format *event, |
| 268 | const char *ev_name, | 268 | const char *ev_name, |
| 269 | struct print_arg *args) | 269 | struct tep_print_arg *args) |
| 270 | { | 270 | { |
| 271 | if (args == NULL) | 271 | if (args == NULL) |
| 272 | return; | 272 | return; |
| 273 | 273 | ||
| 274 | switch (args->type) { | 274 | switch (args->type) { |
| 275 | case PRINT_NULL: | 275 | case TEP_PRINT_NULL: |
| 276 | break; | 276 | break; |
| 277 | case PRINT_ATOM: | 277 | case TEP_PRINT_ATOM: |
| 278 | define_value(PRINT_FLAGS, ev_name, cur_field_name, "0", | 278 | define_value(TEP_PRINT_FLAGS, ev_name, cur_field_name, "0", |
| 279 | args->atom.atom); | 279 | args->atom.atom); |
| 280 | zero_flag_atom = 0; | 280 | zero_flag_atom = 0; |
| 281 | break; | 281 | break; |
| 282 | case PRINT_FIELD: | 282 | case TEP_PRINT_FIELD: |
| 283 | free(cur_field_name); | 283 | free(cur_field_name); |
| 284 | cur_field_name = strdup(args->field.name); | 284 | cur_field_name = strdup(args->field.name); |
| 285 | break; | 285 | break; |
| 286 | case PRINT_FLAGS: | 286 | case TEP_PRINT_FLAGS: |
| 287 | define_event_symbols(event, ev_name, args->flags.field); | 287 | define_event_symbols(event, ev_name, args->flags.field); |
| 288 | define_field(PRINT_FLAGS, ev_name, cur_field_name, | 288 | define_field(TEP_PRINT_FLAGS, ev_name, cur_field_name, |
| 289 | args->flags.delim); | 289 | args->flags.delim); |
| 290 | define_values(PRINT_FLAGS, args->flags.flags, ev_name, | 290 | define_values(TEP_PRINT_FLAGS, args->flags.flags, ev_name, |
| 291 | cur_field_name); | 291 | cur_field_name); |
| 292 | break; | 292 | break; |
| 293 | case PRINT_SYMBOL: | 293 | case TEP_PRINT_SYMBOL: |
| 294 | define_event_symbols(event, ev_name, args->symbol.field); | 294 | define_event_symbols(event, ev_name, args->symbol.field); |
| 295 | define_field(PRINT_SYMBOL, ev_name, cur_field_name, NULL); | 295 | define_field(TEP_PRINT_SYMBOL, ev_name, cur_field_name, NULL); |
| 296 | define_values(PRINT_SYMBOL, args->symbol.symbols, ev_name, | 296 | define_values(TEP_PRINT_SYMBOL, args->symbol.symbols, ev_name, |
| 297 | cur_field_name); | 297 | cur_field_name); |
| 298 | break; | 298 | break; |
| 299 | case PRINT_HEX: | 299 | case TEP_PRINT_HEX: |
| 300 | case PRINT_HEX_STR: | 300 | case TEP_PRINT_HEX_STR: |
| 301 | define_event_symbols(event, ev_name, args->hex.field); | 301 | define_event_symbols(event, ev_name, args->hex.field); |
| 302 | define_event_symbols(event, ev_name, args->hex.size); | 302 | define_event_symbols(event, ev_name, args->hex.size); |
| 303 | break; | 303 | break; |
| 304 | case PRINT_INT_ARRAY: | 304 | case TEP_PRINT_INT_ARRAY: |
| 305 | define_event_symbols(event, ev_name, args->int_array.field); | 305 | define_event_symbols(event, ev_name, args->int_array.field); |
| 306 | define_event_symbols(event, ev_name, args->int_array.count); | 306 | define_event_symbols(event, ev_name, args->int_array.count); |
| 307 | define_event_symbols(event, ev_name, args->int_array.el_size); | 307 | define_event_symbols(event, ev_name, args->int_array.el_size); |
| 308 | break; | 308 | break; |
| 309 | case PRINT_STRING: | 309 | case TEP_PRINT_STRING: |
| 310 | break; | 310 | break; |
| 311 | case PRINT_TYPE: | 311 | case TEP_PRINT_TYPE: |
| 312 | define_event_symbols(event, ev_name, args->typecast.item); | 312 | define_event_symbols(event, ev_name, args->typecast.item); |
| 313 | break; | 313 | break; |
| 314 | case PRINT_OP: | 314 | case TEP_PRINT_OP: |
| 315 | if (strcmp(args->op.op, ":") == 0) | 315 | if (strcmp(args->op.op, ":") == 0) |
| 316 | zero_flag_atom = 1; | 316 | zero_flag_atom = 1; |
| 317 | define_event_symbols(event, ev_name, args->op.left); | 317 | define_event_symbols(event, ev_name, args->op.left); |
| @@ -319,11 +319,11 @@ static void define_event_symbols(struct event_format *event, | |||
| 319 | break; | 319 | break; |
| 320 | default: | 320 | default: |
| 321 | /* gcc warns for these? */ | 321 | /* gcc warns for these? */ |
| 322 | case PRINT_BSTRING: | 322 | case TEP_PRINT_BSTRING: |
| 323 | case PRINT_DYNAMIC_ARRAY: | 323 | case TEP_PRINT_DYNAMIC_ARRAY: |
| 324 | case PRINT_DYNAMIC_ARRAY_LEN: | 324 | case TEP_PRINT_DYNAMIC_ARRAY_LEN: |
| 325 | case PRINT_FUNC: | 325 | case TEP_PRINT_FUNC: |
| 326 | case PRINT_BITMASK: | 326 | case TEP_PRINT_BITMASK: |
| 327 | /* we should warn... */ | 327 | /* we should warn... */ |
| 328 | return; | 328 | return; |
| 329 | } | 329 | } |
| @@ -332,10 +332,10 @@ static void define_event_symbols(struct event_format *event, | |||
| 332 | define_event_symbols(event, ev_name, args->next); | 332 | define_event_symbols(event, ev_name, args->next); |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | static PyObject *get_field_numeric_entry(struct event_format *event, | 335 | static PyObject *get_field_numeric_entry(struct tep_event_format *event, |
| 336 | struct format_field *field, void *data) | 336 | struct tep_format_field *field, void *data) |
| 337 | { | 337 | { |
| 338 | bool is_array = field->flags & FIELD_IS_ARRAY; | 338 | bool is_array = field->flags & TEP_FIELD_IS_ARRAY; |
| 339 | PyObject *obj = NULL, *list = NULL; | 339 | PyObject *obj = NULL, *list = NULL; |
| 340 | unsigned long long val; | 340 | unsigned long long val; |
| 341 | unsigned int item_size, n_items, i; | 341 | unsigned int item_size, n_items, i; |
| @@ -353,7 +353,7 @@ static PyObject *get_field_numeric_entry(struct event_format *event, | |||
| 353 | 353 | ||
| 354 | val = read_size(event, data + field->offset + i * item_size, | 354 | val = read_size(event, data + field->offset + i * item_size, |
| 355 | item_size); | 355 | item_size); |
| 356 | if (field->flags & FIELD_IS_SIGNED) { | 356 | if (field->flags & TEP_FIELD_IS_SIGNED) { |
| 357 | if ((long long)val >= LONG_MIN && | 357 | if ((long long)val >= LONG_MIN && |
| 358 | (long long)val <= LONG_MAX) | 358 | (long long)val <= LONG_MAX) |
| 359 | obj = _PyLong_FromLong(val); | 359 | obj = _PyLong_FromLong(val); |
| @@ -790,11 +790,11 @@ static void python_process_tracepoint(struct perf_sample *sample, | |||
| 790 | struct perf_evsel *evsel, | 790 | struct perf_evsel *evsel, |
| 791 | struct addr_location *al) | 791 | struct addr_location *al) |
| 792 | { | 792 | { |
| 793 | struct event_format *event = evsel->tp_format; | 793 | struct tep_event_format *event = evsel->tp_format; |
| 794 | PyObject *handler, *context, *t, *obj = NULL, *callchain; | 794 | PyObject *handler, *context, *t, *obj = NULL, *callchain; |
| 795 | PyObject *dict = NULL, *all_entries_dict = NULL; | 795 | PyObject *dict = NULL, *all_entries_dict = NULL; |
| 796 | static char handler_name[256]; | 796 | static char handler_name[256]; |
| 797 | struct format_field *field; | 797 | struct tep_format_field *field; |
| 798 | unsigned long s, ns; | 798 | unsigned long s, ns; |
| 799 | unsigned n = 0; | 799 | unsigned n = 0; |
| 800 | int pid; | 800 | int pid; |
| @@ -867,22 +867,22 @@ static void python_process_tracepoint(struct perf_sample *sample, | |||
| 867 | unsigned int offset, len; | 867 | unsigned int offset, len; |
| 868 | unsigned long long val; | 868 | unsigned long long val; |
| 869 | 869 | ||
| 870 | if (field->flags & FIELD_IS_ARRAY) { | 870 | if (field->flags & TEP_FIELD_IS_ARRAY) { |
| 871 | offset = field->offset; | 871 | offset = field->offset; |
| 872 | len = field->size; | 872 | len = field->size; |
| 873 | if (field->flags & FIELD_IS_DYNAMIC) { | 873 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 874 | val = tep_read_number(scripting_context->pevent, | 874 | val = tep_read_number(scripting_context->pevent, |
| 875 | data + offset, len); | 875 | data + offset, len); |
| 876 | offset = val; | 876 | offset = val; |
| 877 | len = offset >> 16; | 877 | len = offset >> 16; |
| 878 | offset &= 0xffff; | 878 | offset &= 0xffff; |
| 879 | } | 879 | } |
| 880 | if (field->flags & FIELD_IS_STRING && | 880 | if (field->flags & TEP_FIELD_IS_STRING && |
| 881 | is_printable_array(data + offset, len)) { | 881 | is_printable_array(data + offset, len)) { |
| 882 | obj = _PyUnicode_FromString((char *) data + offset); | 882 | obj = _PyUnicode_FromString((char *) data + offset); |
| 883 | } else { | 883 | } else { |
| 884 | obj = PyByteArray_FromStringAndSize((const char *) data + offset, len); | 884 | obj = PyByteArray_FromStringAndSize((const char *) data + offset, len); |
| 885 | field->flags &= ~FIELD_IS_STRING; | 885 | field->flags &= ~TEP_FIELD_IS_STRING; |
| 886 | } | 886 | } |
| 887 | } else { /* FIELD_IS_NUMERIC */ | 887 | } else { /* FIELD_IS_NUMERIC */ |
| 888 | obj = get_field_numeric_entry(event, field, data); | 888 | obj = get_field_numeric_entry(event, field, data); |
| @@ -1590,8 +1590,8 @@ static int python_stop_script(void) | |||
| 1590 | 1590 | ||
| 1591 | static int python_generate_script(struct tep_handle *pevent, const char *outfile) | 1591 | static int python_generate_script(struct tep_handle *pevent, const char *outfile) |
| 1592 | { | 1592 | { |
| 1593 | struct event_format *event = NULL; | 1593 | struct tep_event_format *event = NULL; |
| 1594 | struct format_field *f; | 1594 | struct tep_format_field *f; |
| 1595 | char fname[PATH_MAX]; | 1595 | char fname[PATH_MAX]; |
| 1596 | int not_first, count; | 1596 | int not_first, count; |
| 1597 | FILE *ofp; | 1597 | FILE *ofp; |
| @@ -1686,12 +1686,12 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile | |||
| 1686 | count++; | 1686 | count++; |
| 1687 | 1687 | ||
| 1688 | fprintf(ofp, "%s=", f->name); | 1688 | fprintf(ofp, "%s=", f->name); |
| 1689 | if (f->flags & FIELD_IS_STRING || | 1689 | if (f->flags & TEP_FIELD_IS_STRING || |
| 1690 | f->flags & FIELD_IS_FLAG || | 1690 | f->flags & TEP_FIELD_IS_FLAG || |
| 1691 | f->flags & FIELD_IS_ARRAY || | 1691 | f->flags & TEP_FIELD_IS_ARRAY || |
| 1692 | f->flags & FIELD_IS_SYMBOLIC) | 1692 | f->flags & TEP_FIELD_IS_SYMBOLIC) |
| 1693 | fprintf(ofp, "%%s"); | 1693 | fprintf(ofp, "%%s"); |
| 1694 | else if (f->flags & FIELD_IS_SIGNED) | 1694 | else if (f->flags & TEP_FIELD_IS_SIGNED) |
| 1695 | fprintf(ofp, "%%d"); | 1695 | fprintf(ofp, "%%d"); |
| 1696 | else | 1696 | else |
| 1697 | fprintf(ofp, "%%u"); | 1697 | fprintf(ofp, "%%u"); |
| @@ -1709,7 +1709,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile | |||
| 1709 | if (++count % 5 == 0) | 1709 | if (++count % 5 == 0) |
| 1710 | fprintf(ofp, "\n\t\t"); | 1710 | fprintf(ofp, "\n\t\t"); |
| 1711 | 1711 | ||
| 1712 | if (f->flags & FIELD_IS_FLAG) { | 1712 | if (f->flags & TEP_FIELD_IS_FLAG) { |
| 1713 | if ((count - 1) % 5 != 0) { | 1713 | if ((count - 1) % 5 != 0) { |
| 1714 | fprintf(ofp, "\n\t\t"); | 1714 | fprintf(ofp, "\n\t\t"); |
| 1715 | count = 4; | 1715 | count = 4; |
| @@ -1719,7 +1719,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile | |||
| 1719 | event->name); | 1719 | event->name); |
| 1720 | fprintf(ofp, "\"%s\", %s)", f->name, | 1720 | fprintf(ofp, "\"%s\", %s)", f->name, |
| 1721 | f->name); | 1721 | f->name); |
| 1722 | } else if (f->flags & FIELD_IS_SYMBOLIC) { | 1722 | } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) { |
| 1723 | if ((count - 1) % 5 != 0) { | 1723 | if ((count - 1) % 5 != 0) { |
| 1724 | fprintf(ofp, "\n\t\t"); | 1724 | fprintf(ofp, "\n\t\t"); |
| 1725 | count = 4; | 1725 | count = 4; |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 8b9369303561..7d2c8ce6cfad 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
| @@ -199,12 +199,10 @@ void perf_session__delete(struct perf_session *session) | |||
| 199 | free(session); | 199 | free(session); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | static int process_event_synth_tracing_data_stub(struct perf_tool *tool | 202 | static int process_event_synth_tracing_data_stub(struct perf_session *session |
| 203 | __maybe_unused, | 203 | __maybe_unused, |
| 204 | union perf_event *event | 204 | union perf_event *event |
| 205 | __maybe_unused, | 205 | __maybe_unused) |
| 206 | struct perf_session *session | ||
| 207 | __maybe_unused) | ||
| 208 | { | 206 | { |
| 209 | dump_printf(": unhandled!\n"); | 207 | dump_printf(": unhandled!\n"); |
| 210 | return 0; | 208 | return 0; |
| @@ -277,10 +275,8 @@ static int skipn(int fd, off_t n) | |||
| 277 | return 0; | 275 | return 0; |
| 278 | } | 276 | } |
| 279 | 277 | ||
| 280 | static s64 process_event_auxtrace_stub(struct perf_tool *tool __maybe_unused, | 278 | static s64 process_event_auxtrace_stub(struct perf_session *session __maybe_unused, |
| 281 | union perf_event *event, | 279 | union perf_event *event) |
| 282 | struct perf_session *session | ||
| 283 | __maybe_unused) | ||
| 284 | { | 280 | { |
| 285 | dump_printf(": unhandled!\n"); | 281 | dump_printf(": unhandled!\n"); |
| 286 | if (perf_data__is_pipe(session->data)) | 282 | if (perf_data__is_pipe(session->data)) |
| @@ -288,9 +284,8 @@ static s64 process_event_auxtrace_stub(struct perf_tool *tool __maybe_unused, | |||
| 288 | return event->auxtrace.size; | 284 | return event->auxtrace.size; |
| 289 | } | 285 | } |
| 290 | 286 | ||
| 291 | static int process_event_op2_stub(struct perf_tool *tool __maybe_unused, | 287 | static int process_event_op2_stub(struct perf_session *session __maybe_unused, |
| 292 | union perf_event *event __maybe_unused, | 288 | union perf_event *event __maybe_unused) |
| 293 | struct perf_session *session __maybe_unused) | ||
| 294 | { | 289 | { |
| 295 | dump_printf(": unhandled!\n"); | 290 | dump_printf(": unhandled!\n"); |
| 296 | return 0; | 291 | return 0; |
| @@ -298,9 +293,8 @@ static int process_event_op2_stub(struct perf_tool *tool __maybe_unused, | |||
| 298 | 293 | ||
| 299 | 294 | ||
| 300 | static | 295 | static |
| 301 | int process_event_thread_map_stub(struct perf_tool *tool __maybe_unused, | 296 | int process_event_thread_map_stub(struct perf_session *session __maybe_unused, |
| 302 | union perf_event *event __maybe_unused, | 297 | union perf_event *event __maybe_unused) |
| 303 | struct perf_session *session __maybe_unused) | ||
| 304 | { | 298 | { |
| 305 | if (dump_trace) | 299 | if (dump_trace) |
| 306 | perf_event__fprintf_thread_map(event, stdout); | 300 | perf_event__fprintf_thread_map(event, stdout); |
| @@ -310,9 +304,8 @@ int process_event_thread_map_stub(struct perf_tool *tool __maybe_unused, | |||
| 310 | } | 304 | } |
| 311 | 305 | ||
| 312 | static | 306 | static |
| 313 | int process_event_cpu_map_stub(struct perf_tool *tool __maybe_unused, | 307 | int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, |
| 314 | union perf_event *event __maybe_unused, | 308 | union perf_event *event __maybe_unused) |
| 315 | struct perf_session *session __maybe_unused) | ||
| 316 | { | 309 | { |
| 317 | if (dump_trace) | 310 | if (dump_trace) |
| 318 | perf_event__fprintf_cpu_map(event, stdout); | 311 | perf_event__fprintf_cpu_map(event, stdout); |
| @@ -322,9 +315,8 @@ int process_event_cpu_map_stub(struct perf_tool *tool __maybe_unused, | |||
| 322 | } | 315 | } |
| 323 | 316 | ||
| 324 | static | 317 | static |
| 325 | int process_event_stat_config_stub(struct perf_tool *tool __maybe_unused, | 318 | int process_event_stat_config_stub(struct perf_session *session __maybe_unused, |
| 326 | union perf_event *event __maybe_unused, | 319 | union perf_event *event __maybe_unused) |
| 327 | struct perf_session *session __maybe_unused) | ||
| 328 | { | 320 | { |
| 329 | if (dump_trace) | 321 | if (dump_trace) |
| 330 | perf_event__fprintf_stat_config(event, stdout); | 322 | perf_event__fprintf_stat_config(event, stdout); |
| @@ -333,10 +325,8 @@ int process_event_stat_config_stub(struct perf_tool *tool __maybe_unused, | |||
| 333 | return 0; | 325 | return 0; |
| 334 | } | 326 | } |
| 335 | 327 | ||
| 336 | static int process_stat_stub(struct perf_tool *tool __maybe_unused, | 328 | static int process_stat_stub(struct perf_session *perf_session __maybe_unused, |
| 337 | union perf_event *event __maybe_unused, | 329 | union perf_event *event) |
| 338 | struct perf_session *perf_session | ||
| 339 | __maybe_unused) | ||
| 340 | { | 330 | { |
| 341 | if (dump_trace) | 331 | if (dump_trace) |
| 342 | perf_event__fprintf_stat(event, stdout); | 332 | perf_event__fprintf_stat(event, stdout); |
| @@ -345,10 +335,8 @@ static int process_stat_stub(struct perf_tool *tool __maybe_unused, | |||
| 345 | return 0; | 335 | return 0; |
| 346 | } | 336 | } |
| 347 | 337 | ||
| 348 | static int process_stat_round_stub(struct perf_tool *tool __maybe_unused, | 338 | static int process_stat_round_stub(struct perf_session *perf_session __maybe_unused, |
| 349 | union perf_event *event __maybe_unused, | 339 | union perf_event *event) |
| 350 | struct perf_session *perf_session | ||
| 351 | __maybe_unused) | ||
| 352 | { | 340 | { |
| 353 | if (dump_trace) | 341 | if (dump_trace) |
| 354 | perf_event__fprintf_stat_round(event, stdout); | 342 | perf_event__fprintf_stat_round(event, stdout); |
| @@ -1374,37 +1362,37 @@ static s64 perf_session__process_user_event(struct perf_session *session, | |||
| 1374 | case PERF_RECORD_HEADER_TRACING_DATA: | 1362 | case PERF_RECORD_HEADER_TRACING_DATA: |
| 1375 | /* setup for reading amidst mmap */ | 1363 | /* setup for reading amidst mmap */ |
| 1376 | lseek(fd, file_offset, SEEK_SET); | 1364 | lseek(fd, file_offset, SEEK_SET); |
| 1377 | return tool->tracing_data(tool, event, session); | 1365 | return tool->tracing_data(session, event); |
| 1378 | case PERF_RECORD_HEADER_BUILD_ID: | 1366 | case PERF_RECORD_HEADER_BUILD_ID: |
| 1379 | return tool->build_id(tool, event, session); | 1367 | return tool->build_id(session, event); |
| 1380 | case PERF_RECORD_FINISHED_ROUND: | 1368 | case PERF_RECORD_FINISHED_ROUND: |
| 1381 | return tool->finished_round(tool, event, oe); | 1369 | return tool->finished_round(tool, event, oe); |
| 1382 | case PERF_RECORD_ID_INDEX: | 1370 | case PERF_RECORD_ID_INDEX: |
| 1383 | return tool->id_index(tool, event, session); | 1371 | return tool->id_index(session, event); |
| 1384 | case PERF_RECORD_AUXTRACE_INFO: | 1372 | case PERF_RECORD_AUXTRACE_INFO: |
| 1385 | return tool->auxtrace_info(tool, event, session); | 1373 | return tool->auxtrace_info(session, event); |
| 1386 | case PERF_RECORD_AUXTRACE: | 1374 | case PERF_RECORD_AUXTRACE: |
| 1387 | /* setup for reading amidst mmap */ | 1375 | /* setup for reading amidst mmap */ |
| 1388 | lseek(fd, file_offset + event->header.size, SEEK_SET); | 1376 | lseek(fd, file_offset + event->header.size, SEEK_SET); |
| 1389 | return tool->auxtrace(tool, event, session); | 1377 | return tool->auxtrace(session, event); |
| 1390 | case PERF_RECORD_AUXTRACE_ERROR: | 1378 | case PERF_RECORD_AUXTRACE_ERROR: |
| 1391 | perf_session__auxtrace_error_inc(session, event); | 1379 | perf_session__auxtrace_error_inc(session, event); |
| 1392 | return tool->auxtrace_error(tool, event, session); | 1380 | return tool->auxtrace_error(session, event); |
| 1393 | case PERF_RECORD_THREAD_MAP: | 1381 | case PERF_RECORD_THREAD_MAP: |
| 1394 | return tool->thread_map(tool, event, session); | 1382 | return tool->thread_map(session, event); |
| 1395 | case PERF_RECORD_CPU_MAP: | 1383 | case PERF_RECORD_CPU_MAP: |
| 1396 | return tool->cpu_map(tool, event, session); | 1384 | return tool->cpu_map(session, event); |
| 1397 | case PERF_RECORD_STAT_CONFIG: | 1385 | case PERF_RECORD_STAT_CONFIG: |
| 1398 | return tool->stat_config(tool, event, session); | 1386 | return tool->stat_config(session, event); |
| 1399 | case PERF_RECORD_STAT: | 1387 | case PERF_RECORD_STAT: |
| 1400 | return tool->stat(tool, event, session); | 1388 | return tool->stat(session, event); |
| 1401 | case PERF_RECORD_STAT_ROUND: | 1389 | case PERF_RECORD_STAT_ROUND: |
| 1402 | return tool->stat_round(tool, event, session); | 1390 | return tool->stat_round(session, event); |
| 1403 | case PERF_RECORD_TIME_CONV: | 1391 | case PERF_RECORD_TIME_CONV: |
| 1404 | session->time_conv = event->time_conv; | 1392 | session->time_conv = event->time_conv; |
| 1405 | return tool->time_conv(tool, event, session); | 1393 | return tool->time_conv(session, event); |
| 1406 | case PERF_RECORD_HEADER_FEATURE: | 1394 | case PERF_RECORD_HEADER_FEATURE: |
| 1407 | return tool->feature(tool, event, session); | 1395 | return tool->feature(session, event); |
| 1408 | default: | 1396 | default: |
| 1409 | return -EINVAL; | 1397 | return -EINVAL; |
| 1410 | } | 1398 | } |
| @@ -2133,9 +2121,8 @@ out: | |||
| 2133 | return err; | 2121 | return err; |
| 2134 | } | 2122 | } |
| 2135 | 2123 | ||
| 2136 | int perf_event__process_id_index(struct perf_tool *tool __maybe_unused, | 2124 | int perf_event__process_id_index(struct perf_session *session, |
| 2137 | union perf_event *event, | 2125 | union perf_event *event) |
| 2138 | struct perf_session *session) | ||
| 2139 | { | 2126 | { |
| 2140 | struct perf_evlist *evlist = session->evlist; | 2127 | struct perf_evlist *evlist = session->evlist; |
| 2141 | struct id_index_event *ie = &event->id_index; | 2128 | struct id_index_event *ie = &event->id_index; |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index da40b4b380ca..d96eccd7d27f 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
| @@ -120,9 +120,8 @@ int perf_session__deliver_synth_event(struct perf_session *session, | |||
| 120 | union perf_event *event, | 120 | union perf_event *event, |
| 121 | struct perf_sample *sample); | 121 | struct perf_sample *sample); |
| 122 | 122 | ||
| 123 | int perf_event__process_id_index(struct perf_tool *tool, | 123 | int perf_event__process_id_index(struct perf_session *session, |
| 124 | union perf_event *event, | 124 | union perf_event *event); |
| 125 | struct perf_session *session); | ||
| 126 | 125 | ||
| 127 | int perf_event__synthesize_id_index(struct perf_tool *tool, | 126 | int perf_event__synthesize_id_index(struct perf_tool *tool, |
| 128 | perf_event__handler_t process, | 127 | perf_event__handler_t process, |
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py index 97efbcad076e..1942f6dd24f6 100644 --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py | |||
| @@ -35,7 +35,7 @@ class install_lib(_install_lib): | |||
| 35 | 35 | ||
| 36 | cflags = getenv('CFLAGS', '').split() | 36 | cflags = getenv('CFLAGS', '').split() |
| 37 | # switch off several checks (need to be at the end of cflags list) | 37 | # switch off several checks (need to be at the end of cflags list) |
| 38 | cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ] | 38 | cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ] |
| 39 | if cc != "clang": | 39 | if cc != "clang": |
| 40 | cflags += ['-Wno-cast-function-type' ] | 40 | cflags += ['-Wno-cast-function-type' ] |
| 41 | 41 | ||
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b284276ec963..f96c005b3c41 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
| @@ -1884,7 +1884,7 @@ static int __sort_dimension__add_hpp_output(struct sort_dimension *sd, | |||
| 1884 | struct hpp_dynamic_entry { | 1884 | struct hpp_dynamic_entry { |
| 1885 | struct perf_hpp_fmt hpp; | 1885 | struct perf_hpp_fmt hpp; |
| 1886 | struct perf_evsel *evsel; | 1886 | struct perf_evsel *evsel; |
| 1887 | struct format_field *field; | 1887 | struct tep_format_field *field; |
| 1888 | unsigned dynamic_len; | 1888 | unsigned dynamic_len; |
| 1889 | bool raw_trace; | 1889 | bool raw_trace; |
| 1890 | }; | 1890 | }; |
| @@ -1899,7 +1899,7 @@ static int hde_width(struct hpp_dynamic_entry *hde) | |||
| 1899 | if (namelen > len) | 1899 | if (namelen > len) |
| 1900 | len = namelen; | 1900 | len = namelen; |
| 1901 | 1901 | ||
| 1902 | if (!(hde->field->flags & FIELD_IS_STRING)) { | 1902 | if (!(hde->field->flags & TEP_FIELD_IS_STRING)) { |
| 1903 | /* length for print hex numbers */ | 1903 | /* length for print hex numbers */ |
| 1904 | fieldlen = hde->field->size * 2 + 2; | 1904 | fieldlen = hde->field->size * 2 + 2; |
| 1905 | } | 1905 | } |
| @@ -1915,7 +1915,7 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde, | |||
| 1915 | struct hist_entry *he) | 1915 | struct hist_entry *he) |
| 1916 | { | 1916 | { |
| 1917 | char *str, *pos; | 1917 | char *str, *pos; |
| 1918 | struct format_field *field = hde->field; | 1918 | struct tep_format_field *field = hde->field; |
| 1919 | size_t namelen; | 1919 | size_t namelen; |
| 1920 | bool last = false; | 1920 | bool last = false; |
| 1921 | 1921 | ||
| @@ -2000,7 +2000,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | |||
| 2000 | struct hpp_dynamic_entry *hde; | 2000 | struct hpp_dynamic_entry *hde; |
| 2001 | size_t len = fmt->user_len; | 2001 | size_t len = fmt->user_len; |
| 2002 | char *str, *pos; | 2002 | char *str, *pos; |
| 2003 | struct format_field *field; | 2003 | struct tep_format_field *field; |
| 2004 | size_t namelen; | 2004 | size_t namelen; |
| 2005 | bool last = false; | 2005 | bool last = false; |
| 2006 | int ret; | 2006 | int ret; |
| @@ -2060,7 +2060,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, | |||
| 2060 | struct hist_entry *a, struct hist_entry *b) | 2060 | struct hist_entry *a, struct hist_entry *b) |
| 2061 | { | 2061 | { |
| 2062 | struct hpp_dynamic_entry *hde; | 2062 | struct hpp_dynamic_entry *hde; |
| 2063 | struct format_field *field; | 2063 | struct tep_format_field *field; |
| 2064 | unsigned offset, size; | 2064 | unsigned offset, size; |
| 2065 | 2065 | ||
| 2066 | hde = container_of(fmt, struct hpp_dynamic_entry, hpp); | 2066 | hde = container_of(fmt, struct hpp_dynamic_entry, hpp); |
| @@ -2071,7 +2071,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, | |||
| 2071 | } | 2071 | } |
| 2072 | 2072 | ||
| 2073 | field = hde->field; | 2073 | field = hde->field; |
| 2074 | if (field->flags & FIELD_IS_DYNAMIC) { | 2074 | if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
| 2075 | unsigned long long dyn; | 2075 | unsigned long long dyn; |
| 2076 | 2076 | ||
| 2077 | tep_read_number_field(field, a->raw_data, &dyn); | 2077 | tep_read_number_field(field, a->raw_data, &dyn); |
| @@ -2117,7 +2117,7 @@ static void hde_free(struct perf_hpp_fmt *fmt) | |||
| 2117 | } | 2117 | } |
| 2118 | 2118 | ||
| 2119 | static struct hpp_dynamic_entry * | 2119 | static struct hpp_dynamic_entry * |
| 2120 | __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field, | 2120 | __alloc_dynamic_entry(struct perf_evsel *evsel, struct tep_format_field *field, |
| 2121 | int level) | 2121 | int level) |
| 2122 | { | 2122 | { |
| 2123 | struct hpp_dynamic_entry *hde; | 2123 | struct hpp_dynamic_entry *hde; |
| @@ -2252,7 +2252,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam | |||
| 2252 | } | 2252 | } |
| 2253 | 2253 | ||
| 2254 | static int __dynamic_dimension__add(struct perf_evsel *evsel, | 2254 | static int __dynamic_dimension__add(struct perf_evsel *evsel, |
| 2255 | struct format_field *field, | 2255 | struct tep_format_field *field, |
| 2256 | bool raw_trace, int level) | 2256 | bool raw_trace, int level) |
| 2257 | { | 2257 | { |
| 2258 | struct hpp_dynamic_entry *hde; | 2258 | struct hpp_dynamic_entry *hde; |
| @@ -2270,7 +2270,7 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel, | |||
| 2270 | static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace, int level) | 2270 | static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace, int level) |
| 2271 | { | 2271 | { |
| 2272 | int ret; | 2272 | int ret; |
| 2273 | struct format_field *field; | 2273 | struct tep_format_field *field; |
| 2274 | 2274 | ||
| 2275 | field = evsel->tp_format->format.fields; | 2275 | field = evsel->tp_format->format.fields; |
| 2276 | while (field) { | 2276 | while (field) { |
| @@ -2305,7 +2305,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist, | |||
| 2305 | { | 2305 | { |
| 2306 | int ret = -ESRCH; | 2306 | int ret = -ESRCH; |
| 2307 | struct perf_evsel *evsel; | 2307 | struct perf_evsel *evsel; |
| 2308 | struct format_field *field; | 2308 | struct tep_format_field *field; |
| 2309 | 2309 | ||
| 2310 | evlist__for_each_entry(evlist, evsel) { | 2310 | evlist__for_each_entry(evlist, evsel) { |
| 2311 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | 2311 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
| @@ -2327,7 +2327,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok, | |||
| 2327 | { | 2327 | { |
| 2328 | char *str, *event_name, *field_name, *opt_name; | 2328 | char *str, *event_name, *field_name, *opt_name; |
| 2329 | struct perf_evsel *evsel; | 2329 | struct perf_evsel *evsel; |
| 2330 | struct format_field *field; | 2330 | struct tep_format_field *field; |
| 2331 | bool raw_trace = symbol_conf.raw_trace; | 2331 | bool raw_trace = symbol_conf.raw_trace; |
| 2332 | int ret = 0; | 2332 | int ret = 0; |
| 2333 | 2333 | ||
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c new file mode 100644 index 000000000000..e7b4c44ebb62 --- /dev/null +++ b/tools/perf/util/stat-display.c | |||
| @@ -0,0 +1,1166 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <inttypes.h> | ||
| 3 | #include <linux/time64.h> | ||
| 4 | #include <math.h> | ||
| 5 | #include "evlist.h" | ||
| 6 | #include "evsel.h" | ||
| 7 | #include "stat.h" | ||
| 8 | #include "top.h" | ||
| 9 | #include "thread_map.h" | ||
| 10 | #include "cpumap.h" | ||
| 11 | #include "string2.h" | ||
| 12 | #include "sane_ctype.h" | ||
| 13 | #include "cgroup.h" | ||
| 14 | #include <math.h> | ||
| 15 | #include <api/fs/fs.h> | ||
| 16 | |||
| 17 | #define CNTR_NOT_SUPPORTED "<not supported>" | ||
| 18 | #define CNTR_NOT_COUNTED "<not counted>" | ||
| 19 | |||
| 20 | static bool is_duration_time(struct perf_evsel *evsel) | ||
| 21 | { | ||
| 22 | return !strcmp(evsel->name, "duration_time"); | ||
| 23 | } | ||
| 24 | |||
| 25 | static void print_running(struct perf_stat_config *config, | ||
| 26 | u64 run, u64 ena) | ||
| 27 | { | ||
| 28 | if (config->csv_output) { | ||
| 29 | fprintf(config->output, "%s%" PRIu64 "%s%.2f", | ||
| 30 | config->csv_sep, | ||
| 31 | run, | ||
| 32 | config->csv_sep, | ||
| 33 | ena ? 100.0 * run / ena : 100.0); | ||
| 34 | } else if (run != ena) { | ||
| 35 | fprintf(config->output, " (%.2f%%)", 100.0 * run / ena); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | static void print_noise_pct(struct perf_stat_config *config, | ||
| 40 | double total, double avg) | ||
| 41 | { | ||
| 42 | double pct = rel_stddev_stats(total, avg); | ||
| 43 | |||
| 44 | if (config->csv_output) | ||
| 45 | fprintf(config->output, "%s%.2f%%", config->csv_sep, pct); | ||
| 46 | else if (pct) | ||
| 47 | fprintf(config->output, " ( +-%6.2f%% )", pct); | ||
| 48 | } | ||
| 49 | |||
| 50 | static void print_noise(struct perf_stat_config *config, | ||
| 51 | struct perf_evsel *evsel, double avg) | ||
| 52 | { | ||
| 53 | struct perf_stat_evsel *ps; | ||
| 54 | |||
| 55 | if (config->run_count == 1) | ||
| 56 | return; | ||
| 57 | |||
| 58 | ps = evsel->stats; | ||
| 59 | print_noise_pct(config, stddev_stats(&ps->res_stats[0]), avg); | ||
| 60 | } | ||
| 61 | |||
| 62 | static void aggr_printout(struct perf_stat_config *config, | ||
| 63 | struct perf_evsel *evsel, int id, int nr) | ||
| 64 | { | ||
| 65 | switch (config->aggr_mode) { | ||
| 66 | case AGGR_CORE: | ||
| 67 | fprintf(config->output, "S%d-C%*d%s%*d%s", | ||
| 68 | cpu_map__id_to_socket(id), | ||
| 69 | config->csv_output ? 0 : -8, | ||
| 70 | cpu_map__id_to_cpu(id), | ||
| 71 | config->csv_sep, | ||
| 72 | config->csv_output ? 0 : 4, | ||
| 73 | nr, | ||
| 74 | config->csv_sep); | ||
| 75 | break; | ||
| 76 | case AGGR_SOCKET: | ||
| 77 | fprintf(config->output, "S%*d%s%*d%s", | ||
| 78 | config->csv_output ? 0 : -5, | ||
| 79 | id, | ||
| 80 | config->csv_sep, | ||
| 81 | config->csv_output ? 0 : 4, | ||
| 82 | nr, | ||
| 83 | config->csv_sep); | ||
| 84 | break; | ||
| 85 | case AGGR_NONE: | ||
| 86 | fprintf(config->output, "CPU%*d%s", | ||
| 87 | config->csv_output ? 0 : -4, | ||
| 88 | perf_evsel__cpus(evsel)->map[id], config->csv_sep); | ||
| 89 | break; | ||
| 90 | case AGGR_THREAD: | ||
| 91 | fprintf(config->output, "%*s-%*d%s", | ||
| 92 | config->csv_output ? 0 : 16, | ||
| 93 | thread_map__comm(evsel->threads, id), | ||
| 94 | config->csv_output ? 0 : -8, | ||
| 95 | thread_map__pid(evsel->threads, id), | ||
| 96 | config->csv_sep); | ||
| 97 | break; | ||
| 98 | case AGGR_GLOBAL: | ||
| 99 | case AGGR_UNSET: | ||
| 100 | default: | ||
| 101 | break; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | struct outstate { | ||
| 106 | FILE *fh; | ||
| 107 | bool newline; | ||
| 108 | const char *prefix; | ||
| 109 | int nfields; | ||
| 110 | int id, nr; | ||
| 111 | struct perf_evsel *evsel; | ||
| 112 | }; | ||
| 113 | |||
| 114 | #define METRIC_LEN 35 | ||
| 115 | |||
| 116 | static void new_line_std(struct perf_stat_config *config __maybe_unused, | ||
| 117 | void *ctx) | ||
| 118 | { | ||
| 119 | struct outstate *os = ctx; | ||
| 120 | |||
| 121 | os->newline = true; | ||
| 122 | } | ||
| 123 | |||
| 124 | static void do_new_line_std(struct perf_stat_config *config, | ||
| 125 | struct outstate *os) | ||
| 126 | { | ||
| 127 | fputc('\n', os->fh); | ||
| 128 | fputs(os->prefix, os->fh); | ||
| 129 | aggr_printout(config, os->evsel, os->id, os->nr); | ||
| 130 | if (config->aggr_mode == AGGR_NONE) | ||
| 131 | fprintf(os->fh, " "); | ||
| 132 | fprintf(os->fh, " "); | ||
| 133 | } | ||
| 134 | |||
| 135 | static void print_metric_std(struct perf_stat_config *config, | ||
| 136 | void *ctx, const char *color, const char *fmt, | ||
| 137 | const char *unit, double val) | ||
| 138 | { | ||
| 139 | struct outstate *os = ctx; | ||
| 140 | FILE *out = os->fh; | ||
| 141 | int n; | ||
| 142 | bool newline = os->newline; | ||
| 143 | |||
| 144 | os->newline = false; | ||
| 145 | |||
| 146 | if (unit == NULL || fmt == NULL) { | ||
| 147 | fprintf(out, "%-*s", METRIC_LEN, ""); | ||
| 148 | return; | ||
| 149 | } | ||
| 150 | |||
| 151 | if (newline) | ||
| 152 | do_new_line_std(config, os); | ||
| 153 | |||
| 154 | n = fprintf(out, " # "); | ||
| 155 | if (color) | ||
| 156 | n += color_fprintf(out, color, fmt, val); | ||
| 157 | else | ||
| 158 | n += fprintf(out, fmt, val); | ||
| 159 | fprintf(out, " %-*s", METRIC_LEN - n - 1, unit); | ||
| 160 | } | ||
| 161 | |||
| 162 | static void new_line_csv(struct perf_stat_config *config, void *ctx) | ||
| 163 | { | ||
| 164 | struct outstate *os = ctx; | ||
| 165 | int i; | ||
| 166 | |||
| 167 | fputc('\n', os->fh); | ||
| 168 | if (os->prefix) | ||
| 169 | fprintf(os->fh, "%s%s", os->prefix, config->csv_sep); | ||
| 170 | aggr_printout(config, os->evsel, os->id, os->nr); | ||
| 171 | for (i = 0; i < os->nfields; i++) | ||
| 172 | fputs(config->csv_sep, os->fh); | ||
| 173 | } | ||
| 174 | |||
| 175 | static void print_metric_csv(struct perf_stat_config *config __maybe_unused, | ||
| 176 | void *ctx, | ||
| 177 | const char *color __maybe_unused, | ||
| 178 | const char *fmt, const char *unit, double val) | ||
| 179 | { | ||
| 180 | struct outstate *os = ctx; | ||
| 181 | FILE *out = os->fh; | ||
| 182 | char buf[64], *vals, *ends; | ||
| 183 | |||
| 184 | if (unit == NULL || fmt == NULL) { | ||
| 185 | fprintf(out, "%s%s", config->csv_sep, config->csv_sep); | ||
| 186 | return; | ||
| 187 | } | ||
| 188 | snprintf(buf, sizeof(buf), fmt, val); | ||
| 189 | ends = vals = ltrim(buf); | ||
| 190 | while (isdigit(*ends) || *ends == '.') | ||
| 191 | ends++; | ||
| 192 | *ends = 0; | ||
| 193 | while (isspace(*unit)) | ||
| 194 | unit++; | ||
| 195 | fprintf(out, "%s%s%s%s", config->csv_sep, vals, config->csv_sep, unit); | ||
| 196 | } | ||
| 197 | |||
| 198 | /* Filter out some columns that don't work well in metrics only mode */ | ||
| 199 | |||
| 200 | static bool valid_only_metric(const char *unit) | ||
| 201 | { | ||
| 202 | if (!unit) | ||
| 203 | return false; | ||
| 204 | if (strstr(unit, "/sec") || | ||
| 205 | strstr(unit, "hz") || | ||
| 206 | strstr(unit, "Hz") || | ||
| 207 | strstr(unit, "CPUs utilized")) | ||
| 208 | return false; | ||
| 209 | return true; | ||
| 210 | } | ||
| 211 | |||
| 212 | static const char *fixunit(char *buf, struct perf_evsel *evsel, | ||
| 213 | const char *unit) | ||
| 214 | { | ||
| 215 | if (!strncmp(unit, "of all", 6)) { | ||
| 216 | snprintf(buf, 1024, "%s %s", perf_evsel__name(evsel), | ||
| 217 | unit); | ||
| 218 | return buf; | ||
| 219 | } | ||
| 220 | return unit; | ||
| 221 | } | ||
| 222 | |||
| 223 | static void print_metric_only(struct perf_stat_config *config, | ||
| 224 | void *ctx, const char *color, const char *fmt, | ||
| 225 | const char *unit, double val) | ||
| 226 | { | ||
| 227 | struct outstate *os = ctx; | ||
| 228 | FILE *out = os->fh; | ||
| 229 | char buf[1024], str[1024]; | ||
| 230 | unsigned mlen = config->metric_only_len; | ||
| 231 | |||
| 232 | if (!valid_only_metric(unit)) | ||
| 233 | return; | ||
| 234 | unit = fixunit(buf, os->evsel, unit); | ||
| 235 | if (mlen < strlen(unit)) | ||
| 236 | mlen = strlen(unit) + 1; | ||
| 237 | |||
| 238 | if (color) | ||
| 239 | mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1; | ||
| 240 | |||
| 241 | color_snprintf(str, sizeof(str), color ?: "", fmt, val); | ||
| 242 | fprintf(out, "%*s ", mlen, str); | ||
| 243 | } | ||
| 244 | |||
| 245 | static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused, | ||
| 246 | void *ctx, const char *color __maybe_unused, | ||
| 247 | const char *fmt, | ||
| 248 | const char *unit, double val) | ||
| 249 | { | ||
| 250 | struct outstate *os = ctx; | ||
| 251 | FILE *out = os->fh; | ||
| 252 | char buf[64], *vals, *ends; | ||
| 253 | char tbuf[1024]; | ||
| 254 | |||
| 255 | if (!valid_only_metric(unit)) | ||
| 256 | return; | ||
| 257 | unit = fixunit(tbuf, os->evsel, unit); | ||
| 258 | snprintf(buf, sizeof buf, fmt, val); | ||
| 259 | ends = vals = ltrim(buf); | ||
| 260 | while (isdigit(*ends) || *ends == '.') | ||
| 261 | ends++; | ||
| 262 | *ends = 0; | ||
| 263 | fprintf(out, "%s%s", vals, config->csv_sep); | ||
| 264 | } | ||
| 265 | |||
| 266 | static void new_line_metric(struct perf_stat_config *config __maybe_unused, | ||
| 267 | void *ctx __maybe_unused) | ||
| 268 | { | ||
| 269 | } | ||
| 270 | |||
| 271 | static void print_metric_header(struct perf_stat_config *config, | ||
| 272 | void *ctx, const char *color __maybe_unused, | ||
| 273 | const char *fmt __maybe_unused, | ||
| 274 | const char *unit, double val __maybe_unused) | ||
| 275 | { | ||
| 276 | struct outstate *os = ctx; | ||
| 277 | char tbuf[1024]; | ||
| 278 | |||
| 279 | if (!valid_only_metric(unit)) | ||
| 280 | return; | ||
| 281 | unit = fixunit(tbuf, os->evsel, unit); | ||
| 282 | if (config->csv_output) | ||
| 283 | fprintf(os->fh, "%s%s", unit, config->csv_sep); | ||
| 284 | else | ||
| 285 | fprintf(os->fh, "%*s ", config->metric_only_len, unit); | ||
| 286 | } | ||
| 287 | |||
| 288 | static int first_shadow_cpu(struct perf_stat_config *config, | ||
| 289 | struct perf_evsel *evsel, int id) | ||
| 290 | { | ||
| 291 | struct perf_evlist *evlist = evsel->evlist; | ||
| 292 | int i; | ||
| 293 | |||
| 294 | if (!config->aggr_get_id) | ||
| 295 | return 0; | ||
| 296 | |||
| 297 | if (config->aggr_mode == AGGR_NONE) | ||
| 298 | return id; | ||
| 299 | |||
| 300 | if (config->aggr_mode == AGGR_GLOBAL) | ||
| 301 | return 0; | ||
| 302 | |||
| 303 | for (i = 0; i < perf_evsel__nr_cpus(evsel); i++) { | ||
| 304 | int cpu2 = perf_evsel__cpus(evsel)->map[i]; | ||
| 305 | |||
| 306 | if (config->aggr_get_id(config, evlist->cpus, cpu2) == id) | ||
| 307 | return cpu2; | ||
| 308 | } | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | static void abs_printout(struct perf_stat_config *config, | ||
| 313 | int id, int nr, struct perf_evsel *evsel, double avg) | ||
| 314 | { | ||
| 315 | FILE *output = config->output; | ||
| 316 | double sc = evsel->scale; | ||
| 317 | const char *fmt; | ||
| 318 | |||
| 319 | if (config->csv_output) { | ||
| 320 | fmt = floor(sc) != sc ? "%.2f%s" : "%.0f%s"; | ||
| 321 | } else { | ||
| 322 | if (config->big_num) | ||
| 323 | fmt = floor(sc) != sc ? "%'18.2f%s" : "%'18.0f%s"; | ||
| 324 | else | ||
| 325 | fmt = floor(sc) != sc ? "%18.2f%s" : "%18.0f%s"; | ||
| 326 | } | ||
| 327 | |||
| 328 | aggr_printout(config, evsel, id, nr); | ||
| 329 | |||
| 330 | fprintf(output, fmt, avg, config->csv_sep); | ||
| 331 | |||
| 332 | if (evsel->unit) | ||
| 333 | fprintf(output, "%-*s%s", | ||
| 334 | config->csv_output ? 0 : config->unit_width, | ||
| 335 | evsel->unit, config->csv_sep); | ||
| 336 | |||
| 337 | fprintf(output, "%-*s", config->csv_output ? 0 : 25, perf_evsel__name(evsel)); | ||
| 338 | |||
| 339 | if (evsel->cgrp) | ||
| 340 | fprintf(output, "%s%s", config->csv_sep, evsel->cgrp->name); | ||
| 341 | } | ||
| 342 | |||
| 343 | static bool is_mixed_hw_group(struct perf_evsel *counter) | ||
| 344 | { | ||
| 345 | struct perf_evlist *evlist = counter->evlist; | ||
| 346 | u32 pmu_type = counter->attr.type; | ||
| 347 | struct perf_evsel *pos; | ||
| 348 | |||
| 349 | if (counter->nr_members < 2) | ||
| 350 | return false; | ||
| 351 | |||
| 352 | evlist__for_each_entry(evlist, pos) { | ||
| 353 | /* software events can be part of any hardware group */ | ||
| 354 | if (pos->attr.type == PERF_TYPE_SOFTWARE) | ||
| 355 | continue; | ||
| 356 | if (pmu_type == PERF_TYPE_SOFTWARE) { | ||
| 357 | pmu_type = pos->attr.type; | ||
| 358 | continue; | ||
| 359 | } | ||
| 360 | if (pmu_type != pos->attr.type) | ||
| 361 | return true; | ||
| 362 | } | ||
| 363 | |||
| 364 | return false; | ||
| 365 | } | ||
| 366 | |||
| 367 | static void printout(struct perf_stat_config *config, int id, int nr, | ||
| 368 | struct perf_evsel *counter, double uval, | ||
| 369 | char *prefix, u64 run, u64 ena, double noise, | ||
| 370 | struct runtime_stat *st) | ||
| 371 | { | ||
| 372 | struct perf_stat_output_ctx out; | ||
| 373 | struct outstate os = { | ||
| 374 | .fh = config->output, | ||
| 375 | .prefix = prefix ? prefix : "", | ||
| 376 | .id = id, | ||
| 377 | .nr = nr, | ||
| 378 | .evsel = counter, | ||
| 379 | }; | ||
| 380 | print_metric_t pm = print_metric_std; | ||
| 381 | new_line_t nl; | ||
| 382 | |||
| 383 | if (config->metric_only) { | ||
| 384 | nl = new_line_metric; | ||
| 385 | if (config->csv_output) | ||
| 386 | pm = print_metric_only_csv; | ||
| 387 | else | ||
| 388 | pm = print_metric_only; | ||
| 389 | } else | ||
| 390 | nl = new_line_std; | ||
| 391 | |||
| 392 | if (config->csv_output && !config->metric_only) { | ||
| 393 | static int aggr_fields[] = { | ||
| 394 | [AGGR_GLOBAL] = 0, | ||
| 395 | [AGGR_THREAD] = 1, | ||
| 396 | [AGGR_NONE] = 1, | ||
| 397 | [AGGR_SOCKET] = 2, | ||
| 398 | [AGGR_CORE] = 2, | ||
| 399 | }; | ||
| 400 | |||
| 401 | pm = print_metric_csv; | ||
| 402 | nl = new_line_csv; | ||
| 403 | os.nfields = 3; | ||
| 404 | os.nfields += aggr_fields[config->aggr_mode]; | ||
| 405 | if (counter->cgrp) | ||
| 406 | os.nfields++; | ||
| 407 | } | ||
| 408 | if (run == 0 || ena == 0 || counter->counts->scaled == -1) { | ||
| 409 | if (config->metric_only) { | ||
| 410 | pm(config, &os, NULL, "", "", 0); | ||
| 411 | return; | ||
| 412 | } | ||
| 413 | aggr_printout(config, counter, id, nr); | ||
| 414 | |||
| 415 | fprintf(config->output, "%*s%s", | ||
| 416 | config->csv_output ? 0 : 18, | ||
| 417 | counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED, | ||
| 418 | config->csv_sep); | ||
| 419 | |||
| 420 | if (counter->supported) { | ||
| 421 | config->print_free_counters_hint = 1; | ||
| 422 | if (is_mixed_hw_group(counter)) | ||
| 423 | config->print_mixed_hw_group_error = 1; | ||
| 424 | } | ||
| 425 | |||
| 426 | fprintf(config->output, "%-*s%s", | ||
| 427 | config->csv_output ? 0 : config->unit_width, | ||
| 428 | counter->unit, config->csv_sep); | ||
| 429 | |||
| 430 | fprintf(config->output, "%*s", | ||
| 431 | config->csv_output ? 0 : -25, | ||
| 432 | perf_evsel__name(counter)); | ||
| 433 | |||
| 434 | if (counter->cgrp) | ||
| 435 | fprintf(config->output, "%s%s", | ||
| 436 | config->csv_sep, counter->cgrp->name); | ||
| 437 | |||
| 438 | if (!config->csv_output) | ||
| 439 | pm(config, &os, NULL, NULL, "", 0); | ||
| 440 | print_noise(config, counter, noise); | ||
| 441 | print_running(config, run, ena); | ||
| 442 | if (config->csv_output) | ||
| 443 | pm(config, &os, NULL, NULL, "", 0); | ||
| 444 | return; | ||
| 445 | } | ||
| 446 | |||
| 447 | if (!config->metric_only) | ||
| 448 | abs_printout(config, id, nr, counter, uval); | ||
| 449 | |||
| 450 | out.print_metric = pm; | ||
| 451 | out.new_line = nl; | ||
| 452 | out.ctx = &os; | ||
| 453 | out.force_header = false; | ||
| 454 | |||
| 455 | if (config->csv_output && !config->metric_only) { | ||
| 456 | print_noise(config, counter, noise); | ||
| 457 | print_running(config, run, ena); | ||
| 458 | } | ||
| 459 | |||
| 460 | perf_stat__print_shadow_stats(config, counter, uval, | ||
| 461 | first_shadow_cpu(config, counter, id), | ||
| 462 | &out, &config->metric_events, st); | ||
| 463 | if (!config->csv_output && !config->metric_only) { | ||
| 464 | print_noise(config, counter, noise); | ||
| 465 | print_running(config, run, ena); | ||
| 466 | } | ||
| 467 | } | ||
| 468 | |||
| 469 | static void aggr_update_shadow(struct perf_stat_config *config, | ||
| 470 | struct perf_evlist *evlist) | ||
| 471 | { | ||
| 472 | int cpu, s2, id, s; | ||
| 473 | u64 val; | ||
| 474 | struct perf_evsel *counter; | ||
| 475 | |||
| 476 | for (s = 0; s < config->aggr_map->nr; s++) { | ||
| 477 | id = config->aggr_map->map[s]; | ||
| 478 | evlist__for_each_entry(evlist, counter) { | ||
| 479 | val = 0; | ||
| 480 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | ||
| 481 | s2 = config->aggr_get_id(config, evlist->cpus, cpu); | ||
| 482 | if (s2 != id) | ||
| 483 | continue; | ||
| 484 | val += perf_counts(counter->counts, cpu, 0)->val; | ||
| 485 | } | ||
| 486 | perf_stat__update_shadow_stats(counter, val, | ||
| 487 | first_shadow_cpu(config, counter, id), | ||
| 488 | &rt_stat); | ||
| 489 | } | ||
| 490 | } | ||
| 491 | } | ||
| 492 | |||
| 493 | static void uniquify_event_name(struct perf_evsel *counter) | ||
| 494 | { | ||
| 495 | char *new_name; | ||
| 496 | char *config; | ||
| 497 | |||
| 498 | if (counter->uniquified_name || | ||
| 499 | !counter->pmu_name || !strncmp(counter->name, counter->pmu_name, | ||
| 500 | strlen(counter->pmu_name))) | ||
| 501 | return; | ||
| 502 | |||
| 503 | config = strchr(counter->name, '/'); | ||
| 504 | if (config) { | ||
| 505 | if (asprintf(&new_name, | ||
| 506 | "%s%s", counter->pmu_name, config) > 0) { | ||
| 507 | free(counter->name); | ||
| 508 | counter->name = new_name; | ||
| 509 | } | ||
| 510 | } else { | ||
| 511 | if (asprintf(&new_name, | ||
| 512 | "%s [%s]", counter->name, counter->pmu_name) > 0) { | ||
| 513 | free(counter->name); | ||
| 514 | counter->name = new_name; | ||
| 515 | } | ||
| 516 | } | ||
| 517 | |||
| 518 | counter->uniquified_name = true; | ||
| 519 | } | ||
| 520 | |||
| 521 | static void collect_all_aliases(struct perf_stat_config *config, struct perf_evsel *counter, | ||
| 522 | void (*cb)(struct perf_stat_config *config, struct perf_evsel *counter, void *data, | ||
| 523 | bool first), | ||
| 524 | void *data) | ||
| 525 | { | ||
| 526 | struct perf_evlist *evlist = counter->evlist; | ||
| 527 | struct perf_evsel *alias; | ||
| 528 | |||
| 529 | alias = list_prepare_entry(counter, &(evlist->entries), node); | ||
| 530 | list_for_each_entry_continue (alias, &evlist->entries, node) { | ||
| 531 | if (strcmp(perf_evsel__name(alias), perf_evsel__name(counter)) || | ||
| 532 | alias->scale != counter->scale || | ||
| 533 | alias->cgrp != counter->cgrp || | ||
| 534 | strcmp(alias->unit, counter->unit) || | ||
| 535 | perf_evsel__is_clock(alias) != perf_evsel__is_clock(counter)) | ||
| 536 | break; | ||
| 537 | alias->merged_stat = true; | ||
| 538 | cb(config, alias, data, false); | ||
| 539 | } | ||
| 540 | } | ||
| 541 | |||
| 542 | static bool collect_data(struct perf_stat_config *config, struct perf_evsel *counter, | ||
| 543 | void (*cb)(struct perf_stat_config *config, struct perf_evsel *counter, void *data, | ||
| 544 | bool first), | ||
| 545 | void *data) | ||
| 546 | { | ||
| 547 | if (counter->merged_stat) | ||
| 548 | return false; | ||
| 549 | cb(config, counter, data, true); | ||
| 550 | if (config->no_merge) | ||
| 551 | uniquify_event_name(counter); | ||
| 552 | else if (counter->auto_merge_stats) | ||
| 553 | collect_all_aliases(config, counter, cb, data); | ||
| 554 | return true; | ||
| 555 | } | ||
| 556 | |||
| 557 | struct aggr_data { | ||
| 558 | u64 ena, run, val; | ||
| 559 | int id; | ||
| 560 | int nr; | ||
| 561 | int cpu; | ||
| 562 | }; | ||
| 563 | |||
| 564 | static void aggr_cb(struct perf_stat_config *config, | ||
| 565 | struct perf_evsel *counter, void *data, bool first) | ||
| 566 | { | ||
| 567 | struct aggr_data *ad = data; | ||
| 568 | int cpu, s2; | ||
| 569 | |||
| 570 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | ||
| 571 | struct perf_counts_values *counts; | ||
| 572 | |||
| 573 | s2 = config->aggr_get_id(config, perf_evsel__cpus(counter), cpu); | ||
| 574 | if (s2 != ad->id) | ||
| 575 | continue; | ||
| 576 | if (first) | ||
| 577 | ad->nr++; | ||
| 578 | counts = perf_counts(counter->counts, cpu, 0); | ||
| 579 | /* | ||
| 580 | * When any result is bad, make them all to give | ||
| 581 | * consistent output in interval mode. | ||
| 582 | */ | ||
| 583 | if (counts->ena == 0 || counts->run == 0 || | ||
| 584 | counter->counts->scaled == -1) { | ||
| 585 | ad->ena = 0; | ||
| 586 | ad->run = 0; | ||
| 587 | break; | ||
| 588 | } | ||
| 589 | ad->val += counts->val; | ||
| 590 | ad->ena += counts->ena; | ||
| 591 | ad->run += counts->run; | ||
| 592 | } | ||
| 593 | } | ||
| 594 | |||
| 595 | static void print_aggr(struct perf_stat_config *config, | ||
| 596 | struct perf_evlist *evlist, | ||
| 597 | char *prefix) | ||
| 598 | { | ||
| 599 | bool metric_only = config->metric_only; | ||
| 600 | FILE *output = config->output; | ||
| 601 | struct perf_evsel *counter; | ||
| 602 | int s, id, nr; | ||
| 603 | double uval; | ||
| 604 | u64 ena, run, val; | ||
| 605 | bool first; | ||
| 606 | |||
| 607 | if (!(config->aggr_map || config->aggr_get_id)) | ||
| 608 | return; | ||
| 609 | |||
| 610 | aggr_update_shadow(config, evlist); | ||
| 611 | |||
| 612 | /* | ||
| 613 | * With metric_only everything is on a single line. | ||
| 614 | * Without each counter has its own line. | ||
| 615 | */ | ||
| 616 | for (s = 0; s < config->aggr_map->nr; s++) { | ||
| 617 | struct aggr_data ad; | ||
| 618 | if (prefix && metric_only) | ||
| 619 | fprintf(output, "%s", prefix); | ||
| 620 | |||
| 621 | ad.id = id = config->aggr_map->map[s]; | ||
| 622 | first = true; | ||
| 623 | evlist__for_each_entry(evlist, counter) { | ||
| 624 | if (is_duration_time(counter)) | ||
| 625 | continue; | ||
| 626 | |||
| 627 | ad.val = ad.ena = ad.run = 0; | ||
| 628 | ad.nr = 0; | ||
| 629 | if (!collect_data(config, counter, aggr_cb, &ad)) | ||
| 630 | continue; | ||
| 631 | nr = ad.nr; | ||
| 632 | ena = ad.ena; | ||
| 633 | run = ad.run; | ||
| 634 | val = ad.val; | ||
| 635 | if (first && metric_only) { | ||
| 636 | first = false; | ||
| 637 | aggr_printout(config, counter, id, nr); | ||
| 638 | } | ||
| 639 | if (prefix && !metric_only) | ||
| 640 | fprintf(output, "%s", prefix); | ||
| 641 | |||
| 642 | uval = val * counter->scale; | ||
| 643 | printout(config, id, nr, counter, uval, prefix, | ||
| 644 | run, ena, 1.0, &rt_stat); | ||
| 645 | if (!metric_only) | ||
| 646 | fputc('\n', output); | ||
| 647 | } | ||
| 648 | if (metric_only) | ||
| 649 | fputc('\n', output); | ||
| 650 | } | ||
| 651 | } | ||
| 652 | |||
| 653 | static int cmp_val(const void *a, const void *b) | ||
| 654 | { | ||
| 655 | return ((struct perf_aggr_thread_value *)b)->val - | ||
| 656 | ((struct perf_aggr_thread_value *)a)->val; | ||
| 657 | } | ||
| 658 | |||
| 659 | static struct perf_aggr_thread_value *sort_aggr_thread( | ||
| 660 | struct perf_evsel *counter, | ||
| 661 | int nthreads, int ncpus, | ||
| 662 | int *ret, | ||
| 663 | struct target *_target) | ||
| 664 | { | ||
| 665 | int cpu, thread, i = 0; | ||
| 666 | double uval; | ||
| 667 | struct perf_aggr_thread_value *buf; | ||
| 668 | |||
| 669 | buf = calloc(nthreads, sizeof(struct perf_aggr_thread_value)); | ||
| 670 | if (!buf) | ||
| 671 | return NULL; | ||
| 672 | |||
| 673 | for (thread = 0; thread < nthreads; thread++) { | ||
| 674 | u64 ena = 0, run = 0, val = 0; | ||
| 675 | |||
| 676 | for (cpu = 0; cpu < ncpus; cpu++) { | ||
| 677 | val += perf_counts(counter->counts, cpu, thread)->val; | ||
| 678 | ena += perf_counts(counter->counts, cpu, thread)->ena; | ||
| 679 | run += perf_counts(counter->counts, cpu, thread)->run; | ||
| 680 | } | ||
| 681 | |||
| 682 | uval = val * counter->scale; | ||
| 683 | |||
| 684 | /* | ||
| 685 | * Skip value 0 when enabling --per-thread globally, | ||
| 686 | * otherwise too many 0 output. | ||
| 687 | */ | ||
| 688 | if (uval == 0.0 && target__has_per_thread(_target)) | ||
| 689 | continue; | ||
| 690 | |||
| 691 | buf[i].counter = counter; | ||
| 692 | buf[i].id = thread; | ||
| 693 | buf[i].uval = uval; | ||
| 694 | buf[i].val = val; | ||
| 695 | buf[i].run = run; | ||
| 696 | buf[i].ena = ena; | ||
| 697 | i++; | ||
| 698 | } | ||
| 699 | |||
| 700 | qsort(buf, i, sizeof(struct perf_aggr_thread_value), cmp_val); | ||
| 701 | |||
| 702 | if (ret) | ||
| 703 | *ret = i; | ||
| 704 | |||
| 705 | return buf; | ||
| 706 | } | ||
| 707 | |||
| 708 | static void print_aggr_thread(struct perf_stat_config *config, | ||
| 709 | struct target *_target, | ||
| 710 | struct perf_evsel *counter, char *prefix) | ||
| 711 | { | ||
| 712 | FILE *output = config->output; | ||
| 713 | int nthreads = thread_map__nr(counter->threads); | ||
| 714 | int ncpus = cpu_map__nr(counter->cpus); | ||
| 715 | int thread, sorted_threads, id; | ||
| 716 | struct perf_aggr_thread_value *buf; | ||
| 717 | |||
| 718 | buf = sort_aggr_thread(counter, nthreads, ncpus, &sorted_threads, _target); | ||
| 719 | if (!buf) { | ||
| 720 | perror("cannot sort aggr thread"); | ||
| 721 | return; | ||
| 722 | } | ||
| 723 | |||
| 724 | for (thread = 0; thread < sorted_threads; thread++) { | ||
| 725 | if (prefix) | ||
| 726 | fprintf(output, "%s", prefix); | ||
| 727 | |||
| 728 | id = buf[thread].id; | ||
| 729 | if (config->stats) | ||
| 730 | printout(config, id, 0, buf[thread].counter, buf[thread].uval, | ||
| 731 | prefix, buf[thread].run, buf[thread].ena, 1.0, | ||
| 732 | &config->stats[id]); | ||
| 733 | else | ||
| 734 | printout(config, id, 0, buf[thread].counter, buf[thread].uval, | ||
| 735 | prefix, buf[thread].run, buf[thread].ena, 1.0, | ||
| 736 | &rt_stat); | ||
| 737 | fputc('\n', output); | ||
| 738 | } | ||
| 739 | |||
| 740 | free(buf); | ||
| 741 | } | ||
| 742 | |||
| 743 | struct caggr_data { | ||
| 744 | double avg, avg_enabled, avg_running; | ||
| 745 | }; | ||
| 746 | |||
| 747 | static void counter_aggr_cb(struct perf_stat_config *config __maybe_unused, | ||
| 748 | struct perf_evsel *counter, void *data, | ||
| 749 | bool first __maybe_unused) | ||
| 750 | { | ||
| 751 | struct caggr_data *cd = data; | ||
| 752 | struct perf_stat_evsel *ps = counter->stats; | ||
| 753 | |||
| 754 | cd->avg += avg_stats(&ps->res_stats[0]); | ||
| 755 | cd->avg_enabled += avg_stats(&ps->res_stats[1]); | ||
| 756 | cd->avg_running += avg_stats(&ps->res_stats[2]); | ||
| 757 | } | ||
| 758 | |||
| 759 | /* | ||
| 760 | * Print out the results of a single counter: | ||
| 761 | * aggregated counts in system-wide mode | ||
| 762 | */ | ||
| 763 | static void print_counter_aggr(struct perf_stat_config *config, | ||
| 764 | struct perf_evsel *counter, char *prefix) | ||
| 765 | { | ||
| 766 | bool metric_only = config->metric_only; | ||
| 767 | FILE *output = config->output; | ||
| 768 | double uval; | ||
| 769 | struct caggr_data cd = { .avg = 0.0 }; | ||
| 770 | |||
| 771 | if (!collect_data(config, counter, counter_aggr_cb, &cd)) | ||
| 772 | return; | ||
| 773 | |||
| 774 | if (prefix && !metric_only) | ||
| 775 | fprintf(output, "%s", prefix); | ||
| 776 | |||
| 777 | uval = cd.avg * counter->scale; | ||
| 778 | printout(config, -1, 0, counter, uval, prefix, cd.avg_running, cd.avg_enabled, | ||
| 779 | cd.avg, &rt_stat); | ||
| 780 | if (!metric_only) | ||
| 781 | fprintf(output, "\n"); | ||
| 782 | } | ||
| 783 | |||
| 784 | static void counter_cb(struct perf_stat_config *config __maybe_unused, | ||
| 785 | struct perf_evsel *counter, void *data, | ||
| 786 | bool first __maybe_unused) | ||
| 787 | { | ||
| 788 | struct aggr_data *ad = data; | ||
| 789 | |||
| 790 | ad->val += perf_counts(counter->counts, ad->cpu, 0)->val; | ||
| 791 | ad->ena += perf_counts(counter->counts, ad->cpu, 0)->ena; | ||
| 792 | ad->run += perf_counts(counter->counts, ad->cpu, 0)->run; | ||
| 793 | } | ||
| 794 | |||
| 795 | /* | ||
| 796 | * Print out the results of a single counter: | ||
| 797 | * does not use aggregated count in system-wide | ||
| 798 | */ | ||
| 799 | static void print_counter(struct perf_stat_config *config, | ||
| 800 | struct perf_evsel *counter, char *prefix) | ||
| 801 | { | ||
| 802 | FILE *output = config->output; | ||
| 803 | u64 ena, run, val; | ||
| 804 | double uval; | ||
| 805 | int cpu; | ||
| 806 | |||
| 807 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | ||
| 808 | struct aggr_data ad = { .cpu = cpu }; | ||
| 809 | |||
| 810 | if (!collect_data(config, counter, counter_cb, &ad)) | ||
| 811 | return; | ||
| 812 | val = ad.val; | ||
| 813 | ena = ad.ena; | ||
| 814 | run = ad.run; | ||
| 815 | |||
| 816 | if (prefix) | ||
| 817 | fprintf(output, "%s", prefix); | ||
| 818 | |||
| 819 | uval = val * counter->scale; | ||
| 820 | printout(config, cpu, 0, counter, uval, prefix, run, ena, 1.0, | ||
| 821 | &rt_stat); | ||
| 822 | |||
| 823 | fputc('\n', output); | ||
| 824 | } | ||
| 825 | } | ||
| 826 | |||
| 827 | static void print_no_aggr_metric(struct perf_stat_config *config, | ||
| 828 | struct perf_evlist *evlist, | ||
| 829 | char *prefix) | ||
| 830 | { | ||
| 831 | int cpu; | ||
| 832 | int nrcpus = 0; | ||
| 833 | struct perf_evsel *counter; | ||
| 834 | u64 ena, run, val; | ||
| 835 | double uval; | ||
| 836 | |||
| 837 | nrcpus = evlist->cpus->nr; | ||
| 838 | for (cpu = 0; cpu < nrcpus; cpu++) { | ||
| 839 | bool first = true; | ||
| 840 | |||
| 841 | if (prefix) | ||
| 842 | fputs(prefix, config->output); | ||
| 843 | evlist__for_each_entry(evlist, counter) { | ||
| 844 | if (is_duration_time(counter)) | ||
| 845 | continue; | ||
| 846 | if (first) { | ||
| 847 | aggr_printout(config, counter, cpu, 0); | ||
| 848 | first = false; | ||
| 849 | } | ||
| 850 | val = perf_counts(counter->counts, cpu, 0)->val; | ||
| 851 | ena = perf_counts(counter->counts, cpu, 0)->ena; | ||
| 852 | run = perf_counts(counter->counts, cpu, 0)->run; | ||
| 853 | |||
| 854 | uval = val * counter->scale; | ||
| 855 | printout(config, cpu, 0, counter, uval, prefix, run, ena, 1.0, | ||
| 856 | &rt_stat); | ||
| 857 | } | ||
| 858 | fputc('\n', config->output); | ||
| 859 | } | ||
| 860 | } | ||
| 861 | |||
| 862 | static int aggr_header_lens[] = { | ||
| 863 | [AGGR_CORE] = 18, | ||
| 864 | [AGGR_SOCKET] = 12, | ||
| 865 | [AGGR_NONE] = 6, | ||
| 866 | [AGGR_THREAD] = 24, | ||
| 867 | [AGGR_GLOBAL] = 0, | ||
| 868 | }; | ||
| 869 | |||
| 870 | static const char *aggr_header_csv[] = { | ||
| 871 | [AGGR_CORE] = "core,cpus,", | ||
| 872 | [AGGR_SOCKET] = "socket,cpus", | ||
| 873 | [AGGR_NONE] = "cpu,", | ||
| 874 | [AGGR_THREAD] = "comm-pid,", | ||
| 875 | [AGGR_GLOBAL] = "" | ||
| 876 | }; | ||
| 877 | |||
| 878 | static void print_metric_headers(struct perf_stat_config *config, | ||
| 879 | struct perf_evlist *evlist, | ||
| 880 | const char *prefix, bool no_indent) | ||
| 881 | { | ||
| 882 | struct perf_stat_output_ctx out; | ||
| 883 | struct perf_evsel *counter; | ||
| 884 | struct outstate os = { | ||
| 885 | .fh = config->output | ||
| 886 | }; | ||
| 887 | |||
| 888 | if (prefix) | ||
| 889 | fprintf(config->output, "%s", prefix); | ||
| 890 | |||
| 891 | if (!config->csv_output && !no_indent) | ||
| 892 | fprintf(config->output, "%*s", | ||
| 893 | aggr_header_lens[config->aggr_mode], ""); | ||
| 894 | if (config->csv_output) { | ||
| 895 | if (config->interval) | ||
| 896 | fputs("time,", config->output); | ||
| 897 | fputs(aggr_header_csv[config->aggr_mode], config->output); | ||
| 898 | } | ||
| 899 | |||
| 900 | /* Print metrics headers only */ | ||
| 901 | evlist__for_each_entry(evlist, counter) { | ||
| 902 | if (is_duration_time(counter)) | ||
| 903 | continue; | ||
| 904 | os.evsel = counter; | ||
| 905 | out.ctx = &os; | ||
| 906 | out.print_metric = print_metric_header; | ||
| 907 | out.new_line = new_line_metric; | ||
| 908 | out.force_header = true; | ||
| 909 | os.evsel = counter; | ||
| 910 | perf_stat__print_shadow_stats(config, counter, 0, | ||
| 911 | 0, | ||
| 912 | &out, | ||
| 913 | &config->metric_events, | ||
| 914 | &rt_stat); | ||
| 915 | } | ||
| 916 | fputc('\n', config->output); | ||
| 917 | } | ||
| 918 | |||
| 919 | static void print_interval(struct perf_stat_config *config, | ||
| 920 | struct perf_evlist *evlist, | ||
| 921 | char *prefix, struct timespec *ts) | ||
| 922 | { | ||
| 923 | bool metric_only = config->metric_only; | ||
| 924 | unsigned int unit_width = config->unit_width; | ||
| 925 | FILE *output = config->output; | ||
| 926 | static int num_print_interval; | ||
| 927 | |||
| 928 | if (config->interval_clear) | ||
| 929 | puts(CONSOLE_CLEAR); | ||
| 930 | |||
| 931 | sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, config->csv_sep); | ||
| 932 | |||
| 933 | if ((num_print_interval == 0 && !config->csv_output) || config->interval_clear) { | ||
| 934 | switch (config->aggr_mode) { | ||
| 935 | case AGGR_SOCKET: | ||
| 936 | fprintf(output, "# time socket cpus"); | ||
| 937 | if (!metric_only) | ||
| 938 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 939 | break; | ||
| 940 | case AGGR_CORE: | ||
| 941 | fprintf(output, "# time core cpus"); | ||
| 942 | if (!metric_only) | ||
| 943 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 944 | break; | ||
| 945 | case AGGR_NONE: | ||
| 946 | fprintf(output, "# time CPU "); | ||
| 947 | if (!metric_only) | ||
| 948 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 949 | break; | ||
| 950 | case AGGR_THREAD: | ||
| 951 | fprintf(output, "# time comm-pid"); | ||
| 952 | if (!metric_only) | ||
| 953 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 954 | break; | ||
| 955 | case AGGR_GLOBAL: | ||
| 956 | default: | ||
| 957 | fprintf(output, "# time"); | ||
| 958 | if (!metric_only) | ||
| 959 | fprintf(output, " counts %*s events\n", unit_width, "unit"); | ||
| 960 | case AGGR_UNSET: | ||
| 961 | break; | ||
| 962 | } | ||
| 963 | } | ||
| 964 | |||
| 965 | if ((num_print_interval == 0 || config->interval_clear) && metric_only) | ||
| 966 | print_metric_headers(config, evlist, " ", true); | ||
| 967 | if (++num_print_interval == 25) | ||
| 968 | num_print_interval = 0; | ||
| 969 | } | ||
| 970 | |||
| 971 | static void print_header(struct perf_stat_config *config, | ||
| 972 | struct target *_target, | ||
| 973 | int argc, const char **argv) | ||
| 974 | { | ||
| 975 | FILE *output = config->output; | ||
| 976 | int i; | ||
| 977 | |||
| 978 | fflush(stdout); | ||
| 979 | |||
| 980 | if (!config->csv_output) { | ||
| 981 | fprintf(output, "\n"); | ||
| 982 | fprintf(output, " Performance counter stats for "); | ||
| 983 | if (_target->system_wide) | ||
| 984 | fprintf(output, "\'system wide"); | ||
| 985 | else if (_target->cpu_list) | ||
| 986 | fprintf(output, "\'CPU(s) %s", _target->cpu_list); | ||
| 987 | else if (!target__has_task(_target)) { | ||
| 988 | fprintf(output, "\'%s", argv ? argv[0] : "pipe"); | ||
| 989 | for (i = 1; argv && (i < argc); i++) | ||
| 990 | fprintf(output, " %s", argv[i]); | ||
| 991 | } else if (_target->pid) | ||
| 992 | fprintf(output, "process id \'%s", _target->pid); | ||
| 993 | else | ||
| 994 | fprintf(output, "thread id \'%s", _target->tid); | ||
| 995 | |||
| 996 | fprintf(output, "\'"); | ||
| 997 | if (config->run_count > 1) | ||
| 998 | fprintf(output, " (%d runs)", config->run_count); | ||
| 999 | fprintf(output, ":\n\n"); | ||
| 1000 | } | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | static int get_precision(double num) | ||
| 1004 | { | ||
| 1005 | if (num > 1) | ||
| 1006 | return 0; | ||
| 1007 | |||
| 1008 | return lround(ceil(-log10(num))); | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | static void print_table(struct perf_stat_config *config, | ||
| 1012 | FILE *output, int precision, double avg) | ||
| 1013 | { | ||
| 1014 | char tmp[64]; | ||
| 1015 | int idx, indent = 0; | ||
| 1016 | |||
| 1017 | scnprintf(tmp, 64, " %17.*f", precision, avg); | ||
| 1018 | while (tmp[indent] == ' ') | ||
| 1019 | indent++; | ||
| 1020 | |||
| 1021 | fprintf(output, "%*s# Table of individual measurements:\n", indent, ""); | ||
| 1022 | |||
| 1023 | for (idx = 0; idx < config->run_count; idx++) { | ||
| 1024 | double run = (double) config->walltime_run[idx] / NSEC_PER_SEC; | ||
| 1025 | int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5); | ||
| 1026 | |||
| 1027 | fprintf(output, " %17.*f (%+.*f) ", | ||
| 1028 | precision, run, precision, run - avg); | ||
| 1029 | |||
| 1030 | for (h = 0; h < n; h++) | ||
| 1031 | fprintf(output, "#"); | ||
| 1032 | |||
| 1033 | fprintf(output, "\n"); | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | fprintf(output, "\n%*s# Final result:\n", indent, ""); | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | static double timeval2double(struct timeval *t) | ||
| 1040 | { | ||
| 1041 | return t->tv_sec + (double) t->tv_usec/USEC_PER_SEC; | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | static void print_footer(struct perf_stat_config *config) | ||
| 1045 | { | ||
| 1046 | double avg = avg_stats(config->walltime_nsecs_stats) / NSEC_PER_SEC; | ||
| 1047 | FILE *output = config->output; | ||
| 1048 | int n; | ||
| 1049 | |||
| 1050 | if (!config->null_run) | ||
| 1051 | fprintf(output, "\n"); | ||
| 1052 | |||
| 1053 | if (config->run_count == 1) { | ||
| 1054 | fprintf(output, " %17.9f seconds time elapsed", avg); | ||
| 1055 | |||
| 1056 | if (config->ru_display) { | ||
| 1057 | double ru_utime = timeval2double(&config->ru_data.ru_utime); | ||
| 1058 | double ru_stime = timeval2double(&config->ru_data.ru_stime); | ||
| 1059 | |||
| 1060 | fprintf(output, "\n\n"); | ||
| 1061 | fprintf(output, " %17.9f seconds user\n", ru_utime); | ||
| 1062 | fprintf(output, " %17.9f seconds sys\n", ru_stime); | ||
| 1063 | } | ||
| 1064 | } else { | ||
| 1065 | double sd = stddev_stats(config->walltime_nsecs_stats) / NSEC_PER_SEC; | ||
| 1066 | /* | ||
| 1067 | * Display at most 2 more significant | ||
| 1068 | * digits than the stddev inaccuracy. | ||
| 1069 | */ | ||
| 1070 | int precision = get_precision(sd) + 2; | ||
| 1071 | |||
| 1072 | if (config->walltime_run_table) | ||
| 1073 | print_table(config, output, precision, avg); | ||
| 1074 | |||
| 1075 | fprintf(output, " %17.*f +- %.*f seconds time elapsed", | ||
| 1076 | precision, avg, precision, sd); | ||
| 1077 | |||
| 1078 | print_noise_pct(config, sd, avg); | ||
| 1079 | } | ||
| 1080 | fprintf(output, "\n\n"); | ||
| 1081 | |||
| 1082 | if (config->print_free_counters_hint && | ||
| 1083 | sysctl__read_int("kernel/nmi_watchdog", &n) >= 0 && | ||
| 1084 | n > 0) | ||
| 1085 | fprintf(output, | ||
| 1086 | "Some events weren't counted. Try disabling the NMI watchdog:\n" | ||
| 1087 | " echo 0 > /proc/sys/kernel/nmi_watchdog\n" | ||
| 1088 | " perf stat ...\n" | ||
| 1089 | " echo 1 > /proc/sys/kernel/nmi_watchdog\n"); | ||
| 1090 | |||
| 1091 | if (config->print_mixed_hw_group_error) | ||
| 1092 | fprintf(output, | ||
| 1093 | "The events in group usually have to be from " | ||
| 1094 | "the same PMU. Try reorganizing the group.\n"); | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | void | ||
| 1098 | perf_evlist__print_counters(struct perf_evlist *evlist, | ||
| 1099 | struct perf_stat_config *config, | ||
| 1100 | struct target *_target, | ||
| 1101 | struct timespec *ts, | ||
| 1102 | int argc, const char **argv) | ||
| 1103 | { | ||
| 1104 | bool metric_only = config->metric_only; | ||
| 1105 | int interval = config->interval; | ||
| 1106 | struct perf_evsel *counter; | ||
| 1107 | char buf[64], *prefix = NULL; | ||
| 1108 | |||
| 1109 | if (interval) | ||
| 1110 | print_interval(config, evlist, prefix = buf, ts); | ||
| 1111 | else | ||
| 1112 | print_header(config, _target, argc, argv); | ||
| 1113 | |||
| 1114 | if (metric_only) { | ||
| 1115 | static int num_print_iv; | ||
| 1116 | |||
| 1117 | if (num_print_iv == 0 && !interval) | ||
| 1118 | print_metric_headers(config, evlist, prefix, false); | ||
| 1119 | if (num_print_iv++ == 25) | ||
| 1120 | num_print_iv = 0; | ||
| 1121 | if (config->aggr_mode == AGGR_GLOBAL && prefix) | ||
| 1122 | fprintf(config->output, "%s", prefix); | ||
| 1123 | } | ||
| 1124 | |||
| 1125 | switch (config->aggr_mode) { | ||
| 1126 | case AGGR_CORE: | ||
| 1127 | case AGGR_SOCKET: | ||
| 1128 | print_aggr(config, evlist, prefix); | ||
| 1129 | break; | ||
| 1130 | case AGGR_THREAD: | ||
| 1131 | evlist__for_each_entry(evlist, counter) { | ||
| 1132 | if (is_duration_time(counter)) | ||
| 1133 | continue; | ||
| 1134 | print_aggr_thread(config, _target, counter, prefix); | ||
| 1135 | } | ||
| 1136 | break; | ||
| 1137 | case AGGR_GLOBAL: | ||
| 1138 | evlist__for_each_entry(evlist, counter) { | ||
| 1139 | if (is_duration_time(counter)) | ||
| 1140 | continue; | ||
| 1141 | print_counter_aggr(config, counter, prefix); | ||
| 1142 | } | ||
| 1143 | if (metric_only) | ||
| 1144 | fputc('\n', config->output); | ||
| 1145 | break; | ||
| 1146 | case AGGR_NONE: | ||
| 1147 | if (metric_only) | ||
| 1148 | print_no_aggr_metric(config, evlist, prefix); | ||
| 1149 | else { | ||
| 1150 | evlist__for_each_entry(evlist, counter) { | ||
| 1151 | if (is_duration_time(counter)) | ||
| 1152 | continue; | ||
| 1153 | print_counter(config, counter, prefix); | ||
| 1154 | } | ||
| 1155 | } | ||
| 1156 | break; | ||
| 1157 | case AGGR_UNSET: | ||
| 1158 | default: | ||
| 1159 | break; | ||
| 1160 | } | ||
| 1161 | |||
| 1162 | if (!interval && !config->csv_output) | ||
| 1163 | print_footer(config); | ||
| 1164 | |||
| 1165 | fflush(config->output); | ||
| 1166 | } | ||
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 99990f5f2512..8ad32763cfff 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c | |||
| @@ -410,7 +410,8 @@ static double runtime_stat_n(struct runtime_stat *st, | |||
| 410 | return v->stats.n; | 410 | return v->stats.n; |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | static void print_stalled_cycles_frontend(int cpu, | 413 | static void print_stalled_cycles_frontend(struct perf_stat_config *config, |
| 414 | int cpu, | ||
| 414 | struct perf_evsel *evsel, double avg, | 415 | struct perf_evsel *evsel, double avg, |
| 415 | struct perf_stat_output_ctx *out, | 416 | struct perf_stat_output_ctx *out, |
| 416 | struct runtime_stat *st) | 417 | struct runtime_stat *st) |
| @@ -427,13 +428,14 @@ static void print_stalled_cycles_frontend(int cpu, | |||
| 427 | color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio); | 428 | color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio); |
| 428 | 429 | ||
| 429 | if (ratio) | 430 | if (ratio) |
| 430 | out->print_metric(out->ctx, color, "%7.2f%%", "frontend cycles idle", | 431 | out->print_metric(config, out->ctx, color, "%7.2f%%", "frontend cycles idle", |
| 431 | ratio); | 432 | ratio); |
| 432 | else | 433 | else |
| 433 | out->print_metric(out->ctx, NULL, NULL, "frontend cycles idle", 0); | 434 | out->print_metric(config, out->ctx, NULL, NULL, "frontend cycles idle", 0); |
| 434 | } | 435 | } |
| 435 | 436 | ||
| 436 | static void print_stalled_cycles_backend(int cpu, | 437 | static void print_stalled_cycles_backend(struct perf_stat_config *config, |
| 438 | int cpu, | ||
| 437 | struct perf_evsel *evsel, double avg, | 439 | struct perf_evsel *evsel, double avg, |
| 438 | struct perf_stat_output_ctx *out, | 440 | struct perf_stat_output_ctx *out, |
| 439 | struct runtime_stat *st) | 441 | struct runtime_stat *st) |
| @@ -449,10 +451,11 @@ static void print_stalled_cycles_backend(int cpu, | |||
| 449 | 451 | ||
| 450 | color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio); | 452 | color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio); |
| 451 | 453 | ||
| 452 | out->print_metric(out->ctx, color, "%7.2f%%", "backend cycles idle", ratio); | 454 | out->print_metric(config, out->ctx, color, "%7.2f%%", "backend cycles idle", ratio); |
| 453 | } | 455 | } |
| 454 | 456 | ||
| 455 | static void print_branch_misses(int cpu, | 457 | static void print_branch_misses(struct perf_stat_config *config, |
| 458 | int cpu, | ||
| 456 | struct perf_evsel *evsel, | 459 | struct perf_evsel *evsel, |
| 457 | double avg, | 460 | double avg, |
| 458 | struct perf_stat_output_ctx *out, | 461 | struct perf_stat_output_ctx *out, |
| @@ -469,10 +472,11 @@ static void print_branch_misses(int cpu, | |||
| 469 | 472 | ||
| 470 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); | 473 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); |
| 471 | 474 | ||
| 472 | out->print_metric(out->ctx, color, "%7.2f%%", "of all branches", ratio); | 475 | out->print_metric(config, out->ctx, color, "%7.2f%%", "of all branches", ratio); |
| 473 | } | 476 | } |
| 474 | 477 | ||
| 475 | static void print_l1_dcache_misses(int cpu, | 478 | static void print_l1_dcache_misses(struct perf_stat_config *config, |
| 479 | int cpu, | ||
| 476 | struct perf_evsel *evsel, | 480 | struct perf_evsel *evsel, |
| 477 | double avg, | 481 | double avg, |
| 478 | struct perf_stat_output_ctx *out, | 482 | struct perf_stat_output_ctx *out, |
| @@ -490,10 +494,11 @@ static void print_l1_dcache_misses(int cpu, | |||
| 490 | 494 | ||
| 491 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); | 495 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); |
| 492 | 496 | ||
| 493 | out->print_metric(out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio); | 497 | out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio); |
| 494 | } | 498 | } |
| 495 | 499 | ||
| 496 | static void print_l1_icache_misses(int cpu, | 500 | static void print_l1_icache_misses(struct perf_stat_config *config, |
| 501 | int cpu, | ||
| 497 | struct perf_evsel *evsel, | 502 | struct perf_evsel *evsel, |
| 498 | double avg, | 503 | double avg, |
| 499 | struct perf_stat_output_ctx *out, | 504 | struct perf_stat_output_ctx *out, |
| @@ -510,10 +515,11 @@ static void print_l1_icache_misses(int cpu, | |||
| 510 | ratio = avg / total * 100.0; | 515 | ratio = avg / total * 100.0; |
| 511 | 516 | ||
| 512 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); | 517 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); |
| 513 | out->print_metric(out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio); | 518 | out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio); |
| 514 | } | 519 | } |
| 515 | 520 | ||
| 516 | static void print_dtlb_cache_misses(int cpu, | 521 | static void print_dtlb_cache_misses(struct perf_stat_config *config, |
| 522 | int cpu, | ||
| 517 | struct perf_evsel *evsel, | 523 | struct perf_evsel *evsel, |
| 518 | double avg, | 524 | double avg, |
| 519 | struct perf_stat_output_ctx *out, | 525 | struct perf_stat_output_ctx *out, |
| @@ -529,10 +535,11 @@ static void print_dtlb_cache_misses(int cpu, | |||
| 529 | ratio = avg / total * 100.0; | 535 | ratio = avg / total * 100.0; |
| 530 | 536 | ||
| 531 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); | 537 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); |
| 532 | out->print_metric(out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio); | 538 | out->print_metric(config, out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio); |
| 533 | } | 539 | } |
| 534 | 540 | ||
| 535 | static void print_itlb_cache_misses(int cpu, | 541 | static void print_itlb_cache_misses(struct perf_stat_config *config, |
| 542 | int cpu, | ||
| 536 | struct perf_evsel *evsel, | 543 | struct perf_evsel *evsel, |
| 537 | double avg, | 544 | double avg, |
| 538 | struct perf_stat_output_ctx *out, | 545 | struct perf_stat_output_ctx *out, |
| @@ -548,10 +555,11 @@ static void print_itlb_cache_misses(int cpu, | |||
| 548 | ratio = avg / total * 100.0; | 555 | ratio = avg / total * 100.0; |
| 549 | 556 | ||
| 550 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); | 557 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); |
| 551 | out->print_metric(out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio); | 558 | out->print_metric(config, out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio); |
| 552 | } | 559 | } |
| 553 | 560 | ||
| 554 | static void print_ll_cache_misses(int cpu, | 561 | static void print_ll_cache_misses(struct perf_stat_config *config, |
| 562 | int cpu, | ||
| 555 | struct perf_evsel *evsel, | 563 | struct perf_evsel *evsel, |
| 556 | double avg, | 564 | double avg, |
| 557 | struct perf_stat_output_ctx *out, | 565 | struct perf_stat_output_ctx *out, |
| @@ -567,7 +575,7 @@ static void print_ll_cache_misses(int cpu, | |||
| 567 | ratio = avg / total * 100.0; | 575 | ratio = avg / total * 100.0; |
| 568 | 576 | ||
| 569 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); | 577 | color = get_ratio_color(GRC_CACHE_MISSES, ratio); |
| 570 | out->print_metric(out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio); | 578 | out->print_metric(config, out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio); |
| 571 | } | 579 | } |
| 572 | 580 | ||
| 573 | /* | 581 | /* |
| @@ -674,7 +682,8 @@ static double td_be_bound(int ctx, int cpu, struct runtime_stat *st) | |||
| 674 | return sanitize_val(1.0 - sum); | 682 | return sanitize_val(1.0 - sum); |
| 675 | } | 683 | } |
| 676 | 684 | ||
| 677 | static void print_smi_cost(int cpu, struct perf_evsel *evsel, | 685 | static void print_smi_cost(struct perf_stat_config *config, |
| 686 | int cpu, struct perf_evsel *evsel, | ||
| 678 | struct perf_stat_output_ctx *out, | 687 | struct perf_stat_output_ctx *out, |
| 679 | struct runtime_stat *st) | 688 | struct runtime_stat *st) |
| 680 | { | 689 | { |
| @@ -694,11 +703,12 @@ static void print_smi_cost(int cpu, struct perf_evsel *evsel, | |||
| 694 | 703 | ||
| 695 | if (cost > 10) | 704 | if (cost > 10) |
| 696 | color = PERF_COLOR_RED; | 705 | color = PERF_COLOR_RED; |
| 697 | out->print_metric(out->ctx, color, "%8.1f%%", "SMI cycles%", cost); | 706 | out->print_metric(config, out->ctx, color, "%8.1f%%", "SMI cycles%", cost); |
| 698 | out->print_metric(out->ctx, NULL, "%4.0f", "SMI#", smi_num); | 707 | out->print_metric(config, out->ctx, NULL, "%4.0f", "SMI#", smi_num); |
| 699 | } | 708 | } |
| 700 | 709 | ||
| 701 | static void generic_metric(const char *metric_expr, | 710 | static void generic_metric(struct perf_stat_config *config, |
| 711 | const char *metric_expr, | ||
| 702 | struct perf_evsel **metric_events, | 712 | struct perf_evsel **metric_events, |
| 703 | char *name, | 713 | char *name, |
| 704 | const char *metric_name, | 714 | const char *metric_name, |
| @@ -737,20 +747,21 @@ static void generic_metric(const char *metric_expr, | |||
| 737 | const char *p = metric_expr; | 747 | const char *p = metric_expr; |
| 738 | 748 | ||
| 739 | if (expr__parse(&ratio, &pctx, &p) == 0) | 749 | if (expr__parse(&ratio, &pctx, &p) == 0) |
| 740 | print_metric(ctxp, NULL, "%8.1f", | 750 | print_metric(config, ctxp, NULL, "%8.1f", |
| 741 | metric_name ? | 751 | metric_name ? |
| 742 | metric_name : | 752 | metric_name : |
| 743 | out->force_header ? name : "", | 753 | out->force_header ? name : "", |
| 744 | ratio); | 754 | ratio); |
| 745 | else | 755 | else |
| 746 | print_metric(ctxp, NULL, NULL, | 756 | print_metric(config, ctxp, NULL, NULL, |
| 747 | out->force_header ? | 757 | out->force_header ? |
| 748 | (metric_name ? metric_name : name) : "", 0); | 758 | (metric_name ? metric_name : name) : "", 0); |
| 749 | } else | 759 | } else |
| 750 | print_metric(ctxp, NULL, NULL, "", 0); | 760 | print_metric(config, ctxp, NULL, NULL, "", 0); |
| 751 | } | 761 | } |
| 752 | 762 | ||
| 753 | void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | 763 | void perf_stat__print_shadow_stats(struct perf_stat_config *config, |
| 764 | struct perf_evsel *evsel, | ||
| 754 | double avg, int cpu, | 765 | double avg, int cpu, |
| 755 | struct perf_stat_output_ctx *out, | 766 | struct perf_stat_output_ctx *out, |
| 756 | struct rblist *metric_events, | 767 | struct rblist *metric_events, |
| @@ -769,10 +780,10 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 769 | 780 | ||
| 770 | if (total) { | 781 | if (total) { |
| 771 | ratio = avg / total; | 782 | ratio = avg / total; |
| 772 | print_metric(ctxp, NULL, "%7.2f ", | 783 | print_metric(config, ctxp, NULL, "%7.2f ", |
| 773 | "insn per cycle", ratio); | 784 | "insn per cycle", ratio); |
| 774 | } else { | 785 | } else { |
| 775 | print_metric(ctxp, NULL, NULL, "insn per cycle", 0); | 786 | print_metric(config, ctxp, NULL, NULL, "insn per cycle", 0); |
| 776 | } | 787 | } |
| 777 | 788 | ||
| 778 | total = runtime_stat_avg(st, STAT_STALLED_CYCLES_FRONT, | 789 | total = runtime_stat_avg(st, STAT_STALLED_CYCLES_FRONT, |
| @@ -783,20 +794,20 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 783 | ctx, cpu)); | 794 | ctx, cpu)); |
| 784 | 795 | ||
| 785 | if (total && avg) { | 796 | if (total && avg) { |
| 786 | out->new_line(ctxp); | 797 | out->new_line(config, ctxp); |
| 787 | ratio = total / avg; | 798 | ratio = total / avg; |
| 788 | print_metric(ctxp, NULL, "%7.2f ", | 799 | print_metric(config, ctxp, NULL, "%7.2f ", |
| 789 | "stalled cycles per insn", | 800 | "stalled cycles per insn", |
| 790 | ratio); | 801 | ratio); |
| 791 | } else if (have_frontend_stalled) { | 802 | } else if (have_frontend_stalled) { |
| 792 | print_metric(ctxp, NULL, NULL, | 803 | print_metric(config, ctxp, NULL, NULL, |
| 793 | "stalled cycles per insn", 0); | 804 | "stalled cycles per insn", 0); |
| 794 | } | 805 | } |
| 795 | } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) { | 806 | } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) { |
| 796 | if (runtime_stat_n(st, STAT_BRANCHES, ctx, cpu) != 0) | 807 | if (runtime_stat_n(st, STAT_BRANCHES, ctx, cpu) != 0) |
| 797 | print_branch_misses(cpu, evsel, avg, out, st); | 808 | print_branch_misses(config, cpu, evsel, avg, out, st); |
| 798 | else | 809 | else |
| 799 | print_metric(ctxp, NULL, NULL, "of all branches", 0); | 810 | print_metric(config, ctxp, NULL, NULL, "of all branches", 0); |
| 800 | } else if ( | 811 | } else if ( |
| 801 | evsel->attr.type == PERF_TYPE_HW_CACHE && | 812 | evsel->attr.type == PERF_TYPE_HW_CACHE && |
| 802 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D | | 813 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D | |
| @@ -804,9 +815,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 804 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { | 815 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { |
| 805 | 816 | ||
| 806 | if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0) | 817 | if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0) |
| 807 | print_l1_dcache_misses(cpu, evsel, avg, out, st); | 818 | print_l1_dcache_misses(config, cpu, evsel, avg, out, st); |
| 808 | else | 819 | else |
| 809 | print_metric(ctxp, NULL, NULL, "of all L1-dcache hits", 0); | 820 | print_metric(config, ctxp, NULL, NULL, "of all L1-dcache hits", 0); |
| 810 | } else if ( | 821 | } else if ( |
| 811 | evsel->attr.type == PERF_TYPE_HW_CACHE && | 822 | evsel->attr.type == PERF_TYPE_HW_CACHE && |
| 812 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1I | | 823 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1I | |
| @@ -814,9 +825,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 814 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { | 825 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { |
| 815 | 826 | ||
| 816 | if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0) | 827 | if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0) |
| 817 | print_l1_icache_misses(cpu, evsel, avg, out, st); | 828 | print_l1_icache_misses(config, cpu, evsel, avg, out, st); |
| 818 | else | 829 | else |
| 819 | print_metric(ctxp, NULL, NULL, "of all L1-icache hits", 0); | 830 | print_metric(config, ctxp, NULL, NULL, "of all L1-icache hits", 0); |
| 820 | } else if ( | 831 | } else if ( |
| 821 | evsel->attr.type == PERF_TYPE_HW_CACHE && | 832 | evsel->attr.type == PERF_TYPE_HW_CACHE && |
| 822 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_DTLB | | 833 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_DTLB | |
| @@ -824,9 +835,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 824 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { | 835 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { |
| 825 | 836 | ||
| 826 | if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0) | 837 | if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0) |
| 827 | print_dtlb_cache_misses(cpu, evsel, avg, out, st); | 838 | print_dtlb_cache_misses(config, cpu, evsel, avg, out, st); |
| 828 | else | 839 | else |
| 829 | print_metric(ctxp, NULL, NULL, "of all dTLB cache hits", 0); | 840 | print_metric(config, ctxp, NULL, NULL, "of all dTLB cache hits", 0); |
| 830 | } else if ( | 841 | } else if ( |
| 831 | evsel->attr.type == PERF_TYPE_HW_CACHE && | 842 | evsel->attr.type == PERF_TYPE_HW_CACHE && |
| 832 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_ITLB | | 843 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_ITLB | |
| @@ -834,9 +845,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 834 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { | 845 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { |
| 835 | 846 | ||
| 836 | if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0) | 847 | if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0) |
| 837 | print_itlb_cache_misses(cpu, evsel, avg, out, st); | 848 | print_itlb_cache_misses(config, cpu, evsel, avg, out, st); |
| 838 | else | 849 | else |
| 839 | print_metric(ctxp, NULL, NULL, "of all iTLB cache hits", 0); | 850 | print_metric(config, ctxp, NULL, NULL, "of all iTLB cache hits", 0); |
| 840 | } else if ( | 851 | } else if ( |
| 841 | evsel->attr.type == PERF_TYPE_HW_CACHE && | 852 | evsel->attr.type == PERF_TYPE_HW_CACHE && |
| 842 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_LL | | 853 | evsel->attr.config == ( PERF_COUNT_HW_CACHE_LL | |
| @@ -844,9 +855,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 844 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { | 855 | ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) { |
| 845 | 856 | ||
| 846 | if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0) | 857 | if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0) |
| 847 | print_ll_cache_misses(cpu, evsel, avg, out, st); | 858 | print_ll_cache_misses(config, cpu, evsel, avg, out, st); |
| 848 | else | 859 | else |
| 849 | print_metric(ctxp, NULL, NULL, "of all LL-cache hits", 0); | 860 | print_metric(config, ctxp, NULL, NULL, "of all LL-cache hits", 0); |
| 850 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) { | 861 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) { |
| 851 | total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu); | 862 | total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu); |
| 852 | 863 | ||
| @@ -854,32 +865,32 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 854 | ratio = avg * 100 / total; | 865 | ratio = avg * 100 / total; |
| 855 | 866 | ||
| 856 | if (runtime_stat_n(st, STAT_CACHEREFS, ctx, cpu) != 0) | 867 | if (runtime_stat_n(st, STAT_CACHEREFS, ctx, cpu) != 0) |
| 857 | print_metric(ctxp, NULL, "%8.3f %%", | 868 | print_metric(config, ctxp, NULL, "%8.3f %%", |
| 858 | "of all cache refs", ratio); | 869 | "of all cache refs", ratio); |
| 859 | else | 870 | else |
| 860 | print_metric(ctxp, NULL, NULL, "of all cache refs", 0); | 871 | print_metric(config, ctxp, NULL, NULL, "of all cache refs", 0); |
| 861 | } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) { | 872 | } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) { |
| 862 | print_stalled_cycles_frontend(cpu, evsel, avg, out, st); | 873 | print_stalled_cycles_frontend(config, cpu, evsel, avg, out, st); |
| 863 | } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) { | 874 | } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) { |
| 864 | print_stalled_cycles_backend(cpu, evsel, avg, out, st); | 875 | print_stalled_cycles_backend(config, cpu, evsel, avg, out, st); |
| 865 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) { | 876 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) { |
| 866 | total = runtime_stat_avg(st, STAT_NSECS, 0, cpu); | 877 | total = runtime_stat_avg(st, STAT_NSECS, 0, cpu); |
| 867 | 878 | ||
| 868 | if (total) { | 879 | if (total) { |
| 869 | ratio = avg / total; | 880 | ratio = avg / total; |
| 870 | print_metric(ctxp, NULL, "%8.3f", "GHz", ratio); | 881 | print_metric(config, ctxp, NULL, "%8.3f", "GHz", ratio); |
| 871 | } else { | 882 | } else { |
| 872 | print_metric(ctxp, NULL, NULL, "Ghz", 0); | 883 | print_metric(config, ctxp, NULL, NULL, "Ghz", 0); |
| 873 | } | 884 | } |
| 874 | } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) { | 885 | } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) { |
| 875 | total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu); | 886 | total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu); |
| 876 | 887 | ||
| 877 | if (total) | 888 | if (total) |
| 878 | print_metric(ctxp, NULL, | 889 | print_metric(config, ctxp, NULL, |
| 879 | "%7.2f%%", "transactional cycles", | 890 | "%7.2f%%", "transactional cycles", |
| 880 | 100.0 * (avg / total)); | 891 | 100.0 * (avg / total)); |
| 881 | else | 892 | else |
| 882 | print_metric(ctxp, NULL, NULL, "transactional cycles", | 893 | print_metric(config, ctxp, NULL, NULL, "transactional cycles", |
| 883 | 0); | 894 | 0); |
| 884 | } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) { | 895 | } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) { |
| 885 | total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu); | 896 | total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu); |
| @@ -888,10 +899,10 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 888 | if (total2 < avg) | 899 | if (total2 < avg) |
| 889 | total2 = avg; | 900 | total2 = avg; |
| 890 | if (total) | 901 | if (total) |
| 891 | print_metric(ctxp, NULL, "%7.2f%%", "aborted cycles", | 902 | print_metric(config, ctxp, NULL, "%7.2f%%", "aborted cycles", |
| 892 | 100.0 * ((total2-avg) / total)); | 903 | 100.0 * ((total2-avg) / total)); |
| 893 | else | 904 | else |
| 894 | print_metric(ctxp, NULL, NULL, "aborted cycles", 0); | 905 | print_metric(config, ctxp, NULL, NULL, "aborted cycles", 0); |
| 895 | } else if (perf_stat_evsel__is(evsel, TRANSACTION_START)) { | 906 | } else if (perf_stat_evsel__is(evsel, TRANSACTION_START)) { |
| 896 | total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, | 907 | total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, |
| 897 | ctx, cpu); | 908 | ctx, cpu); |
| @@ -900,10 +911,10 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 900 | ratio = total / avg; | 911 | ratio = total / avg; |
| 901 | 912 | ||
| 902 | if (runtime_stat_n(st, STAT_CYCLES_IN_TX, ctx, cpu) != 0) | 913 | if (runtime_stat_n(st, STAT_CYCLES_IN_TX, ctx, cpu) != 0) |
| 903 | print_metric(ctxp, NULL, "%8.0f", | 914 | print_metric(config, ctxp, NULL, "%8.0f", |
| 904 | "cycles / transaction", ratio); | 915 | "cycles / transaction", ratio); |
| 905 | else | 916 | else |
| 906 | print_metric(ctxp, NULL, NULL, "cycles / transaction", | 917 | print_metric(config, ctxp, NULL, NULL, "cycles / transaction", |
| 907 | 0); | 918 | 0); |
| 908 | } else if (perf_stat_evsel__is(evsel, ELISION_START)) { | 919 | } else if (perf_stat_evsel__is(evsel, ELISION_START)) { |
| 909 | total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, | 920 | total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, |
| @@ -912,33 +923,33 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 912 | if (avg) | 923 | if (avg) |
| 913 | ratio = total / avg; | 924 | ratio = total / avg; |
| 914 | 925 | ||
| 915 | print_metric(ctxp, NULL, "%8.0f", "cycles / elision", ratio); | 926 | print_metric(config, ctxp, NULL, "%8.0f", "cycles / elision", ratio); |
| 916 | } else if (perf_evsel__is_clock(evsel)) { | 927 | } else if (perf_evsel__is_clock(evsel)) { |
| 917 | if ((ratio = avg_stats(&walltime_nsecs_stats)) != 0) | 928 | if ((ratio = avg_stats(&walltime_nsecs_stats)) != 0) |
| 918 | print_metric(ctxp, NULL, "%8.3f", "CPUs utilized", | 929 | print_metric(config, ctxp, NULL, "%8.3f", "CPUs utilized", |
| 919 | avg / (ratio * evsel->scale)); | 930 | avg / (ratio * evsel->scale)); |
| 920 | else | 931 | else |
| 921 | print_metric(ctxp, NULL, NULL, "CPUs utilized", 0); | 932 | print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0); |
| 922 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_FETCH_BUBBLES)) { | 933 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_FETCH_BUBBLES)) { |
| 923 | double fe_bound = td_fe_bound(ctx, cpu, st); | 934 | double fe_bound = td_fe_bound(ctx, cpu, st); |
| 924 | 935 | ||
| 925 | if (fe_bound > 0.2) | 936 | if (fe_bound > 0.2) |
| 926 | color = PERF_COLOR_RED; | 937 | color = PERF_COLOR_RED; |
| 927 | print_metric(ctxp, color, "%8.1f%%", "frontend bound", | 938 | print_metric(config, ctxp, color, "%8.1f%%", "frontend bound", |
| 928 | fe_bound * 100.); | 939 | fe_bound * 100.); |
| 929 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_RETIRED)) { | 940 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_RETIRED)) { |
| 930 | double retiring = td_retiring(ctx, cpu, st); | 941 | double retiring = td_retiring(ctx, cpu, st); |
| 931 | 942 | ||
| 932 | if (retiring > 0.7) | 943 | if (retiring > 0.7) |
| 933 | color = PERF_COLOR_GREEN; | 944 | color = PERF_COLOR_GREEN; |
| 934 | print_metric(ctxp, color, "%8.1f%%", "retiring", | 945 | print_metric(config, ctxp, color, "%8.1f%%", "retiring", |
| 935 | retiring * 100.); | 946 | retiring * 100.); |
| 936 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_RECOVERY_BUBBLES)) { | 947 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_RECOVERY_BUBBLES)) { |
| 937 | double bad_spec = td_bad_spec(ctx, cpu, st); | 948 | double bad_spec = td_bad_spec(ctx, cpu, st); |
| 938 | 949 | ||
| 939 | if (bad_spec > 0.1) | 950 | if (bad_spec > 0.1) |
| 940 | color = PERF_COLOR_RED; | 951 | color = PERF_COLOR_RED; |
| 941 | print_metric(ctxp, color, "%8.1f%%", "bad speculation", | 952 | print_metric(config, ctxp, color, "%8.1f%%", "bad speculation", |
| 942 | bad_spec * 100.); | 953 | bad_spec * 100.); |
| 943 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_ISSUED)) { | 954 | } else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_ISSUED)) { |
| 944 | double be_bound = td_be_bound(ctx, cpu, st); | 955 | double be_bound = td_be_bound(ctx, cpu, st); |
| @@ -955,12 +966,12 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 955 | if (be_bound > 0.2) | 966 | if (be_bound > 0.2) |
| 956 | color = PERF_COLOR_RED; | 967 | color = PERF_COLOR_RED; |
| 957 | if (td_total_slots(ctx, cpu, st) > 0) | 968 | if (td_total_slots(ctx, cpu, st) > 0) |
| 958 | print_metric(ctxp, color, "%8.1f%%", name, | 969 | print_metric(config, ctxp, color, "%8.1f%%", name, |
| 959 | be_bound * 100.); | 970 | be_bound * 100.); |
| 960 | else | 971 | else |
| 961 | print_metric(ctxp, NULL, NULL, name, 0); | 972 | print_metric(config, ctxp, NULL, NULL, name, 0); |
| 962 | } else if (evsel->metric_expr) { | 973 | } else if (evsel->metric_expr) { |
| 963 | generic_metric(evsel->metric_expr, evsel->metric_events, evsel->name, | 974 | generic_metric(config, evsel->metric_expr, evsel->metric_events, evsel->name, |
| 964 | evsel->metric_name, avg, cpu, out, st); | 975 | evsel->metric_name, avg, cpu, out, st); |
| 965 | } else if (runtime_stat_n(st, STAT_NSECS, 0, cpu) != 0) { | 976 | } else if (runtime_stat_n(st, STAT_NSECS, 0, cpu) != 0) { |
| 966 | char unit = 'M'; | 977 | char unit = 'M'; |
| @@ -975,9 +986,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 975 | unit = 'K'; | 986 | unit = 'K'; |
| 976 | } | 987 | } |
| 977 | snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit); | 988 | snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit); |
| 978 | print_metric(ctxp, NULL, "%8.3f", unit_buf, ratio); | 989 | print_metric(config, ctxp, NULL, "%8.3f", unit_buf, ratio); |
| 979 | } else if (perf_stat_evsel__is(evsel, SMI_NUM)) { | 990 | } else if (perf_stat_evsel__is(evsel, SMI_NUM)) { |
| 980 | print_smi_cost(cpu, evsel, out, st); | 991 | print_smi_cost(config, cpu, evsel, out, st); |
| 981 | } else { | 992 | } else { |
| 982 | num = 0; | 993 | num = 0; |
| 983 | } | 994 | } |
| @@ -987,12 +998,12 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
| 987 | 998 | ||
| 988 | list_for_each_entry (mexp, &me->head, nd) { | 999 | list_for_each_entry (mexp, &me->head, nd) { |
| 989 | if (num++ > 0) | 1000 | if (num++ > 0) |
| 990 | out->new_line(ctxp); | 1001 | out->new_line(config, ctxp); |
| 991 | generic_metric(mexp->metric_expr, mexp->metric_events, | 1002 | generic_metric(config, mexp->metric_expr, mexp->metric_events, |
| 992 | evsel->name, mexp->metric_name, | 1003 | evsel->name, mexp->metric_name, |
| 993 | avg, cpu, out, st); | 1004 | avg, cpu, out, st); |
| 994 | } | 1005 | } |
| 995 | } | 1006 | } |
| 996 | if (num == 0) | 1007 | if (num == 0) |
| 997 | print_metric(ctxp, NULL, NULL, NULL, 0); | 1008 | print_metric(config, ctxp, NULL, NULL, NULL, 0); |
| 998 | } | 1009 | } |
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index a0061e0b0fad..4d40515307b8 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
| @@ -374,9 +374,8 @@ int perf_stat_process_counter(struct perf_stat_config *config, | |||
| 374 | return 0; | 374 | return 0; |
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused, | 377 | int perf_event__process_stat_event(struct perf_session *session, |
| 378 | union perf_event *event, | 378 | union perf_event *event) |
| 379 | struct perf_session *session) | ||
| 380 | { | 379 | { |
| 381 | struct perf_counts_values count; | 380 | struct perf_counts_values count; |
| 382 | struct stat_event *st = &event->stat; | 381 | struct stat_event *st = &event->stat; |
| @@ -435,3 +434,98 @@ size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp) | |||
| 435 | 434 | ||
| 436 | return ret; | 435 | return ret; |
| 437 | } | 436 | } |
| 437 | |||
| 438 | int create_perf_stat_counter(struct perf_evsel *evsel, | ||
| 439 | struct perf_stat_config *config, | ||
| 440 | struct target *target) | ||
| 441 | { | ||
| 442 | struct perf_event_attr *attr = &evsel->attr; | ||
| 443 | struct perf_evsel *leader = evsel->leader; | ||
| 444 | |||
| 445 | if (config->scale) { | ||
| 446 | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | | ||
| 447 | PERF_FORMAT_TOTAL_TIME_RUNNING; | ||
| 448 | } | ||
| 449 | |||
| 450 | /* | ||
| 451 | * The event is part of non trivial group, let's enable | ||
| 452 | * the group read (for leader) and ID retrieval for all | ||
| 453 | * members. | ||
| 454 | */ | ||
| 455 | if (leader->nr_members > 1) | ||
| 456 | attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP; | ||
| 457 | |||
| 458 | attr->inherit = !config->no_inherit; | ||
| 459 | |||
| 460 | /* | ||
| 461 | * Some events get initialized with sample_(period/type) set, | ||
| 462 | * like tracepoints. Clear it up for counting. | ||
| 463 | */ | ||
| 464 | attr->sample_period = 0; | ||
| 465 | |||
| 466 | if (config->identifier) | ||
| 467 | attr->sample_type = PERF_SAMPLE_IDENTIFIER; | ||
| 468 | |||
| 469 | /* | ||
| 470 | * Disabling all counters initially, they will be enabled | ||
| 471 | * either manually by us or by kernel via enable_on_exec | ||
| 472 | * set later. | ||
| 473 | */ | ||
| 474 | if (perf_evsel__is_group_leader(evsel)) { | ||
| 475 | attr->disabled = 1; | ||
| 476 | |||
| 477 | /* | ||
| 478 | * In case of initial_delay we enable tracee | ||
| 479 | * events manually. | ||
| 480 | */ | ||
| 481 | if (target__none(target) && !config->initial_delay) | ||
| 482 | attr->enable_on_exec = 1; | ||
| 483 | } | ||
| 484 | |||
| 485 | if (target__has_cpu(target) && !target__has_per_thread(target)) | ||
| 486 | return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel)); | ||
| 487 | |||
| 488 | return perf_evsel__open_per_thread(evsel, evsel->threads); | ||
| 489 | } | ||
| 490 | |||
| 491 | int perf_stat_synthesize_config(struct perf_stat_config *config, | ||
| 492 | struct perf_tool *tool, | ||
| 493 | struct perf_evlist *evlist, | ||
| 494 | perf_event__handler_t process, | ||
| 495 | bool attrs) | ||
| 496 | { | ||
| 497 | int err; | ||
| 498 | |||
| 499 | if (attrs) { | ||
| 500 | err = perf_event__synthesize_attrs(tool, evlist, process); | ||
| 501 | if (err < 0) { | ||
| 502 | pr_err("Couldn't synthesize attrs.\n"); | ||
| 503 | return err; | ||
| 504 | } | ||
| 505 | } | ||
| 506 | |||
| 507 | err = perf_event__synthesize_extra_attr(tool, evlist, process, | ||
| 508 | attrs); | ||
| 509 | |||
| 510 | err = perf_event__synthesize_thread_map2(tool, evlist->threads, | ||
| 511 | process, NULL); | ||
| 512 | if (err < 0) { | ||
| 513 | pr_err("Couldn't synthesize thread map.\n"); | ||
| 514 | return err; | ||
| 515 | } | ||
| 516 | |||
| 517 | err = perf_event__synthesize_cpu_map(tool, evlist->cpus, | ||
| 518 | process, NULL); | ||
| 519 | if (err < 0) { | ||
| 520 | pr_err("Couldn't synthesize thread map.\n"); | ||
| 521 | return err; | ||
| 522 | } | ||
| 523 | |||
| 524 | err = perf_event__synthesize_stat_config(tool, config, process, NULL); | ||
| 525 | if (err < 0) { | ||
| 526 | pr_err("Couldn't synthesize config.\n"); | ||
| 527 | return err; | ||
| 528 | } | ||
| 529 | |||
| 530 | return 0; | ||
| 531 | } | ||
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 36efb986f7fc..2f9c9159a364 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
| @@ -4,8 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
| 6 | #include <stdio.h> | 6 | #include <stdio.h> |
| 7 | #include <sys/types.h> | ||
| 8 | #include <sys/time.h> | ||
| 9 | #include <sys/resource.h> | ||
| 10 | #include <sys/wait.h> | ||
| 7 | #include "xyarray.h" | 11 | #include "xyarray.h" |
| 8 | #include "rblist.h" | 12 | #include "rblist.h" |
| 13 | #include "perf.h" | ||
| 14 | #include "event.h" | ||
| 9 | 15 | ||
| 10 | struct stats { | 16 | struct stats { |
| 11 | double n, mean, M2; | 17 | double n, mean, M2; |
| @@ -84,15 +90,42 @@ struct runtime_stat { | |||
| 84 | struct rblist value_list; | 90 | struct rblist value_list; |
| 85 | }; | 91 | }; |
| 86 | 92 | ||
| 93 | typedef int (*aggr_get_id_t)(struct perf_stat_config *config, | ||
| 94 | struct cpu_map *m, int cpu); | ||
| 95 | |||
| 87 | struct perf_stat_config { | 96 | struct perf_stat_config { |
| 88 | enum aggr_mode aggr_mode; | 97 | enum aggr_mode aggr_mode; |
| 89 | bool scale; | 98 | bool scale; |
| 90 | FILE *output; | 99 | bool no_inherit; |
| 91 | unsigned int interval; | 100 | bool identifier; |
| 92 | unsigned int timeout; | 101 | bool csv_output; |
| 93 | int times; | 102 | bool interval_clear; |
| 94 | struct runtime_stat *stats; | 103 | bool metric_only; |
| 95 | int stats_num; | 104 | bool null_run; |
| 105 | bool ru_display; | ||
| 106 | bool big_num; | ||
| 107 | bool no_merge; | ||
| 108 | bool walltime_run_table; | ||
| 109 | FILE *output; | ||
| 110 | unsigned int interval; | ||
| 111 | unsigned int timeout; | ||
| 112 | unsigned int initial_delay; | ||
| 113 | unsigned int unit_width; | ||
| 114 | unsigned int metric_only_len; | ||
| 115 | int times; | ||
| 116 | int run_count; | ||
| 117 | int print_free_counters_hint; | ||
| 118 | int print_mixed_hw_group_error; | ||
| 119 | struct runtime_stat *stats; | ||
| 120 | int stats_num; | ||
| 121 | const char *csv_sep; | ||
| 122 | struct stats *walltime_nsecs_stats; | ||
| 123 | struct rusage ru_data; | ||
| 124 | struct cpu_map *aggr_map; | ||
| 125 | aggr_get_id_t aggr_get_id; | ||
| 126 | struct cpu_map *cpus_aggr_map; | ||
| 127 | u64 *walltime_run; | ||
| 128 | struct rblist metric_events; | ||
| 96 | }; | 129 | }; |
| 97 | 130 | ||
| 98 | void update_stats(struct stats *stats, u64 val); | 131 | void update_stats(struct stats *stats, u64 val); |
| @@ -130,9 +163,10 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel, | |||
| 130 | extern struct runtime_stat rt_stat; | 163 | extern struct runtime_stat rt_stat; |
| 131 | extern struct stats walltime_nsecs_stats; | 164 | extern struct stats walltime_nsecs_stats; |
| 132 | 165 | ||
| 133 | typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit, | 166 | typedef void (*print_metric_t)(struct perf_stat_config *config, |
| 167 | void *ctx, const char *color, const char *unit, | ||
| 134 | const char *fmt, double val); | 168 | const char *fmt, double val); |
| 135 | typedef void (*new_line_t )(void *ctx); | 169 | typedef void (*new_line_t)(struct perf_stat_config *config, void *ctx); |
| 136 | 170 | ||
| 137 | void runtime_stat__init(struct runtime_stat *st); | 171 | void runtime_stat__init(struct runtime_stat *st); |
| 138 | void runtime_stat__exit(struct runtime_stat *st); | 172 | void runtime_stat__exit(struct runtime_stat *st); |
| @@ -148,7 +182,8 @@ struct perf_stat_output_ctx { | |||
| 148 | bool force_header; | 182 | bool force_header; |
| 149 | }; | 183 | }; |
| 150 | 184 | ||
| 151 | void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | 185 | void perf_stat__print_shadow_stats(struct perf_stat_config *config, |
| 186 | struct perf_evsel *evsel, | ||
| 152 | double avg, int cpu, | 187 | double avg, int cpu, |
| 153 | struct perf_stat_output_ctx *out, | 188 | struct perf_stat_output_ctx *out, |
| 154 | struct rblist *metric_events, | 189 | struct rblist *metric_events, |
| @@ -164,11 +199,25 @@ int perf_stat_process_counter(struct perf_stat_config *config, | |||
| 164 | struct perf_tool; | 199 | struct perf_tool; |
| 165 | union perf_event; | 200 | union perf_event; |
| 166 | struct perf_session; | 201 | struct perf_session; |
| 167 | int perf_event__process_stat_event(struct perf_tool *tool, | 202 | int perf_event__process_stat_event(struct perf_session *session, |
| 168 | union perf_event *event, | 203 | union perf_event *event); |
| 169 | struct perf_session *session); | ||
| 170 | 204 | ||
| 171 | size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp); | 205 | size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp); |
| 172 | size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp); | 206 | size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp); |
| 173 | size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp); | 207 | size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp); |
| 208 | |||
| 209 | int create_perf_stat_counter(struct perf_evsel *evsel, | ||
| 210 | struct perf_stat_config *config, | ||
| 211 | struct target *target); | ||
| 212 | int perf_stat_synthesize_config(struct perf_stat_config *config, | ||
| 213 | struct perf_tool *tool, | ||
| 214 | struct perf_evlist *evlist, | ||
| 215 | perf_event__handler_t process, | ||
| 216 | bool attrs); | ||
| 217 | void | ||
| 218 | perf_evlist__print_counters(struct perf_evlist *evlist, | ||
| 219 | struct perf_stat_config *config, | ||
| 220 | struct target *_target, | ||
| 221 | struct timespec *ts, | ||
| 222 | int argc, const char **argv); | ||
| 174 | #endif | 223 | #endif |
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index dd17d6a38d3a..c091635bf7dc 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | * @branch_count: the branch count when the entry was created | 36 | * @branch_count: the branch count when the entry was created |
| 37 | * @cp: call path | 37 | * @cp: call path |
| 38 | * @no_call: a 'call' was not seen | 38 | * @no_call: a 'call' was not seen |
| 39 | * @trace_end: a 'call' but trace ended | ||
| 39 | */ | 40 | */ |
| 40 | struct thread_stack_entry { | 41 | struct thread_stack_entry { |
| 41 | u64 ret_addr; | 42 | u64 ret_addr; |
| @@ -44,6 +45,7 @@ struct thread_stack_entry { | |||
| 44 | u64 branch_count; | 45 | u64 branch_count; |
| 45 | struct call_path *cp; | 46 | struct call_path *cp; |
| 46 | bool no_call; | 47 | bool no_call; |
| 48 | bool trace_end; | ||
| 47 | }; | 49 | }; |
| 48 | 50 | ||
| 49 | /** | 51 | /** |
| @@ -112,7 +114,8 @@ static struct thread_stack *thread_stack__new(struct thread *thread, | |||
| 112 | return ts; | 114 | return ts; |
| 113 | } | 115 | } |
| 114 | 116 | ||
| 115 | static int thread_stack__push(struct thread_stack *ts, u64 ret_addr) | 117 | static int thread_stack__push(struct thread_stack *ts, u64 ret_addr, |
| 118 | bool trace_end) | ||
| 116 | { | 119 | { |
| 117 | int err = 0; | 120 | int err = 0; |
| 118 | 121 | ||
| @@ -124,6 +127,7 @@ static int thread_stack__push(struct thread_stack *ts, u64 ret_addr) | |||
| 124 | } | 127 | } |
| 125 | } | 128 | } |
| 126 | 129 | ||
| 130 | ts->stack[ts->cnt].trace_end = trace_end; | ||
| 127 | ts->stack[ts->cnt++].ret_addr = ret_addr; | 131 | ts->stack[ts->cnt++].ret_addr = ret_addr; |
| 128 | 132 | ||
| 129 | return err; | 133 | return err; |
| @@ -150,6 +154,18 @@ static void thread_stack__pop(struct thread_stack *ts, u64 ret_addr) | |||
| 150 | } | 154 | } |
| 151 | } | 155 | } |
| 152 | 156 | ||
| 157 | static void thread_stack__pop_trace_end(struct thread_stack *ts) | ||
| 158 | { | ||
| 159 | size_t i; | ||
| 160 | |||
| 161 | for (i = ts->cnt; i; ) { | ||
| 162 | if (ts->stack[--i].trace_end) | ||
| 163 | ts->cnt = i; | ||
| 164 | else | ||
| 165 | return; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 153 | static bool thread_stack__in_kernel(struct thread_stack *ts) | 169 | static bool thread_stack__in_kernel(struct thread_stack *ts) |
| 154 | { | 170 | { |
| 155 | if (!ts->cnt) | 171 | if (!ts->cnt) |
| @@ -254,10 +270,19 @@ int thread_stack__event(struct thread *thread, u32 flags, u64 from_ip, | |||
| 254 | ret_addr = from_ip + insn_len; | 270 | ret_addr = from_ip + insn_len; |
| 255 | if (ret_addr == to_ip) | 271 | if (ret_addr == to_ip) |
| 256 | return 0; /* Zero-length calls are excluded */ | 272 | return 0; /* Zero-length calls are excluded */ |
| 257 | return thread_stack__push(thread->ts, ret_addr); | 273 | return thread_stack__push(thread->ts, ret_addr, |
| 258 | } else if (flags & PERF_IP_FLAG_RETURN) { | 274 | flags & PERF_IP_FLAG_TRACE_END); |
| 259 | if (!from_ip) | 275 | } else if (flags & PERF_IP_FLAG_TRACE_BEGIN) { |
| 260 | return 0; | 276 | /* |
| 277 | * If the caller did not change the trace number (which would | ||
| 278 | * have flushed the stack) then try to make sense of the stack. | ||
| 279 | * Possibly, tracing began after returning to the current | ||
| 280 | * address, so try to pop that. Also, do not expect a call made | ||
| 281 | * when the trace ended, to return, so pop that. | ||
| 282 | */ | ||
| 283 | thread_stack__pop(thread->ts, to_ip); | ||
| 284 | thread_stack__pop_trace_end(thread->ts); | ||
| 285 | } else if ((flags & PERF_IP_FLAG_RETURN) && from_ip) { | ||
| 261 | thread_stack__pop(thread->ts, to_ip); | 286 | thread_stack__pop(thread->ts, to_ip); |
| 262 | } | 287 | } |
| 263 | 288 | ||
| @@ -332,7 +357,7 @@ void call_return_processor__free(struct call_return_processor *crp) | |||
| 332 | 357 | ||
| 333 | static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr, | 358 | static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr, |
| 334 | u64 timestamp, u64 ref, struct call_path *cp, | 359 | u64 timestamp, u64 ref, struct call_path *cp, |
| 335 | bool no_call) | 360 | bool no_call, bool trace_end) |
| 336 | { | 361 | { |
| 337 | struct thread_stack_entry *tse; | 362 | struct thread_stack_entry *tse; |
| 338 | int err; | 363 | int err; |
| @@ -350,6 +375,7 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr, | |||
| 350 | tse->branch_count = ts->branch_count; | 375 | tse->branch_count = ts->branch_count; |
| 351 | tse->cp = cp; | 376 | tse->cp = cp; |
| 352 | tse->no_call = no_call; | 377 | tse->no_call = no_call; |
| 378 | tse->trace_end = trace_end; | ||
| 353 | 379 | ||
| 354 | return 0; | 380 | return 0; |
| 355 | } | 381 | } |
| @@ -423,7 +449,7 @@ static int thread_stack__bottom(struct thread *thread, struct thread_stack *ts, | |||
| 423 | return -ENOMEM; | 449 | return -ENOMEM; |
| 424 | 450 | ||
| 425 | return thread_stack__push_cp(thread->ts, ip, sample->time, ref, cp, | 451 | return thread_stack__push_cp(thread->ts, ip, sample->time, ref, cp, |
| 426 | true); | 452 | true, false); |
| 427 | } | 453 | } |
| 428 | 454 | ||
| 429 | static int thread_stack__no_call_return(struct thread *thread, | 455 | static int thread_stack__no_call_return(struct thread *thread, |
| @@ -455,7 +481,7 @@ static int thread_stack__no_call_return(struct thread *thread, | |||
| 455 | if (!cp) | 481 | if (!cp) |
| 456 | return -ENOMEM; | 482 | return -ENOMEM; |
| 457 | return thread_stack__push_cp(ts, 0, sample->time, ref, | 483 | return thread_stack__push_cp(ts, 0, sample->time, ref, |
| 458 | cp, true); | 484 | cp, true, false); |
| 459 | } | 485 | } |
| 460 | } else if (thread_stack__in_kernel(ts) && sample->ip < ks) { | 486 | } else if (thread_stack__in_kernel(ts) && sample->ip < ks) { |
| 461 | /* Return to userspace, so pop all kernel addresses */ | 487 | /* Return to userspace, so pop all kernel addresses */ |
| @@ -480,7 +506,7 @@ static int thread_stack__no_call_return(struct thread *thread, | |||
| 480 | return -ENOMEM; | 506 | return -ENOMEM; |
| 481 | 507 | ||
| 482 | err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp, | 508 | err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp, |
| 483 | true); | 509 | true, false); |
| 484 | if (err) | 510 | if (err) |
| 485 | return err; | 511 | return err; |
| 486 | 512 | ||
| @@ -500,7 +526,7 @@ static int thread_stack__trace_begin(struct thread *thread, | |||
| 500 | 526 | ||
| 501 | /* Pop trace end */ | 527 | /* Pop trace end */ |
| 502 | tse = &ts->stack[ts->cnt - 1]; | 528 | tse = &ts->stack[ts->cnt - 1]; |
| 503 | if (tse->cp->sym == NULL && tse->cp->ip == 0) { | 529 | if (tse->trace_end) { |
| 504 | err = thread_stack__call_return(thread, ts, --ts->cnt, | 530 | err = thread_stack__call_return(thread, ts, --ts->cnt, |
| 505 | timestamp, ref, false); | 531 | timestamp, ref, false); |
| 506 | if (err) | 532 | if (err) |
| @@ -529,7 +555,7 @@ static int thread_stack__trace_end(struct thread_stack *ts, | |||
| 529 | ret_addr = sample->ip + sample->insn_len; | 555 | ret_addr = sample->ip + sample->insn_len; |
| 530 | 556 | ||
| 531 | return thread_stack__push_cp(ts, ret_addr, sample->time, ref, cp, | 557 | return thread_stack__push_cp(ts, ret_addr, sample->time, ref, cp, |
| 532 | false); | 558 | false, true); |
| 533 | } | 559 | } |
| 534 | 560 | ||
| 535 | int thread_stack__process(struct thread *thread, struct comm *comm, | 561 | int thread_stack__process(struct thread *thread, struct comm *comm, |
| @@ -579,6 +605,7 @@ int thread_stack__process(struct thread *thread, struct comm *comm, | |||
| 579 | ts->last_time = sample->time; | 605 | ts->last_time = sample->time; |
| 580 | 606 | ||
| 581 | if (sample->flags & PERF_IP_FLAG_CALL) { | 607 | if (sample->flags & PERF_IP_FLAG_CALL) { |
| 608 | bool trace_end = sample->flags & PERF_IP_FLAG_TRACE_END; | ||
| 582 | struct call_path_root *cpr = ts->crp->cpr; | 609 | struct call_path_root *cpr = ts->crp->cpr; |
| 583 | struct call_path *cp; | 610 | struct call_path *cp; |
| 584 | u64 ret_addr; | 611 | u64 ret_addr; |
| @@ -596,7 +623,7 @@ int thread_stack__process(struct thread *thread, struct comm *comm, | |||
| 596 | if (!cp) | 623 | if (!cp) |
| 597 | return -ENOMEM; | 624 | return -ENOMEM; |
| 598 | err = thread_stack__push_cp(ts, ret_addr, sample->time, ref, | 625 | err = thread_stack__push_cp(ts, ret_addr, sample->time, ref, |
| 599 | cp, false); | 626 | cp, false, trace_end); |
| 600 | } else if (sample->flags & PERF_IP_FLAG_RETURN) { | 627 | } else if (sample->flags & PERF_IP_FLAG_RETURN) { |
| 601 | if (!sample->ip || !sample->addr) | 628 | if (!sample->ip || !sample->addr) |
| 602 | return 0; | 629 | return 0; |
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 183c91453522..56e4ca54020a 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h | |||
| @@ -26,15 +26,12 @@ typedef int (*event_attr_op)(struct perf_tool *tool, | |||
| 26 | union perf_event *event, | 26 | union perf_event *event, |
| 27 | struct perf_evlist **pevlist); | 27 | struct perf_evlist **pevlist); |
| 28 | 28 | ||
| 29 | typedef int (*event_op2)(struct perf_tool *tool, union perf_event *event, | 29 | typedef int (*event_op2)(struct perf_session *session, union perf_event *event); |
| 30 | struct perf_session *session); | 30 | typedef s64 (*event_op3)(struct perf_session *session, union perf_event *event); |
| 31 | 31 | ||
| 32 | typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event, | 32 | typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event, |
| 33 | struct ordered_events *oe); | 33 | struct ordered_events *oe); |
| 34 | 34 | ||
| 35 | typedef s64 (*event_op3)(struct perf_tool *tool, union perf_event *event, | ||
| 36 | struct perf_session *session); | ||
| 37 | |||
| 38 | enum show_feature_header { | 35 | enum show_feature_header { |
| 39 | SHOW_FEAT_NO_HEADER = 0, | 36 | SHOW_FEAT_NO_HEADER = 0, |
| 40 | SHOW_FEAT_HEADER, | 37 | SHOW_FEAT_HEADER, |
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index e76214f8d596..a4d7de1c96d1 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
| @@ -33,8 +33,8 @@ static int get_common_field(struct scripting_context *context, | |||
| 33 | int *offset, int *size, const char *type) | 33 | int *offset, int *size, const char *type) |
| 34 | { | 34 | { |
| 35 | struct tep_handle *pevent = context->pevent; | 35 | struct tep_handle *pevent = context->pevent; |
| 36 | struct event_format *event; | 36 | struct tep_event_format *event; |
| 37 | struct format_field *field; | 37 | struct tep_format_field *field; |
| 38 | 38 | ||
| 39 | if (!*size) { | 39 | if (!*size) { |
| 40 | if (!pevent->events) | 40 | if (!pevent->events) |
| @@ -94,9 +94,9 @@ int common_pc(struct scripting_context *context) | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | unsigned long long | 96 | unsigned long long |
| 97 | raw_field_value(struct event_format *event, const char *name, void *data) | 97 | raw_field_value(struct tep_event_format *event, const char *name, void *data) |
| 98 | { | 98 | { |
| 99 | struct format_field *field; | 99 | struct tep_format_field *field; |
| 100 | unsigned long long val; | 100 | unsigned long long val; |
| 101 | 101 | ||
| 102 | field = tep_find_any_field(event, name); | 102 | field = tep_find_any_field(event, name); |
| @@ -108,12 +108,12 @@ raw_field_value(struct event_format *event, const char *name, void *data) | |||
| 108 | return val; | 108 | return val; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | unsigned long long read_size(struct event_format *event, void *ptr, int size) | 111 | unsigned long long read_size(struct tep_event_format *event, void *ptr, int size) |
| 112 | { | 112 | { |
| 113 | return tep_read_number(event->pevent, ptr, size); | 113 | return tep_read_number(event->pevent, ptr, size); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | void event_format__fprintf(struct event_format *event, | 116 | void event_format__fprintf(struct tep_event_format *event, |
| 117 | int cpu, void *data, int size, FILE *fp) | 117 | int cpu, void *data, int size, FILE *fp) |
| 118 | { | 118 | { |
| 119 | struct tep_record record; | 119 | struct tep_record record; |
| @@ -130,7 +130,7 @@ void event_format__fprintf(struct event_format *event, | |||
| 130 | trace_seq_destroy(&s); | 130 | trace_seq_destroy(&s); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | void event_format__print(struct event_format *event, | 133 | void event_format__print(struct tep_event_format *event, |
| 134 | int cpu, void *data, int size) | 134 | int cpu, void *data, int size) |
| 135 | { | 135 | { |
| 136 | return event_format__fprintf(event, cpu, data, size, stdout); | 136 | return event_format__fprintf(event, cpu, data, size, stdout); |
| @@ -188,8 +188,8 @@ int parse_event_file(struct tep_handle *pevent, | |||
| 188 | return tep_parse_event(pevent, buf, size, sys); | 188 | return tep_parse_event(pevent, buf, size, sys); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | struct event_format *trace_find_next_event(struct tep_handle *pevent, | 191 | struct tep_event_format *trace_find_next_event(struct tep_handle *pevent, |
| 192 | struct event_format *event) | 192 | struct tep_event_format *event) |
| 193 | { | 193 | { |
| 194 | static int idx; | 194 | static int idx; |
| 195 | 195 | ||
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index 3dfc1db6b25b..b98ee2a2eb44 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c | |||
| @@ -102,7 +102,7 @@ static unsigned int read4(struct tep_handle *pevent) | |||
| 102 | 102 | ||
| 103 | if (do_read(&data, 4) < 0) | 103 | if (do_read(&data, 4) < 0) |
| 104 | return 0; | 104 | return 0; |
| 105 | return __data2host4(pevent, data); | 105 | return __tep_data2host4(pevent, data); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static unsigned long long read8(struct tep_handle *pevent) | 108 | static unsigned long long read8(struct tep_handle *pevent) |
| @@ -111,7 +111,7 @@ static unsigned long long read8(struct tep_handle *pevent) | |||
| 111 | 111 | ||
| 112 | if (do_read(&data, 8) < 0) | 112 | if (do_read(&data, 8) < 0) |
| 113 | return 0; | 113 | return 0; |
| 114 | return __data2host8(pevent, data); | 114 | return __tep_data2host8(pevent, data); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | static char *read_string(void) | 117 | static char *read_string(void) |
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 58bb72f266f3..95664b2f771e 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c | |||
| @@ -72,12 +72,12 @@ void trace_event__cleanup(struct trace_event *t) | |||
| 72 | /* | 72 | /* |
| 73 | * Returns pointer with encoded error via <linux/err.h> interface. | 73 | * Returns pointer with encoded error via <linux/err.h> interface. |
| 74 | */ | 74 | */ |
| 75 | static struct event_format* | 75 | static struct tep_event_format* |
| 76 | tp_format(const char *sys, const char *name) | 76 | tp_format(const char *sys, const char *name) |
| 77 | { | 77 | { |
| 78 | char *tp_dir = get_events_file(sys); | 78 | char *tp_dir = get_events_file(sys); |
| 79 | struct tep_handle *pevent = tevent.pevent; | 79 | struct tep_handle *pevent = tevent.pevent; |
| 80 | struct event_format *event = NULL; | 80 | struct tep_event_format *event = NULL; |
| 81 | char path[PATH_MAX]; | 81 | char path[PATH_MAX]; |
| 82 | size_t size; | 82 | size_t size; |
| 83 | char *data; | 83 | char *data; |
| @@ -102,7 +102,7 @@ tp_format(const char *sys, const char *name) | |||
| 102 | /* | 102 | /* |
| 103 | * Returns pointer with encoded error via <linux/err.h> interface. | 103 | * Returns pointer with encoded error via <linux/err.h> interface. |
| 104 | */ | 104 | */ |
| 105 | struct event_format* | 105 | struct tep_event_format* |
| 106 | trace_event__tp_format(const char *sys, const char *name) | 106 | trace_event__tp_format(const char *sys, const char *name) |
| 107 | { | 107 | { |
| 108 | if (!tevent_initialized && trace_event__init2()) | 108 | if (!tevent_initialized && trace_event__init2()) |
| @@ -111,7 +111,7 @@ trace_event__tp_format(const char *sys, const char *name) | |||
| 111 | return tp_format(sys, name); | 111 | return tp_format(sys, name); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | struct event_format *trace_event__tp_format_id(int id) | 114 | struct tep_event_format *trace_event__tp_format_id(int id) |
| 115 | { | 115 | { |
| 116 | if (!tevent_initialized && trace_event__init2()) | 116 | if (!tevent_initialized && trace_event__init2()) |
| 117 | return ERR_PTR(-ENOMEM); | 117 | return ERR_PTR(-ENOMEM); |
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 40204ec3a7a2..f024d73bfc40 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #define _PERF_UTIL_TRACE_EVENT_H | 3 | #define _PERF_UTIL_TRACE_EVENT_H |
| 4 | 4 | ||
| 5 | #include <traceevent/event-parse.h> | 5 | #include <traceevent/event-parse.h> |
| 6 | #include <traceevent/trace-seq.h> | ||
| 6 | #include "parse-events.h" | 7 | #include "parse-events.h" |
| 7 | 8 | ||
| 8 | struct machine; | 9 | struct machine; |
| @@ -10,28 +11,28 @@ struct perf_sample; | |||
| 10 | union perf_event; | 11 | union perf_event; |
| 11 | struct perf_tool; | 12 | struct perf_tool; |
| 12 | struct thread; | 13 | struct thread; |
| 13 | struct plugin_list; | 14 | struct tep_plugin_list; |
| 14 | 15 | ||
| 15 | struct trace_event { | 16 | struct trace_event { |
| 16 | struct tep_handle *pevent; | 17 | struct tep_handle *pevent; |
| 17 | struct plugin_list *plugin_list; | 18 | struct tep_plugin_list *plugin_list; |
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 20 | int trace_event__init(struct trace_event *t); | 21 | int trace_event__init(struct trace_event *t); |
| 21 | void trace_event__cleanup(struct trace_event *t); | 22 | void trace_event__cleanup(struct trace_event *t); |
| 22 | int trace_event__register_resolver(struct machine *machine, | 23 | int trace_event__register_resolver(struct machine *machine, |
| 23 | tep_func_resolver_t *func); | 24 | tep_func_resolver_t *func); |
| 24 | struct event_format* | 25 | struct tep_event_format* |
| 25 | trace_event__tp_format(const char *sys, const char *name); | 26 | trace_event__tp_format(const char *sys, const char *name); |
| 26 | 27 | ||
| 27 | struct event_format *trace_event__tp_format_id(int id); | 28 | struct tep_event_format *trace_event__tp_format_id(int id); |
| 28 | 29 | ||
| 29 | int bigendian(void); | 30 | int bigendian(void); |
| 30 | 31 | ||
| 31 | void event_format__fprintf(struct event_format *event, | 32 | void event_format__fprintf(struct tep_event_format *event, |
| 32 | int cpu, void *data, int size, FILE *fp); | 33 | int cpu, void *data, int size, FILE *fp); |
| 33 | 34 | ||
| 34 | void event_format__print(struct event_format *event, | 35 | void event_format__print(struct tep_event_format *event, |
| 35 | int cpu, void *data, int size); | 36 | int cpu, void *data, int size); |
| 36 | 37 | ||
| 37 | int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); | 38 | int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); |
| @@ -39,7 +40,7 @@ int parse_event_file(struct tep_handle *pevent, | |||
| 39 | char *buf, unsigned long size, char *sys); | 40 | char *buf, unsigned long size, char *sys); |
| 40 | 41 | ||
| 41 | unsigned long long | 42 | unsigned long long |
| 42 | raw_field_value(struct event_format *event, const char *name, void *data); | 43 | raw_field_value(struct tep_event_format *event, const char *name, void *data); |
| 43 | 44 | ||
| 44 | void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); | 45 | void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); |
| 45 | void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); | 46 | void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); |
| @@ -47,9 +48,9 @@ void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int siz | |||
| 47 | 48 | ||
| 48 | ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); | 49 | ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); |
| 49 | 50 | ||
| 50 | struct event_format *trace_find_next_event(struct tep_handle *pevent, | 51 | struct tep_event_format *trace_find_next_event(struct tep_handle *pevent, |
| 51 | struct event_format *event); | 52 | struct tep_event_format *event); |
| 52 | unsigned long long read_size(struct event_format *event, void *ptr, int size); | 53 | unsigned long long read_size(struct tep_event_format *event, void *ptr, int size); |
| 53 | unsigned long long eval_flag(const char *flag); | 54 | unsigned long long eval_flag(const char *flag); |
| 54 | 55 | ||
| 55 | int read_tracing_data(int fd, struct list_head *pattrs); | 56 | int read_tracing_data(int fd, struct list_head *pattrs); |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index eac5b858a371..093352e93d50 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
| @@ -221,7 +221,7 @@ out: | |||
| 221 | return err; | 221 | return err; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | static int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size) | 224 | int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size) |
| 225 | { | 225 | { |
| 226 | void *ptr; | 226 | void *ptr; |
| 227 | loff_t pgoff; | 227 | loff_t pgoff; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index dc58254a2b69..14508ee7707a 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ | 6 | /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ |
| 7 | #define _DEFAULT_SOURCE 1 | 7 | #define _DEFAULT_SOURCE 1 |
| 8 | 8 | ||
| 9 | #include <fcntl.h> | ||
| 9 | #include <stdbool.h> | 10 | #include <stdbool.h> |
| 10 | #include <stddef.h> | 11 | #include <stddef.h> |
| 11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
| @@ -35,6 +36,7 @@ bool lsdir_no_dot_filter(const char *name, struct dirent *d); | |||
| 35 | int copyfile(const char *from, const char *to); | 36 | int copyfile(const char *from, const char *to); |
| 36 | int copyfile_mode(const char *from, const char *to, mode_t mode); | 37 | int copyfile_mode(const char *from, const char *to, mode_t mode); |
| 37 | int copyfile_ns(const char *from, const char *to, struct nsinfo *nsi); | 38 | int copyfile_ns(const char *from, const char *to, struct nsinfo *nsi); |
| 39 | int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size); | ||
| 38 | 40 | ||
| 39 | ssize_t readn(int fd, void *buf, size_t n); | 41 | ssize_t readn(int fd, void *buf, size_t n); |
| 40 | ssize_t writen(int fd, const void *buf, size_t n); | 42 | ssize_t writen(int fd, const void *buf, size_t n); |
diff --git a/tools/testing/selftests/powerpc/alignment/Makefile b/tools/testing/selftests/powerpc/alignment/Makefile index 93baacab7693..d056486f49de 100644 --- a/tools/testing/selftests/powerpc/alignment/Makefile +++ b/tools/testing/selftests/powerpc/alignment/Makefile | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | TEST_GEN_PROGS := copy_first_unaligned alignment_handler | 1 | TEST_GEN_PROGS := copy_first_unaligned alignment_handler |
| 2 | 2 | ||
| 3 | top_srcdir = ../../../../.. | ||
| 3 | include ../../lib.mk | 4 | include ../../lib.mk |
| 4 | 5 | ||
| 5 | $(TEST_GEN_PROGS): ../harness.c ../utils.c | 6 | $(TEST_GEN_PROGS): ../harness.c ../utils.c |
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile index b4d7432a0ecd..d40300a65b42 100644 --- a/tools/testing/selftests/powerpc/benchmarks/Makefile +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile | |||
| @@ -4,6 +4,7 @@ TEST_GEN_FILES := exec_target | |||
| 4 | 4 | ||
| 5 | CFLAGS += -O2 | 5 | CFLAGS += -O2 |
| 6 | 6 | ||
| 7 | top_srcdir = ../../../../.. | ||
| 7 | include ../../lib.mk | 8 | include ../../lib.mk |
| 8 | 9 | ||
| 9 | $(TEST_GEN_PROGS): ../harness.c | 10 | $(TEST_GEN_PROGS): ../harness.c |
diff --git a/tools/testing/selftests/powerpc/cache_shape/Makefile b/tools/testing/selftests/powerpc/cache_shape/Makefile index 1be547434a49..ede4d3dae750 100644 --- a/tools/testing/selftests/powerpc/cache_shape/Makefile +++ b/tools/testing/selftests/powerpc/cache_shape/Makefile | |||
| @@ -5,6 +5,7 @@ all: $(TEST_PROGS) | |||
| 5 | 5 | ||
| 6 | $(TEST_PROGS): ../harness.c ../utils.c | 6 | $(TEST_PROGS): ../harness.c ../utils.c |
| 7 | 7 | ||
| 8 | top_srcdir = ../../../../.. | ||
| 8 | include ../../lib.mk | 9 | include ../../lib.mk |
| 9 | 10 | ||
| 10 | clean: | 11 | clean: |
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile index 1cf89a34d97c..44574f3818b3 100644 --- a/tools/testing/selftests/powerpc/copyloops/Makefile +++ b/tools/testing/selftests/powerpc/copyloops/Makefile | |||
| @@ -17,6 +17,7 @@ TEST_GEN_PROGS := copyuser_64_t0 copyuser_64_t1 copyuser_64_t2 \ | |||
| 17 | 17 | ||
| 18 | EXTRA_SOURCES := validate.c ../harness.c stubs.S | 18 | EXTRA_SOURCES := validate.c ../harness.c stubs.S |
| 19 | 19 | ||
| 20 | top_srcdir = ../../../../.. | ||
| 20 | include ../../lib.mk | 21 | include ../../lib.mk |
| 21 | 22 | ||
| 22 | $(OUTPUT)/copyuser_64_t%: copyuser_64.S $(EXTRA_SOURCES) | 23 | $(OUTPUT)/copyuser_64_t%: copyuser_64.S $(EXTRA_SOURCES) |
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile index 55d7db7a616b..5df476364b4d 100644 --- a/tools/testing/selftests/powerpc/dscr/Makefile +++ b/tools/testing/selftests/powerpc/dscr/Makefile | |||
| @@ -3,6 +3,7 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \ | |||
| 3 | dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test \ | 3 | dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test \ |
| 4 | dscr_sysfs_thread_test | 4 | dscr_sysfs_thread_test |
| 5 | 5 | ||
| 6 | top_srcdir = ../../../../.. | ||
| 6 | include ../../lib.mk | 7 | include ../../lib.mk |
| 7 | 8 | ||
| 8 | $(OUTPUT)/dscr_default_test: LDLIBS += -lpthread | 9 | $(OUTPUT)/dscr_default_test: LDLIBS += -lpthread |
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile index 0dd3a01fdab9..11a10d7a2bbd 100644 --- a/tools/testing/selftests/powerpc/math/Makefile +++ b/tools/testing/selftests/powerpc/math/Makefile | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt | 2 | TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt |
| 3 | 3 | ||
| 4 | top_srcdir = ../../../../.. | ||
| 4 | include ../../lib.mk | 5 | include ../../lib.mk |
| 5 | 6 | ||
| 6 | $(TEST_GEN_PROGS): ../harness.c | 7 | $(TEST_GEN_PROGS): ../harness.c |
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile index 8ebbe96d80a8..33ced6e0ad25 100644 --- a/tools/testing/selftests/powerpc/mm/Makefile +++ b/tools/testing/selftests/powerpc/mm/Makefile | |||
| @@ -5,6 +5,7 @@ noarg: | |||
| 5 | TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao segv_errors | 5 | TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao segv_errors |
| 6 | TEST_GEN_FILES := tempfile | 6 | TEST_GEN_FILES := tempfile |
| 7 | 7 | ||
| 8 | top_srcdir = ../../../../.. | ||
| 8 | include ../../lib.mk | 9 | include ../../lib.mk |
| 9 | 10 | ||
| 10 | $(TEST_GEN_PROGS): ../harness.c | 11 | $(TEST_GEN_PROGS): ../harness.c |
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile index 6e1629bf5b09..19046db995fe 100644 --- a/tools/testing/selftests/powerpc/pmu/Makefile +++ b/tools/testing/selftests/powerpc/pmu/Makefile | |||
| @@ -5,6 +5,7 @@ noarg: | |||
| 5 | TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes | 5 | TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes |
| 6 | EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c | 6 | EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c |
| 7 | 7 | ||
| 8 | top_srcdir = ../../../../.. | ||
| 8 | include ../../lib.mk | 9 | include ../../lib.mk |
| 9 | 10 | ||
| 10 | all: $(TEST_GEN_PROGS) ebb | 11 | all: $(TEST_GEN_PROGS) ebb |
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile index c4e64bc2e265..bd5dfa509272 100644 --- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile +++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile | |||
| @@ -17,6 +17,7 @@ TEST_GEN_PROGS := reg_access_test event_attributes_test cycles_test \ | |||
| 17 | lost_exception_test no_handler_test \ | 17 | lost_exception_test no_handler_test \ |
| 18 | cycles_with_mmcr2_test | 18 | cycles_with_mmcr2_test |
| 19 | 19 | ||
| 20 | top_srcdir = ../../../../../.. | ||
| 20 | include ../../../lib.mk | 21 | include ../../../lib.mk |
| 21 | 22 | ||
| 22 | $(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \ | 23 | $(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \ |
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile index 175366db7be8..ea2b7bd09e36 100644 --- a/tools/testing/selftests/powerpc/primitives/Makefile +++ b/tools/testing/selftests/powerpc/primitives/Makefile | |||
| @@ -2,6 +2,7 @@ CFLAGS += -I$(CURDIR) | |||
| 2 | 2 | ||
| 3 | TEST_GEN_PROGS := load_unaligned_zeropad | 3 | TEST_GEN_PROGS := load_unaligned_zeropad |
| 4 | 4 | ||
| 5 | top_srcdir = ../../../../.. | ||
| 5 | include ../../lib.mk | 6 | include ../../lib.mk |
| 6 | 7 | ||
| 7 | $(TEST_GEN_PROGS): ../harness.c | 8 | $(TEST_GEN_PROGS): ../harness.c |
diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index 28f5b781a553..923d531265f8 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile | |||
| @@ -4,6 +4,7 @@ TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ | |||
| 4 | ptrace-tm-spd-vsx ptrace-tm-spr ptrace-hwbreak ptrace-pkey core-pkey \ | 4 | ptrace-tm-spd-vsx ptrace-tm-spr ptrace-hwbreak ptrace-pkey core-pkey \ |
| 5 | perf-hwbreak | 5 | perf-hwbreak |
| 6 | 6 | ||
| 7 | top_srcdir = ../../../../.. | ||
| 7 | include ../../lib.mk | 8 | include ../../lib.mk |
| 8 | 9 | ||
| 9 | all: $(TEST_PROGS) | 10 | all: $(TEST_PROGS) |
diff --git a/tools/testing/selftests/powerpc/signal/Makefile b/tools/testing/selftests/powerpc/signal/Makefile index a7cbd5082e27..1fca25c6ace0 100644 --- a/tools/testing/selftests/powerpc/signal/Makefile +++ b/tools/testing/selftests/powerpc/signal/Makefile | |||
| @@ -8,6 +8,7 @@ $(TEST_PROGS): ../harness.c ../utils.c signal.S | |||
| 8 | CFLAGS += -maltivec | 8 | CFLAGS += -maltivec |
| 9 | signal_tm: CFLAGS += -mhtm | 9 | signal_tm: CFLAGS += -mhtm |
| 10 | 10 | ||
| 11 | top_srcdir = ../../../../.. | ||
| 11 | include ../../lib.mk | 12 | include ../../lib.mk |
| 12 | 13 | ||
| 13 | clean: | 14 | clean: |
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile index 10b35c87a4f4..7fc0623d85c3 100644 --- a/tools/testing/selftests/powerpc/stringloops/Makefile +++ b/tools/testing/selftests/powerpc/stringloops/Makefile | |||
| @@ -29,6 +29,7 @@ endif | |||
| 29 | 29 | ||
| 30 | ASFLAGS = $(CFLAGS) | 30 | ASFLAGS = $(CFLAGS) |
| 31 | 31 | ||
| 32 | top_srcdir = ../../../../.. | ||
| 32 | include ../../lib.mk | 33 | include ../../lib.mk |
| 33 | 34 | ||
| 34 | $(TEST_GEN_PROGS): $(EXTRA_SOURCES) | 35 | $(TEST_GEN_PROGS): $(EXTRA_SOURCES) |
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile index 30b8ff8fb82e..fcd2dcb8972b 100644 --- a/tools/testing/selftests/powerpc/switch_endian/Makefile +++ b/tools/testing/selftests/powerpc/switch_endian/Makefile | |||
| @@ -5,6 +5,7 @@ ASFLAGS += -O2 -Wall -g -nostdlib -m64 | |||
| 5 | 5 | ||
| 6 | EXTRA_CLEAN = $(OUTPUT)/*.o $(OUTPUT)/check-reversed.S | 6 | EXTRA_CLEAN = $(OUTPUT)/*.o $(OUTPUT)/check-reversed.S |
| 7 | 7 | ||
| 8 | top_srcdir = ../../../../.. | ||
| 8 | include ../../lib.mk | 9 | include ../../lib.mk |
| 9 | 10 | ||
| 10 | $(OUTPUT)/switch_endian_test: $(OUTPUT)/check-reversed.S | 11 | $(OUTPUT)/switch_endian_test: $(OUTPUT)/check-reversed.S |
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile index da22ca7c38c1..161b8846336f 100644 --- a/tools/testing/selftests/powerpc/syscalls/Makefile +++ b/tools/testing/selftests/powerpc/syscalls/Makefile | |||
| @@ -2,6 +2,7 @@ TEST_GEN_PROGS := ipc_unmuxed | |||
| 2 | 2 | ||
| 3 | CFLAGS += -I../../../../../usr/include | 3 | CFLAGS += -I../../../../../usr/include |
| 4 | 4 | ||
| 5 | top_srcdir = ../../../../.. | ||
| 5 | include ../../lib.mk | 6 | include ../../lib.mk |
| 6 | 7 | ||
| 7 | $(TEST_GEN_PROGS): ../harness.c | 8 | $(TEST_GEN_PROGS): ../harness.c |
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile index c0e45d2dde25..9fc2cf6fbc92 100644 --- a/tools/testing/selftests/powerpc/tm/Makefile +++ b/tools/testing/selftests/powerpc/tm/Makefile | |||
| @@ -6,6 +6,7 @@ TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack | |||
| 6 | tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail tm-unavailable tm-trap \ | 6 | tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail tm-unavailable tm-trap \ |
| 7 | $(SIGNAL_CONTEXT_CHK_TESTS) tm-sigreturn | 7 | $(SIGNAL_CONTEXT_CHK_TESTS) tm-sigreturn |
| 8 | 8 | ||
| 9 | top_srcdir = ../../../../.. | ||
| 9 | include ../../lib.mk | 10 | include ../../lib.mk |
| 10 | 11 | ||
| 11 | $(TEST_GEN_PROGS): ../harness.c ../utils.c | 12 | $(TEST_GEN_PROGS): ../harness.c ../utils.c |
diff --git a/tools/testing/selftests/powerpc/vphn/Makefile b/tools/testing/selftests/powerpc/vphn/Makefile index f8ced26748f8..fb82068c9fda 100644 --- a/tools/testing/selftests/powerpc/vphn/Makefile +++ b/tools/testing/selftests/powerpc/vphn/Makefile | |||
| @@ -2,6 +2,7 @@ TEST_GEN_PROGS := test-vphn | |||
| 2 | 2 | ||
| 3 | CFLAGS += -m64 | 3 | CFLAGS += -m64 |
| 4 | 4 | ||
| 5 | top_srcdir = ../../../../.. | ||
| 5 | include ../../lib.mk | 6 | include ../../lib.mk |
| 6 | 7 | ||
| 7 | $(TEST_GEN_PROGS): ../harness.c | 8 | $(TEST_GEN_PROGS): ../harness.c |
