* [PATCH next/mmotm] slab: fix DEBUG_SLAB build
@ 2011-07-11 18:56 Hugh Dickins
2011-07-11 20:35 ` Hugh Dickins
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Hugh Dickins @ 2011-07-11 18:56 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1571 bytes --]
Fix CONFIG_SLAB=y CONFIG_DEBUG_SLAB=y build error and warnings.
Now that ARCH_SLAB_MINALIGN defaults to __alignof__(unsigned long long),
it is always defined (when slab.h included), but cannot be used in #if:
mm/slab.c: In function ‘cache_alloc_debugcheck_after’:
mm/slab.c:3156:5: warning: "__alignof__" is not defined
mm/slab.c:3156:5: error: missing binary operator before token "("
make[1]: *** [mm/slab.o] Error 1
So just remove the #if and #endif lines, but then 64-bit build warns:
mm/slab.c: In function ‘cache_alloc_debugcheck_after’:
mm/slab.c:3156:6: warning: cast from pointer to integer of different size
mm/slab.c:3158:10: warning: format ‘%d’ expects type ‘int’, but argument
3 has type ‘long unsigned int’
Fix those with casts, whatever the actual type of ARCH_SLAB_MINALIGN.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/slab.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- mmotm/mm/slab.c 2011-07-05 12:36:54.294718254 -0700
+++ linux/mm/slab.c 2011-07-05 14:19:24.942328542 -0700
@@ -3153,12 +3153,10 @@ static void *cache_alloc_debugcheck_afte
objp += obj_offset(cachep);
if (cachep->ctor && cachep->flags & SLAB_POISON)
cachep->ctor(objp);
-#if ARCH_SLAB_MINALIGN
- if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
+ if ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1)) {
printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
- objp, ARCH_SLAB_MINALIGN);
+ objp, (int)ARCH_SLAB_MINALIGN);
}
-#endif
return objp;
}
#else
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-11 18:56 [PATCH next/mmotm] slab: fix DEBUG_SLAB build Hugh Dickins
@ 2011-07-11 20:35 ` Hugh Dickins
2011-07-12 15:45 ` Christoph Lameter
2011-07-13 16:08 ` Christoph Lameter
2 siblings, 0 replies; 8+ messages in thread
From: Hugh Dickins @ 2011-07-11 20:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Christoph Lameter, Pekka Enberg, linux-kernel
Fix CONFIG_SLAB=y CONFIG_DEBUG_SLAB=y build error and warnings.
Now that ARCH_SLAB_MINALIGN defaults to __alignof__(unsigned long long),
it is always defined (when slab.h included), but cannot be used in #if:
mm/slab.c: In function `cache_alloc_debugcheck_after':
mm/slab.c:3156:5: warning: "__alignof__" is not defined
mm/slab.c:3156:5: error: missing binary operator before token "("
make[1]: *** [mm/slab.o] Error 1
So just remove the #if and #endif lines, but then 64-bit build warns:
mm/slab.c: In function `cache_alloc_debugcheck_after':
mm/slab.c:3156:6: warning: cast from pointer to integer of different size
mm/slab.c:3158:10: warning: format `%d' expects type `int', but argument
3 has type `long unsigned int'
Fix those with casts, whatever the actual type of ARCH_SLAB_MINALIGN.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
Sorry, as akpm points out, the patch I sent first was mime-mangled:
compiler uses non-ASCII quotes in its messages, which mislead my mailer.
mm/slab.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- mmotm/mm/slab.c 2011-07-05 12:36:54.294718254 -0700
+++ linux/mm/slab.c 2011-07-05 14:19:24.942328542 -0700
@@ -3153,12 +3153,10 @@ static void *cache_alloc_debugcheck_afte
objp += obj_offset(cachep);
if (cachep->ctor && cachep->flags & SLAB_POISON)
cachep->ctor(objp);
-#if ARCH_SLAB_MINALIGN
- if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
+ if ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1)) {
printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
- objp, ARCH_SLAB_MINALIGN);
+ objp, (int)ARCH_SLAB_MINALIGN);
}
-#endif
return objp;
}
#else
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-11 18:56 [PATCH next/mmotm] slab: fix DEBUG_SLAB build Hugh Dickins
2011-07-11 20:35 ` Hugh Dickins
@ 2011-07-12 15:45 ` Christoph Lameter
2011-07-12 21:00 ` Hugh Dickins
2011-07-13 16:08 ` Christoph Lameter
2 siblings, 1 reply; 8+ messages in thread
From: Christoph Lameter @ 2011-07-12 15:45 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
On Mon, 11 Jul 2011, Hugh Dickins wrote:
> -#if ARCH_SLAB_MINALIGN
> - if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
> + if ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1)) {
> printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
Change %d to %ul for consistencies sake and drop the cast of
ARCH_SLAB_MINALIGN?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-12 15:45 ` Christoph Lameter
@ 2011-07-12 21:00 ` Hugh Dickins
2011-07-13 15:39 ` Christoph Lameter
0 siblings, 1 reply; 8+ messages in thread
From: Hugh Dickins @ 2011-07-12 21:00 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
On Tue, 12 Jul 2011, Christoph Lameter wrote:
> On Mon, 11 Jul 2011, Hugh Dickins wrote:
>
> > -#if ARCH_SLAB_MINALIGN
> > - if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
> > + if ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1)) {
> > printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
>
> Change %d to %ul for consistencies sake and drop the cast of
> ARCH_SLAB_MINALIGN?
I don't think we can drop the cast of ARCH_SLAB_MINALIGN, or not without
a wander through all the architectures: it could well be defined as a bare
integer in some of them, even if the default definition as __alignof__
comes out as an unsigned long (which itself surprised me).
I could make it an unsigned long cast, and change the %d to %lu,
but there doesn't seem to be any real point to doing so.
Hugh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-12 21:00 ` Hugh Dickins
@ 2011-07-13 15:39 ` Christoph Lameter
2011-07-13 15:59 ` Hugh Dickins
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Lameter @ 2011-07-13 15:39 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
On Tue, 12 Jul 2011, Hugh Dickins wrote:
> On Tue, 12 Jul 2011, Christoph Lameter wrote:
> > On Mon, 11 Jul 2011, Hugh Dickins wrote:
> >
> > > -#if ARCH_SLAB_MINALIGN
> > > - if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
> > > + if ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1)) {
> > > printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
> >
> > Change %d to %ul for consistencies sake and drop the cast of
> > ARCH_SLAB_MINALIGN?
>
> I don't think we can drop the cast of ARCH_SLAB_MINALIGN, or not without
> a wander through all the architectures: it could well be defined as a bare
> integer in some of them, even if the default definition as __alignof__
> comes out as an unsigned long (which itself surprised me).
A bare integer can be handled by a %lu in a printk without the need for a
cast.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-13 15:39 ` Christoph Lameter
@ 2011-07-13 15:59 ` Hugh Dickins
2011-07-13 16:07 ` Christoph Lameter
0 siblings, 1 reply; 8+ messages in thread
From: Hugh Dickins @ 2011-07-13 15:59 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
On Wed, 13 Jul 2011, Christoph Lameter wrote:
> On Tue, 12 Jul 2011, Hugh Dickins wrote:
> > On Tue, 12 Jul 2011, Christoph Lameter wrote:
> > > On Mon, 11 Jul 2011, Hugh Dickins wrote:
> > >
> > > > -#if ARCH_SLAB_MINALIGN
> > > > - if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
> > > > + if ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1)) {
> > > > printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
> > >
> > > Change %d to %ul for consistencies sake and drop the cast of
> > > ARCH_SLAB_MINALIGN?
> >
> > I don't think we can drop the cast of ARCH_SLAB_MINALIGN, or not without
> > a wander through all the architectures: it could well be defined as a bare
> > integer in some of them, even if the default definition as __alignof__
> > comes out as an unsigned long (which itself surprised me).
>
> A bare integer can be handled by a %lu in a printk without the need for a
> cast.
Really? Here if I try that on x86_64 with #define ARCH_SLAB_MINALIGN 8, I get
mm/slab.c: In function `cache_alloc_debugcheck_after':
mm/slab.c:3160:10: warning: format `%lu' expects type `long unsigned int', but argument 3 has type `int'
Hugh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-13 15:59 ` Hugh Dickins
@ 2011-07-13 16:07 ` Christoph Lameter
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Lameter @ 2011-07-13 16:07 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
On Wed, 13 Jul 2011, Hugh Dickins wrote:
> Really? Here if I try that on x86_64 with #define ARCH_SLAB_MINALIGN 8, I get
> mm/slab.c: In function `cache_alloc_debugcheck_after':
> mm/slab.c:3160:10: warning: format `%lu' expects type `long unsigned int', but argument 3 has type `int'
Gosh. I thought integers (especially constants) are automatically
converted to the right format. Guess that is not possible here since the
format strings is not always available for checking.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH next/mmotm] slab: fix DEBUG_SLAB build
2011-07-11 18:56 [PATCH next/mmotm] slab: fix DEBUG_SLAB build Hugh Dickins
2011-07-11 20:35 ` Hugh Dickins
2011-07-12 15:45 ` Christoph Lameter
@ 2011-07-13 16:08 ` Christoph Lameter
2 siblings, 0 replies; 8+ messages in thread
From: Christoph Lameter @ 2011-07-13 16:08 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Pekka Enberg, Andrew Morton, linux-kernel
Acked-by: Christoph Lameter <cl@linux.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-07-13 16:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-11 18:56 [PATCH next/mmotm] slab: fix DEBUG_SLAB build Hugh Dickins
2011-07-11 20:35 ` Hugh Dickins
2011-07-12 15:45 ` Christoph Lameter
2011-07-12 21:00 ` Hugh Dickins
2011-07-13 15:39 ` Christoph Lameter
2011-07-13 15:59 ` Hugh Dickins
2011-07-13 16:07 ` Christoph Lameter
2011-07-13 16:08 ` Christoph Lameter
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.