WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] domain.c idle_loop declaration (take 2)

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] domain.c idle_loop declaration (take 2)
From: "Mike D. Day" <ncmike@xxxxxxxxxx>
Date: Wed, 22 Dec 2004 09:45:49 -0500
Delivery-date: Wed, 22 Dec 2004 14:39:25 +0000
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Reply-to: ncmike@xxxxxxxxxx
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
The recent change to the declaration of idle_loop in domain.c fixed a
compilation problem on gcc 3.4.2. Enclosed patch is another suggestion
on how to solve that problem. 

Some further analysis, with much help from Jimmy Xenidis of IBM
research, shows that the problem was not the declaration of the function
as static void, but that the compiler is optimizing the function out of
the assembled code. 

Compile domain.c to assembly: 

[mdday@mdday xen]$ gcc -nostdinc -fno-builtin -fno-common -fno-strict-
aliasing -iwithprefix include -Wall -Werror -pipe -
I/home/mdday/src/edited/xen-2.0-testing.bk/xen/include -Wno-pointer-
arith -Wredundant-decls -O3 -Wunused-function -Wunused -fomit-frame-
pointer -msoft-float -m32 -march=i686 -DNDEBUG -S arch/x86/domain.c -
o /tmp/d.S

grep for the label idle_loop in the assembled output: 

[mdday@mdday xen]$ grep idle_loop /tmp/d.S .globl
startup_cpu_idle_loop         .type   startup_cpu_idle_loop, @function
startup_cpu_idle_loop:         .size   startup_cpu_idle_loop, .-
startup_cpu_idle_loop
        movl %eax,%esp; jmp idle_loop

Compile domain.c to assembly without optimization: 

[mdday@mdday xen]$ gcc -nostdinc -fno-builtin -fno-common -fno-strict-
aliasing -iwithprefix include -Wall -Werror -pipe -
I/home/mdday/src/edited/xen-2.0-testing.bk/xen/include -Wno-pointer-
arith -Wredundant-decls -O0 -Wunused-function -Wunused -fomit-frame-
pointer -msoft-float -m32 -march=i686 -DNDEBUG -S arch/x86/domain.c -
o /tmp/d.S

grep for the label idle_loop in the assembled output: 

[mdday@mdday xen]$ grep idle_loop /tmp/d.S         .type   idle_loop,
@function idle_loop:         .size   idle_loop, .-idle_loop .globl
startup_cpu_idle_loop
        .type   startup_cpu_idle_loop, @function
startup_cpu_idle_loop:
        call    idle_loop
        .size   startup_cpu_idle_loop, .-startup_cpu_idle_loop
        movl %eax,%esp; jmp idle_loop

The compiler is probably correct in optimizing out the function. It is
only called through inline assembly, and it is static void. Further
experiments with -02 -01 and -0s also cause idle_loop to be optimized
out. 

It is a good idea to keep idle_loop declared static void. The patch
simply includes a declaration using __attribute__ ((used)) that prevents
the compiler from optimizing out the function. 

-- 
Mike D. Day
Architect, Open Virtualization
IBM Linux Technology Center
3039 Cornwallis Road
Research Triangle Park, NC  27709
Phone: (919) 543-4283
ncmike@xxxxxxxxxx

Attachment: domain.patch
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>