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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'perf-urgent-2020-08-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
"Misc fixes, an expansion of perf syscall access to CAP_PERFMON
privileged tools, plus a RAPL HW-enablement for Intel SPR platforms"

* tag 'perf-urgent-2020-08-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf/x86/rapl: Add support for Intel SPR platform
perf/x86/rapl: Support multiple RAPL unit quirks
perf/x86/rapl: Fix missing psys sysfs attributes
hw_breakpoint: Remove unused __register_perf_hw_breakpoint() declaration
kprobes: Remove show_registers() function prototype
perf/core: Take over CAP_SYS_PTRACE creds to CAP_PERFMON capability

+38 -15
+36 -10
arch/x86/events/rapl.c
··· 130 130 struct rapl_pmu *pmus[]; 131 131 }; 132 132 133 + enum rapl_unit_quirk { 134 + RAPL_UNIT_QUIRK_NONE, 135 + RAPL_UNIT_QUIRK_INTEL_HSW, 136 + RAPL_UNIT_QUIRK_INTEL_SPR, 137 + }; 138 + 133 139 struct rapl_model { 134 140 struct perf_msr *rapl_msrs; 135 141 unsigned long events; 136 142 unsigned int msr_power_unit; 137 - bool apply_quirk; 143 + enum rapl_unit_quirk unit_quirk; 138 144 }; 139 145 140 146 /* 1/2^hw_unit Joule */ ··· 618 612 for (i = 0; i < NR_RAPL_DOMAINS; i++) 619 613 rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; 620 614 615 + switch (rm->unit_quirk) { 621 616 /* 622 617 * DRAM domain on HSW server and KNL has fixed energy unit which can be 623 618 * different than the unit from power unit MSR. See 624 619 * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2 625 620 * of 2. Datasheet, September 2014, Reference Number: 330784-001 " 626 621 */ 627 - if (rm->apply_quirk) 622 + case RAPL_UNIT_QUIRK_INTEL_HSW: 628 623 rapl_hw_unit[PERF_RAPL_RAM] = 16; 624 + break; 625 + /* 626 + * SPR shares the same DRAM domain energy unit as HSW, plus it 627 + * also has a fixed energy unit for Psys domain. 628 + */ 629 + case RAPL_UNIT_QUIRK_INTEL_SPR: 630 + rapl_hw_unit[PERF_RAPL_RAM] = 16; 631 + rapl_hw_unit[PERF_RAPL_PSYS] = 0; 632 + break; 633 + default: 634 + break; 635 + } 636 + 629 637 630 638 /* 631 639 * Calculate the timer rate: ··· 685 665 &rapl_events_pkg_group, 686 666 &rapl_events_ram_group, 687 667 &rapl_events_gpu_group, 688 - &rapl_events_gpu_group, 668 + &rapl_events_psys_group, 689 669 NULL, 690 670 }; 691 671 ··· 718 698 .events = BIT(PERF_RAPL_PP0) | 719 699 BIT(PERF_RAPL_PKG) | 720 700 BIT(PERF_RAPL_PP1), 721 - .apply_quirk = false, 722 701 .msr_power_unit = MSR_RAPL_POWER_UNIT, 723 702 .rapl_msrs = intel_rapl_msrs, 724 703 }; ··· 726 707 .events = BIT(PERF_RAPL_PP0) | 727 708 BIT(PERF_RAPL_PKG) | 728 709 BIT(PERF_RAPL_RAM), 729 - .apply_quirk = false, 730 710 .msr_power_unit = MSR_RAPL_POWER_UNIT, 731 711 .rapl_msrs = intel_rapl_msrs, 732 712 }; ··· 735 717 BIT(PERF_RAPL_PKG) | 736 718 BIT(PERF_RAPL_RAM) | 737 719 BIT(PERF_RAPL_PP1), 738 - .apply_quirk = false, 739 720 .msr_power_unit = MSR_RAPL_POWER_UNIT, 740 721 .rapl_msrs = intel_rapl_msrs, 741 722 }; ··· 743 726 .events = BIT(PERF_RAPL_PP0) | 744 727 BIT(PERF_RAPL_PKG) | 745 728 BIT(PERF_RAPL_RAM), 746 - .apply_quirk = true, 729 + .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, 747 730 .msr_power_unit = MSR_RAPL_POWER_UNIT, 748 731 .rapl_msrs = intel_rapl_msrs, 749 732 }; ··· 751 734 static struct rapl_model model_knl = { 752 735 .events = BIT(PERF_RAPL_PKG) | 753 736 BIT(PERF_RAPL_RAM), 754 - .apply_quirk = true, 737 + .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, 755 738 .msr_power_unit = MSR_RAPL_POWER_UNIT, 756 739 .rapl_msrs = intel_rapl_msrs, 757 740 }; ··· 762 745 BIT(PERF_RAPL_RAM) | 763 746 BIT(PERF_RAPL_PP1) | 764 747 BIT(PERF_RAPL_PSYS), 765 - .apply_quirk = false, 748 + .msr_power_unit = MSR_RAPL_POWER_UNIT, 749 + .rapl_msrs = intel_rapl_msrs, 750 + }; 751 + 752 + static struct rapl_model model_spr = { 753 + .events = BIT(PERF_RAPL_PP0) | 754 + BIT(PERF_RAPL_PKG) | 755 + BIT(PERF_RAPL_RAM) | 756 + BIT(PERF_RAPL_PSYS), 757 + .unit_quirk = RAPL_UNIT_QUIRK_INTEL_SPR, 766 758 .msr_power_unit = MSR_RAPL_POWER_UNIT, 767 759 .rapl_msrs = intel_rapl_msrs, 768 760 }; 769 761 770 762 static struct rapl_model model_amd_fam17h = { 771 763 .events = BIT(PERF_RAPL_PKG), 772 - .apply_quirk = false, 773 764 .msr_power_unit = MSR_AMD_RAPL_POWER_UNIT, 774 765 .rapl_msrs = amd_rapl_msrs, 775 766 }; ··· 812 787 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &model_hsx), 813 788 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L, &model_skl), 814 789 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, &model_skl), 790 + X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &model_spr), 815 791 X86_MATCH_VENDOR_FAM(AMD, 0x17, &model_amd_fam17h), 816 792 X86_MATCH_VENDOR_FAM(HYGON, 0x18, &model_amd_fam17h), 817 793 {},
-3
include/linux/hw_breakpoint.h
··· 72 72 void *context); 73 73 74 74 extern int register_perf_hw_breakpoint(struct perf_event *bp); 75 - extern int __register_perf_hw_breakpoint(struct perf_event *bp); 76 75 extern void unregister_hw_breakpoint(struct perf_event *bp); 77 76 extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events); 78 77 ··· 118 119 void *context) { return NULL; } 119 120 static inline int 120 121 register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } 121 - static inline int 122 - __register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } 123 122 static inline void unregister_hw_breakpoint(struct perf_event *bp) { } 124 123 static inline void 125 124 unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
+2 -2
kernel/events/core.c
··· 11706 11706 goto err_task; 11707 11707 11708 11708 /* 11709 - * Reuse ptrace permission checks for now. 11709 + * Preserve ptrace permission check for backwards compatibility. 11710 11710 * 11711 11711 * We must hold exec_update_mutex across this and any potential 11712 11712 * perf_install_in_context() call for this new event to ··· 11714 11714 * perf_event_exit_task() that could imply). 11715 11715 */ 11716 11716 err = -EACCES; 11717 - if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) 11717 + if (!perfmon_capable() && !ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) 11718 11718 goto err_cred; 11719 11719 } 11720 11720