Commit 7835e98b authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds
Browse files

[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: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 70dc991d
......@@ -357,7 +357,7 @@ free_reserved_mem(void *start, void *end)
void *__start = start;
for (; __start < end; __start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(__start));
set_page_count(virt_to_page(__start), 1);
init_page_count(virt_to_page(__start));
free_page((long)__start);
totalram_pages++;
}
......
......@@ -531,7 +531,7 @@ static inline void free_area(unsigned long addr, unsigned long end, char *s)
for (; addr < end; addr += PAGE_SIZE) {
struct page *page = virt_to_page(addr);
ClearPageReserved(page);
set_page_count(page, 1);
init_page_count(page);
free_page(addr);
totalram_pages++;
}
......
......@@ -324,7 +324,7 @@ static inline void free_area(unsigned long addr, unsigned long end, char *s)
for (; addr < end; addr += PAGE_SIZE) {
struct page *page = virt_to_page(addr);
ClearPageReserved(page);
set_page_count(page, 1);
init_page_count(page);
free_page(addr);
totalram_pages++;
}
......
......@@ -216,7 +216,7 @@ free_initmem(void)
addr = (unsigned long)(&__init_begin);
for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
totalram_pages++;
}
......
......@@ -169,7 +169,7 @@ void __init mem_init(void)
struct page *page = &mem_map[pfn];
ClearPageReserved(page);
set_page_count(page, 1);
init_page_count(page);
__free_page(page);
totalram_pages++;
}
......@@ -210,7 +210,7 @@ void __init free_initmem(void)
/* next to check that the page we free is not a partial page */
for (addr = start; addr < end; addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
totalram_pages++;
}
......@@ -230,7 +230,7 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)
int pages = 0;
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
totalram_pages++;
pages++;
......
......@@ -196,7 +196,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
int pages = 0;
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
totalram_pages++;
pages++;
......@@ -219,7 +219,7 @@ free_initmem()
/* next to check that the page we free is not a partial page */
for (; addr + PAGE_SIZE < (unsigned long)(&__init_end); addr +=PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
totalram_pages++;
}
......
......@@ -270,7 +270,7 @@ static void __init permanent_kmaps_init(pgd_t *pgd_base)
static void __meminit free_new_highpage(struct page *page)
{
set_page_count(page, 1);
init_page_count(page);
__free_page(page);
totalhigh_pages++;
}
......@@ -727,7 +727,7 @@ void free_initmem(void)
addr = (unsigned long)(&__init_begin);
for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
memset((void *)addr, 0xcc, PAGE_SIZE);
free_page(addr);
totalram_pages++;
......@@ -766,7 +766,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
totalram_pages++;
}
......
......@@ -197,7 +197,7 @@ free_initmem (void)
eaddr = (unsigned long) ia64_imva(__init_end);
while (addr < eaddr) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
++totalram_pages;
addr += PAGE_SIZE;
......@@ -252,7 +252,7 @@ free_initrd_mem (unsigned long start, unsigned long end)
continue;
page = virt_to_page(start);
ClearPageReserved(page);
set_page_count(page, 1);
init_page_count(page);
free_page(start);
++totalram_pages;
}
......@@ -640,7 +640,7 @@ mem_init (void)
void online_page(struct page *page)
{
ClearPageReserved(page);
set_page_count(page, 1);
init_page_count(page);
__free_page(page);
totalram_pages++;
num_physpages++;
......
......@@ -226,7 +226,7 @@ void free_initmem(void)
addr = (unsigned long)(&__init_begin);
for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
totalram_pages++;
}
......@@ -244,7 +244,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
unsigned long p;
for (p = start; p < end; p += PAGE_SIZE) {
ClearPageReserved(virt_to_page(p));
set_page_count(virt_to_page(p), 1);
init_page_count(virt_to_page(p));
free_page(p);
totalram_pages++;
}
......
......@@ -137,7 +137,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
int pages = 0;
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
totalram_pages++;
pages++;
......
......@@ -54,7 +54,7 @@ void __init init_pointer_table(unsigned long ptable)
/* unreserve the page so it's possible to free that page */
PD_PAGE(dp)->flags &= ~(1 << PG_reserved);
set_page_count(PD_PAGE(dp), 1);
init_page_count(PD_PAGE(dp));
return;
}
......
......@@ -276,7 +276,7 @@ void free_initmem(void)
addr = (unsigned long)&__init_begin;
for (; addr < (unsigned long)&__init_end; addr += PAGE_SIZE) {
virt_to_page(addr)->flags &= ~(1 << PG_reserved);
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
totalram_pages++;
}
......
......@@ -195,7 +195,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
int pages = 0;
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
totalram_pages++;
pages++;
......@@ -218,7 +218,7 @@ free_initmem()
/* next to check that the page we free is not a partial page */
for (; addr + PAGE_SIZE < (unsigned long)(&__init_end); addr +=PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
totalram_pages++;
}
......
......@@ -158,7 +158,7 @@ unsigned long __init prom_free_prom_memory(void)
while (addr < boot_mem_map.map[i].addr
+ boot_mem_map.map[i].size) {
ClearPageReserved(virt_to_page(__va(addr)));
set_page_count(virt_to_page(__va(addr)), 1);
init_page_count(virt_to_page(__va(addr)));
free_page((unsigned long)__va(addr));
addr += PAGE_SIZE;
freed += PAGE_SIZE;
......
......@@ -118,7 +118,7 @@ unsigned long __init prom_free_prom_memory(void)
addr = PAGE_SIZE;
while (addr < end) {
ClearPageReserved(virt_to_page(__va(addr)));
set_page_count(virt_to_page(__va(addr)), 1);
init_page_count(virt_to_page(__va(addr)));
free_page((unsigned long)__va(addr));
addr += PAGE_SIZE;
}
......
......@@ -174,7 +174,7 @@ unsigned long __init prom_free_prom_memory(void)
while (addr < boot_mem_map.map[i].addr
+ boot_mem_map.map[i].size) {
ClearPageReserved(virt_to_page(__va(addr)));
set_page_count(virt_to_page(__va(addr)), 1);
init_page_count(virt_to_page(__va(addr)));
free_page((unsigned long)__va(addr));
addr += PAGE_SIZE;
freed += PAGE_SIZE;
......
......@@ -117,7 +117,7 @@ unsigned long __init prom_free_prom_memory(void)
while (addr < boot_mem_map.map[i].addr
+ boot_mem_map.map[i].size) {
ClearPageReserved(virt_to_page(__va(addr)));
set_page_count(virt_to_page(__va(addr)), 1);
init_page_count(virt_to_page(__va(addr)));
free_page((unsigned long)__va(addr));
addr += PAGE_SIZE;
freed += PAGE_SIZE;
......
......@@ -245,7 +245,7 @@ void __init mem_init(void)
#ifdef CONFIG_LIMITED_DMA
set_page_address(page, lowmem_page_address(page));
#endif
set_page_count(page, 1);
init_page_count(page);
__free_page(page);
totalhigh_pages++;
}
......@@ -292,7 +292,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
totalram_pages++;
}
......@@ -315,7 +315,7 @@ void free_initmem(void)
page = addr;
#endif
ClearPageReserved(virt_to_page(page));
set_page_count(virt_to_page(page), 1);
init_page_count(virt_to_page(page));
free_page(page);
totalram_pages++;
freed += PAGE_SIZE;
......
......@@ -559,7 +559,7 @@ void __init mem_init(void)
/* if (!page_is_ram(pgnr)) continue; */
/* commented out until page_is_ram works */
ClearPageReserved(p);
set_page_count(p, 1);
init_page_count(p);
__free_page(p);
totalram_pages++;
}
......
......@@ -398,7 +398,7 @@ void free_initmem(void)
addr = (unsigned long)(&__init_begin);
for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
init_page_count(virt_to_page(addr));
free_page(addr);
num_physpages++;
totalram_pages++;
......@@ -1018,7 +1018,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
init_page_count(virt_to_page(start));
free_page(start);
num_physpages++;
totalram_pages++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment