linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm : add check for the return value
@ 2010-01-04  2:22 Huang Shijie
  2010-01-04  3:21 ` Minchan Kim
  0 siblings, 1 reply; 17+ messages in thread
From: Huang Shijie @ 2010-01-04  2:22 UTC (permalink / raw)
  To: akpm; +Cc: mel, linux-mm, Huang Shijie

When the `page' returned by __rmqueue() is NULL, the origin code
still adds -(1 << order) to zone's NR_FREE_PAGES item.

The patch fixes it.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 mm/page_alloc.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 4e9f5cc..620921d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1222,10 +1222,14 @@ again:
 		}
 		spin_lock_irqsave(&zone->lock, flags);
 		page = __rmqueue(zone, order, migratetype);
-		__mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order));
-		spin_unlock(&zone->lock);
-		if (!page)
+		if (likely(page)) {
+			__mod_zone_page_state(zone, NR_FREE_PAGES,
+						-(1 << order));
+			spin_unlock(&zone->lock);
+		} else {
+			spin_unlock(&zone->lock);
 			goto failed;
+		}
 	}
 
 	__count_zone_vm_events(PGALLOC, zone, 1 << order);
-- 
1.6.5.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-01-08 23:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-04  2:22 [PATCH] mm : add check for the return value Huang Shijie
2010-01-04  3:21 ` Minchan Kim
2010-01-04  4:10   ` shijie8
2010-01-04  4:48     ` Minchan Kim
2010-01-04  5:18       ` Huang Shijie
2010-01-04  6:06         ` Minchan Kim
2010-01-08 22:59           ` Andrew Morton
2010-01-04  5:52   ` [PATCH] page allocator: fix update NR_FREE_PAGES only as necessary KOSAKI Motohiro
2010-01-04  6:03     ` Minchan Kim
2010-01-04  6:11     ` Huang Shijie
2010-01-04  6:16       ` KOSAKI Motohiro
2010-01-04  9:35         ` Huang Shijie
2010-01-05  7:24           ` KOSAKI Motohiro
2010-01-04  9:58     ` Mel Gorman
2010-01-04 17:46       ` Christoph Lameter
2010-01-05  1:08       ` KOSAKI Motohiro
2010-01-08 23:02     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).