From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [RFC PATCH 3/3] mm/zsmalloc: change ZS_MAX_PAGES_PER_ZSPAGE
Date: Thu, 18 Feb 2016 12:02:36 +0900 [thread overview]
Message-ID: <1455764556-13979-4-git-send-email-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <1455764556-13979-1-git-send-email-sergey.senozhatsky@gmail.com>
ZS_MAX_PAGES_PER_ZSPAGE does not have to be order or 2. The existing
limit of 4 pages per zspage sets a tight limit on ->huge classes, which
results in increased memory wastage and consumption.
For example, on x86_64, PAGE_SHIFT 12, ->huge class_size range is
ZS_MAX_PAGES_PER_ZSPAGE ->huge classes size range
4 3280-4096
5 3424-4096
6 3520-4096
With bigger ZS_MAX_PAGES_PER_ZSPAGE we have less ->huge classes, because
some of the previously known as ->huge classes now have better chances to
form zspages that will waste less memory. This increases the density and
improves memory efficiency.
Example,
class_size 3328 with ZS_MAX_PAGES_PER_ZSPAGE=5 has pages_per_zspage 5
and max_objects 6, while with ZS_MAX_PAGES_PER_ZSPAGE=1 it had
pages_per_zspage 1 and max_objects 1. So now every 6th 3328-bytes object
stored by zram will not consume a new zspage (and order-0 page), but will
share an already allocated one.
TEST
====
Create a text file and do rounds of dd (one process). The amount of
copied data, its content and order are stable.
test script:
rm /tmp/test-file
for i in {1..200}; do
cat /media/dev/linux-mmots/mm/zsmalloc.c >> /tmp/test-file;
done
for i in {1..5}; do
umount /zram
rmmod zram
# create a 4G zram device, LZ0, multi stream, ext4 fs
./create-zram 4g
for k in {1..3}; do
j=1;
while [ $j -lt $((1024*1024)) ]; do
dd if=/tmp/test-file of=/zram/file-$k-$j bs=$j count=1 \
oflag=sync > /dev/null 2>&1
let j=$j+512
done
done
sync
cat /sys/block/zram0/mm_stat >> /tmp/zram-stat
umount /zram
rmmod zram
done
RESULTS
=======
cat /sys/block/zram0/mm_stat column 3 is zs_get_total_pages() << PAGE_SHIFT
BASE
3371106304 1714719722 1842778112 0 1842778112 16 0 1
3371098112 1714667024 1842831360 0 1842831360 16 0 1
3371110400 1714767329 1842716672 0 1842716672 16 0 1
3371110400 1714717615 1842601984 0 1842601984 16 0 1
3371106304 1714744207 1842135040 0 1842135040 16 0 1
ZS_MAX_PAGES_PER_ZSPAGE=5
3371094016 1714584459 1804095488 0 1804095488 16 0 1
3371102208 1714619140 1804660736 0 1804660736 16 0 1
3371114496 1714755452 1804316672 0 1804316672 16 0 1
3371081728 1714606179 1804800000 0 1804800000 16 0 1
3371122688 1714871507 1804361728 0 1804361728 16 0 1
ZS_MAX_PAGES_PER_ZSPAGE=6
3371114496 1714704275 1789206528 0 1789206528 16 0 1
3371102208 1714740225 1789259776 0 1789259776 16 0 1
3371102208 1714717465 1789071360 0 1789071360 16 0 1
3371110400 1714704079 1789194240 0 1789194240 16 0 1
3371085824 1714792954 1789308928 0 1789308928 16 0 1
So that's
around 36MB of saved space between BASE and ZS_MAX_PAGES_PER_ZSPAGE=5
and
around 51MB of saved space between BASE and ZS_MAX_PAGES_PER_ZSPAGE=6.
Set ZS_MAX_PAGES_PER_ZSPAGE to 6 for now.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
mm/zsmalloc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 61b1b35..0c9f117 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -74,11 +74,10 @@
#define ZS_ALIGN 8
/*
- * A single 'zspage' is composed of up to 2^N discontiguous 0-order (single)
- * pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N.
+ * A single 'zspage' is composed of up ZS_MAX_PAGES_PER_ZSPAGE discontiguous
+ * 0-order (single) pages.
*/
-#define ZS_MAX_ZSPAGE_ORDER 2
-#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER)
+#define ZS_MAX_PAGES_PER_ZSPAGE 6
#define ZS_HANDLE_SIZE (sizeof(unsigned long))
--
2.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-02-18 3:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 3:02 [RFC PATCH 0/3] mm/zsmalloc: increase density and reduce memory wastage Sergey Senozhatsky
2016-02-18 3:02 ` [RFC PATCH 1/3] mm/zsmalloc: introduce zs_get_huge_class_size_watermark() Sergey Senozhatsky
2016-02-18 3:02 ` [RFC PATCH 2/3] zram: use zs_get_huge_class_size_watermark() Sergey Senozhatsky
2016-02-18 3:02 ` Sergey Senozhatsky [this message]
2016-02-18 4:41 ` [RFC PATCH 3/3] mm/zsmalloc: change ZS_MAX_PAGES_PER_ZSPAGE Sergey Senozhatsky
2016-02-18 4:46 ` Sergey Senozhatsky
2016-02-18 5:03 ` Sergey Senozhatsky
2016-02-18 8:28 ` Joonsoo Kim
2016-02-18 9:55 ` Sergey Senozhatsky
2016-02-18 10:19 ` Sergey Senozhatsky
2016-02-19 1:19 ` Joonsoo Kim
2016-02-19 4:16 ` Sergey Senozhatsky
2016-02-19 4:19 ` Sergey Senozhatsky
2016-02-19 4:46 ` Sergey Senozhatsky
2016-02-19 5:38 ` Sergey Senozhatsky
2016-02-19 5:55 ` Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455764556-13979-4-git-send-email-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox