2005-05-18 12:53:33

by Jeff Dike

[permalink] [raw]
Subject: [PATCH 4/9] UML - Delay loop cleanups

This patch cleans up the delay implementations a bit, makes the loops
unoptimizable, and exports __udelay and __const_udelay.

Signed-off-by: Jeff Dike <[email protected]>

Index: linux-2.6.12-rc/arch/um/sys-i386/delay.c
===================================================================
--- linux-2.6.12-rc.orig/arch/um/sys-i386/delay.c 2005-05-17 18:02:25.000000000 -0400
+++ linux-2.6.12-rc/arch/um/sys-i386/delay.c 2005-05-17 18:11:21.000000000 -0400
@@ -1,5 +1,7 @@
-#include "linux/delay.h"
-#include "asm/param.h"
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <asm/param.h>

void __delay(unsigned long time)
{
@@ -20,13 +22,19 @@ void __udelay(unsigned long usecs)
int i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ barrier();
}

+EXPORT_SYMBOL(__udelay);
+
void __const_udelay(unsigned long usecs)
{
int i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ barrier();
}
+
+EXPORT_SYMBOL(__const_udelay);
Index: linux-2.6.12-rc/arch/um/sys-x86_64/delay.c
===================================================================
--- linux-2.6.12-rc.orig/arch/um/sys-x86_64/delay.c 2005-05-17 18:02:25.000000000 -0400
+++ linux-2.6.12-rc/arch/um/sys-x86_64/delay.c 2005-05-17 18:11:21.000000000 -0400
@@ -5,40 +5,37 @@
* Licensed under the GPL
*/

-#include "linux/delay.h"
-#include "asm/processor.h"
-#include "asm/param.h"
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <asm/processor.h>
+#include <asm/param.h>

void __delay(unsigned long loops)
{
unsigned long i;

- for(i = 0; i < loops; i++) ;
+ for(i = 0; i < loops; i++)
+ barrier();
}

void __udelay(unsigned long usecs)
{
- int i, n;
+ unsigned long i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ barrier();
}

+EXPORT_SYMBOL(__udelay);
+
void __const_udelay(unsigned long usecs)
{
- int i, n;
+ unsigned long i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ barrier();
}

-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+EXPORT_SYMBOL(__const_udelay);


2005-05-18 13:10:27

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [PATCH 4/9] UML - Delay loop cleanups

On Wed, 2005-05-18 at 00:20 -0400, Jeff Dike wrote:
> This patch cleans up the delay implementations a bit, makes the loops
> unoptimizable, and exports __udelay and __const_udelay.


you actually want cpu_relax(); for HT niceness...


2005-05-18 14:21:18

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH 4/9] UML - Delay loop cleanups

On Wed, May 18, 2005 at 12:20:26AM -0400, Jeff Dike wrote:
> This patch cleans up the delay implementations a bit, makes the loops
> unoptimizable, and exports __udelay and __const_udelay.

If you do exports in i386 delay.c, remove them from
arch/um/sys-i386/ksyms.c...

2005-05-20 14:41:44

by Jeff Dike

[permalink] [raw]
Subject: Re: [PATCH 4/9] UML - Delay loop cleanups

[email protected] said:
> I'll drop this in light of the review comments - pls redo&&resend

Here 'tis.

This patch cleans up the delay implementations a bit, makes the loops
unoptimizable, and exports __udelay and __const_udelay.

Signed-off-by: Jeff Dike <[email protected]>

Index: linux-2.6.11/arch/um/sys-i386/delay.c
===================================================================
--- linux-2.6.11.orig/arch/um/sys-i386/delay.c 2005-05-19 13:18:50.000000000 -0400
+++ linux-2.6.11/arch/um/sys-i386/delay.c 2005-05-19 13:19:40.000000000 -0400
@@ -1,5 +1,7 @@
-#include "linux/delay.h"
-#include "asm/param.h"
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <asm/param.h>

void __delay(unsigned long time)
{
@@ -20,13 +22,19 @@ void __udelay(unsigned long usecs)
int i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ cpu_relax();
}

+EXPORT_SYMBOL(__udelay);
+
void __const_udelay(unsigned long usecs)
{
int i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ cpu_relax();
}
+
+EXPORT_SYMBOL(__const_udelay);
Index: linux-2.6.11/arch/um/sys-x86_64/delay.c
===================================================================
--- linux-2.6.11.orig/arch/um/sys-x86_64/delay.c 2005-05-19 13:18:50.000000000 -0400
+++ linux-2.6.11/arch/um/sys-x86_64/delay.c 2005-05-19 13:19:40.000000000 -0400
@@ -5,40 +5,37 @@
* Licensed under the GPL
*/

-#include "linux/delay.h"
-#include "asm/processor.h"
-#include "asm/param.h"
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <asm/processor.h>
+#include <asm/param.h>

void __delay(unsigned long loops)
{
unsigned long i;

- for(i = 0; i < loops; i++) ;
+ for(i = 0; i < loops; i++)
+ cpu_relax();
}

void __udelay(unsigned long usecs)
{
- int i, n;
+ unsigned long i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ cpu_relax();
}

+EXPORT_SYMBOL(__udelay);
+
void __const_udelay(unsigned long usecs)
{
- int i, n;
+ unsigned long i, n;

n = (loops_per_jiffy * HZ * usecs) / MILLION;
- for(i=0;i<n;i++) ;
+ for(i=0;i<n;i++)
+ cpu_relax();
}

-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+EXPORT_SYMBOL(__const_udelay);

2005-05-22 19:47:31

by Eric BEGOT

