linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6.37-rc1] Build failure: __divdi3
@ 2010-11-05  8:59 Tetsuo Handa
  2010-11-05 16:09 ` Randy Dunlap
  0 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2010-11-05  8:59 UTC (permalink / raw)
  To: linux-fsdevel


WARNING: modpost: Found 5 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
fs/built-in.o(.text+0x3e357): In function `alignfile':
: undefined reference to `__divdi3'
fs/built-in.o(.text+0x3e39b): In function `alignfile':
: undefined reference to `__divdi3'
fs/built-in.o(.text+0x3f1af): In function `elf_core_dump':
: undefined reference to `__divdi3'
make: *** [.tmp_vmlinux1] Error 1

Regards.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05  8:59 [2.6.37-rc1] Build failure: __divdi3 Tetsuo Handa
@ 2010-11-05 16:09 ` Randy Dunlap
  2010-11-05 16:48   ` Tetsuo Handa
  0 siblings, 1 reply; 10+ messages in thread
From: Randy Dunlap @ 2010-11-05 16:09 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: linux-fsdevel

On Fri, 05 Nov 2010 17:59:42 +0900 Tetsuo Handa wrote:

> 
> WARNING: modpost: Found 5 section mismatch(es).
> To see full details build your kernel with:
> 'make CONFIG_DEBUG_SECTION_MISMATCH=y'
> fs/built-in.o(.text+0x3e357): In function `alignfile':
> : undefined reference to `__divdi3'
> fs/built-in.o(.text+0x3e39b): In function `alignfile':
> : undefined reference to `__divdi3'
> fs/built-in.o(.text+0x3f1af): In function `elf_core_dump':
> : undefined reference to `__divdi3'
> make: *** [.tmp_vmlinux1] Error 1


Hm, all due to usage of roundup() AFAICT.  Unfortunate.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 16:09 ` Randy Dunlap
@ 2010-11-05 16:48   ` Tetsuo Handa
  2010-11-05 16:55     ` Eric Paris
  0 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2010-11-05 16:48 UTC (permalink / raw)
  To: rdunlap, akpm, eparis, jmorris; +Cc: linux-fsdevel

Hello.

Randy Dunlap wrote:
> On Fri, 05 Nov 2010 17:59:42 +0900 Tetsuo Handa wrote:
> 
> > 
> > WARNING: modpost: Found 5 section mismatch(es).
> > To see full details build your kernel with:
> > 'make CONFIG_DEBUG_SECTION_MISMATCH=y'
> > fs/built-in.o(.text+0x3e357): In function `alignfile':
> > : undefined reference to `__divdi3'
> > fs/built-in.o(.text+0x3e39b): In function `alignfile':
> > : undefined reference to `__divdi3'
> > fs/built-in.o(.text+0x3f1af): In function `elf_core_dump':
> > : undefined reference to `__divdi3'
> > make: *** [.tmp_vmlinux1] Error 1
> 
> 
> Hm, all due to usage of roundup() AFAICT.  Unfortunate.

