linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] mm: fix a BUG, the page is allocated 2 times
@ 2015-10-12  2:40 yalin wang
  2015-10-12  7:38 ` Vlastimil Babka
  2015-10-12 13:52 ` Mel Gorman
  0 siblings, 2 replies; 7+ messages in thread
From: yalin wang @ 2015-10-12  2:40 UTC (permalink / raw)
  To: akpm, vbabka, mgorman, mhocko, rientjes, js1304, kirill.shutemov,
	hannes, alexander.h.duyck, linux-mm, linux-kernel
  Cc: yalin wang

Remove unlikely(order), because we are sure order is not zero if
code reach here, also add if (page == NULL), only allocate page again if
__rmqueue_smallest() failed or alloc_flags & ALLOC_HARDER == 0

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
---
 mm/page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0d6f540..de82e2c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2241,13 +2241,13 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
 		spin_lock_irqsave(&zone->lock, flags);
 
 		page = NULL;
-		if (unlikely(order) && (alloc_flags & ALLOC_HARDER)) {
+		if (alloc_flags & ALLOC_HARDER) {
 			page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC);
 			if (page)
 				trace_mm_page_alloc_zone_locked(page, order, migratetype);
 		}
-
-		page = __rmqueue(zone, order, migratetype, gfp_flags);
+		if (page == NULL)
+			page = __rmqueue(zone, order, migratetype, gfp_flags);
 		spin_unlock(&zone->lock);
 		if (!page)
 			goto failed;
-- 
1.9.1

--
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	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-13  1:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12  2:40 [RFC] mm: fix a BUG, the page is allocated 2 times yalin wang
2015-10-12  7:38 ` Vlastimil Babka
2015-10-12  7:58   ` yalin wang
2015-10-12 10:05     ` Kirill A. Shutemov
2015-10-12 11:22       ` Vlastimil Babka
2015-10-12 13:52 ` Mel Gorman
2015-10-13  1:43   ` yalin wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox