From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: eparis@redhat.com, rdunlap@xenotime.net, jmorris@namei.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [2.6.37-rc1] Build failure: __divdi3
Date: Mon, 8 Nov 2010 16:13:44 -0800 [thread overview]
Message-ID: <20101108161344.1d508a72.akpm@linux-foundation.org> (raw)
In-Reply-To: <201011060336.GHC90161.OMVOtHSFFJOQFL@I-love.SAKURA.ne.jp>
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; \
} \
)
_
prev parent reply other threads:[~2010-11-09 0:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101108161344.1d508a72.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=eparis@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rdunlap@xenotime.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.