Skip to content

Commit 119b57e

Browse files
sergey-senozhatskyakpm00
authored andcommitted
zsmalloc: document new fullness grouping
Patch series "zsmalloc: minor documentation updates". Two minor patches that bring zsmalloc documentation up to date. This patch (of 2): Update documentation and reflect new zspages fullness grouping (we don't use almost_empty and almost_full anymore). Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sergey Senozhatsky <[email protected]> Fixes: 67e157e ("zsmalloc: show per fullness group class stats") Cc: Minchan Kim <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f76b3a3 commit 119b57e

File tree

1 file changed

+74
-59
lines changed

1 file changed

+74
-59
lines changed

Documentation/mm/zsmalloc.rst

+74-59
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ With CONFIG_ZSMALLOC_STAT, we could see zsmalloc internal information via
3939

4040
# cat /sys/kernel/debug/zsmalloc/zram0/classes
4141

42-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage
42+
class size 10% 20% 30% 40% 50% 60% 70% 80% 90% 99% 100% obj_allocated obj_used pages_used pages_per_zspage freeable
4343
...
4444
...
45-
9 176 0 1 186 129 8 4
46-
10 192 1 0 2880 2872 135 3
47-
11 208 0 1 819 795 42 2
48-
12 224 0 1 219 159 12 4
45+
30 512 0 12 4 1 0 1 0 0 1 0 414 3464 3346 433 1 14
46+
31 528 2 7 2 2 1 0 1 0 0 2 117 4154 3793 536 4 44
47+
32 544 6 3 4 1 2 1 0 0 0 1 260 4170 3965 556 2 26
4948
...
5049
...
5150

@@ -54,10 +53,28 @@ class
5453
index
5554
size
5655
object size zspage stores
57-
almost_empty
58-
the number of ZS_ALMOST_EMPTY zspages(see below)
59-
almost_full
60-
the number of ZS_ALMOST_FULL zspages(see below)
56+
10%
57+
the number of zspages with usage ratio less than 10% (see below)
58+
20%
59+
the number of zspages with usage ratio between 10% and 20%
60+
30%
61+
the number of zspages with usage ratio between 20% and 30%
62+
40%
63+
the number of zspages with usage ratio between 30% and 40%
64+
50%
65+
the number of zspages with usage ratio between 40% and 50%
66+
60%
67+
the number of zspages with usage ratio between 50% and 60%
68+
70%
69+
the number of zspages with usage ratio between 60% and 70%
70+
80%
71+
the number of zspages with usage ratio between 70% and 80%
72+
90%
73+
the number of zspages with usage ratio between 80% and 90%
74+
99%
75+
the number of zspages with usage ratio between 90% and 99%
76+
100%
77+
the number of zspages with usage ratio 100%
6178
obj_allocated
6279
the number of objects allocated
6380
obj_used
@@ -67,18 +84,11 @@ pages_used
6784
pages_per_zspage
6885
the number of 0-order pages to make a zspage
6986

70-
We assign a zspage to ZS_ALMOST_EMPTY fullness group when n <= N / f, where
71-
72-
* n = number of allocated objects
73-
* N = total number of objects zspage can store
74-
* f = fullness_threshold_frac(ie, 4 at the moment)
75-
76-
Similarly, we assign zspage to:
77-
78-
* ZS_ALMOST_FULL when n > N / f
79-
* ZS_EMPTY when n == 0
80-
* ZS_FULL when n == N
81-
87+
Each zspage maintains inuse counter which keeps track of the number of
88+
objects stored in the zspage. The inuse counter determines the zspage's
89+
"fullness group" which is calculated as the ratio of the "inuse" objects to
90+
the total number of objects the zspage can hold (objs_per_zspage). The
91+
closer the inuse counter is to objs_per_zspage, the better.
8292

8393
Internals
8494
=========
@@ -94,10 +104,10 @@ of objects that each zspage can store.
94104

95105
For instance, consider the following size classes:::
96106

97-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
107+
class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
98108
...
99-
94 1536 0 0 0 0 0 3 0
100-
100 1632 0 0 0 0 0 2 0
109+
94 1536 0 .... 0 0 0 0 3 0
110+
100 1632 0 .... 0 0 0 0 2 0
101111
...
102112

103113

@@ -134,10 +144,11 @@ reduces memory wastage.
134144

135145
Let's take a closer look at the bottom of `/sys/kernel/debug/zsmalloc/zramX/classes`:::
136146

137-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
147+
class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
148+
138149
...
139-
202 3264 0 0 0 0 0 4 0
140-
254 4096 0 0 0 0 0 1 0
150+
202 3264 0 .. 0 0 0 0 4 0
151+
254 4096 0 .. 0 0 0 0 1 0
141152
...
142153

143154
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.
151162

152163
For zspage chain size of 8, huge class watermark becomes 3632 bytes:::
153164

154-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
165+
class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
166+
155167
...
156-
202 3264 0 0 0 0 0 4 0
157-
211 3408 0 0 0 0 0 5 0
158-
217 3504 0 0 0 0 0 6 0
159-
222 3584 0 0 0 0 0 7 0
160-
225 3632 0 0 0 0 0 8 0
161-
254 4096 0 0 0 0 0 1 0
168+
202 3264 0 .. 0 0 0 0 4 0
169+
211 3408 0 .. 0 0 0 0 5 0
170+
217 3504 0 .. 0 0 0 0 6 0
171+
222 3584 0 .. 0 0 0 0 7 0
172+
225 3632 0 .. 0 0 0 0 8 0
173+
254 4096 0 .. 0 0 0 0 1 0
162174
...
163175

164176
For zspage chain size of 16, huge class watermark becomes 3840 bytes:::
165177

166-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
178+
class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
179+
167180
...
168-
202 3264 0 0 0 0 0 4 0
169-
206 3328 0 0 0 0 0 13 0
170-
207 3344 0 0 0 0 0 9 0
171-
208 3360 0 0 0 0 0 14 0
172-
211 3408 0 0 0 0 0 5 0
173-
212 3424 0 0 0 0 0 16 0
174-
214 3456 0 0 0 0 0 11 0
175-
217 3504 0 0 0 0 0 6 0
176-
219 3536 0 0 0 0 0 13 0
177-
222 3584 0 0 0 0 0 7 0
178-
223 3600 0 0 0 0 0 15 0
179-
225 3632 0 0 0 0 0 8 0
180-
228 3680 0 0 0 0 0 9 0
181-
230 3712 0 0 0 0 0 10 0
182-
232 3744 0 0 0 0 0 11 0
183-
234 3776 0 0 0 0 0 12 0
184-
235 3792 0 0 0 0 0 13 0
185-
236 3808 0 0 0 0 0 14 0
186-
238 3840 0 0 0 0 0 15 0
187-
254 4096 0 0 0 0 0 1 0
181+
202 3264 0 .. 0 0 0 0 4 0
182+
206 3328 0 .. 0 0 0 0 13 0
183+
207 3344 0 .. 0 0 0 0 9 0
184+
208 3360 0 .. 0 0 0 0 14 0
185+
211 3408 0 .. 0 0 0 0 5 0
186+
212 3424 0 .. 0 0 0 0 16 0
187+
214 3456 0 .. 0 0 0 0 11 0
188+
217 3504 0 .. 0 0 0 0 6 0
189+
219 3536 0 .. 0 0 0 0 13 0
190+
222 3584 0 .. 0 0 0 0 7 0
191+
223 3600 0 .. 0 0 0 0 15 0
192+
225 3632 0 .. 0 0 0 0 8 0
193+
228 3680 0 .. 0 0 0 0 9 0
194+
230 3712 0 .. 0 0 0 0 10 0
195+
232 3744 0 .. 0 0 0 0 11 0
196+
234 3776 0 .. 0 0 0 0 12 0
197+
235 3792 0 .. 0 0 0 0 13 0
198+
236 3808 0 .. 0 0 0 0 14 0
199+
238 3840 0 .. 0 0 0 0 15 0
200+
254 4096 0 .. 0 0 0 0 1 0
188201
...
189202

190203
Overall the combined zspage chain size effect on zsmalloc pool configuration:::
@@ -214,9 +227,10 @@ zram as a build artifacts storage (Linux kernel compilation).
214227

215228
zsmalloc classes stats:::
216229

217-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
230+
class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
231+
218232
...
219-
Total 13 51 413836 412973 159955 3
233+
Total 13 .. 51 413836 412973 159955 3
220234

221235
zram mm_stat:::
222236

@@ -227,9 +241,10 @@ zram as a build artifacts storage (Linux kernel compilation).
227241

228242
zsmalloc classes stats:::
229243

230-
class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable
244+
class size 10% .... 100% obj_allocated obj_used pages_used pages_per_zspage freeable
245+
231246
...
232-
Total 18 87 414852 412978 156666 0
247+
Total 18 .. 87 414852 412978 156666 0
233248

234249
zram mm_stat:::
235250

0 commit comments

Comments
 (0)