Indeed. There is a commit for avoiding 64-bit division.

  commit ea7f1b6ee9dc96c5827b06ba21d7769d553efb7d
  Author: Bjorn Helgaas <bjorn.helgaas@hp.com>
  Date:   Thu Nov 5 11:17:11 2009 -0600
  
      x86/PCI: remove 64-bit division
  
      The roundup() caused a build error (undefined reference to `__udivdi3').
      We're aligning to power-of-two boundaries, so it's simpler to just use
      ALIGN() anyway, which avoids the division.
  
      Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
      Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

It seems that the code itself has not changed between 2.6.36 and 2.6.37-rc1

  static int elf_core_dump(struct coredump_params *cprm)
  {
  (...snipped...)
  	loff_t offset = 0, dataoff, foffset;
  (...snipped...)
  	dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);

but the definition of roundup() has changed by

  commit b28efd54d9d5c8005a29cd8782335beb9daaa32d
  Author: Eric Paris <eparis@redhat.com>
  Date:   Wed Oct 13 17:50:08 2010 -0400
  
      kernel: roundup should only reference arguments once
  
      Currently the roundup macro references it's arguments more than one time.
      This patch changes it so it will only use its arguments once.
  
      Suggested-by: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: Eric Paris <eparis@redhat.com>
      Signed-off-by: James Morris <jmorris@namei.org>

between 2.6.36 and 2.6.37-rc1.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 16:48   ` Tetsuo Handa
@ 2010-11-05 16:55     ` Eric Paris
  2010-11-05 17:08       ` Tetsuo Handa
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Paris @ 2010-11-05 16:55 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: rdunlap, akpm, jmorris, linux-fsdevel

On Sat, 2010-11-06 at 01:48 +0900, Tetsuo Handa wrote:
> Hello.
> 
> Randy Dunlap wrote:
> > On Fri, 05 Nov 2010 17:59:42 +0900 Tetsuo Handa wrote:
> > 
> > > 
> > > WARNING: modpost: Found 5 section mismatch(es).
> > > To see full details build your kernel with:
> > > 'make CONFIG_DEBUG_SECTION_MISMATCH=y'
> > > fs/built-in.o(.text+0x3e357): In function `alignfile':
> > > : undefined reference to `__divdi3'
> > > fs/built-in.o(.text+0x3e39b): In function `alignfile':
> > > : undefined reference to `__divdi3'
> > > fs/built-in.o(.text+0x3f1af): In function `elf_core_dump':
> > > : undefined reference to `__divdi3'
> > > make: *** [.tmp_vmlinux1] Error 1
> > 
> > 
> > Hm, all due to usage of roundup() AFAICT.  Unfortunate.
> 
> Indeed. There is a commit for avoiding 64-bit division.
> 
>   commit ea7f1b6ee9dc96c5827b06ba21d7769d553efb7d
>   Author: Bjorn Helgaas <bjorn.helgaas@hp.com>
>   Date:   Thu Nov 5 11:17:11 2009 -0600
>   
>       x86/PCI: remove 64-bit division
>   
>       The roundup() caused a build error (undefined reference to `__udivdi3').
>       We're aligning to power-of-two boundaries, so it's simpler to just use
>       ALIGN() anyway, which avoids the division.
>   
>       Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
>       Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
>       Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> 
> It seems that the code itself has not changed between 2.6.36 and 2.6.37-rc1
> 
>   static int elf_core_dump(struct coredump_params *cprm)
>   {
>   (...snipped...)
>   	loff_t offset = 0, dataoff, foffset;
>   (...snipped...)
>   	dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
> 
> but the definition of roundup() has changed by
> 
>   commit b28efd54d9d5c8005a29cd8782335beb9daaa32d
>   Author: Eric Paris <eparis@redhat.com>
>   Date:   Wed Oct 13 17:50:08 2010 -0400
>   
>       kernel: roundup should only reference arguments once
>   
>       Currently the roundup macro references it's arguments more than one time.
>       This patch changes it so it will only use its arguments once.
>   
>       Suggested-by: Andrew Morton <akpm@linux-foundation.org>
>       Signed-off-by: Eric Paris <eparis@redhat.com>
>       Signed-off-by: James Morris <jmorris@namei.org>
> 
> between 2.6.36 and 2.6.37-rc1.

Interesting, is this a result of the compiler previously being able to
optimize the division since it could tell it was a power of 2 and now
that we have a private variable it can't?  The patch can easily be
reverted without breaking anyone else....

-Eric



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 16:55     ` Eric Paris
@ 2010-11-05 17:08       ` Tetsuo Handa
  2010-11-05 17:16         ` Tetsuo Handa
  0 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2010-11-05 17:08 UTC (permalink / raw)
  To: eparis; +Cc: rdunlap, akpm, jmorris, linux-fsdevel

Eric Paris wrote:
> Interesting, is this a result of the compiler previously being able to
> optimize the division since it could tell it was a power of 2 and now
> that we have a private variable it can't?  The patch can easily be
> reverted without breaking anyone else....

It seems that GCC 3.x can optimize

  roundup((long long), (const))

but cannot optimize

  #define roundup(x, y) (                                 \
  {                                                       \
  	typeof(y) __y = y;                              \
  	(((x) + (__y - 1)) / __y) * __y;                \
  }                                                       \
  )

when y is a constant value.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 17:08       ` Tetsuo Handa
@ 2010-11-05 17:16         ` Tetsuo Handa
  2010-11-05 17:41           ` Eric Paris
  0 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2010-11-05 17:16 UTC (permalink / raw)
  To: eparis; +Cc: rdunlap, akpm, jmorris, linux-fsdevel

Tetsuo Handa wrote:
> Eric Paris wrote:
> > Interesting, is this a result of the compiler previously being able to
> > optimize the division since it could tell it was a power of 2 and now
> > that we have a private variable it can't?  The patch can easily be
> > reverted without breaking anyone else....
> 
I meant to say that it seems that GCC 3.x can optimize

  #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))

for roundup((long long), (const)) case but cannot optimize

  #define roundup(x, y) (                                 \
  {                                                       \
  	typeof(y) __y = y;                              \
  	(((x) + (__y - 1)) / __y) * __y;                \
  }                                                       \
  )

for roundup((long long), (const)) case.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 17:16         ` Tetsuo Handa
@ 2010-11-05 17:41           ` Eric Paris
  2010-11-05 17:53             ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Paris @ 2010-11-05 17:41 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: rdunlap, akpm, jmorris, linux-fsdevel

On Sat, 2010-11-06 at 02:16 +0900, Tetsuo Handa wrote:
> Tetsuo Handa wrote:
> > Eric Paris wrote:
> > > Interesting, is this a result of the compiler previously being able to
> > > optimize the division since it could tell it was a power of 2 and now
> > > that we have a private variable it can't?  The patch can easily be
> > > reverted without breaking anyone else....
> > 
> I meant to say that it seems that GCC 3.x can optimize
> 
>   #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
> 
> for roundup((long long), (const)) case but cannot optimize
> 
>   #define roundup(x, y) (                                 \
>   {                                                       \
>   	typeof(y) __y = y;                              \
>   	(((x) + (__y - 1)) / __y) * __y;                \
>   }                                                       \
>   )
> 
> for roundup((long long), (const)) case.

I guess this is my fault (I'm not completely convinced) since my testing
was done with gcc 4.  I just retested to make sure that
gcc-4.5.1-4.fc14.x86_64 is able to optimize both (and it does).  Is the
fact that it requires compiler optimizations for the code to build a
good thing?

-Eric


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 17:41           ` Eric Paris
@ 2010-11-05 17:53             ` Andrew Morton
  2010-11-05 18:36               ` Tetsuo Handa
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2010-11-05 17:53 UTC (permalink / raw)
  To: Eric Paris; +Cc: Tetsuo Handa, rdunlap, jmorris, linux-fsdevel

On Fri, 05 Nov 2010 13:41:45 -0400
Eric Paris <eparis@redhat.com> wrote:

> On Sat, 2010-11-06 at 02:16 +0900, Tetsuo Handa wrote:
> > Tetsuo Handa wrote:
> > > Eric Paris wrote:
> > > > Interesting, is this a result of the compiler previously being able to
> > > > optimize the division since it could tell it was a power of 2 and now
> > > > that we have a private variable it can't?  The patch can easily be
> > > > reverted without breaking anyone else....
> > > 
> > I meant to say that it seems that GCC 3.x can optimize
> > 
> >   #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
> > 
> > for roundup((long long), (const)) case but cannot optimize
> > 
> >   #define roundup(x, y) (                                 \
> >   {                                                       \
> >   	typeof(y) __y = y;                              \
> >   	(((x) + (__y - 1)) / __y) * __y;                \
> >   }                                                       \
> >   )
> > 
> > for roundup((long long), (const)) case.
> 
> I guess this is my fault (I'm not completely convinced) since my testing
> was done with gcc 4.  I just retested to make sure that
> gcc-4.5.1-4.fc14.x86_64 is able to optimize both (and it does).  Is the
> fact that it requires compiler optimizations for the code to build a
> good thing?

It does make us pretty fragile against future compiler versions, but we
do rely quite a lot on such compiler things.  And things do break, such
as the several-month outbreak of calls to
you_cannot_kmalloc_that_much() a while back.

I wonder if there's some way of tricking gcc back into doing the right
thing here.  Make __y const or something?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 17:53             ` Andrew Morton
@ 2010-11-05 18:36               ` Tetsuo Handa
  2010-11-09  0:13                 ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2010-11-05 18:36 UTC (permalink / raw)
  To: akpm, eparis; +Cc: rdunlap, jmorris, linux-fsdevel

Andrew Morton wrote:
> > >   #define roundup(x, y) (                                 \
> > >   {                                                       \
> > >   	typeof(y) __y = y;                              \
> > >   	(((x) + (__y - 1)) / __y) * __y;                \
> > >   }                                                       \
> > >   )
> > > 
> > > for roundup((long long), (const)) case.
> > 
> > I guess this is my fault (I'm not completely convinced) since my testing
> > was done with gcc 4.  I just retested to make sure that
> > gcc-4.5.1-4.fc14.x86_64 is able to optimize both (and it does).  Is the
> > fact that it requires compiler optimizations for the code to build a
> > good thing?
> 
> It does make us pretty fragile against future compiler versions, but we
> do rely quite a lot on such compiler things.  And things do break, such
> as the several-month outbreak of calls to
> you_cannot_kmalloc_that_much() a while back.
> 
> I wonder if there's some way of tricking gcc back into doing the right
> thing here.  Make __y const or something?

Nice suggestion.

-typeof(y) __y = y;
+const typeof(y) __y = y;

solved __divdi3 problem with GCC 3.3.5.

Regards.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6.37-rc1] Build failure: __divdi3
  2010-11-05 18:36               ` Tetsuo Handa
@ 2010-11-09  0:13                 ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2010-11-09  0:13 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: eparis, rdunlap, jmorris, linux-fsdevel

On Sat, 6 Nov 2010 03:36:27 +0900
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:

> Andrew Morton wrote:
> > > >   #define roundup(x, y) (                                 \
> > > >   {                                                       \
> > > >   	typeof(y) __y = y;                              \
> > > >   	(((x) + (__y - 1)) / __y) * __y;                \
> > > >   }                                                       \
> > > >   )
> > > > 
> > > > for roundup((long long), (const)) case.
> > > 
> > > I guess this is my fault (I'm not completely convinced) since my testing
> > > was done with gcc 4.  I just retested to make sure that
> > > gcc-4.5.1-4.fc14.x86_64 is able to optimize both (and it does).  Is the
> > > fact that it requires compiler optimizations for the code to build a
> > > good thing?
> > 
> > It does make us pretty fragile against future compiler versions, but we
> > do rely quite a lot on such compiler things.  And things do break, such
> > as the several-month outbreak of calls to
> > you_cannot_kmalloc_that_much() a while back.
> > 
> > I wonder if there's some way of tricking gcc back into doing the right
> > thing here.  Make __y const or something?
> 
> Nice suggestion.
> 
> -typeof(y) __y = y;
> +const typeof(y) __y = y;
> 
> solved __divdi3 problem with GCC 3.3.5.
> 

OK, thanks.  Pending any better ideas, I typed this in:


From: Andrew Morton <akpm@linux-foundation.org>

gcc-3.3.5 (at least) is failing to optimise away the divide when `y' is a
constant 64-bit power-of-two value - it emits a call to __divdi3().

