drm/amd/powerplay: add helper function of smu_set_hard_freq_range
[linux-2.6-microblaze.git] / mm / compaction.c
index 3319e08..9febc8c 100644 (file)
@@ -1164,7 +1164,9 @@ static bool suitable_migration_target(struct compact_control *cc,
 static inline unsigned int
 freelist_scan_limit(struct compact_control *cc)
 {
-       return (COMPACT_CLUSTER_MAX >> cc->fast_search_fail) + 1;
+       unsigned short shift = BITS_PER_LONG - 1;
+
+       return (COMPACT_CLUSTER_MAX >> min(shift, cc->fast_search_fail)) + 1;
 }
 
 /*
@@ -1228,7 +1230,7 @@ fast_isolate_around(struct compact_control *cc, unsigned long pfn, unsigned long
 
        /* Pageblock boundaries */
        start_pfn = pageblock_start_pfn(pfn);
-       end_pfn = min(start_pfn + pageblock_nr_pages, zone_end_pfn(cc->zone));
+       end_pfn = min(pageblock_end_pfn(pfn), zone_end_pfn(cc->zone)) - 1;
 
        /* Scan before */
        if (start_pfn != pfn) {
@@ -1239,7 +1241,7 @@ fast_isolate_around(struct compact_control *cc, unsigned long pfn, unsigned long
 
        /* Scan after */
        start_pfn = pfn + nr_isolated;
-       if (start_pfn != end_pfn)
+       if (start_pfn < end_pfn)
                isolate_freepages_block(cc, &start_pfn, end_pfn, &cc->freepages, 1, false);
 
        /* Skip this pageblock in the future as it's full or nearly full */
@@ -1886,13 +1888,13 @@ static enum compact_result __compact_finished(struct compact_control *cc)
                bool can_steal;
 
                /* Job done if page is free of the right migratetype */
-               if (!list_empty(&area->free_list[migratetype]))
+               if (!free_area_empty(area, migratetype))
                        return COMPACT_SUCCESS;
 
 #ifdef CONFIG_CMA
                /* MIGRATE_MOVABLE can fallback on MIGRATE_CMA */
                if (migratetype == MIGRATE_MOVABLE &&
-                       !list_empty(&area->free_list[MIGRATE_CMA]))
+                       !free_area_empty(area, MIGRATE_CMA))
                        return COMPACT_SUCCESS;
 #endif
                /*