Re: [RFC PATCH] x86: Add safe_udelay() and safe_msleep()

From: Christoph Lameter
Date: Fri Jan 14 2011 - 09:50:38 EST


On Thu, 13 Jan 2011, Yinghai Lu wrote:

> from code review, we should not use udelay() that early.
>
> in arch/x86/lib/delay.c we have
> inline void __const_udelay(unsigned long xloops)
> {
> int d0;
>
> xloops *= 4;
> asm("mull %%edx"
> :"=d" (xloops), "=&a" (d0)
> :"1" (xloops), "0"
> (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));

^^^^ this line was recently changed through the commit included at the end
of the message. Solution would be to revert the commit or set the
loops_per_jiffy in the early per cpu segment (as done in the last patch I
saw from you).

commit 357089fca91f639dd005ae0721f5f932b4f276ab
Author: Christoph Lameter <cl@xxxxxxxxx>
Date: Thu Dec 16 12:14:43 2010 -0600

x86: udelay: Use this_cpu_read to avoid address calculation

The code will use a segment prefix instead of doing the lookup and
calculation.

Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>
Acked-by: "H. Peter Anvin" <hpa@xxxxxxxxx>
Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>

diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index ff485d3..fc45ba8 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -121,7 +121,7 @@ inline void __const_udelay(unsigned long xloops)
asm("mull %%edx"
:"=d" (xloops), "=&a" (d0)
:"1" (xloops), "0"
- (cpu_data(raw_smp_processor_id()).loops_per_jiffy *
(HZ/4)));
+ (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));

__delay(++xloops);
}

--
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/