Re: [PATCH] perf_events: fix bug in AMD per-cpu initialization

From: Stephane Eranian
Date: Wed Mar 17 2010 - 20:33:42 EST


On Thu, Mar 18, 2010 at 12:47 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Wed, 2010-03-17 at 10:40 +0200, Stephane Eranian wrote:
>> Â Â Â On AMD processors, we need to allocate a data structure per Northbridge
>> Â Â Â to handle certain events.
>>
>> Â Â Â On CPU initialization, we need to query the Northbridge id and check
>> Â Â Â whether the structure is already allocated or not. We use the
>> Â Â Â amd_get_nb_id() function to request the Northbridge identification.
>>
>> Â Â Â The recent cleanup of the CPU online/offline initialization introduced
>> Â Â Â a bug. AMD cpu initialization is invoked on CPU_UP_PREPARE callback.
>> Â Â Â This is before the CPU Northbridge id is calculated. Therefore no
>> Â Â Â processor had a Northbridge structure allocated except the boot
>> Â Â Â processor. That was causing bogus NB event scheduling.
>>
>> Â Â Â This patch uses the CPU_ONLINE callback to initialize the AMD
>> Â Â Â Northbridge structure. This way amd_get_nb_id() returns valid
>> Â Â Â information.
>>
>> Â Â Â The x86_cpu_up() callback was added. Could not call it cpu_online
>> Â Â Â because of existing macro.
>>
>> Â Â Â Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>
>
>
> No, ONLINE is not exposed for a good reason, its always wrong.
>
> Use prepare to allocate data, and starting to initialize stuff on the
> cpu proper once its up. Online is after the cpu is up and running and we
> are already scheduling stuff on it so its too late to initialize things.
>
>
I can't because amd_get_nb_id() returns garbage for the CPU
when you call from CPU_STARTING. So looks like initialization
of cpu_llc_id needs to be moved way earlier. I don't want to have
to duplicate that code.
--
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/