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

i386: do not BUG_ON() when MSR is unknown

Here is a small patch to change the behavior of the PMU msr allocator
to avoid BUG_ON() when the MSR is unknwon. Instead, it now returns
ok, which means "I do not manage". The current allocator is not
yet managing the full set of PMU registers (e.g., GLOBAL_* on Core 2).

[watchdog] do not BUG_ON() in the MSR allocator if MSR is unknown, return ok
instead

Signed-off-by: Stephane Eranian <eranian@hpl.hp.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Stephane Eranian and committed by
Thomas Gleixner
124d395f 71b31233

+12 -4
+12 -4
arch/x86/kernel/cpu/perfctr-watchdog.c
··· 120 120 unsigned int counter; 121 121 122 122 counter = nmi_perfctr_msr_to_bit(msr); 123 - BUG_ON(counter > NMI_MAX_COUNTER_BITS); 123 + /* register not managed by the allocator? */ 124 + if (counter > NMI_MAX_COUNTER_BITS) 125 + return 1; 124 126 125 127 if (!test_and_set_bit(counter, perfctr_nmi_owner)) 126 128 return 1; ··· 134 132 unsigned int counter; 135 133 136 134 counter = nmi_perfctr_msr_to_bit(msr); 137 - BUG_ON(counter > NMI_MAX_COUNTER_BITS); 135 + /* register not managed by the allocator? */ 136 + if (counter > NMI_MAX_COUNTER_BITS) 137 + return; 138 138 139 139 clear_bit(counter, perfctr_nmi_owner); 140 140 } ··· 146 142 unsigned int counter; 147 143 148 144 counter = nmi_evntsel_msr_to_bit(msr); 149 - BUG_ON(counter > NMI_MAX_COUNTER_BITS); 145 + /* register not managed by the allocator? */ 146 + if (counter > NMI_MAX_COUNTER_BITS) 147 + return 1; 150 148 151 149 if (!test_and_set_bit(counter, evntsel_nmi_owner)) 152 150 return 1; ··· 160 154 unsigned int counter; 161 155 162 156 counter = nmi_evntsel_msr_to_bit(msr); 163 - BUG_ON(counter > NMI_MAX_COUNTER_BITS); 157 + /* register not managed by the allocator? */ 158 + if (counter > NMI_MAX_COUNTER_BITS) 159 + return; 164 160 165 161 clear_bit(counter, evntsel_nmi_owner); 166 162 }