Subject: Re: [Cbe-oss-dev] [PATCH] Updated: Reworked Cell OProfile: SPU mutex lock fix

From: Jochen Roth <[email-masked]>
Date: Thu, 08 May 2008 09:50:25 +0200

Carl Love wrote:

>>  > +void oprofile_add_value(unsigned long value, int cpu) {
>>  > +	struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[cpu];
>>
>> Shouldn't it be
>> 	struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu);
> 
> No, I don't think so.  Take a look at the other functions in
> drivers/oprofile/cpu_buffer.c.  For example oprofile_add_trace().  You
> will see that the cpu_buffer is not accessed using the per_cpu
> construct.  Not sure why the compiler would complain about the
> oprofile_add_value() function but not one of the other functions like
> oprofile_add_trace().

Well, actually the other functions like oprofile_add_trace are using the 
&__get_cpu_var(cpu_buffer) construct.

> What was the compiler error that you saw?

Here they are:
/home/jroth/kernel/spufs/arch/powerpc/oprofile/../../../drivers/oprofile/cpu_buffer.c: 
In function ‘oprofile_add_value’:
/home/jroth/kernel/spufs/arch/powerpc/oprofile/../../../drivers/oprofile/cpu_buffer.c:234: 
error: ‘cpu_buffer’ undeclared (first use in this function)

cpu_buffer is defined by the DEFINE_PER_CPU_SHARED_ALIGNED macro:
DEFINE_PER_CPU_SHARED_ALIGNED(struct oprofile_cpu_buffer, cpu_buffer);

> I will try getting Jeremy's kernel and applying the patch there to see
> if it works.

You'll find his tree at 
git://git.kernel.org/pub/scm/linux/kernel/git/jk/spufs.git