From: Hugh Dickins <hugh@veritas.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>, linux-kernel@vger.kernel.org
Subject: [PATCH 10/11] unpaged: PG_reserved bad_page
Date: Thu, 17 Nov 2005 19:39:22 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.61.0511171938490.4563@goblin.wat.veritas.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0511171925290.4563@goblin.wat.veritas.com>
It used to be the case that PG_reserved pages were silently never freed,
but in 2.6.15-rc1 they may be freed with a "Bad page state" message. We
should work through such cases as they appear, fixing the code; but for
now it's safer to issue the message without freeing the page, leaving
PG_reserved set.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
mm/page_alloc.c | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
--- unpaged09/mm/page_alloc.c 2005-11-17 15:10:50.000000000 +0000
+++ unpaged10/mm/page_alloc.c 2005-11-17 15:12:12.000000000 +0000
@@ -140,8 +140,7 @@ static void bad_page(const char *functio
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;
@@ -335,7 +334,7 @@ static inline void __free_pages_bulk (st
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 ||
@@ -353,6 +352,12 @@ static inline void free_pages_check(cons
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);
}
/*
@@ -392,11 +397,10 @@ void __free_pages_ok(struct page *page,
{
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)
@@ -404,8 +408,12 @@ void __free_pages_ok(struct page *page,
#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);
}
@@ -463,7 +471,7 @@ void set_page_refs(struct page *page, in
/*
* 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 ||
@@ -481,12 +489,20 @@ static void prep_new_page(struct page *p
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;
}
/*
@@ -669,11 +685,14 @@ static void fastcall free_hot_cold_page(
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);
@@ -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)
@@ -739,7 +760,8 @@ buffered_rmqueue(struct zone *zone, int
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);
next prev parent reply other threads:[~2005-11-17 19:40 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-17 19:28 [PATCH 00/11] unpaged: PageReserved VM fixups Hugh Dickins
2005-11-17 19:29 ` [PATCH 01/11] unpaged: get_user_pages VM_RESERVED Hugh Dickins
2005-11-17 23:29 ` David S. Miller
2005-11-17 19:30 ` [PATCH 02/11] unpaged: private write VM_RESERVED Hugh Dickins
2005-11-17 19:41 ` Dave Jones
2005-11-17 20:46 ` Dominik Brodowski
2005-11-17 20:51 ` Dave Jones
2005-11-17 23:58 ` David S. Miller
2005-11-18 7:12 ` Dominik Brodowski
2005-11-18 7:59 ` David S. Miller
2005-11-17 20:59 ` Dominik Brodowski
2005-11-17 23:36 ` David S. Miller
2005-11-17 19:31 ` [PATCH 03/11] unpaged: sound nopage get_page Hugh Dickins
2005-11-17 23:41 ` David S. Miller
2005-11-17 19:32 ` [PATCH 04/11] unpaged: unifdefed PageCompound Hugh Dickins
2005-11-17 23:43 ` David S. Miller
2005-11-19 20:15 ` Hugh Dickins
2005-11-19 20:55 ` William Lee Irwin III
2005-11-19 21:41 ` David S. Miller
2005-11-19 21:58 ` William Lee Irwin III
2005-11-17 19:34 ` [PATCH 05/11] unpaged: VM_UNPAGED Hugh Dickins
2005-11-17 20:59 ` William Lee Irwin III
2005-11-17 23:46 ` David S. Miller
2005-11-17 19:36 ` [PATCH 06/11] unpaged: VM_NONLINEAR VM_RESERVED Hugh Dickins
2005-11-17 19:37 ` [PATCH 07/11] unpaged: COW on VM_UNPAGED Hugh Dickins
2005-11-17 23:52 ` David S. Miller
2005-11-18 5:46 ` Nick Piggin
2005-11-18 6:45 ` David S. Miller
2005-11-18 7:27 ` Hugh Dickins
2005-11-18 7:46 ` Andrew Morton
2005-11-18 8:04 ` David S. Miller
2005-11-18 8:12 ` Hugh Dickins
2005-11-18 8:02 ` Hugh Dickins
2005-11-18 8:08 ` David S. Miller
2005-11-18 8:13 ` Hugh Dickins
2005-11-18 8:36 ` David S. Miller
2005-11-18 9:33 ` Hugh Dickins
2005-11-18 21:08 ` Dave Jones
2005-11-18 19:12 ` Alan Cox
2005-11-17 19:38 ` [PATCH 08/11] unpaged: anon in VM_UNPAGED Hugh Dickins
2005-11-17 19:38 ` [PATCH 09/11] unpaged: ZERO_PAGE " Hugh Dickins
2005-11-17 21:25 ` Ingo Oeser
2005-11-18 19:58 ` Hugh Dickins
2005-11-17 19:39 ` Hugh Dickins [this message]
2005-11-17 19:40 ` [PATCH 11/11] unpaged: copy_page_range vma Hugh Dickins
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=Pine.LNX.4.61.0511171938490.4563@goblin.wat.veritas.com \
--to=hugh@veritas.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.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
all inboxes | Powered by JetHome®