mm: mm_event: remove get/put_online_cpus call
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / mm / compaction.c
index 85395dc6eb137f128961a4429ed69b8e030ca816..c4fd6f95734854152411b7f1dcb5e9683e009165 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/page_owner.h>
+#include <linux/psi.h>
 #include "internal.h"
 
 #ifdef CONFIG_COMPACTION
@@ -1017,8 +1018,8 @@ static bool suitable_migration_target(struct compact_control *cc,
        if (cc->ignore_block_suitable)
                return true;
 
-       /* If the block is MIGRATE_MOVABLE or MIGRATE_CMA, allow migration */
-       if (is_migrate_movable(get_pageblock_migratetype(page)))
+       /* If the block is MIGRATE_MOVABLE, allow migration */
+       if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE)
                return true;
 
        /* Otherwise skip the block */
@@ -1338,12 +1339,6 @@ static enum compact_result __compact_finished(struct zone *zone,
                if (!list_empty(&area->free_list[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]))
-                       return COMPACT_SUCCESS;
-#endif
                /*
                 * Job done if allocation would steal freepages from
                 * other migratetype buddy lists.
@@ -1427,14 +1422,12 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
         * if compaction succeeds.
         * For costly orders, we require low watermark instead of min for
         * compaction to proceed to increase its chances.
-        * ALLOC_CMA is used, as pages in CMA pageblocks are considered
-        * suitable migration targets
         */
        watermark = (order > PAGE_ALLOC_COSTLY_ORDER) ?
                                low_wmark_pages(zone) : min_wmark_pages(zone);
        watermark += compact_gap(order);
        if (!__zone_watermark_ok(zone, 0, watermark, classzone_idx,
-                                               ALLOC_CMA, wmark_target))
+                                               0, wmark_target))
                return COMPACT_SKIPPED;
 
        return COMPACT_CONTINUE;
@@ -1516,6 +1509,7 @@ static enum compact_result compact_zone(struct zone *zone, struct compact_contro
        unsigned long start_pfn = zone->zone_start_pfn;
        unsigned long end_pfn = zone_end_pfn(zone);
        const bool sync = cc->mode != MIGRATE_ASYNC;
+       ktime_t event_ts;
 
        cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
        ret = compaction_suitable(zone, cc->order, cc->alloc_flags,
@@ -1562,6 +1556,7 @@ static enum compact_result compact_zone(struct zone *zone, struct compact_contro
 
        cc->last_migrated_pfn = 0;
 
+       mm_event_start(&event_ts);
        trace_mm_compaction_begin(start_pfn, cc->migrate_pfn,
                                cc->free_pfn, end_pfn, sync);
 
@@ -1646,6 +1641,7 @@ check_drain:
        }
 
 out:
+       mm_event_end(MM_COMPACTION, event_ts);
        /*
         * Release free pages and update where the free scanner should restart,
         * so we don't leave any returned pages behind in the next attempt.
@@ -1727,6 +1723,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
        struct zoneref *z;
        struct zone *zone;
        enum compact_result rc = COMPACT_SKIPPED;
+       ktime_t event_ts;
 
        /*
         * Check if the GFP flags allow compaction - GFP_NOIO is really
@@ -1735,6 +1732,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
        if (!may_perform_io)
                return COMPACT_SKIPPED;
 
+       mm_event_start(&event_ts);
        trace_mm_compaction_try_to_compact_pages(order, gfp_mask, prio);
 
        /* Compact each zone in the list */
@@ -1784,6 +1782,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
                        break;
        }
 
+       mm_event_end(MM_COMPACTION, event_ts);
        return rc;
 }
 
@@ -2038,11 +2037,15 @@ static int kcompactd(void *p)
        pgdat->kcompactd_classzone_idx = pgdat->nr_zones - 1;
 
        while (!kthread_should_stop()) {
+               unsigned long pflags;
+
                trace_mm_compaction_kcompactd_sleep(pgdat->node_id);
                wait_event_freezable(pgdat->kcompactd_wait,
                                kcompactd_work_requested(pgdat));
 
+               psi_memstall_enter(&pflags);
                kcompactd_do_work(pgdat);
+               psi_memstall_leave(&pflags);
        }
 
        return 0;