From 937cc3d00b30677e3d06d882140835a355c78718 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Fri, 12 May 2017 20:54:25 +0900 Subject: [PATCH] [COMMON] mm: hpa: fix parameter that hides global identifier The first parameter to is_movable_chunk() is start_pfn that is declared as a global variable with the file scope. It is not harm even though the parameter hids the global variable but it causes the readers confusing so that it likely leads a mistake in the change of some statements in the function. Therefore the name of the first parameter to is_movable_chunk() is changed and modified the logic of the body of is_movable_chunk() for clear understanding. Change-Id: I7b97aefb0b25dd09ca6c22fe0077b3d76b372210 Signed-off-by: Cho KyongHo --- mm/hpa.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/mm/hpa.c b/mm/hpa.c index f2664f4e3ec2..5bcac8790013 100644 --- a/mm/hpa.c +++ b/mm/hpa.c @@ -128,24 +128,18 @@ static int hpa_killer(void) return ret; } -static bool is_movable_chunk(unsigned long start_pfn, unsigned int order) +static bool is_movable_chunk(unsigned long pfn, unsigned int order) { - unsigned long pfn = start_pfn; - struct page *page = pfn_to_page(start_pfn); + struct page *page = pfn_to_page(pfn); + struct page *page_end = pfn_to_page(pfn + (1 << order)); - for (pfn = start_pfn; pfn < start_pfn + (1 << order); pfn++) { - page = pfn_to_page(pfn); - if (PageBuddy(page)) { - pfn += (1 << page_order(page)) - 1; - continue; - } - if (PageCompound(page)) - return false; - if (PageReserved(page)) - return false; - if (!PageLRU(page)) + while (page != page_end) { + if (PageCompound(page) || PageReserved(page) || !PageLRU(page)) return false; + + page += PageBuddy(page) ? 1 << page_order(page) : 1; } + return true; } -- 2.20.1