Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
perf: Provide generic perf_sample_data initialization
MAINTAINERS: Add Arnaldo as tools/perf/ co-maintainer
perf trace: Don't use pager if scripting
perf trace/scripting: Remove extraneous header read
perf, ARM: Modify kuser rmb() call to compile for Thumb-2
x86/stacktrace: Don't dereference bad frame pointers
perf archive: Don't try to collect files without a build-id
perf_events, x86: Fixup fixed counter constraints
perf, x86: Restrict the ANY flag
perf, x86: rename macro in ARCH_PERFMON_EVENTSEL_ENABLE
perf, x86: add some IBS macros to perf_event.h
perf, x86: make IBS macros available in perf_event.h
hw-breakpoints: Remove stub unthrottle callback
x86/hw-breakpoints: Remove the name field
perf: Remove pointless breakpoint union
perf lock: Drop the buffers multiplexing dependency
perf lock: Fix and add misc documentally things
percpu: Add __percpu sparse annotations to hw_breakpoint

+327 -129
+1
MAINTAINERS
··· 4316 4316 M: Peter Zijlstra <a.p.zijlstra@chello.nl> 4317 4317 M: Paul Mackerras <paulus@samba.org> 4318 4318 M: Ingo Molnar <mingo@elte.hu> 4319 + M: Arnaldo Carvalho de Melo <acme@redhat.com> 4319 4320 S: Supported 4320 4321 F: kernel/perf_event.c 4321 4322 F: include/linux/perf_event.h
+2 -2
arch/arm/kernel/perf_event.c
··· 965 965 */ 966 966 armv6_pmcr_write(pmcr); 967 967 968 - data.addr = 0; 968 + perf_sample_data_init(&data, 0); 969 969 970 970 cpuc = &__get_cpu_var(cpu_hw_events); 971 971 for (idx = 0; idx <= armpmu->num_events; ++idx) { ··· 1945 1945 */ 1946 1946 regs = get_irq_regs(); 1947 1947 1948 - data.addr = 0; 1948 + perf_sample_data_init(&data, 0); 1949 1949 1950 1950 cpuc = &__get_cpu_var(cpu_hw_events); 1951 1951 for (idx = 0; idx <= armpmu->num_events; ++idx) {
+4 -4
arch/powerpc/kernel/perf_event.c
··· 1164 1164 * Finally record data if requested. 1165 1165 */ 1166 1166 if (record) { 1167 - struct perf_sample_data data = { 1168 - .addr = ~0ULL, 1169 - .period = event->hw.last_period, 1170 - }; 1167 + struct perf_sample_data data; 1168 + 1169 + perf_sample_data_init(&data, ~0ULL); 1170 + data.period = event->hw.last_period; 1171 1171 1172 1172 if (event->attr.sample_type & PERF_SAMPLE_ADDR) 1173 1173 perf_get_data_addr(regs, &data.addr);
+1 -1
arch/sparc/kernel/perf_event.c
··· 1189 1189 1190 1190 regs = args->regs; 1191 1191 1192 - data.addr = 0; 1192 + perf_sample_data_init(&data, 0); 1193 1193 1194 1194 cpuc = &__get_cpu_var(cpu_hw_events); 1195 1195
-1
arch/x86/include/asm/hw_breakpoint.h
··· 10 10 * (display/resolving) 11 11 */ 12 12 struct arch_hw_breakpoint { 13 - char *name; /* Contains name of the symbol to set bkpt */ 14 13 unsigned long address; 15 14 u8 len; 16 15 u8 type;
+14 -2
arch/x86/include/asm/perf_event.h
··· 18 18 #define MSR_ARCH_PERFMON_EVENTSEL0 0x186 19 19 #define MSR_ARCH_PERFMON_EVENTSEL1 0x187 20 20 21 - #define ARCH_PERFMON_EVENTSEL0_ENABLE (1 << 22) 21 + #define ARCH_PERFMON_EVENTSEL_ENABLE (1 << 22) 22 22 #define ARCH_PERFMON_EVENTSEL_ANY (1 << 21) 23 23 #define ARCH_PERFMON_EVENTSEL_INT (1 << 20) 24 24 #define ARCH_PERFMON_EVENTSEL_OS (1 << 17) ··· 50 50 INTEL_ARCH_INV_MASK| \ 51 51 INTEL_ARCH_EDGE_MASK|\ 52 52 INTEL_ARCH_UNIT_MASK|\ 53 - INTEL_ARCH_EVTSEL_MASK) 53 + INTEL_ARCH_EVENT_MASK) 54 54 55 55 #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c 56 56 #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) ··· 117 117 */ 118 118 #define X86_PMC_IDX_FIXED_BTS (X86_PMC_IDX_FIXED + 16) 119 119 120 + /* IbsFetchCtl bits/masks */ 121 + #define IBS_FETCH_RAND_EN (1ULL<<57) 122 + #define IBS_FETCH_VAL (1ULL<<49) 123 + #define IBS_FETCH_ENABLE (1ULL<<48) 124 + #define IBS_FETCH_CNT 0xFFFF0000ULL 125 + #define IBS_FETCH_MAX_CNT 0x0000FFFFULL 126 + 127 + /* IbsOpCtl bits */ 128 + #define IBS_OP_CNT_CTL (1ULL<<19) 129 + #define IBS_OP_VAL (1ULL<<18) 130 + #define IBS_OP_ENABLE (1ULL<<17) 131 + #define IBS_OP_MAX_CNT 0x0000FFFFULL 120 132 121 133 #ifdef CONFIG_PERF_EVENTS 122 134 extern void init_hw_perf_events(void);
+26 -13
arch/x86/kernel/cpu/perf_event.c
··· 73 73 struct event_constraint { 74 74 union { 75 75 unsigned long idxmsk[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 76 - u64 idxmsk64[1]; 76 + u64 idxmsk64; 77 77 }; 78 - int code; 79 - int cmask; 78 + u64 code; 79 + u64 cmask; 80 80 int weight; 81 81 }; 82 82 ··· 103 103 }; 104 104 105 105 #define __EVENT_CONSTRAINT(c, n, m, w) {\ 106 - { .idxmsk64[0] = (n) }, \ 106 + { .idxmsk64 = (n) }, \ 107 107 .code = (c), \ 108 108 .cmask = (m), \ 109 109 .weight = (w), \ ··· 116 116 EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVTSEL_MASK) 117 117 118 118 #define FIXED_EVENT_CONSTRAINT(c, n) \ 119 - EVENT_CONSTRAINT(c, n, INTEL_ARCH_FIXED_MASK) 119 + EVENT_CONSTRAINT(c, (1ULL << (32+n)), INTEL_ARCH_FIXED_MASK) 120 120 121 121 #define EVENT_CONSTRAINT_END \ 122 122 EVENT_CONSTRAINT(0, 0, 0) ··· 503 503 */ 504 504 if (attr->type == PERF_TYPE_RAW) { 505 505 hwc->config |= x86_pmu.raw_event(attr->config); 506 + if ((hwc->config & ARCH_PERFMON_EVENTSEL_ANY) && 507 + perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN)) 508 + return -EACCES; 506 509 return 0; 507 510 } 508 511 ··· 556 553 if (!test_bit(idx, cpuc->active_mask)) 557 554 continue; 558 555 rdmsrl(x86_pmu.eventsel + idx, val); 559 - if (!(val & ARCH_PERFMON_EVENTSEL0_ENABLE)) 556 + if (!(val & ARCH_PERFMON_EVENTSEL_ENABLE)) 560 557 continue; 561 - val &= ~ARCH_PERFMON_EVENTSEL0_ENABLE; 558 + val &= ~ARCH_PERFMON_EVENTSEL_ENABLE; 562 559 wrmsrl(x86_pmu.eventsel + idx, val); 563 560 } 564 561 } ··· 593 590 continue; 594 591 595 592 val = event->hw.config; 596 - val |= ARCH_PERFMON_EVENTSEL0_ENABLE; 593 + val |= ARCH_PERFMON_EVENTSEL_ENABLE; 597 594 wrmsrl(x86_pmu.eventsel + idx, val); 598 595 } 599 596 } ··· 615 612 bitmap_zero(used_mask, X86_PMC_IDX_MAX); 616 613 617 614 for (i = 0; i < n; i++) { 618 - constraints[i] = 619 - x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]); 615 + c = x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]); 616 + constraints[i] = c; 620 617 } 621 618 622 619 /* ··· 856 853 static inline void __x86_pmu_enable_event(struct hw_perf_event *hwc, int idx) 857 854 { 858 855 (void)checking_wrmsrl(hwc->config_base + idx, 859 - hwc->config | ARCH_PERFMON_EVENTSEL0_ENABLE); 856 + hwc->config | ARCH_PERFMON_EVENTSEL_ENABLE); 860 857 } 861 858 862 859 static inline void x86_pmu_disable_event(struct hw_perf_event *hwc, int idx) ··· 1097 1094 int idx, handled = 0; 1098 1095 u64 val; 1099 1096 1100 - data.addr = 0; 1101 - data.raw = NULL; 1097 + perf_sample_data_init(&data, 0); 1102 1098 1103 1099 cpuc = &__get_cpu_var(cpu_hw_events); 1104 1100 ··· 1349 1347 1350 1348 void __init init_hw_perf_events(void) 1351 1349 { 1350 + struct event_constraint *c; 1352 1351 int err; 1353 1352 1354 1353 pr_info("Performance Events: "); ··· 1397 1394 unconstrained = (struct event_constraint) 1398 1395 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_events) - 1, 1399 1396 0, x86_pmu.num_events); 1397 + 1398 + if (x86_pmu.event_constraints) { 1399 + for_each_event_constraint(c, x86_pmu.event_constraints) { 1400 + if (c->cmask != INTEL_ARCH_FIXED_MASK) 1401 + continue; 1402 + 1403 + c->idxmsk64 |= (1ULL << x86_pmu.num_events) - 1; 1404 + c->weight += x86_pmu.num_events; 1405 + } 1406 + } 1400 1407 1401 1408 pr_info("... version: %d\n", x86_pmu.version); 1402 1409 pr_info("... bit width: %d\n", x86_pmu.event_bits);
+23 -14
arch/x86/kernel/cpu/perf_event_intel.c
··· 1 1 #ifdef CONFIG_CPU_SUP_INTEL 2 2 3 3 /* 4 - * Intel PerfMon v3. Used on Core2 and later. 4 + * Intel PerfMon, used on Core and later. 5 5 */ 6 6 static const u64 intel_perfmon_event_map[] = 7 7 { ··· 27 27 28 28 static struct event_constraint intel_core2_event_constraints[] = 29 29 { 30 - FIXED_EVENT_CONSTRAINT(0xc0, (0x3|(1ULL<<32))), /* INSTRUCTIONS_RETIRED */ 31 - FIXED_EVENT_CONSTRAINT(0x3c, (0x3|(1ULL<<33))), /* UNHALTED_CORE_CYCLES */ 30 + FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ 31 + FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ 32 + /* 33 + * Core2 has Fixed Counter 2 listed as CPU_CLK_UNHALTED.REF and event 34 + * 0x013c as CPU_CLK_UNHALTED.BUS and specifies there is a fixed 35 + * ratio between these counters. 36 + */ 37 + /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */ 32 38 INTEL_EVENT_CONSTRAINT(0x10, 0x1), /* FP_COMP_OPS_EXE */ 33 39 INTEL_EVENT_CONSTRAINT(0x11, 0x2), /* FP_ASSIST */ 34 40 INTEL_EVENT_CONSTRAINT(0x12, 0x2), /* MUL */ ··· 43 37 INTEL_EVENT_CONSTRAINT(0x18, 0x1), /* IDLE_DURING_DIV */ 44 38 INTEL_EVENT_CONSTRAINT(0x19, 0x2), /* DELAYED_BYPASS */ 45 39 INTEL_EVENT_CONSTRAINT(0xa1, 0x1), /* RS_UOPS_DISPATCH_CYCLES */ 40 + INTEL_EVENT_CONSTRAINT(0xc9, 0x1), /* ITLB_MISS_RETIRED (T30-9) */ 46 41 INTEL_EVENT_CONSTRAINT(0xcb, 0x1), /* MEM_LOAD_RETIRED */ 47 42 EVENT_CONSTRAINT_END 48 43 }; 49 44 50 45 static struct event_constraint intel_nehalem_event_constraints[] = 51 46 { 52 - FIXED_EVENT_CONSTRAINT(0xc0, (0xf|(1ULL<<32))), /* INSTRUCTIONS_RETIRED */ 53 - FIXED_EVENT_CONSTRAINT(0x3c, (0xf|(1ULL<<33))), /* UNHALTED_CORE_CYCLES */ 47 + FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ 48 + FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ 49 + /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */ 54 50 INTEL_EVENT_CONSTRAINT(0x40, 0x3), /* L1D_CACHE_LD */ 55 51 INTEL_EVENT_CONSTRAINT(0x41, 0x3), /* L1D_CACHE_ST */ 56 52 INTEL_EVENT_CONSTRAINT(0x42, 0x3), /* L1D_CACHE_LOCK */ ··· 66 58 67 59 static struct event_constraint intel_westmere_event_constraints[] = 68 60 { 69 - FIXED_EVENT_CONSTRAINT(0xc0, (0xf|(1ULL<<32))), /* INSTRUCTIONS_RETIRED */ 70 - FIXED_EVENT_CONSTRAINT(0x3c, (0xf|(1ULL<<33))), /* UNHALTED_CORE_CYCLES */ 61 + FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ 62 + FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ 63 + /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */ 71 64 INTEL_EVENT_CONSTRAINT(0x51, 0x3), /* L1D */ 72 65 INTEL_EVENT_CONSTRAINT(0x60, 0x1), /* OFFCORE_REQUESTS_OUTSTANDING */ 73 66 INTEL_EVENT_CONSTRAINT(0x63, 0x3), /* CACHE_LOCK_CYCLES */ ··· 77 68 78 69 static struct event_constraint intel_gen_event_constraints[] = 79 70 { 80 - FIXED_EVENT_CONSTRAINT(0xc0, (0x3|(1ULL<<32))), /* INSTRUCTIONS_RETIRED */ 81 - FIXED_EVENT_CONSTRAINT(0x3c, (0x3|(1ULL<<33))), /* UNHALTED_CORE_CYCLES */ 71 + FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ 72 + FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ 73 + /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */ 82 74 EVENT_CONSTRAINT_END 83 75 }; 84 76 ··· 590 580 591 581 ds->bts_index = ds->bts_buffer_base; 592 582 583 + perf_sample_data_init(&data, 0); 593 584 594 585 data.period = event->hw.last_period; 595 - data.addr = 0; 596 - data.raw = NULL; 597 586 regs.ip = 0; 598 587 599 588 /* ··· 741 732 int bit, loops; 742 733 u64 ack, status; 743 734 744 - data.addr = 0; 745 - data.raw = NULL; 735 + perf_sample_data_init(&data, 0); 746 736 747 737 cpuc = &__get_cpu_var(cpu_hw_events); 748 738 ··· 943 935 x86_pmu.event_constraints = intel_nehalem_event_constraints; 944 936 pr_cont("Nehalem/Corei7 events, "); 945 937 break; 946 - case 28: 938 + case 28: /* Atom */ 947 939 memcpy(hw_cache_event_ids, atom_hw_cache_event_ids, 948 940 sizeof(hw_cache_event_ids)); 949 941 ··· 959 951 x86_pmu.event_constraints = intel_westmere_event_constraints; 960 952 pr_cont("Westmere events, "); 961 953 break; 954 + 962 955 default: 963 956 /* 964 957 * default constraints for v2 and up
+4 -4
arch/x86/kernel/cpu/perf_event_p6.c
··· 62 62 63 63 /* p6 only has one enable register */ 64 64 rdmsrl(MSR_P6_EVNTSEL0, val); 65 - val &= ~ARCH_PERFMON_EVENTSEL0_ENABLE; 65 + val &= ~ARCH_PERFMON_EVENTSEL_ENABLE; 66 66 wrmsrl(MSR_P6_EVNTSEL0, val); 67 67 } 68 68 ··· 72 72 73 73 /* p6 only has one enable register */ 74 74 rdmsrl(MSR_P6_EVNTSEL0, val); 75 - val |= ARCH_PERFMON_EVENTSEL0_ENABLE; 75 + val |= ARCH_PERFMON_EVENTSEL_ENABLE; 76 76 wrmsrl(MSR_P6_EVNTSEL0, val); 77 77 } 78 78 ··· 83 83 u64 val = P6_NOP_EVENT; 84 84 85 85 if (cpuc->enabled) 86 - val |= ARCH_PERFMON_EVENTSEL0_ENABLE; 86 + val |= ARCH_PERFMON_EVENTSEL_ENABLE; 87 87 88 88 (void)checking_wrmsrl(hwc->config_base + idx, val); 89 89 } ··· 95 95 96 96 val = hwc->config; 97 97 if (cpuc->enabled) 98 - val |= ARCH_PERFMON_EVENTSEL0_ENABLE; 98 + val |= ARCH_PERFMON_EVENTSEL_ENABLE; 99 99 100 100 (void)checking_wrmsrl(hwc->config_base + idx, val); 101 101 }
+1 -1
arch/x86/kernel/cpu/perfctr-watchdog.c
··· 680 680 cpu_nmi_set_wd_enabled(); 681 681 682 682 apic_write(APIC_LVTPC, APIC_DM_NMI); 683 - evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE; 683 + evntsel |= ARCH_PERFMON_EVENTSEL_ENABLE; 684 684 wrmsr(evntsel_msr, evntsel, 0); 685 685 intel_arch_wd_ops.checkbit = 1ULL << (eax.split.bit_width - 1); 686 686 return 1;
+8 -2
arch/x86/kernel/dumpstack_64.c
··· 120 120 { 121 121 #ifdef CONFIG_FRAME_POINTER 122 122 struct stack_frame *frame = (struct stack_frame *)bp; 123 + unsigned long next; 123 124 124 - if (!in_irq_stack(stack, irq_stack, irq_stack_end)) 125 - return (unsigned long)frame->next_frame; 125 + if (!in_irq_stack(stack, irq_stack, irq_stack_end)) { 126 + if (!probe_kernel_address(&frame->next_frame, next)) 127 + return next; 128 + else 129 + WARN_ONCE(1, "Perf: bad frame pointer = %p in " 130 + "callchain\n", &frame->next_frame); 131 + } 126 132 #endif 127 133 return bp; 128 134 }
-12
arch/x86/kernel/hw_breakpoint.c
··· 344 344 } 345 345 346 346 /* 347 - * For kernel-addresses, either the address or symbol name can be 348 - * specified. 349 - */ 350 - if (info->name) 351 - info->address = (unsigned long) 352 - kallsyms_lookup_name(info->name); 353 - /* 354 347 * Check that the low-order bits of the address are appropriate 355 348 * for the alignment implied by len. 356 349 */ ··· 525 532 } 526 533 527 534 void hw_breakpoint_pmu_read(struct perf_event *bp) 528 - { 529 - /* TODO */ 530 - } 531 - 532 - void hw_breakpoint_pmu_unthrottle(struct perf_event *bp) 533 535 { 534 536 /* TODO */ 535 537 }
+6 -17
arch/x86/oprofile/op_model_amd.c
··· 46 46 47 47 static unsigned long reset_value[NUM_VIRT_COUNTERS]; 48 48 49 - /* IbsFetchCtl bits/masks */ 50 - #define IBS_FETCH_RAND_EN (1ULL<<57) 51 - #define IBS_FETCH_VAL (1ULL<<49) 52 - #define IBS_FETCH_ENABLE (1ULL<<48) 53 - #define IBS_FETCH_CNT_MASK 0xFFFF0000ULL 54 - 55 - /* IbsOpCtl bits */ 56 - #define IBS_OP_CNT_CTL (1ULL<<19) 57 - #define IBS_OP_VAL (1ULL<<18) 58 - #define IBS_OP_ENABLE (1ULL<<17) 59 - 60 49 #define IBS_FETCH_SIZE 6 61 50 #define IBS_OP_SIZE 12 62 51 ··· 171 182 continue; 172 183 } 173 184 rdmsrl(msrs->controls[i].addr, val); 174 - if (val & ARCH_PERFMON_EVENTSEL0_ENABLE) 185 + if (val & ARCH_PERFMON_EVENTSEL_ENABLE) 175 186 op_x86_warn_in_use(i); 176 187 val &= model->reserved; 177 188 wrmsrl(msrs->controls[i].addr, val); ··· 279 290 oprofile_write_commit(&entry); 280 291 281 292 /* reenable the IRQ */ 282 - ctl &= ~(IBS_FETCH_VAL | IBS_FETCH_CNT_MASK); 293 + ctl &= ~(IBS_FETCH_VAL | IBS_FETCH_CNT); 283 294 ctl |= IBS_FETCH_ENABLE; 284 295 wrmsrl(MSR_AMD64_IBSFETCHCTL, ctl); 285 296 } ··· 319 330 return; 320 331 321 332 if (ibs_config.fetch_enabled) { 322 - val = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF; 333 + val = (ibs_config.max_cnt_fetch >> 4) & IBS_FETCH_MAX_CNT; 323 334 val |= ibs_config.rand_en ? IBS_FETCH_RAND_EN : 0; 324 335 val |= IBS_FETCH_ENABLE; 325 336 wrmsrl(MSR_AMD64_IBSFETCHCTL, val); ··· 341 352 * avoid underflows. 342 353 */ 343 354 ibs_op_ctl = min(ibs_op_ctl + IBS_RANDOM_MAXCNT_OFFSET, 344 - 0xFFFFULL); 355 + IBS_OP_MAX_CNT); 345 356 } 346 357 if (ibs_caps & IBS_CAPS_OPCNT && ibs_config.dispatched_ops) 347 358 ibs_op_ctl |= IBS_OP_CNT_CTL; ··· 398 409 if (!reset_value[op_x86_phys_to_virt(i)]) 399 410 continue; 400 411 rdmsrl(msrs->controls[i].addr, val); 401 - val |= ARCH_PERFMON_EVENTSEL0_ENABLE; 412 + val |= ARCH_PERFMON_EVENTSEL_ENABLE; 402 413 wrmsrl(msrs->controls[i].addr, val); 403 414 } 404 415 ··· 418 429 if (!reset_value[op_x86_phys_to_virt(i)]) 419 430 continue; 420 431 rdmsrl(msrs->controls[i].addr, val); 421 - val &= ~ARCH_PERFMON_EVENTSEL0_ENABLE; 432 + val &= ~ARCH_PERFMON_EVENTSEL_ENABLE; 422 433 wrmsrl(msrs->controls[i].addr, val); 423 434 } 424 435
+3 -3
arch/x86/oprofile/op_model_ppro.c
··· 88 88 continue; 89 89 } 90 90 rdmsrl(msrs->controls[i].addr, val); 91 - if (val & ARCH_PERFMON_EVENTSEL0_ENABLE) 91 + if (val & ARCH_PERFMON_EVENTSEL_ENABLE) 92 92 op_x86_warn_in_use(i); 93 93 val &= model->reserved; 94 94 wrmsrl(msrs->controls[i].addr, val); ··· 166 166 for (i = 0; i < num_counters; ++i) { 167 167 if (reset_value[i]) { 168 168 rdmsrl(msrs->controls[i].addr, val); 169 - val |= ARCH_PERFMON_EVENTSEL0_ENABLE; 169 + val |= ARCH_PERFMON_EVENTSEL_ENABLE; 170 170 wrmsrl(msrs->controls[i].addr, val); 171 171 } 172 172 } ··· 184 184 if (!reset_value[i]) 185 185 continue; 186 186 rdmsrl(msrs->controls[i].addr, val); 187 - val &= ~ARCH_PERFMON_EVENTSEL0_ENABLE; 187 + val &= ~ARCH_PERFMON_EVENTSEL_ENABLE; 188 188 wrmsrl(msrs->controls[i].addr, val); 189 189 } 190 190 }
+4 -4
include/linux/hw_breakpoint.h
··· 66 66 perf_overflow_handler_t triggered, 67 67 int cpu); 68 68 69 - extern struct perf_event ** 69 + extern struct perf_event * __percpu * 70 70 register_wide_hw_breakpoint(struct perf_event_attr *attr, 71 71 perf_overflow_handler_t triggered); 72 72 73 73 extern int register_perf_hw_breakpoint(struct perf_event *bp); 74 74 extern int __register_perf_hw_breakpoint(struct perf_event *bp); 75 75 extern void unregister_hw_breakpoint(struct perf_event *bp); 76 - extern void unregister_wide_hw_breakpoint(struct perf_event **cpu_events); 76 + extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events); 77 77 78 78 extern int dbg_reserve_bp_slot(struct perf_event *bp); 79 79 extern int dbg_release_bp_slot(struct perf_event *bp); ··· 100 100 register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr, 101 101 perf_overflow_handler_t triggered, 102 102 int cpu) { return NULL; } 103 - static inline struct perf_event ** 103 + static inline struct perf_event * __percpu * 104 104 register_wide_hw_breakpoint(struct perf_event_attr *attr, 105 105 perf_overflow_handler_t triggered) { return NULL; } 106 106 static inline int ··· 109 109 __register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } 110 110 static inline void unregister_hw_breakpoint(struct perf_event *bp) { } 111 111 static inline void 112 - unregister_wide_hw_breakpoint(struct perf_event **cpu_events) { } 112 + unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { } 113 113 static inline int 114 114 reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; } 115 115 static inline void release_bp_slot(struct perf_event *bp) { }
+24 -3
include/linux/perf_event.h
··· 487 487 struct hrtimer hrtimer; 488 488 }; 489 489 #ifdef CONFIG_HAVE_HW_BREAKPOINT 490 - union { /* breakpoint */ 491 - struct arch_hw_breakpoint info; 492 - }; 490 + /* breakpoint */ 491 + struct arch_hw_breakpoint info; 493 492 #endif 494 493 }; 495 494 atomic64_t prev_count; ··· 801 802 struct perf_raw_record *raw; 802 803 }; 803 804 805 + static inline 806 + void perf_sample_data_init(struct perf_sample_data *data, u64 addr) 807 + { 808 + data->addr = addr; 809 + data->raw = NULL; 810 + } 811 + 804 812 extern void perf_output_sample(struct perf_output_handle *handle, 805 813 struct perf_event_header *header, 806 814 struct perf_sample_data *data, ··· 863 857 extern int sysctl_perf_event_paranoid; 864 858 extern int sysctl_perf_event_mlock; 865 859 extern int sysctl_perf_event_sample_rate; 860 + 861 + static inline bool perf_paranoid_tracepoint_raw(void) 862 + { 863 + return sysctl_perf_event_paranoid > -1; 864 + } 865 + 866 + static inline bool perf_paranoid_cpu(void) 867 + { 868 + return sysctl_perf_event_paranoid > 0; 869 + } 870 + 871 + static inline bool perf_paranoid_kernel(void) 872 + { 873 + return sysctl_perf_event_paranoid > 1; 874 + } 866 875 867 876 extern void perf_event_init(void); 868 877 extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, int entry_size);
+5 -6
kernel/hw_breakpoint.c
··· 413 413 * 414 414 * @return a set of per_cpu pointers to perf events 415 415 */ 416 - struct perf_event ** 416 + struct perf_event * __percpu * 417 417 register_wide_hw_breakpoint(struct perf_event_attr *attr, 418 418 perf_overflow_handler_t triggered) 419 419 { 420 - struct perf_event **cpu_events, **pevent, *bp; 420 + struct perf_event * __percpu *cpu_events, **pevent, *bp; 421 421 long err; 422 422 int cpu; 423 423 424 424 cpu_events = alloc_percpu(typeof(*cpu_events)); 425 425 if (!cpu_events) 426 - return ERR_PTR(-ENOMEM); 426 + return (void __percpu __force *)ERR_PTR(-ENOMEM); 427 427 428 428 get_online_cpus(); 429 429 for_each_online_cpu(cpu) { ··· 451 451 put_online_cpus(); 452 452 453 453 free_percpu(cpu_events); 454 - return ERR_PTR(err); 454 + return (void __percpu __force *)ERR_PTR(err); 455 455 } 456 456 EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint); 457 457 ··· 459 459 * unregister_wide_hw_breakpoint - unregister a wide breakpoint in the kernel 460 460 * @cpu_events: the per cpu set of events to unregister 461 461 */ 462 - void unregister_wide_hw_breakpoint(struct perf_event **cpu_events) 462 + void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) 463 463 { 464 464 int cpu; 465 465 struct perf_event **pevent; ··· 489 489 .enable = arch_install_hw_breakpoint, 490 490 .disable = arch_uninstall_hw_breakpoint, 491 491 .read = hw_breakpoint_pmu_read, 492 - .unthrottle = hw_breakpoint_pmu_unthrottle 493 492 };
+8 -28
kernel/perf_event.c
··· 56 56 */ 57 57 int sysctl_perf_event_paranoid __read_mostly = 1; 58 58 59 - static inline bool perf_paranoid_tracepoint_raw(void) 60 - { 61 - return sysctl_perf_event_paranoid > -1; 62 - } 63 - 64 - static inline bool perf_paranoid_cpu(void) 65 - { 66 - return sysctl_perf_event_paranoid > 0; 67 - } 68 - 69 - static inline bool perf_paranoid_kernel(void) 70 - { 71 - return sysctl_perf_event_paranoid > 1; 72 - } 73 - 74 59 int sysctl_perf_event_mlock __read_mostly = 512; /* 'free' kb per user */ 75 60 76 61 /* ··· 4108 4123 if (rctx < 0) 4109 4124 return; 4110 4125 4111 - data.addr = addr; 4112 - data.raw = NULL; 4126 + perf_sample_data_init(&data, addr); 4113 4127 4114 4128 do_perf_sw_event(PERF_TYPE_SOFTWARE, event_id, nr, nmi, &data, regs); 4115 4129 ··· 4153 4169 struct perf_event *event; 4154 4170 u64 period; 4155 4171 4156 - event = container_of(hrtimer, struct perf_event, hw.hrtimer); 4172 + event = container_of(hrtimer, struct perf_event, hw.hrtimer); 4157 4173 event->pmu->read(event); 4158 4174 4159 - data.addr = 0; 4160 - data.raw = NULL; 4175 + perf_sample_data_init(&data, 0); 4161 4176 data.period = event->hw.last_period; 4162 4177 regs = get_irq_regs(); 4163 4178 /* ··· 4320 4337 void perf_tp_event(int event_id, u64 addr, u64 count, void *record, 4321 4338 int entry_size) 4322 4339 { 4340 + struct pt_regs *regs = get_irq_regs(); 4341 + struct perf_sample_data data; 4323 4342 struct perf_raw_record raw = { 4324 4343 .size = entry_size, 4325 4344 .data = record, 4326 4345 }; 4327 4346 4328 - struct perf_sample_data data = { 4329 - .addr = addr, 4330 - .raw = &raw, 4331 - }; 4332 - 4333 - struct pt_regs *regs = get_irq_regs(); 4347 + perf_sample_data_init(&data, addr); 4348 + data.raw = &raw; 4334 4349 4335 4350 if (!regs) 4336 4351 regs = task_pt_regs(current); ··· 4444 4463 struct perf_sample_data sample; 4445 4464 struct pt_regs *regs = data; 4446 4465 4447 - sample.raw = NULL; 4448 - sample.addr = bp->attr.bp_addr; 4466 + perf_sample_data_init(&sample, bp->attr.bp_addr); 4449 4467 4450 4468 if (!perf_exclude_event(bp, regs)) 4451 4469 perf_swevent_add(bp, 1, 1, &sample, regs);
+8
lib/Kconfig.debug
··· 532 532 533 533 For more details, see Documentation/lockstat.txt 534 534 535 + This also enables lock events required by "perf lock", 536 + subcommand of perf. 537 + If you want to use "perf lock", you also need to turn on 538 + CONFIG_EVENT_TRACING. 539 + 540 + CONFIG_LOCK_STAT defines "contended" and "acquired" lock events. 541 + (CONFIG_LOCKDEP defines "acquire" and "release" events.) 542 + 535 543 config DEBUG_LOCKDEP 536 544 bool "Lock dependency engine debugging" 537 545 depends on DEBUG_KERNEL && LOCKDEP
+3 -3
samples/hw_breakpoint/data_breakpoint.c
··· 34 34 #include <linux/perf_event.h> 35 35 #include <linux/hw_breakpoint.h> 36 36 37 - struct perf_event **sample_hbp; 37 + struct perf_event * __percpu *sample_hbp; 38 38 39 39 static char ksym_name[KSYM_NAME_LEN] = "pid_max"; 40 40 module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO); ··· 61 61 attr.bp_type = HW_BREAKPOINT_W | HW_BREAKPOINT_R; 62 62 63 63 sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler); 64 - if (IS_ERR(sample_hbp)) { 65 - ret = PTR_ERR(sample_hbp); 64 + if (IS_ERR((void __force *)sample_hbp)) { 65 + ret = PTR_ERR((void __force *)sample_hbp); 66 66 goto fail; 67 67 } 68 68
+29
tools/perf/Documentation/perf-lock.txt
··· 1 + perf-lock(1) 2 + ============ 3 + 4 + NAME 5 + ---- 6 + perf-lock - Analyze lock events 7 + 8 + SYNOPSIS 9 + -------- 10 + [verse] 11 + 'perf lock' {record|report|trace} 12 + 13 + DESCRIPTION 14 + ----------- 15 + You can analyze various lock behaviours 16 + and statistics with this 'perf lock' command. 17 + 18 + 'perf lock record <command>' records lock events 19 + between start and end <command>. And this command 20 + produces the file "perf.data" which contains tracing 21 + results of lock events. 22 + 23 + 'perf lock trace' shows raw lock events. 24 + 25 + 'perf lock report' reports statistical data. 26 + 27 + SEE ALSO 28 + -------- 29 + linkperf:perf[1]
+146 -2
tools/perf/builtin-lock.c
··· 460 460 process_lock_release_event(data, event, cpu, timestamp, thread); 461 461 } 462 462 463 + struct raw_event_queue { 464 + u64 timestamp; 465 + int cpu; 466 + void *data; 467 + struct thread *thread; 468 + struct list_head list; 469 + }; 470 + 471 + static LIST_HEAD(raw_event_head); 472 + 473 + #define FLUSH_PERIOD (5 * NSEC_PER_SEC) 474 + 475 + static u64 flush_limit = ULLONG_MAX; 476 + static u64 last_flush = 0; 477 + struct raw_event_queue *last_inserted; 478 + 479 + static void flush_raw_event_queue(u64 limit) 480 + { 481 + struct raw_event_queue *tmp, *iter; 482 + 483 + list_for_each_entry_safe(iter, tmp, &raw_event_head, list) { 484 + if (iter->timestamp > limit) 485 + return; 486 + 487 + if (iter == last_inserted) 488 + last_inserted = NULL; 489 + 490 + process_raw_event(iter->data, iter->cpu, iter->timestamp, 491 + iter->thread); 492 + 493 + last_flush = iter->timestamp; 494 + list_del(&iter->list); 495 + free(iter->data); 496 + free(iter); 497 + } 498 + } 499 + 500 + static void __queue_raw_event_end(struct raw_event_queue *new) 501 + { 502 + struct raw_event_queue *iter; 503 + 504 + list_for_each_entry_reverse(iter, &raw_event_head, list) { 505 + if (iter->timestamp < new->timestamp) { 506 + list_add(&new->list, &iter->list); 507 + return; 508 + } 509 + } 510 + 511 + list_add(&new->list, &raw_event_head); 512 + } 513 + 514 + static void __queue_raw_event_before(struct raw_event_queue *new, 515 + struct raw_event_queue *iter) 516 + { 517 + list_for_each_entry_continue_reverse(iter, &raw_event_head, list) { 518 + if (iter->timestamp < new->timestamp) { 519 + list_add(&new->list, &iter->list); 520 + return; 521 + } 522 + } 523 + 524 + list_add(&new->list, &raw_event_head); 525 + } 526 + 527 + static void __queue_raw_event_after(struct raw_event_queue *new, 528 + struct raw_event_queue *iter) 529 + { 530 + list_for_each_entry_continue(iter, &raw_event_head, list) { 531 + if (iter->timestamp > new->timestamp) { 532 + list_add_tail(&new->list, &iter->list); 533 + return; 534 + } 535 + } 536 + list_add_tail(&new->list, &raw_event_head); 537 + } 538 + 539 + /* The queue is ordered by time */ 540 + static void __queue_raw_event(struct raw_event_queue *new) 541 + { 542 + if (!last_inserted) { 543 + __queue_raw_event_end(new); 544 + return; 545 + } 546 + 547 + /* 548 + * Most of the time the current event has a timestamp 549 + * very close to the last event inserted, unless we just switched 550 + * to another event buffer. Having a sorting based on a list and 551 + * on the last inserted event that is close to the current one is 552 + * probably more efficient than an rbtree based sorting. 553 + */ 554 + if (last_inserted->timestamp >= new->timestamp) 555 + __queue_raw_event_before(new, last_inserted); 556 + else 557 + __queue_raw_event_after(new, last_inserted); 558 + } 559 + 560 + static void queue_raw_event(void *data, int raw_size, int cpu, 561 + u64 timestamp, struct thread *thread) 562 + { 563 + struct raw_event_queue *new; 564 + 565 + if (flush_limit == ULLONG_MAX) 566 + flush_limit = timestamp + FLUSH_PERIOD; 567 + 568 + if (timestamp < last_flush) { 569 + printf("Warning: Timestamp below last timeslice flush\n"); 570 + return; 571 + } 572 + 573 + new = malloc(sizeof(*new)); 574 + if (!new) 575 + die("Not enough memory\n"); 576 + 577 + new->timestamp = timestamp; 578 + new->cpu = cpu; 579 + new->thread = thread; 580 + 581 + new->data = malloc(raw_size); 582 + if (!new->data) 583 + die("Not enough memory\n"); 584 + 585 + memcpy(new->data, data, raw_size); 586 + 587 + __queue_raw_event(new); 588 + last_inserted = new; 589 + 590 + /* 591 + * We want to have a slice of events covering 2 * FLUSH_PERIOD 592 + * If FLUSH_PERIOD is big enough, it ensures every events that occured 593 + * in the first half of the timeslice have all been buffered and there 594 + * are none remaining (we need that because of the weakly ordered 595 + * event recording we have). Then once we reach the 2 * FLUSH_PERIOD 596 + * timeslice, we flush the first half to be gentle with the memory 597 + * (the second half can still get new events in the middle, so wait 598 + * another period to flush it) 599 + */ 600 + if (new->timestamp > flush_limit && 601 + new->timestamp - flush_limit > FLUSH_PERIOD) { 602 + flush_limit += FLUSH_PERIOD; 603 + flush_raw_event_queue(flush_limit); 604 + } 605 + } 606 + 463 607 static int process_sample_event(event_t *event, struct perf_session *session) 464 608 { 465 609 struct thread *thread; ··· 624 480 if (profile_cpu != -1 && profile_cpu != (int) data.cpu) 625 481 return 0; 626 482 627 - process_raw_event(data.raw_data, data.cpu, data.time, thread); 483 + queue_raw_event(data.raw_data, data.raw_size, data.cpu, data.time, thread); 628 484 629 485 return 0; 630 486 } ··· 720 576 setup_pager(); 721 577 select_key(); 722 578 read_events(); 579 + flush_raw_event_queue(ULLONG_MAX); 723 580 sort_result(); 724 581 print_result(); 725 582 } ··· 753 608 "record", 754 609 "-a", 755 610 "-R", 756 - "-M", 757 611 "-f", 758 612 "-m", "1024", 759 613 "-c", "1",
+2 -2
tools/perf/builtin-trace.c
··· 573 573 574 574 if (symbol__init() < 0) 575 575 return -1; 576 - setup_pager(); 576 + if (!script_name) 577 + setup_pager(); 577 578 578 579 session = perf_session__new(input_name, O_RDONLY, 0); 579 580 if (session == NULL) ··· 609 608 return -1; 610 609 } 611 610 612 - perf_header__read(&session->header, input); 613 611 err = scripting_ops->generate_script("perf-trace"); 614 612 goto out; 615 613 }
+1
tools/perf/command-list.txt
··· 18 18 perf-trace mainporcelain common 19 19 perf-probe mainporcelain common 20 20 perf-kmem mainporcelain common 21 + perf-lock mainporcelain common
+2 -1
tools/perf/perf-archive.sh
··· 9 9 10 10 DEBUGDIR=~/.debug/ 11 11 BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX) 12 + NOBUILDID=0000000000000000000000000000000000000000 12 13 13 - perf buildid-list -i $PERF_DATA --with-hits > $BUILDIDS 14 + perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS 14 15 if [ ! -s $BUILDIDS ] ; then 15 16 echo "perf archive: no build-ids found" 16 17 rm -f $BUILDIDS
+1 -3
tools/perf/perf.h
··· 65 65 * Use the __kuser_memory_barrier helper in the CPU helper page. See 66 66 * arch/arm/kernel/entry-armv.S in the kernel source for details. 67 67 */ 68 - #define rmb() asm volatile("mov r0, #0xffff0fff; mov lr, pc;" \ 69 - "sub pc, r0, #95" ::: "r0", "lr", "cc", \ 70 - "memory") 68 + #define rmb() ((void(*)(void))0xffff0fa0)() 71 69 #define cpu_relax() asm volatile("":::"memory") 72 70 #endif 73 71
+1 -1
tools/perf/util/probe-event.c
··· 508 508 struct str_node *ent; 509 509 510 510 setup_pager(); 511 - 512 511 memset(&pp, 0, sizeof(pp)); 512 + 513 513 fd = open_kprobe_events(O_RDONLY, 0); 514 514 rawlist = get_trace_kprobe_event_rawlist(fd); 515 515 close(fd);