Re: [PATCH 0/3] perf_events: update extra shared registers management (v2)

From: Stephane Eranian
Date: Mon May 23 2011 - 06:58:31 EST


On Mon, May 23, 2011 at 11:36 AM, Stephane Eranian <eranian@xxxxxxxxxx> wrote:
> On Mon, May 23, 2011 at 11:32 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>> On Mon, 2011-05-23 at 11:11 +0200, Peter Zijlstra wrote:
>>> + Â Â Â if (event->hw.extra_reg.idx == EXTRA_REG_RSP_0) {
>>> + Â Â Â Â Â Â Â event->attr.config = 0x01bb;
>>> + Â Â Â Â Â Â Â event->hw.extra_reg.idx = EXTRA_REG_RSP_1;
>>> + Â Â Â Â Â Â Â event->hw.extra_reg.msr = MSR_OFFCORE_RSP_1;
>>> + Â Â Â } else if (event->hw.extra_reg.idx == EXTRA_REG_RSP_1) {
>>> + Â Â Â Â Â Â Â event->attr.config = 0x01b7;
>>> + Â Â Â Â Â Â Â event->hw.extra_reg.idx = EXTRA_REG_RSP_0;
>>> + Â Â Â Â Â Â Â event->hw.extra_reg.msr = MSR_OFFCORE_RSP_0;
>>> + Â Â Â }
>>
>> clearly I meant to write:
>>
>> event->hw.config &= ~X86_RAW_EVENT_MASK;

Not quite, you want INTEL_ARCH_EVENT_MASK instead
because you only want to modify umask+event code.

There is a major issue as it stands, though. You can
get into an infinite loop bouncing between RSP_0 and RSP_1
in case there is no solution in the group, i.e., you have 3 values
for the extra MSR. I think you need to count the number of times
you've called intel_try_alt_er() with success or maintain some sort
of bitmask of possible alternate choices and when you exhaust that,
you simply fail.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/