aboutsummaryrefslogtreecommitdiffstats
path: root/mm/zsmalloc.c
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2015-09-08 18:04:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-08 18:35:28 -0400
commit860c707dca155a56dfa115ddd6c00959296144a6 (patch)
treee46b5110aa65f7b75ed8c8b6e5fa97367f10c05a /mm/zsmalloc.c
parent7d3f3938236b4bb878214e6791e76fd8409bdeee (diff)
zsmalloc: account the number of compacted pages
Compaction returns back to zram the number of migrated objects, which is quite uninformative -- we have objects of different sizes so user space cannot obtain any valuable data from that number. Change compaction to operate in terms of pages and return back to compaction issuer the number of pages that were freed during compaction. So from now on we will export more meaningful value in zram<id>/mm_stat -- the number of freed (compacted) pages. This requires: (a) a rename of `num_migrated' to 'pages_compacted' (b) a internal API change -- return first_page's fullness_group from putback_zspage(), so we know when putback_zspage() did free_zspage(). It helps us to account compaction stats correctly. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/zsmalloc.c')
-rw-r--r--mm/zsmalloc.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 8f76d8875aca..b7b4a5612ec7 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1579,8 +1579,6 @@ struct zs_compact_control {
1579 /* Starting object index within @s_page which used for live object 1579 /* Starting object index within @s_page which used for live object
1580 * in the subpage. */ 1580 * in the subpage. */
1581 int index; 1581 int index;
1582 /* How many of objects were migrated */
1583 int nr_migrated;
1584}; 1582};
1585 1583
1586static int migrate_zspage(struct zs_pool *pool, struct size_class *class, 1584static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
@@ -1617,7 +1615,6 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
1617 record_obj(handle, free_obj); 1615 record_obj(handle, free_obj);
1618 unpin_tag(handle); 1616 unpin_tag(handle);
1619 obj_free(pool, class, used_obj); 1617 obj_free(pool, class, used_obj);
1620 cc->nr_migrated++;
1621 } 1618 }
1622 1619
1623 /* Remember last position in this iteration */ 1620 /* Remember last position in this iteration */
@@ -1643,8 +1640,17 @@ static struct page *isolate_target_page(struct size_class *class)
1643 return page; 1640 return page;
1644} 1641}
1645 1642
1646static void putback_zspage(struct zs_pool *pool, struct size_class *class, 1643/*
1647 struct page *first_page) 1644 * putback_zspage - add @first_page into right class's fullness list
1645 * @pool: target pool
1646 * @class: destination class
1647 * @first_page: target page
1648 *
1649 * Return @fist_page's fullness_group
1650 */
1651static enum fullness_group putback_zspage(struct zs_pool *pool,
1652 struct size_class *class,
1653 struct page *first_page)
1648{ 1654{
1649 enum fullness_group fullness; 1655 enum fullness_group fullness;
1650 1656
@@ -1662,6 +1668,8 @@ static void putback_zspage(struct zs_pool *pool, struct size_class *class,
1662 1668
1663 free_zspage(first_page); 1669 free_zspage(first_page);
1664 } 1670 }
1671
1672 return fullness;
1665} 1673}
1666 1674
1667static struct page *isolate_source_page(struct size_class *class) 1675static struct page *isolate_source_page(struct size_class *class)
@@ -1704,7 +1712,6 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
1704 struct page *src_page; 1712 struct page *src_page;
1705 struct page *dst_page = NULL; 1713 struct page *dst_page = NULL;
1706 1714
1707 cc.nr_migrated = 0;
1708 spin_lock(&class->lock); 1715 spin_lock(&class->lock);
1709 while ((src_page = isolate_source_page(class))) { 1716 while ((src_page = isolate_source_page(class))) {
1710 1717
@@ -1733,7 +1740,9 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
1733 break; 1740 break;
1734 1741
1735 putback_zspage(pool, class, dst_page); 1742 putback_zspage(pool, class, dst_page);
1736 putback_zspage(pool, class, src_page); 1743 if (putback_zspage(pool, class, src_page) == ZS_EMPTY)
1744 pool->stats.pages_compacted +=
1745 get_pages_per_zspage(class->size);
1737 spin_unlock(&class->lock); 1746 spin_unlock(&class->lock);
1738 cond_resched(); 1747 cond_resched();
1739 spin_lock(&class->lock); 1748 spin_lock(&class->lock);
@@ -1742,8 +1751,6 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
1742 if (src_page) 1751 if (src_page)
1743 putback_zspage(pool, class, src_page); 1752 putback_zspage(pool, class, src_page);
1744 1753
1745 pool->stats.num_migrated += cc.nr_migrated;
1746
1747 spin_unlock(&class->lock); 1754 spin_unlock(&class->lock);
1748} 1755}
1749 1756
@@ -1761,7 +1768,7 @@ unsigned long zs_compact(struct zs_pool *pool)
1761 __zs_compact(pool, class); 1768 __zs_compact(pool, class);
1762 } 1769 }
1763 1770
1764 return pool->stats.num_migrated; 1771 return pool->stats.pages_compacted;
1765} 1772}
1766EXPORT_SYMBOL_GPL(zs_compact); 1773EXPORT_SYMBOL_GPL(zs_compact);
1767 1774