[permalink] [raw]
Subject: [PATCH] UML - 2.6.12-rc4-mm2 Compile error

Here is a patch to correct a compile error on linux 2.6.12-rc4-mm2 for uml.
At the compilation of init/main.c, it complains because it doens't find
the 2 constants FIXADDR_USER_START and FIXADDR_USER_END


--- linux-2.6.12-rc4-mm2/include/asm/fixmap.h.orig 2005-05-22
21:37:13.000000000 +0200
+++ linux-2.6.12-rc4-mm2/include/asm/fixmap.h 2005-05-22
21:38:17.000000000 +0200
@@ -60,7 +60,8 @@ extern unsigned long get_kmem_end(void);

#define FIXADDR_TOP (get_kmem_end() - 0x2000)
#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
-#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
+#define FIXADDR_USER_START (FIXADDR_TOP - FIXADDR_SIZE)
+#define FIXADDR_USER_END FIXADDR_TOP

#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
@@ -91,7 +92,7 @@ static inline unsigned long fix_to_virt(

static inline unsigned long virt_to_fix(const unsigned long vaddr)
{
- BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
+ BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_USER_START);
return __virt_to_fix(vaddr);
}

2005-05-23 14:08:18

by Blaisorblade

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] UML - 2.6.12-rc4-mm2 Compile error

On Sunday 22 May 2005 21:47, Eric BEGOT wrote:
> Here is a patch to correct a compile error on linux 2.6.12-rc4-mm2 for uml.
> At the compilation of init/main.c, it complains because it doens't find
> the 2 constants FIXADDR_USER_START and FIXADDR_USER_END
Why deleting FIXADDR_START? Also FIXADDR_USER_* are defined, just in a
different way (and the patch below is IIRC uncorrect).
>
> --- linux-2.6.12-rc4-mm2/include/asm/fixmap.h.orig 2005-05-22
> 21:37:13.000000000 +0200
> +++ linux-2.6.12-rc4-mm2/include/asm/fixmap.h 2005-05-22
> 21:38:17.000000000 +0200
> @@ -60,7 +60,8 @@ extern unsigned long get_kmem_end(void);
>
> #define FIXADDR_TOP (get_kmem_end() - 0x2000)
> #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
> -#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
> +#define FIXADDR_USER_START (FIXADDR_TOP - FIXADDR_SIZE)
> +#define FIXADDR_USER_END FIXADDR_TOP
>
> #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
> #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
> @@ -91,7 +92,7 @@ static inline unsigned long fix_to_virt(
>
> static inline unsigned long virt_to_fix(const unsigned long vaddr)
> {
> - BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
> + BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_USER_START);
> return __virt_to_fix(vaddr);
> }

--
Paolo Giarrusso, aka Blaisorblade
Skype user "PaoloGiarrusso"
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade

2005-05-23 14:17:02

by Miklos Szeredi

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] UML - 2.6.12-rc4-mm2 Compile error

> > Here is a patch to correct a compile error on linux 2.6.12-rc4-mm2 for uml.
> > At the compilation of init/main.c, it complains because it doens't find
> > the 2 constants FIXADDR_USER_START and FIXADDR_USER_END
> Why deleting FIXADDR_START? Also FIXADDR_USER_* are defined, just in a
> different way (and the patch below is IIRC uncorrect).

I've seen this error too after 'make menuconfig ARCH=um' on a clean
tree.

The following fixes it:

cp .config /tmp
make mrproper ARCH=um
cp /tmp/.config .
make ARCH=um

So there's definitely something wrong with the build on UML.

Miklos

2005-05-23 17:40:51

by Blaisorblade

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] UML - 2.6.12-rc4-mm2 Compile error

On Monday 23 May 2005 16:16, Miklos Szeredi wrote:
> > > Here is a patch to correct a compile error on linux 2.6.12-rc4-mm2 for
> > > uml. At the compilation of init/main.c, it complains because it doens't
> > > find the 2 constants FIXADDR_USER_START and FIXADDR_USER_END
> >
> > Why deleting FIXADDR_START? Also FIXADDR_USER_* are defined, just in a
> > different way (and the patch below is IIRC uncorrect).
>
> I've seen this error too after 'make menuconfig ARCH=um' on a clean
> tree.
>
> The following fixes it:
>
> cp .config /tmp
> make mrproper ARCH=um
> cp /tmp/.config .
> make ARCH=um
>
> So there's definitely something wrong with the build on UML.
Yes, an empty include/asm-um/elf.h which is not by default replaced by a
symlink. Sadly a patch which should have been deleted it simply emptied it
(courtesy of quilt). So

include/asm-um/elf.h:
$(call create_the_symlink)
(which is pseudo-code) won't create it.

As a last resort I'll force that symlink to be unconditional (I hope not
needing this).
--
Paolo Giarrusso, aka Blaisorblade
Skype user "PaoloGiarrusso"
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade

2005-05-23 17:40:51

by Blaisorblade

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] UML - 2.6.12-rc4-mm2 Compile error

On Sunday 22 May 2005 21:47, Eric BEGOT wrote:
> Here is a patch to correct a compile error on linux 2.6.12-rc4-mm2 for uml.
> At the compilation of init/main.c, it complains because it doens't find
> the 2 constants FIXADDR_USER_START and FIXADDR_USER_END
On mainline it's defined by either include/asm-um/archparam-x86_64.h or
include/asm-um/elf-i386.h.

Make sure you used a clean tree and a correct command line (make init/main.o
ARCH=um wouldn't work because it would not create the needed header
symlinks).
--
Paolo Giarrusso, aka Blaisorblade
Skype user "PaoloGiarrusso"
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade