summaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2017-02-22 18:44:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 19:41:29 -0500
commit7f354a548d1cb6bb01b6ee74aee9264aa152f1ec (patch)
tree37036eef9c0d3c708c2fcacebacaa138a884a68e /mm/compaction.c
parente57b9d8c5ad08ed8cbca7e51fe252719a2845394 (diff)
mm, compaction: add vmstats for kcompactd work
A "compact_daemon_wake" vmstat exists that represents the number of times kcompactd has woken up. This doesn't represent how much work it actually did, though. It's useful to understand how much compaction work is being done by kcompactd versus other methods such as direct compaction and explicitly triggered per-node (or system) compaction. This adds two new vmstats: "compact_daemon_migrate_scanned" and "compact_daemon_free_scanned" to represent the number of pages kcompactd has scanned as part of its migration scanner and freeing scanner, respectively. These values are still accounted for in the general "compact_migrate_scanned" and "compact_free_scanned" for compatibility. It could be argued that explicitly triggered compaction could also be tracked separately, and that could be added if others find it useful. Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1612071749390.69852@chino.kir.corp.google.com Signed-off-by: David Rientjes <rientjes@google.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Michal Hocko <mhocko@kernel.org> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index 949198d01260..c6178bbd3e04 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -548,7 +548,7 @@ isolate_fail:
548 if (blockpfn == end_pfn) 548 if (blockpfn == end_pfn)
549 update_pageblock_skip(cc, valid_page, total_isolated, false); 549 update_pageblock_skip(cc, valid_page, total_isolated, false);
550 550
551 count_compact_events(COMPACTFREE_SCANNED, nr_scanned); 551 cc->total_free_scanned += nr_scanned;
552 if (total_isolated) 552 if (total_isolated)
553 count_compact_events(COMPACTISOLATED, total_isolated); 553 count_compact_events(COMPACTISOLATED, total_isolated);
554 return total_isolated; 554 return total_isolated;
@@ -931,7 +931,7 @@ isolate_fail:
931 trace_mm_compaction_isolate_migratepages(start_pfn, low_pfn, 931 trace_mm_compaction_isolate_migratepages(start_pfn, low_pfn,
932 nr_scanned, nr_isolated); 932 nr_scanned, nr_isolated);
933 933
934 count_compact_events(COMPACTMIGRATE_SCANNED, nr_scanned); 934 cc->total_migrate_scanned += nr_scanned;
935 if (nr_isolated) 935 if (nr_isolated)
936 count_compact_events(COMPACTISOLATED, nr_isolated); 936 count_compact_events(COMPACTISOLATED, nr_isolated);
937 937
@@ -1631,6 +1631,9 @@ out:
1631 zone->compact_cached_free_pfn = free_pfn; 1631 zone->compact_cached_free_pfn = free_pfn;
1632 } 1632 }
1633 1633
1634 count_compact_events(COMPACTMIGRATE_SCANNED, cc->total_migrate_scanned);
1635 count_compact_events(COMPACTFREE_SCANNED, cc->total_free_scanned);
1636
1634 trace_mm_compaction_end(start_pfn, cc->migrate_pfn, 1637 trace_mm_compaction_end(start_pfn, cc->migrate_pfn,
1635 cc->free_pfn, end_pfn, sync, ret); 1638 cc->free_pfn, end_pfn, sync, ret);
1636 1639
@@ -1645,6 +1648,8 @@ static enum compact_result compact_zone_order(struct zone *zone, int order,
1645 struct compact_control cc = { 1648 struct compact_control cc = {
1646 .nr_freepages = 0, 1649 .nr_freepages = 0,
1647 .nr_migratepages = 0, 1650 .nr_migratepages = 0,
1651 .total_migrate_scanned = 0,
1652 .total_free_scanned = 0,
1648 .order = order, 1653 .order = order,
1649 .gfp_mask = gfp_mask, 1654 .gfp_mask = gfp_mask,
1650 .zone = zone, 1655 .zone = zone,
@@ -1757,6 +1762,8 @@ static void compact_node(int nid)
1757 struct zone *zone; 1762 struct zone *zone;
1758 struct compact_control cc = { 1763 struct compact_control cc = {
1759 .order = -1, 1764 .order = -1,
1765 .total_migrate_scanned = 0,
1766 .total_free_scanned = 0,
1760 .mode = MIGRATE_SYNC, 1767 .mode = MIGRATE_SYNC,
1761 .ignore_skip_hint = true, 1768 .ignore_skip_hint = true,
1762 .whole_zone = true, 1769 .whole_zone = true,
@@ -1883,6 +1890,8 @@ static void kcompactd_do_work(pg_data_t *pgdat)
1883 struct zone *zone; 1890 struct zone *zone;
1884 struct compact_control cc = { 1891 struct compact_control cc = {
1885 .order = pgdat->kcompactd_max_order, 1892 .order = pgdat->kcompactd_max_order,
1893 .total_migrate_scanned = 0,
1894 .total_free_scanned = 0,
1886 .classzone_idx = pgdat->kcompactd_classzone_idx, 1895 .classzone_idx = pgdat->kcompactd_classzone_idx,
1887 .mode = MIGRATE_SYNC_LIGHT, 1896 .mode = MIGRATE_SYNC_LIGHT,
1888 .ignore_skip_hint = true, 1897 .ignore_skip_hint = true,
@@ -1891,7 +1900,7 @@ static void kcompactd_do_work(pg_data_t *pgdat)
1891 }; 1900 };
1892 trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order, 1901 trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order,
1893 cc.classzone_idx); 1902 cc.classzone_idx);
1894 count_vm_event(KCOMPACTD_WAKE); 1903 count_compact_event(KCOMPACTD_WAKE);
1895 1904
1896 for (zoneid = 0; zoneid <= cc.classzone_idx; zoneid++) { 1905 for (zoneid = 0; zoneid <= cc.classzone_idx; zoneid++) {
1897 int status; 1906 int status;
@@ -1909,6 +1918,8 @@ static void kcompactd_do_work(pg_data_t *pgdat)
1909 1918
1910 cc.nr_freepages = 0; 1919 cc.nr_freepages = 0;
1911 cc.nr_migratepages = 0; 1920 cc.nr_migratepages = 0;
1921 cc.total_migrate_scanned = 0;
1922 cc.total_free_scanned = 0;
1912 cc.zone = zone; 1923 cc.zone = zone;
1913 INIT_LIST_HEAD(&cc.freepages); 1924 INIT_LIST_HEAD(&cc.freepages);
1914 INIT_LIST_HEAD(&cc.migratepages); 1925 INIT_LIST_HEAD(&cc.migratepages);
@@ -1927,6 +1938,11 @@ static void kcompactd_do_work(pg_data_t *pgdat)
1927 defer_compaction(zone, cc.order); 1938 defer_compaction(zone, cc.order);
1928 } 1939 }
1929 1940
1941 count_compact_events(KCOMPACTD_MIGRATE_SCANNED,
1942 cc.total_migrate_scanned);
1943 count_compact_events(KCOMPACTD_FREE_SCANNED,
1944 cc.total_free_scanned);
1945
1930 VM_BUG_ON(!list_empty(&cc.freepages)); 1946 VM_BUG_ON(!list_empty(&cc.freepages));
1931 VM_BUG_ON(!list_empty(&cc.migratepages)); 1947 VM_BUG_ON(!list_empty(&cc.migratepages));
1932 } 1948 }