* [PATCH 0/2] zsmalloc: minor documentation updates
@ 2023-03-25 2:46 Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 1/2] zsmalloc: document new fullness grouping Sergey Senozhatsky
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-03-25 2:46 UTC (permalink / raw)
To: Andrew Morton, Minchan Kim; +Cc: linux-kernel, linux-mm, Sergey Senozhatsky
Hi,
Two minor patches that bring zsmalloc documentation up to date.
Sergey Senozhatsky (2):
zsmalloc: document new fullness grouping
zsmalloc: document freeable stats
Documentation/mm/zsmalloc.rst | 135 +++++++++++++++++++---------------
1 file changed, 76 insertions(+), 59 deletions(-)
--
2.40.0.348.gf938b09366-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] zsmalloc: document new fullness grouping
2023-03-25 2:46 [PATCH 0/2] zsmalloc: minor documentation updates Sergey Senozhatsky
@ 2023-03-25 2:46 ` Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 2/2] zsmalloc: document freeable stats Sergey Senozhatsky
2023-03-25 19:54 ` [PATCH 0/2] zsmalloc: minor documentation updates Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-03-25 2:46 UTC (permalink / raw)
To: Andrew Morton, Minchan Kim; +Cc: linux-kernel, linux-mm, Sergey Senozhatsky
Update documentation and reflect new zspages fullness grouping
(we don't use almost_empty and almost_full anymore).
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
Documentation/mm/zsmalloc.rst | 133 +++++++++++++++++++---------------
1 file changed, 74 insertions(+), 59 deletions(-)
diff --git a/Documentation/mm/zsmalloc.rst b/Documentation/mm/zsmalloc.rst
index 64d127bfc221..3c6bf639887f 100644
--- a/Documentation/mm/zsmalloc.rst
+++ b/Documentation/mm/zsmalloc.rst
@@ -39,13 +39,12 @@ With CONFIG_ZSMALLOC_STAT, we could see zsmalloc internal information via
# cat /sys/kernel/debug/zsmalloc/zram0/classes
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage
+ class size 10% 20% 30% 40% 50% 60% 70% 80% 90% 99% 100% obj_allocated obj_used pages_used pages_per_zspage freeable
...
...
- 9 176 0 1 186 129 8 4
- 10 192 1 0 2880 2872 135 3
- 11 208 0 1 819 795 42 2
- 12 224 0 1 219 159 12 4
+ 30 512 0 12 4 1 0 1 0 0 1 0 414 3464 3346 433 1 14
+ 31 528 2 7 2 2 1 0 1 0 0 2 117 4154 3793 536 4 44
+ 32 544 6 3 4 1 2 1 0 0 0 1 260 4170 3965 556 2 26
...
...
@@ -54,10 +53,28 @@ class
index
size
object size zspage stores
-almost_empty
- the number of ZS_ALMOST_EMPTY zspages(see below)
-almost_full
- the number of ZS_ALMOST_FULL zspages(see below)
+10%
+ the number of zspages with usage ratio less than 10% (see below)
+20%
+ the number of zspages with usage ratio between 10% and 20%
+30%
+ the number of zspages with usage ratio between 20% and 30%
+40%
+ the number of zspages with usage ratio between 30% and 40%
+50%
+ the number of zspages with usage ratio between 40% and 50%
+60%
+ the number of zspages with usage ratio between 50% and 60%
+70%
+ the number of zspages with usage ratio between 60% and 70%
+80%
+ the number of zspages with usage ratio between 70% and 80%
+90%
+ the number of zspages with usage ratio between 80% and 90%
+99%
+ the number of zspages with usage ratio between 90% and 99%
+100%
+ the number of zspages with usage ratio 100%
obj_allocated
the number of objects allocated
obj_used
@@ -67,18 +84,11 @@ pages_used
pages_per_zspage
the number of 0-order pages to make a zspage
-We assign a zspage to ZS_ALMOST_EMPTY fullness group when n <= N / f, where
-
-* n = number of allocated objects
-* N = total number of objects zspage can store
-* f = fullness_threshold_frac(ie, 4 at the moment)
-
-Similarly, we assign zspage to:
-
-* ZS_ALMOST_FULL when n > N / f
-* ZS_EMPTY when n == 0
-* ZS_FULL when n == N
-
+Each zspage maintains inuse counter which keeps track of the number of
+objects stored in the zspage. The inuse counter determines the zspage's
+"fullness group" which is calculated as the ratio of the "inuse" objects to
+the total number of objects the zspage can hold (objs_per_zspage). The
+closer the inuse counter is to objs_per_zspage, the better.
Internals
=========
@@ -94,10 +104,10 @@ of objects that each zspage can store.
For instance, consider the following size classes:::
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
+ class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
...
- 94 1536 0 0 0 0 0 3 0
- 100 1632 0 0 0 0 0 2 0
+ 94 1536 0 .... 0 0 0 0 3 0
+ 100 1632 0 .... 0 0 0 0 2 0
...
@@ -134,10 +144,11 @@ reduces memory wastage.
Let's take a closer look at the bottom of `/sys/kernel/debug/zsmalloc/zramX/classes`:::
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
+ class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
+
...
- 202 3264 0 0 0 0 0 4 0
- 254 4096 0 0 0 0 0 1 0
+ 202 3264 0 .. 0 0 0 0 4 0
+ 254 4096 0 .. 0 0 0 0 1 0
...
Size class #202 stores objects of size 3264 bytes and has a maximum of 4 pages
@@ -151,40 +162,42 @@ efficient storage of large objects.
For zspage chain size of 8, huge class watermark becomes 3632 bytes:::
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
+ class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
+
...
- 202 3264 0 0 0 0 0 4 0
- 211 3408 0 0 0 0 0 5 0
- 217 3504 0 0 0 0 0 6 0
- 222 3584 0 0 0 0 0 7 0
- 225 3632 0 0 0 0 0 8 0
- 254 4096 0 0 0 0 0 1 0
+ 202 3264 0 .. 0 0 0 0 4 0
+ 211 3408 0 .. 0 0 0 0 5 0
+ 217 3504 0 .. 0 0 0 0 6 0
+ 222 3584 0 .. 0 0 0 0 7 0
+ 225 3632 0 .. 0 0 0 0 8 0
+ 254 4096 0 .. 0 0 0 0 1 0
...
For zspage chain size of 16, huge class watermark becomes 3840 bytes:::
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
+ class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
+
...
- 202 3264 0 0 0 0 0 4 0
- 206 3328 0 0 0 0 0 13 0
- 207 3344 0 0 0 0 0 9 0
- 208 3360 0 0 0 0 0 14 0
- 211 3408 0 0 0 0 0 5 0
- 212 3424 0 0 0 0 0 16 0
- 214 3456 0 0 0 0 0 11 0
- 217 3504 0 0 0 0 0 6 0
- 219 3536 0 0 0 0 0 13 0
- 222 3584 0 0 0 0 0 7 0
- 223 3600 0 0 0 0 0 15 0
- 225 3632 0 0 0 0 0 8 0
- 228 3680 0 0 0 0 0 9 0
- 230 3712 0 0 0 0 0 10 0
- 232 3744 0 0 0 0 0 11 0
- 234 3776 0 0 0 0 0 12 0
- 235 3792 0 0 0 0 0 13 0
- 236 3808 0 0 0 0 0 14 0
- 238 3840 0 0 0 0 0 15 0
- 254 4096 0 0 0 0 0 1 0
+ 202 3264 0 .. 0 0 0 0 4 0
+ 206 3328 0 .. 0 0 0 0 13 0
+ 207 3344 0 .. 0 0 0 0 9 0
+ 208 3360 0 .. 0 0 0 0 14 0
+ 211 3408 0 .. 0 0 0 0 5 0
+ 212 3424 0 .. 0 0 0 0 16 0
+ 214 3456 0 .. 0 0 0 0 11 0
+ 217 3504 0 .. 0 0 0 0 6 0
+ 219 3536 0 .. 0 0 0 0 13 0
+ 222 3584 0 .. 0 0 0 0 7 0
+ 223 3600 0 .. 0 0 0 0 15 0
+ 225 3632 0 .. 0 0 0 0 8 0
+ 228 3680 0 .. 0 0 0 0 9 0
+ 230 3712 0 .. 0 0 0 0 10 0
+ 232 3744 0 .. 0 0 0 0 11 0
+ 234 3776 0 .. 0 0 0 0 12 0
+ 235 3792 0 .. 0 0 0 0 13 0
+ 236 3808 0 .. 0 0 0 0 14 0
+ 238 3840 0 .. 0 0 0 0 15 0
+ 254 4096 0 .. 0 0 0 0 1 0
...
Overall the combined zspage chain size effect on zsmalloc pool configuration:::
@@ -214,9 +227,10 @@ zram as a build artifacts storage (Linux kernel compilation).
zsmalloc classes stats:::
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
+ class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
+
...
- Total 13 51 413836 412973 159955 3
+ Total 13 .. 51 413836 412973 159955 3
zram mm_stat:::
@@ -227,9 +241,10 @@ zram as a build artifacts storage (Linux kernel compilation).
zsmalloc classes stats:::
- class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
+ class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
+
...
- Total 18 87 414852 412978 156666 0
+ Total 18 .. 87 414852 412978 156666 0
zram mm_stat:::
--
2.40.0.348.gf938b09366-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] zsmalloc: document freeable stats
2023-03-25 2:46 [PATCH 0/2] zsmalloc: minor documentation updates Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 1/2] zsmalloc: document new fullness grouping Sergey Senozhatsky
@ 2023-03-25 2:46 ` Sergey Senozhatsky
2023-03-25 19:54 ` [PATCH 0/2] zsmalloc: minor documentation updates Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-03-25 2:46 UTC (permalink / raw)
To: Andrew Morton, Minchan Kim; +Cc: linux-kernel, linux-mm, Sergey Senozhatsky
When freeable class stat was added to classes file (back in 2016)
we forgot to update zsmalloc documentation. Fix that.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
Documentation/mm/zsmalloc.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/mm/zsmalloc.rst b/Documentation/mm/zsmalloc.rst
index 3c6bf639887f..a3c26d587752 100644
--- a/Documentation/mm/zsmalloc.rst
+++ b/Documentation/mm/zsmalloc.rst
@@ -83,6 +83,8 @@ pages_used
the number of pages allocated for the class
pages_per_zspage
the number of 0-order pages to make a zspage
+freeable
+ the approximate number of pages class compaction can free
Each zspage maintains inuse counter which keeps track of the number of
objects stored in the zspage. The inuse counter determines the zspage's
--
2.40.0.348.gf938b09366-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] zsmalloc: minor documentation updates
2023-03-25 2:46 [PATCH 0/2] zsmalloc: minor documentation updates Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 1/2] zsmalloc: document new fullness grouping Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 2/2] zsmalloc: document freeable stats Sergey Senozhatsky
@ 2023-03-25 19:54 ` Andrew Morton
2023-03-26 1:21 ` Sergey Senozhatsky
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2023-03-25 19:54 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Minchan Kim, linux-kernel, linux-mm
On Sat, 25 Mar 2023 11:46:29 +0900 Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
> Two minor patches that bring zsmalloc documentation up to date.
>
It would be best to keep the in-kernel documentation accurate
for the kernel version with which it is shipped. So can you
please suggest a Fixes: for these two?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] zsmalloc: minor documentation updates
2023-03-25 19:54 ` [PATCH 0/2] zsmalloc: minor documentation updates Andrew Morton
@ 2023-03-26 1:21 ` Sergey Senozhatsky
0 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-03-26 1:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Sergey Senozhatsky, Minchan Kim, linux-kernel, linux-mm
On (23/03/25 12:54), Andrew Morton wrote:
> On Sat, 25 Mar 2023 11:46:29 +0900 Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
>
> > Two minor patches that bring zsmalloc documentation up to date.
> >
>
> It would be best to keep the in-kernel documentation accurate
> for the kernel version with which it is shipped. So can you
> please suggest a Fixes: for these two?
Sure.
For zsmalloc-document-new-fullness-grouping.patch it's not very trivial,
since the patch covers several internal zsmalloc changes: new fullness
grouping and new zsmalloc classes stats fullness format. I think it's OK
to just say that it fixes patch that converted zsmalloc classes stats to
new format.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-26 1:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-25 2:46 [PATCH 0/2] zsmalloc: minor documentation updates Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 1/2] zsmalloc: document new fullness grouping Sergey Senozhatsky
2023-03-25 2:46 ` [PATCH 2/2] zsmalloc: document freeable stats Sergey Senozhatsky
2023-03-25 19:54 ` [PATCH 0/2] zsmalloc: minor documentation updates Andrew Morton
2023-03-26 1:21 ` Sergey Senozhatsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox