diff options
author | Nick Piggin <npiggin@suse.de> | 2006-09-26 02:30:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:48:44 -0400 |
commit | 725d704ecaca4a43f067092c140d4f3271cf2856 (patch) | |
tree | 320cf8ab5457ac6c01c05da8c30d6026538ee259 /include/linux/mm.h | |
parent | a6ca1b99ed434f3fb41bbed647ed36c0420501e5 (diff) |
[PATCH] mm: VM_BUG_ON
Introduce a VM_BUG_ON, which is turned on with CONFIG_DEBUG_VM. Use this
in the lightweight, inline refcounting functions; PageLRU and PageActive
checks in vmscan, because they're pretty well confined to vmscan. And in
page allocate/free fastpaths which can be the hottest parts of the kernel
for kbuilds.
Unlike BUG_ON, VM_BUG_ON must not be used to execute statements with
side-effects, and should not be used outside core mm code.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Christoph Lameter <clameter@engr.sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 224178a000d2..7d20b25c58fc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -278,6 +278,12 @@ struct page { | |||
278 | */ | 278 | */ |
279 | #include <linux/page-flags.h> | 279 | #include <linux/page-flags.h> |
280 | 280 | ||
281 | #ifdef CONFIG_DEBUG_VM | ||
282 | #define VM_BUG_ON(cond) BUG_ON(cond) | ||
283 | #else | ||
284 | #define VM_BUG_ON(condition) do { } while(0) | ||
285 | #endif | ||
286 | |||
281 | /* | 287 | /* |
282 | * Methods to modify the page usage count. | 288 | * Methods to modify the page usage count. |
283 | * | 289 | * |
@@ -297,7 +303,7 @@ struct page { | |||
297 | */ | 303 | */ |
298 | static inline int put_page_testzero(struct page *page) | 304 | static inline int put_page_testzero(struct page *page) |
299 | { | 305 | { |
300 | BUG_ON(atomic_read(&page->_count) == 0); | 306 | VM_BUG_ON(atomic_read(&page->_count) == 0); |
301 | return atomic_dec_and_test(&page->_count); | 307 | return atomic_dec_and_test(&page->_count); |
302 | } | 308 | } |
303 | 309 | ||
@@ -307,6 +313,7 @@ static inline int put_page_testzero(struct page *page) | |||
307 | */ | 313 | */ |
308 | static inline int get_page_unless_zero(struct page *page) | 314 | static inline int get_page_unless_zero(struct page *page) |
309 | { | 315 | { |
316 | VM_BUG_ON(PageCompound(page)); | ||
310 | return atomic_inc_not_zero(&page->_count); | 317 | return atomic_inc_not_zero(&page->_count); |
311 | } | 318 | } |
312 | 319 | ||
@@ -323,6 +330,7 @@ static inline void get_page(struct page *page) | |||
323 | { | 330 | { |
324 | if (unlikely(PageCompound(page))) | 331 | if (unlikely(PageCompound(page))) |
325 | page = (struct page *)page_private(page); | 332 | page = (struct page *)page_private(page); |
333 | VM_BUG_ON(atomic_read(&page->_count) == 0); | ||
326 | atomic_inc(&page->_count); | 334 | atomic_inc(&page->_count); |
327 | } | 335 | } |
328 | 336 | ||