Re: [PATCH v2 2/2] mm/compaction: avoid rescanning pageblocks in isolate_freepages
From: Vlastimil Babka
Date: Mon May 19 2014 - 06:15:12 EST
I wonder why nobody complained about the build warning... sorry.
----8<----
From: Vlastimil Babka <vbabka@xxxxxxx>
Date: Mon, 19 May 2014 12:02:38 +0200
Subject: mm-compaction-avoid-rescanning-pageblocks-in-isolate_freepages-fix
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix a (spurious) build warning:
mm/compaction.c:860:15: warning: ânext_free_pfnâ may be used uninitialized in this function [-Wmaybe-uninitialized]
Seems like the compiler cannot prove that exiting the for loop without updating
next_free_pfn there will mean that the check for crossing the scanners will
trigger. So let's not confuse people who try to see why this warning occurs.
Instead of initializing next_free_pfn to zero with an explaining comment, just
drop the damned variable altogether and work with cc->free_pfn directly as
Nayoa originally suggested.
Suggested-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx>
Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>
---
mm/compaction.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/mm/compaction.c b/mm/compaction.c
index 8db9820..b0f939b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -760,7 +760,6 @@ static void isolate_freepages(struct zone *zone,
unsigned long block_start_pfn; /* start of current pageblock */
unsigned long block_end_pfn; /* end of current pageblock */
unsigned long low_pfn; /* lowest pfn scanner is able to scan */
- unsigned long next_free_pfn; /* start pfn for scaning at next round */
int nr_freepages = cc->nr_freepages;
struct list_head *freelist = &cc->freepages;
@@ -822,7 +821,7 @@ static void isolate_freepages(struct zone *zone,
continue;
/* Found a block suitable for isolating free pages from */
- next_free_pfn = block_start_pfn;
+ cc->free_pfn = block_start_pfn;
isolated = isolate_freepages_block(cc, block_start_pfn,
block_end_pfn, freelist, false);
nr_freepages += isolated;
@@ -852,9 +851,8 @@ static void isolate_freepages(struct zone *zone,
* so that compact_finished() may detect this
*/
if (block_start_pfn < low_pfn)
- next_free_pfn = cc->migrate_pfn;
+ cc->free_pfn = cc->migrate_pfn;
- cc->free_pfn = next_free_pfn;
cc->nr_freepages = nr_freepages;
}
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/