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

Configure Feed

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

perf/x86: Use macros to replace magic numbers in attr_rdpmc

Replace magic numbers in attr_rdpmc with macros to improve readability
and make their meanings clearer for users.

Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260114011750.350569-7-dapeng1.mi@linux.intel.com

authored by

Dapeng Mi and committed by
Peter Zijlstra
8c74e4e3 c847a208

+12 -4
+4 -3
arch/x86/events/core.c
··· 2163 2163 2164 2164 pr_cont("%s PMU driver.\n", x86_pmu.name); 2165 2165 2166 - x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */ 2166 + /* enable userspace RDPMC usage by default */ 2167 + x86_pmu.attr_rdpmc = X86_USER_RDPMC_CONDITIONAL_ENABLE; 2167 2168 2168 2169 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next) 2169 2170 quirk->func(); ··· 2644 2643 */ 2645 2644 if (val == 0) 2646 2645 static_branch_inc(&rdpmc_never_available_key); 2647 - else if (x86_pmu.attr_rdpmc == 0) 2646 + else if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_NEVER_ENABLE) 2648 2647 static_branch_dec(&rdpmc_never_available_key); 2649 2648 2650 2649 if (val == 2) 2651 2650 static_branch_inc(&rdpmc_always_available_key); 2652 - else if (x86_pmu.attr_rdpmc == 2) 2651 + else if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_ALWAYS_ENABLE) 2653 2652 static_branch_dec(&rdpmc_always_available_key); 2654 2653 2655 2654 on_each_cpu(cr4_update_pce, NULL, 1);
+1 -1
arch/x86/events/intel/p6.c
··· 243 243 */ 244 244 pr_warn("Userspace RDPMC support disabled due to a CPU erratum\n"); 245 245 x86_pmu.attr_rdpmc_broken = 1; 246 - x86_pmu.attr_rdpmc = 0; 246 + x86_pmu.attr_rdpmc = X86_USER_RDPMC_NEVER_ENABLE; 247 247 } 248 248 } 249 249
+7
arch/x86/events/perf_event.h
··· 187 187 (1ULL << PERF_REG_X86_R14) | \ 188 188 (1ULL << PERF_REG_X86_R15)) 189 189 190 + /* user space rdpmc control values */ 191 + enum { 192 + X86_USER_RDPMC_NEVER_ENABLE = 0, 193 + X86_USER_RDPMC_CONDITIONAL_ENABLE = 1, 194 + X86_USER_RDPMC_ALWAYS_ENABLE = 2, 195 + }; 196 + 190 197 /* 191 198 * Per register state. 192 199 */