It turns out that defining `y' as const prevents this.

Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Eric Paris <eparis@redhat.com>
Cc: James Morris <jmorris@namei.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/kernel.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN include/linux/kernel.h~include-linux-kernelh-roundup-work-around-a-gcc-33-miscompile include/linux/kernel.h
--- a/include/linux/kernel.h~include-linux-kernelh-roundup-work-around-a-gcc-33-miscompile
+++ a/include/linux/kernel.h
@@ -58,9 +58,11 @@ extern const char linux_proc_banner[];
 
 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+
+/* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
 #define roundup(x, y) (					\
 {							\
-	typeof(y) __y = y;				\
+	const typeof(y) __y = y;			\
 	(((x) + (__y - 1)) / __y) * __y;		\
 }							\
 )
_


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-11-09  0:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05  8:59 [2.6.37-rc1] Build failure: __divdi3 Tetsuo Handa
2010-11-05 16:09 ` Randy Dunlap
2010-11-05 16:48   ` Tetsuo Handa
2010-11-05 16:55     ` Eric Paris
2010-11-05 17:08       ` Tetsuo Handa
2010-11-05 17:16         ` Tetsuo Handa
2010-11-05 17:41           ` Eric Paris
2010-11-05 17:53             ` Andrew Morton
2010-11-05 18:36               ` Tetsuo Handa
2010-11-09  0:13                 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).