From: Dave Hansen <dave@sr71.net>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jan Beulich <JBeulich@novell.com>,
Christoph Lameter <cl@linux.com>,
akpm <akpm@linux-foundation.org>, linux-mm <linux-mm@kvack.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: BUILD_BUG_ON() breaks sparse gfp_t checks
Date: Thu, 14 Apr 2011 08:41:35 -0700 [thread overview]
Message-ID: <1302795695.14658.6801.camel@nimitz> (raw)
Running sparse on page_alloc.c today, it errors out:
mm/page_alloc.c:96:5: warning: symbol 'percpu_pagelist_fraction' was not declared. Should it be static?
mm/page_alloc.c:175:5: warning: symbol 'min_free_kbytes' was not declared. Should it be static?
include/linux/gfp.h:254:17: error: bad constant expression
include/linux/gfp.h:254:17: error: cannot size expression
which is a line in gfp_zone():
BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
That's really unfortunate, because it ends up hiding all of the other
legitimate sparse messages (like I introduced with the appended patch):
mm/page_alloc.c:96:5: warning: symbol 'percpu_pagelist_fraction' was not declared. Should it be static?
mm/page_alloc.c:175:5: warning: symbol 'min_free_kbytes' was not declared. Should it be static?
mm/page_alloc.c:3692:15: warning: symbol '__early_pfn_to_nid' was not declared. Should it be static?
mm/page_alloc.c:5315:59: warning: incorrect type in argument 1 (different base types)
mm/page_alloc.c:5315:59: expected unsigned long [unsigned] [usertype] size
mm/page_alloc.c:5315:59: got restricted gfp_t [usertype] <noident>
...
Is sparse broken, or is that ? Even if it is, should we be working
around this somehow? It looks like we've basically crippled sparse in
some spots.
---
linux-2.6.git-dave/include/linux/gfp.h | 3 ++-
linux-2.6.git-dave/mm/page_alloc.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff -puN include/linux/gfp.h~fix-gfp_h-sparse include/linux/gfp.h
--- linux-2.6.git/include/linux/gfp.h~fix-gfp_h-sparse 2011-04-14 08:23:33.402280424 -0700
+++ linux-2.6.git-dave/include/linux/gfp.h 2011-04-14 08:32:33.782224008 -0700
@@ -249,7 +249,7 @@ static inline enum zone_type gfp_zone(gf
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
((1 << ZONES_SHIFT) - 1);
-
+/*
if (__builtin_constant_p(bit))
BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
else {
@@ -257,6 +257,7 @@ static inline enum zone_type gfp_zone(gf
BUG_ON((GFP_ZONE_BAD >> bit) & 1);
#endif
}
+ */
return z;
}
diff -puN mm/page_alloc.c~fix-gfp_h-sparse mm/page_alloc.c
--- linux-2.6.git/mm/page_alloc.c~fix-gfp_h-sparse 2011-04-14 08:24:20.806271357 -0700
+++ linux-2.6.git-dave/mm/page_alloc.c 2011-04-14 08:24:35.554268529 -0700
@@ -5312,6 +5312,7 @@ void *__init alloc_large_system_hash(con
*/
if (get_order(size) < MAX_ORDER) {
table = alloc_pages_exact(size, GFP_ATOMIC);
+ table = alloc_pages_exact(GFP_ATOMIC, size);
kmemleak_alloc(table, size, 1, GFP_ATOMIC);
}
}
_
-- Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2011-04-14 15:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-14 15:41 Dave Hansen [this message]
2011-04-14 20:22 ` BUILD_BUG_ON() breaks sparse gfp_t checks Andrew Morton
2011-04-14 21:39 ` Dave Hansen
2011-04-15 14:45 ` Christoph Lameter
2011-04-15 19:16 ` [PATCH] make new gfp.h BUG_ON() in to VM_BUG_ON() Dave Hansen
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=1302795695.14658.6801.camel@nimitz \
--to=dave@sr71.net \
--cc=JBeulich@novell.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rusty@rustcorp.com.au \
/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 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).