Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 14612
b: refs/heads/master
c: 689bceb
h: refs/heads/master
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Nov 22, 2005
1 parent ddb1d4b commit f342f61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f57e88a8d83de8d844b57e16b84d2f762fe9f092
refs/heads/master: 689bcebfda16d7bace742740bfb3137fff30b529
46 changes: 34 additions & 12 deletions trunk/mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ static void bad_page(const char *function, struct page *page)
1 << PG_reclaim |
1 << PG_slab |
1 << PG_swapcache |
1 << PG_writeback |
1 << PG_reserved );
1 << PG_writeback );
set_page_count(page, 0);
reset_page_mapcount(page);
page->mapping = NULL;
Expand Down Expand Up @@ -335,7 +334,7 @@ static inline void __free_pages_bulk (struct page *page,
zone->free_area[order].nr_free++;
}

static inline void free_pages_check(const char *function, struct page *page)
static inline int free_pages_check(const char *function, struct page *page)
{
if ( page_mapcount(page) ||
page->mapping != NULL ||
Expand All @@ -353,6 +352,12 @@ static inline void free_pages_check(const char *function, struct page *page)
bad_page(function, page);
if (PageDirty(page))
__ClearPageDirty(page);
/*
* For now, we report if PG_reserved was found set, but do not
* clear it, and do not free the page. But we shall soon need
* to do more, for when the ZERO_PAGE count wraps negative.
*/
return PageReserved(page);
}

/*
Expand Down Expand Up @@ -392,20 +397,23 @@ void __free_pages_ok(struct page *page, unsigned int order)
{
LIST_HEAD(list);
int i;
int reserved = 0;

arch_free_page(page, order);

mod_page_state(pgfree, 1 << order);

#ifndef CONFIG_MMU
if (order > 0)
for (i = 1 ; i < (1 << order) ; ++i)
__put_page(page + i);
#endif

for (i = 0 ; i < (1 << order) ; ++i)
free_pages_check(__FUNCTION__, page + i);
reserved += free_pages_check(__FUNCTION__, page + i);
if (reserved)
return;

list_add(&page->lru, &list);
mod_page_state(pgfree, 1 << order);
kernel_map_pages(page, 1<<order, 0);
free_pages_bulk(page_zone(page), 1, &list, order);
}
Expand Down Expand Up @@ -463,7 +471,7 @@ void set_page_refs(struct page *page, int order)
/*
* This page is about to be returned from the page allocator
*/
static void prep_new_page(struct page *page, int order)
static int prep_new_page(struct page *page, int order)
{
if ( page_mapcount(page) ||
page->mapping != NULL ||
Expand All @@ -481,12 +489,20 @@ static void prep_new_page(struct page *page, int order)
1 << PG_reserved )))
bad_page(__FUNCTION__, page);

/*
* For now, we report if PG_reserved was found set, but do not
* clear it, and do not allocate the page: as a safety net.
*/
if (PageReserved(page))
return 1;

page->flags &= ~(1 << PG_uptodate | 1 << PG_error |
1 << PG_referenced | 1 << PG_arch_1 |
1 << PG_checked | 1 << PG_mappedtodisk);
set_page_private(page, 0);
set_page_refs(page, order);
kernel_map_pages(page, 1 << order, 1);
return 0;
}

/*
Expand Down Expand Up @@ -669,11 +685,14 @@ static void fastcall free_hot_cold_page(struct page *page, int cold)

arch_free_page(page, 0);

kernel_map_pages(page, 1, 0);
inc_page_state(pgfree);
if (PageAnon(page))
page->mapping = NULL;
free_pages_check(__FUNCTION__, page);
if (free_pages_check(__FUNCTION__, page))
return;

inc_page_state(pgfree);
kernel_map_pages(page, 1, 0);

pcp = &zone_pcp(zone, get_cpu())->pcp[cold];
local_irq_save(flags);
list_add(&page->lru, &pcp->list);
Expand Down Expand Up @@ -712,12 +731,14 @@ static struct page *
buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
{
unsigned long flags;
struct page *page = NULL;
struct page *page;
int cold = !!(gfp_flags & __GFP_COLD);

again:
if (order == 0) {
struct per_cpu_pages *pcp;

page = NULL;
pcp = &zone_pcp(zone, get_cpu())->pcp[cold];
local_irq_save(flags);
if (pcp->count <= pcp->low)
Expand All @@ -739,7 +760,8 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
if (page != NULL) {
BUG_ON(bad_range(zone, page));
mod_page_state_zone(zone, pgalloc, 1 << order);
prep_new_page(page, order);
if (prep_new_page(page, order))
goto again;

if (gfp_flags & __GFP_ZERO)
prep_zero_page(page, order, gfp_flags);
Expand Down

0 comments on commit f342f61

Please sign in to comment.