cpu_relax() usage in raid6algos.c

cpu_relax() usage in raid6algos.c

am 10.09.2010 03:55:12 von Drew

Hi,

I was going through the raid6 code in 2.6.35 and I came across an
empty function definition for cpu_relax() in include/linux/raid/pq.h
(line 135) that appears to be called in drivers/md/raid6algos.c (line
113). My C code skills are a bit rusty but I'm assuming the
cpu_relax() call in raid6algos.c uses the definition in pq.h.

If so, why is cpu_relax() in pq.h an empty function when there's
already a definition for cpu_relax() in
arch/x86/include/asm/processor.h?

Conversely, if the cpu_relax() function call in raid6algos.c uses the
definition in processor.h, why do we have a second definition in pq.h?

It strikes me that if the purpose of cpu_relax() is to signal the
kernel that we're not doing anything, why create our own empty
function when there's already one that is correct across all supported
architectures?

--
Drew

"Nothing in life is to be feared. It is only to be understood."
--Marie Curie
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: cpu_relax() usage in raid6algos.c

am 10.09.2010 04:49:02 von NeilBrown

On Thu, 9 Sep 2010 18:55:12 -0700
Drew wrote:

> Hi,
>
> I was going through the raid6 code in 2.6.35 and I came across an
> empty function definition for cpu_relax() in include/linux/raid/pq.h
> (line 135) that appears to be called in drivers/md/raid6algos.c (line
> 113). My C code skills are a bit rusty but I'm assuming the
> cpu_relax() call in raid6algos.c uses the definition in pq.h.
>
> If so, why is cpu_relax() in pq.h an empty function when there's
> already a definition for cpu_relax() in
> arch/x86/include/asm/processor.h?
>
> Conversely, if the cpu_relax() function call in raid6algos.c uses the
> definition in processor.h, why do we have a second definition in pq.h?
>
> It strikes me that if the purpose of cpu_relax() is to signal the
> kernel that we're not doing anything, why create our own empty
> function when there's already one that is correct across all supported
> architectures?
>


That is inside
#ifndef __KERNEL__
#endif

and so is not used when compiling the kernel. It is used when compiling the
same code into a user-space test program.

Thanks for the review though.

NeilBrown
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html