mm: show migration types in show_mem
[platform/adaptation/renesas_rcar/renesas_kernel.git] / mm / page_alloc.c
index 7bb35ac..dc018b4 100644 (file)
@@ -1405,7 +1405,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype)
 
        mt = get_pageblock_migratetype(page);
        if (unlikely(mt != MIGRATE_ISOLATE))
-               __mod_zone_freepage_state(zone, -(1UL << order), mt);
+               __mod_zone_freepage_state(zone, -(1UL << alloc_order), mt);
 
        if (alloc_order != order)
                expand(zone, page, alloc_order, order,
@@ -1422,7 +1422,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype)
                }
        }
 
-       return 1UL << order;
+       return 1UL << alloc_order;
 }
 
 /*
@@ -2416,8 +2416,9 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
                goto nopage;
 
 restart:
-       wake_all_kswapd(order, zonelist, high_zoneidx,
-                                       zone_idx(preferred_zone));
+       if (!(gfp_mask & __GFP_NO_KSWAPD))
+               wake_all_kswapd(order, zonelist, high_zoneidx,
+                                               zone_idx(preferred_zone));
 
        /*
         * OK, we're below the kswapd watermark and have kicked background
@@ -2494,7 +2495,7 @@ rebalance:
         * system then fail the allocation instead of entering direct reclaim.
         */
        if ((deferred_compaction || contended_compaction) &&
-           (gfp_mask & (__GFP_MOVABLE|__GFP_REPEAT)) == __GFP_MOVABLE)
+                                               (gfp_mask & __GFP_NO_KSWAPD))
                goto nopage;
 
        /* Try direct reclaim and then allocating */
@@ -2876,6 +2877,31 @@ out:
 
 #define K(x) ((x) << (PAGE_SHIFT-10))
 
+static void show_migration_types(unsigned char type)
+{
+       static const char types[MIGRATE_TYPES] = {
+               [MIGRATE_UNMOVABLE]     = 'U',
+               [MIGRATE_RECLAIMABLE]   = 'E',
+               [MIGRATE_MOVABLE]       = 'M',
+               [MIGRATE_RESERVE]       = 'R',
+#ifdef CONFIG_CMA
+               [MIGRATE_CMA]           = 'C',
+#endif
+               [MIGRATE_ISOLATE]       = 'I',
+       };
+       char tmp[MIGRATE_TYPES + 1];
+       char *p = tmp;
+       int i;
+
+       for (i = 0; i < MIGRATE_TYPES; i++) {
+               if (type & (1 << i))
+                       *p++ = types[i];
+       }
+
+       *p = '\0';
+       printk("(%s) ", tmp);
+}
+
 /*
  * Show free area list (used inside shift_scroll-lock stuff)
  * We also calculate the percentage fragmentation. We do this by counting the
@@ -3004,6 +3030,7 @@ void show_free_areas(unsigned int filter)
 
        for_each_populated_zone(zone) {
                unsigned long nr[MAX_ORDER], flags, order, total = 0;
+               unsigned char types[MAX_ORDER];
 
                if (skip_free_areas_node(filter, zone_to_nid(zone)))
                        continue;
@@ -3012,12 +3039,24 @@ void show_free_areas(unsigned int filter)
 
                spin_lock_irqsave(&zone->lock, flags);
                for (order = 0; order < MAX_ORDER; order++) {
-                       nr[order] = zone->free_area[order].nr_free;
+                       struct free_area *area = &zone->free_area[order];
+                       int type;
+
+                       nr[order] = area->nr_free;
                        total += nr[order] << order;
+
+                       types[order] = 0;
+                       for (type = 0; type < MIGRATE_TYPES; type++) {
+                               if (!list_empty(&area->free_list[type]))
+                                       types[order] |= 1 << type;
+                       }
                }
                spin_unlock_irqrestore(&zone->lock, flags);
-               for (order = 0; order < MAX_ORDER; order++)
+               for (order = 0; order < MAX_ORDER; order++) {
                        printk("%lu*%lukB ", nr[order], K(1UL) << order);
+                       if (nr[order])
+                               show_migration_types(types[order]);
+               }
                printk("= %lukB\n", K(total));
        }