@@ -39,13 +39,12 @@ With CONFIG_ZSMALLOC_STAT, we could see zsmalloc internal information via
39
39
40
40
# cat /sys/kernel/debug/zsmalloc/zram0/classes
41
41
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
43
43
...
44
44
...
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
49
48
...
50
49
...
51
50
@@ -54,10 +53,28 @@ class
54
53
index
55
54
size
56
55
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%
61
78
obj_allocated
62
79
the number of objects allocated
63
80
obj_used
@@ -67,18 +84,11 @@ pages_used
67
84
pages_per_zspage
68
85
the number of 0-order pages to make a zspage
69
86
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.
82
92
83
93
Internals
84
94
=========
@@ -94,10 +104,10 @@ of objects that each zspage can store.
94
104
95
105
For instance, consider the following size classes:::
96
106
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
98
108
...
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
101
111
...
102
112
103
113
@@ -134,10 +144,11 @@ reduces memory wastage.
134
144
135
145
Let's take a closer look at the bottom of `/sys/kernel/debug/zsmalloc/zramX/classes `:::
136
146
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
+
138
149
...
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
141
152
...
142
153
143
154
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.
151
162
152
163
For zspage chain size of 8, huge class watermark becomes 3632 bytes:::
153
164
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
+
155
167
...
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
162
174
...
163
175
164
176
For zspage chain size of 16, huge class watermark becomes 3840 bytes:::
165
177
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
+
167
180
...
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
188
201
...
189
202
190
203
Overall the combined zspage chain size effect on zsmalloc pool configuration:::
@@ -214,9 +227,10 @@ zram as a build artifacts storage (Linux kernel compilation).
214
227
215
228
zsmalloc classes stats:::
216
229
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
+
218
232
...
219
- Total 13 51 413836 412973 159955 3
233
+ Total 13 .. 51 413836 412973 159955 3
220
234
221
235
zram mm_stat:::
222
236
@@ -227,9 +241,10 @@ zram as a build artifacts storage (Linux kernel compilation).
227
241
228
242
zsmalloc classes stats:::
229
243
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
+
231
246
...
232
- Total 18 87 414852 412978 156666 0
247
+ Total 18 .. 87 414852 412978 156666 0
233
248
234
249
zram mm_stat:::
235
250
0 commit comments