All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] mm/compaction: fix invalid free_pfn and compact_cached_free_pfn
@ 2016-02-04  6:19 ` Joonsoo Kim
  0 siblings, 0 replies; 30+ messages in thread
From: Joonsoo Kim @ 2016-02-04  6:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, Aaron Lu, Mel Gorman, Rik van Riel,
	David Rientjes, linux-kernel, linux-mm, Joonsoo Kim

free_pfn and compact_cached_free_pfn are the pointer that remember
restart position of freepage scanner. When they are reset or invalid,
we set them to zone_end_pfn because freepage scanner works in reverse
direction. But, because zone range is defined as [zone_start_pfn,
zone_end_pfn), zone_end_pfn is invalid to access. Therefore, we should
not store it to free_pfn and compact_cached_free_pfn. Instead, we need
to store zone_end_pfn - 1 to them. There is one more thing we should
consider. Freepage scanner scan reversely by pageblock unit. If free_pfn
and compact_cached_free_pfn are set to middle of pageblock, it regards
that sitiation as that it already scans front part of pageblock so we
lose opportunity to scan there. To fix-up, this patch do round_down()
to guarantee that reset position will be pageblock aligned.

Note that thanks to the current pageblock_pfn_to_page() implementation,
actual access to zone_end_pfn doesn't happen until now. But, following
patch will change pageblock_pfn_to_page() so this patch is needed
from now on.

Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/compaction.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 585de54..56fa321 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -200,7 +200,8 @@ static void reset_cached_positions(struct zone *zone)
 {
 	zone->compact_cached_migrate_pfn[0] = zone->zone_start_pfn;
 	zone->compact_cached_migrate_pfn[1] = zone->zone_start_pfn;
-	zone->compact_cached_free_pfn = zone_end_pfn(zone);
+	zone->compact_cached_free_pfn =
+			round_down(zone_end_pfn(zone) - 1, pageblock_nr_pages);
 }
 
 /*
@@ -1371,11 +1372,11 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
 	 */
 	cc->migrate_pfn = zone->compact_cached_migrate_pfn[sync];
 	cc->free_pfn = zone->compact_cached_free_pfn;
-	if (cc->free_pfn < start_pfn || cc->free_pfn > end_pfn) {
-		cc->free_pfn = end_pfn & ~(pageblock_nr_pages-1);
+	if (cc->free_pfn < start_pfn || cc->free_pfn >= end_pfn) {
+		cc->free_pfn = round_down(end_pfn - 1, pageblock_nr_pages);
 		zone->compact_cached_free_pfn = cc->free_pfn;
 	}
-	if (cc->migrate_pfn < start_pfn || cc->migrate_pfn > end_pfn) {
+	if (cc->migrate_pfn < start_pfn || cc->migrate_pfn >= end_pfn) {
 		cc->migrate_pfn = start_pfn;
 		zone->compact_cached_migrate_pfn[0] = cc->migrate_pfn;
 		zone->compact_cached_migrate_pfn[1] = cc->migrate_pfn;
-- 
1.9.1

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

end of thread, other threads:[~2016-02-15 14:24 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04  6:19 [PATCH v2 1/3] mm/compaction: fix invalid free_pfn and compact_cached_free_pfn Joonsoo Kim
2016-02-04  6:19 ` Joonsoo Kim
2016-02-04  6:19 ` [PATCH v2 2/3] mm/compaction: pass only pageblock aligned range to pageblock_pfn_to_page Joonsoo Kim
2016-02-04  6:19   ` Joonsoo Kim
2016-02-10 12:52   ` Vlastimil Babka
2016-02-10 12:52     ` Vlastimil Babka
2016-02-04  6:19 ` [PATCH v2 3/3] mm/compaction: speed up pageblock_pfn_to_page() when zone is contiguous Joonsoo Kim
2016-02-04  6:19   ` Joonsoo Kim
2016-02-05  0:49   ` Andrew Morton
2016-02-05  0:49     ` Andrew Morton
2016-02-05 16:11     ` Joonsoo Kim
2016-02-05 16:11       ` Joonsoo Kim
2016-02-09 17:58       ` Vlastimil Babka
2016-02-09 17:58         ` Vlastimil Babka
2016-02-09 20:53         ` Andrew Morton
2016-02-09 20:53           ` Andrew Morton
2016-02-10 13:42           ` Vlastimil Babka
2016-02-10 13:42             ` Vlastimil Babka
2016-02-10 18:58             ` Andrew Morton
2016-02-10 18:58               ` Andrew Morton
2016-02-11  1:58               ` Joonsoo Kim
2016-02-11  1:58                 ` Joonsoo Kim
2016-02-14 10:21       ` zhong jiang
2016-02-14 10:21         ` zhong jiang
2016-02-15  2:42         ` Joonsoo Kim
2016-02-15  2:42           ` Joonsoo Kim
2016-02-15 10:06           ` Xishi Qiu
2016-02-15 10:06             ` Xishi Qiu
2016-02-15 14:24             ` Joonsoo Kim
2016-02-15 14:24               ` Joonsoo Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.