aboutsummaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2006-03-22 00:08:40 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-22 07:54:02 -0800
commit7835e98b2e3c66dba79cb0ff8ebb90a2fe030c29 (patch)
tree405a96eade34845dabe2f125b6c5eb095846869d /mm
parent70dc991d66cac40fdb07346dba2b5d862d732c34 (diff)
downloadvexpress-lsk-7835e98b2e3c66dba79cb0ff8ebb90a2fe030c29.tar.gz
[PATCH] remove set_page_count() outside mm/
set_page_count usage outside mm/ is limited to setting the refcount to 1. Remove set_page_count from outside mm/, and replace those users with init_page_count() and set_page_refcounted(). This allows more debug checking, and tighter control on how code is allowed to play around with page->_count. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/hugetlb.c5
-rw-r--r--mm/internal.h13
-rw-r--r--mm/page_alloc.c14
3 files changed, 21 insertions, 11 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 39d49ecea8e..20117a4b8ab 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -18,6 +18,7 @@
#include <asm/pgtable.h>
#include <linux/hugetlb.h>
+#include "internal.h"
const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
static unsigned long nr_huge_pages, free_huge_pages;
@@ -106,7 +107,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, unsigned long addr)
return NULL;
}
spin_unlock(&hugetlb_lock);
- set_page_count(page, 1);
+ set_page_refcounted(page);
for (i = 0; i < (HPAGE_SIZE/PAGE_SIZE); ++i)
clear_user_highpage(&page[i], addr);
return page;
@@ -152,7 +153,7 @@ static void update_and_free_page(struct page *page)
1 << PG_private | 1<< PG_writeback);
}
page[1].lru.next = NULL;
- set_page_count(page, 1);
+ set_page_refcounted(page);
__free_pages(page, HUGETLB_PAGE_ORDER);
}
diff --git a/mm/internal.h b/mm/internal.h
index 7bb33977981..d20e3cc4aef 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -13,8 +13,19 @@
#include <linux/mm.h>
-static inline void set_page_refs(struct page *page, int order)
+static inline void set_page_count(struct page *page, int v)
{
+ atomic_set(&page->_count, v);
+}
+
+/*
+ * Turn a non-refcounted page (->_count == 0) into refcounted with
+ * a count of one.
+ */
+static inline void set_page_refcounted(struct page *page)
+{
+ BUG_ON(PageCompound(page) && page_private(page) != (unsigned long)page);
+ BUG_ON(atomic_read(&page->_count));
set_page_count(page, 1);
}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e197818a7cf..7f65b5a63bb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -442,7 +442,7 @@ void fastcall __init __free_pages_bootmem(struct page *page, unsigned int order)
if (order == 0) {
__ClearPageReserved(page);
set_page_count(page, 0);
- set_page_refs(page, 0);
+ set_page_refcounted(page);
__free_page(page);
} else {
int loop;
@@ -457,7 +457,7 @@ void fastcall __init __free_pages_bootmem(struct page *page, unsigned int order)
set_page_count(p, 0);
}
- set_page_refs(page, order);
+ set_page_refcounted(page);
__free_pages(page, order);
}
}
@@ -525,7 +525,7 @@ static int prep_new_page(struct page *page, int order)
1 << PG_referenced | 1 << PG_arch_1 |
1 << PG_checked | 1 << PG_mappedtodisk);
set_page_private(page, 0);
- set_page_refs(page, order);
+ set_page_refcounted(page);
kernel_map_pages(page, 1 << order, 1);
return 0;
}
@@ -755,10 +755,8 @@ void split_page(struct page *page, unsigned int order)
BUG_ON(PageCompound(page));
BUG_ON(!page_count(page));
- for (i = 1; i < (1 << order); i++) {
- BUG_ON(page_count(page + i));
- set_page_count(page + i, 1);
- }
+ for (i = 1; i < (1 << order); i++)
+ set_page_refcounted(page + i);
}
/*
@@ -1771,7 +1769,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
continue;
page = pfn_to_page(pfn);
set_page_links(page, zone, nid, pfn);
- set_page_count(page, 1);
+ init_page_count(page);
reset_page_mapcount(page);
SetPageReserved(page);
INIT_LIST_HEAD(&page->lru);