Commit 1ff3d7d7 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Ingo Molnar

x86, perf: P4 PMU - fix counters management logic

Jaswinder reported this #GP:

 |
 | Message from syslogd@ht at May 14 09:39:32 ...
 | kernel:[  314.908612] EIP: [<c100ccca>]
 | x86_perf_event_set_period+0x19d/0x1b2 SS:ESP 0068:edac3d70
 |

Ming has narrowed it down to a comparision issue
between arguments with different sizes and
signs. As result event index reached a wrong
value which in turn led to a GP fault.

At the same time it was found that p4_next_cntr
has broken logic and should return the counter
index only if it was not yet borrowed for
another event.
Reported-by: default avatarJaswinder Singh Rajput <jaswinderlinux@gmail.com>
Reported-by: default avatarLin Ming <ming.m.lin@intel.com>
Bisected-by: default avatarLin Ming <ming.m.lin@intel.com>
Tested-by: default avatarJaswinder Singh Rajput <jaswinderlinux@gmail.com>
Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
CC: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20100514190815.GG13509@lenovo>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 5d2be7cb
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
struct p4_event_bind { struct p4_event_bind {
unsigned int opcode; /* Event code and ESCR selector */ unsigned int opcode; /* Event code and ESCR selector */
unsigned int escr_msr[2]; /* ESCR MSR for this event */ unsigned int escr_msr[2]; /* ESCR MSR for this event */
unsigned char cntr[2][P4_CNTR_LIMIT]; /* counter index (offset), -1 on abscence */ char cntr[2][P4_CNTR_LIMIT]; /* counter index (offset), -1 on abscence */
}; };
struct p4_cache_event_bind { struct p4_cache_event_bind {
...@@ -747,11 +747,11 @@ static int p4_get_escr_idx(unsigned int addr) ...@@ -747,11 +747,11 @@ static int p4_get_escr_idx(unsigned int addr)
static int p4_next_cntr(int thread, unsigned long *used_mask, static int p4_next_cntr(int thread, unsigned long *used_mask,
struct p4_event_bind *bind) struct p4_event_bind *bind)
{ {
int i = 0, j; int i, j;
for (i = 0; i < P4_CNTR_LIMIT; i++) { for (i = 0; i < P4_CNTR_LIMIT; i++) {
j = bind->cntr[thread][i++]; j = bind->cntr[thread][i];
if (j == -1 || !test_bit(j, used_mask)) if (j != -1 && !test_bit(j, used_mask))
return j; return j;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment