blob: d3028554b1e9c5e0ec3daffb02696cbae9600b84 [file] [log] [blame]
Mike Rapoport0c143982018-03-21 21:22:37 +02001.. _slub:
2
3==========================
Christoph Lameter35243422007-05-06 14:49:47 -07004Short users guide for SLUB
Mike Rapoport0c143982018-03-21 21:22:37 +02005==========================
Christoph Lameter35243422007-05-06 14:49:47 -07006
Christoph Lameter35243422007-05-06 14:49:47 -07007The basic philosophy of SLUB is very different from SLAB. SLAB
8requires rebuilding the kernel to activate debug options for all
Christoph Lameterc1aee212007-05-31 00:40:47 -07009slab caches. SLUB always includes full debugging but it is off by default.
Christoph Lameter35243422007-05-06 14:49:47 -070010SLUB can enable debugging only for selected slabs in order to avoid
11an impact on overall system performance which may make a bug more
12difficult to find.
13
Mike Rapoport0c143982018-03-21 21:22:37 +020014In order to switch debugging on one can add an option ``slub_debug``
Christoph Lameter35243422007-05-06 14:49:47 -070015to the kernel command line. That will enable full debugging for
16all slabs.
17
Mike Rapoport0c143982018-03-21 21:22:37 +020018Typically one would then use the ``slabinfo`` command to get statistical
19data and perform operation on the slabs. By default ``slabinfo`` only lists
Christoph Lameter35243422007-05-06 14:49:47 -070020slabs that have data in them. See "slabinfo -h" for more options when
Mike Rapoport0c143982018-03-21 21:22:37 +020021running the command. ``slabinfo`` can be compiled with
22::
Christoph Lameter35243422007-05-06 14:49:47 -070023
Mike Rapoport0c143982018-03-21 21:22:37 +020024 gcc -o slabinfo tools/vm/slabinfo.c
Christoph Lameter35243422007-05-06 14:49:47 -070025
Mike Rapoport0c143982018-03-21 21:22:37 +020026Some of the modes of operation of ``slabinfo`` require that slub debugging
Christoph Lameter35243422007-05-06 14:49:47 -070027be enabled on the command line. F.e. no tracking information will be
28available without debugging on and validation can only partially
29be performed if debugging was not switched on.
30
31Some more sophisticated uses of slub_debug:
32-------------------------------------------
33
Mike Rapoport0c143982018-03-21 21:22:37 +020034Parameters may be given to ``slub_debug``. If none is specified then full
Christoph Lameter35243422007-05-06 14:49:47 -070035debugging is enabled. Format:
36
Mike Rapoport0c143982018-03-21 21:22:37 +020037slub_debug=<Debug-Options>
38 Enable options for all slabs
Christoph Lameter35243422007-05-06 14:49:47 -070039
Aaron Tomlinc5fd3ca2018-10-26 15:03:15 -070040slub_debug=<Debug-Options>,<slab name1>,<slab name2>,...
41 Enable options only for select slabs (no spaces
42 after a comma)
Mike Rapoport0c143982018-03-21 21:22:37 +020043
Vlastimil Babkae17f1df2020-08-06 23:18:35 -070044Multiple blocks of options for all slabs or selected slabs can be given, with
45blocks of options delimited by ';'. The last of "all slabs" blocks is applied
46to all slabs except those that match one of the "select slabs" block. Options
47of the first "select slabs" blocks that matches the slab's name are applied.
48
Mike Rapoport0c143982018-03-21 21:22:37 +020049Possible debug options are::
50
Laura Abbottbecfda62016-03-15 14:55:06 -070051 F Sanity checks on (enables SLAB_DEBUG_CONSISTENCY_CHECKS
52 Sorry SLAB legacy issues)
Christoph Lameter35243422007-05-06 14:49:47 -070053 Z Red zoning
54 P Poisoning (object and padding)
55 U User tracking (free and alloc)
56 T Trace (please only use on single slabs)
Andrew Mortona3df6922020-06-01 21:46:00 -070057 A Enable failslab filter mark for the cache
David Rientjesfa5ec8a2009-07-07 00:14:14 -070058 O Switch debugging off for caches that would have
59 caused higher minimum slab orders
Christoph Lameterf0630ff2007-07-15 23:38:14 -070060 - Switch all debugging off (useful if the kernel is
61 configured with CONFIG_SLUB_DEBUG_ON)
Christoph Lameter35243422007-05-06 14:49:47 -070062
Mike Rapoport0c143982018-03-21 21:22:37 +020063F.e. in order to boot just with sanity checks and red zoning one would specify::
Christoph Lameter35243422007-05-06 14:49:47 -070064
65 slub_debug=FZ
66
Mike Rapoport0c143982018-03-21 21:22:37 +020067Trying to find an issue in the dentry cache? Try::
Christoph Lameter35243422007-05-06 14:49:47 -070068
Itaru Kitayama989a7242008-03-05 15:07:30 -080069 slub_debug=,dentry
Christoph Lameter35243422007-05-06 14:49:47 -070070
Aaron Tomlinc5fd3ca2018-10-26 15:03:15 -070071to only enable debugging on the dentry cache. You may use an asterisk at the
72end of the slab name, in order to cover all slabs with the same prefix. For
73example, here's how you can poison the dentry cache as well as all kmalloc
Tobin C. Harding11ede502019-01-31 15:06:22 +110074slabs::
Aaron Tomlinc5fd3ca2018-10-26 15:03:15 -070075
76 slub_debug=P,kmalloc-*,dentry
Christoph Lameter35243422007-05-06 14:49:47 -070077
78Red zoning and tracking may realign the slab. We can just apply sanity checks
Mike Rapoport0c143982018-03-21 21:22:37 +020079to the dentry cache with::
Christoph Lameter35243422007-05-06 14:49:47 -070080
Itaru Kitayama989a7242008-03-05 15:07:30 -080081 slub_debug=F,dentry
Christoph Lameter35243422007-05-06 14:49:47 -070082
David Rientjesfa5ec8a2009-07-07 00:14:14 -070083Debugging options may require the minimum possible slab order to increase as
84a result of storing the metadata (for example, caches with PAGE_SIZE object
85sizes). This has a higher liklihood of resulting in slab allocation errors
86in low memory situations or if there's high fragmentation of memory. To
Mike Rapoport0c143982018-03-21 21:22:37 +020087switch off debugging for such caches by default, use::
David Rientjesfa5ec8a2009-07-07 00:14:14 -070088
89 slub_debug=O
90
Vlastimil Babkae17f1df2020-08-06 23:18:35 -070091You can apply different options to different list of slab names, using blocks
92of options. This will enable red zoning for dentry and user tracking for
93kmalloc. All other slabs will not get any debugging enabled::
94
95 slub_debug=Z,dentry;U,kmalloc-*
96
97You can also enable options (e.g. sanity checks and poisoning) for all caches
98except some that are deemed too performance critical and don't need to be
99debugged by specifying global debug options followed by a list of slab names
100with "-" as options::
101
102 slub_debug=FZ;-,zs_handle,zspage
103
Vlastimil Babkaad38b5b2020-08-06 23:18:38 -0700104The state of each debug option for a slab can be found in the respective files
105under::
Christoph Lameter35243422007-05-06 14:49:47 -0700106
Mike Rapoport0c143982018-03-21 21:22:37 +0200107 /sys/kernel/slab/<slab name>/
Christoph Lameter35243422007-05-06 14:49:47 -0700108
Vlastimil Babkaad38b5b2020-08-06 23:18:38 -0700109If the file contains 1, the option is enabled, 0 means disabled. The debug
110options from the ``slub_debug`` parameter translate to the following files::
Christoph Lameter35243422007-05-06 14:49:47 -0700111
Vlastimil Babkaad38b5b2020-08-06 23:18:38 -0700112 F sanity_checks
113 Z red_zone
114 P poison
115 U store_user
116 T trace
117 A failslab
118
Vlastimil Babka060807f2020-08-06 23:18:45 -0700119Careful with tracing: It may spew out lots of information and never stop if
120used on the wrong slab.
Christoph Lameter35243422007-05-06 14:49:47 -0700121
Christoph Lameterc1aee212007-05-31 00:40:47 -0700122Slab merging
Mike Rapoport0c143982018-03-21 21:22:37 +0200123============
Christoph Lameter35243422007-05-06 14:49:47 -0700124
Christoph Lameterc1aee212007-05-31 00:40:47 -0700125If no debug options are specified then SLUB may merge similar slabs together
Christoph Lameter35243422007-05-06 14:49:47 -0700126in order to reduce overhead and increase cache hotness of objects.
Mike Rapoport0c143982018-03-21 21:22:37 +0200127``slabinfo -a`` displays which slabs were merged together.
Christoph Lameter35243422007-05-06 14:49:47 -0700128
Christoph Lameterc1aee212007-05-31 00:40:47 -0700129Slab validation
Mike Rapoport0c143982018-03-21 21:22:37 +0200130===============
Christoph Lameterc1aee212007-05-31 00:40:47 -0700131
132SLUB can validate all object if the kernel was booted with slub_debug. In
Mike Rapoport0c143982018-03-21 21:22:37 +0200133order to do so you must have the ``slabinfo`` tool. Then you can do
134::
Christoph Lameterc1aee212007-05-31 00:40:47 -0700135
Mike Rapoport0c143982018-03-21 21:22:37 +0200136 slabinfo -v
Christoph Lameterc1aee212007-05-31 00:40:47 -0700137
138which will test all objects. Output will be generated to the syslog.
139
140This also works in a more limited way if boot was without slab debug.
Mike Rapoport0c143982018-03-21 21:22:37 +0200141In that case ``slabinfo -v`` simply tests all reachable objects. Usually
Christoph Lameterc1aee212007-05-31 00:40:47 -0700142these are in the cpu slabs and the partial slabs. Full slabs are not
143tracked by SLUB in a non debug situation.
144
Christoph Lameter35243422007-05-06 14:49:47 -0700145Getting more performance
Mike Rapoport0c143982018-03-21 21:22:37 +0200146========================
Christoph Lameter35243422007-05-06 14:49:47 -0700147
148To some degree SLUB's performance is limited by the need to take the
149list_lock once in a while to deal with partial slabs. That overhead is
150governed by the order of the allocation for each slab. The allocations
151can be influenced by kernel parameters:
152
Mike Rapoport0c143982018-03-21 21:22:37 +0200153.. slub_min_objects=x (default 4)
154.. slub_min_order=x (default 0)
155.. slub_max_order=x (default 3 (PAGE_ALLOC_COSTLY_ORDER))
Christoph Lameter35243422007-05-06 14:49:47 -0700156
Mike Rapoport0c143982018-03-21 21:22:37 +0200157``slub_min_objects``
158 allows to specify how many objects must at least fit into one
159 slab in order for the allocation order to be acceptable. In
160 general slub will be able to perform this number of
161 allocations on a slab without consulting centralized resources
162 (list_lock) where contention may occur.
Christoph Lameter35243422007-05-06 14:49:47 -0700163
Mike Rapoport0c143982018-03-21 21:22:37 +0200164``slub_min_order``
Tobin C. Harding358b6ba2019-01-31 15:06:21 +1100165 specifies a minimum order of slabs. A similar effect like
Mike Rapoport0c143982018-03-21 21:22:37 +0200166 ``slub_min_objects``.
Christoph Lameter35243422007-05-06 14:49:47 -0700167
Mike Rapoport0c143982018-03-21 21:22:37 +0200168``slub_max_order``
169 specified the order at which ``slub_min_objects`` should no
170 longer be checked. This is useful to avoid SLUB trying to
171 generate super large order pages to fit ``slub_min_objects``
172 of a slab cache with large object sizes into one high order
173 page. Setting command line parameter
174 ``debug_guardpage_minorder=N`` (N > 0), forces setting
175 ``slub_max_order`` to 0, what cause minimum possible order of
176 slabs allocation.
Christoph Lameter35243422007-05-06 14:49:47 -0700177
Christoph Lameterc1aee212007-05-31 00:40:47 -0700178SLUB Debug output
Mike Rapoport0c143982018-03-21 21:22:37 +0200179=================
Christoph Lameter35243422007-05-06 14:49:47 -0700180
Mike Rapoport0c143982018-03-21 21:22:37 +0200181Here is a sample of slub debug output::
Christoph Lameterc1aee212007-05-31 00:40:47 -0700182
Mike Rapoport0c143982018-03-21 21:22:37 +0200183 ====================================================================
Kees Cook8669dba2021-06-15 18:23:19 -0700184 BUG kmalloc-8: Right Redzone overwritten
Mike Rapoport0c143982018-03-21 21:22:37 +0200185 --------------------------------------------------------------------
Christoph Lameter24922682007-07-17 04:03:18 -0700186
Mike Rapoport0c143982018-03-21 21:22:37 +0200187 INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc
188 INFO: Slab 0xc528c530 flags=0x400000c3 inuse=61 fp=0xc90f6d58
189 INFO: Object 0xc90f6d20 @offset=3360 fp=0xc90f6d58
190 INFO: Allocated in get_modalias+0x61/0xf5 age=53 cpu=1 pid=554
Christoph Lameter24922682007-07-17 04:03:18 -0700191
Kees Cook8669dba2021-06-15 18:23:19 -0700192 Bytes b4 (0xc90f6d10): 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ
193 Object (0xc90f6d20): 31 30 31 39 2e 30 30 35 1019.005
194 Redzone (0xc90f6d28): 00 cc cc cc .
195 Padding (0xc90f6d50): 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
Christoph Lameter24922682007-07-17 04:03:18 -0700196
Mike Rapoport0c143982018-03-21 21:22:37 +0200197 [<c010523d>] dump_trace+0x63/0x1eb
198 [<c01053df>] show_trace_log_lvl+0x1a/0x2f
199 [<c010601d>] show_trace+0x12/0x14
200 [<c0106035>] dump_stack+0x16/0x18
201 [<c017e0fa>] object_err+0x143/0x14b
202 [<c017e2cc>] check_object+0x66/0x234
203 [<c017eb43>] __slab_free+0x239/0x384
204 [<c017f446>] kfree+0xa6/0xc6
205 [<c02e2335>] get_modalias+0xb9/0xf5
206 [<c02e23b7>] dmi_dev_uevent+0x27/0x3c
207 [<c027866a>] dev_uevent+0x1ad/0x1da
208 [<c0205024>] kobject_uevent_env+0x20a/0x45b
209 [<c020527f>] kobject_uevent+0xa/0xf
210 [<c02779f1>] store_uevent+0x4f/0x58
211 [<c027758e>] dev_attr_store+0x29/0x2f
212 [<c01bec4f>] sysfs_write_file+0x16e/0x19c
213 [<c0183ba7>] vfs_write+0xd1/0x15a
214 [<c01841d7>] sys_write+0x3d/0x72
215 [<c0104112>] sysenter_past_esp+0x5f/0x99
216 [<b7f7b410>] 0xb7f7b410
217 =======================
Christoph Lameterc1aee212007-05-31 00:40:47 -0700218
Mike Rapoport0c143982018-03-21 21:22:37 +0200219 FIX kmalloc-8: Restoring Redzone 0xc90f6d28-0xc90f6d2b=0xcc
Christoph Lameterc1aee212007-05-31 00:40:47 -0700220
Christoph Lameter24922682007-07-17 04:03:18 -0700221If SLUB encounters a corrupted object (full detection requires the kernel
222to be booted with slub_debug) then the following output will be dumped
223into the syslog:
Christoph Lameterc1aee212007-05-31 00:40:47 -0700224
Christoph Lameter24922682007-07-17 04:03:18 -07002251. Description of the problem encountered
Christoph Lameterc1aee212007-05-31 00:40:47 -0700226
Mike Rapoport0c143982018-03-21 21:22:37 +0200227 This will be a message in the system log starting with::
Christoph Lameterc1aee212007-05-31 00:40:47 -0700228
Mike Rapoport0c143982018-03-21 21:22:37 +0200229 ===============================================
230 BUG <slab cache affected>: <What went wrong>
231 -----------------------------------------------
Christoph Lameterc1aee212007-05-31 00:40:47 -0700232
Mike Rapoport0c143982018-03-21 21:22:37 +0200233 INFO: <corruption start>-<corruption_end> <more info>
234 INFO: Slab <address> <slab information>
235 INFO: Object <address> <object information>
236 INFO: Allocated in <kernel function> age=<jiffies since alloc> cpu=<allocated by
Christoph Lameter24922682007-07-17 04:03:18 -0700237 cpu> pid=<pid of the process>
Mike Rapoport0c143982018-03-21 21:22:37 +0200238 INFO: Freed in <kernel function> age=<jiffies since free> cpu=<freed by cpu>
239 pid=<pid of the process>
Christoph Lameterc1aee212007-05-31 00:40:47 -0700240
Mike Rapoport0c143982018-03-21 21:22:37 +0200241 (Object allocation / free information is only available if SLAB_STORE_USER is
242 set for the slab. slub_debug sets that option)
Christoph Lameterc1aee212007-05-31 00:40:47 -0700243
Christoph Lameter24922682007-07-17 04:03:18 -07002442. The object contents if an object was involved.
Christoph Lameterc1aee212007-05-31 00:40:47 -0700245
Mike Rapoport0c143982018-03-21 21:22:37 +0200246 Various types of lines can follow the BUG SLUB line:
Christoph Lameterc1aee212007-05-31 00:40:47 -0700247
Mike Rapoport0c143982018-03-21 21:22:37 +0200248 Bytes b4 <address> : <bytes>
Christoph Lameter24922682007-07-17 04:03:18 -0700249 Shows a few bytes before the object where the problem was detected.
Christoph Lameterc1aee212007-05-31 00:40:47 -0700250 Can be useful if the corruption does not stop with the start of the
251 object.
252
Mike Rapoport0c143982018-03-21 21:22:37 +0200253 Object <address> : <bytes>
Christoph Lameterc1aee212007-05-31 00:40:47 -0700254 The bytes of the object. If the object is inactive then the bytes
Christoph Lameter24922682007-07-17 04:03:18 -0700255 typically contain poison values. Any non-poison value shows a
Christoph Lameterc1aee212007-05-31 00:40:47 -0700256 corruption by a write after free.
257
Mike Rapoport0c143982018-03-21 21:22:37 +0200258 Redzone <address> : <bytes>
Christoph Lameter24922682007-07-17 04:03:18 -0700259 The Redzone following the object. The Redzone is used to detect
Christoph Lameterc1aee212007-05-31 00:40:47 -0700260 writes after the object. All bytes should always have the same
261 value. If there is any deviation then it is due to a write after
262 the object boundary.
263
Christoph Lameter24922682007-07-17 04:03:18 -0700264 (Redzone information is only available if SLAB_RED_ZONE is set.
265 slub_debug sets that option)
Christoph Lameterc1aee212007-05-31 00:40:47 -0700266
Mike Rapoport0c143982018-03-21 21:22:37 +0200267 Padding <address> : <bytes>
Christoph Lameterc1aee212007-05-31 00:40:47 -0700268 Unused data to fill up the space in order to get the next object
269 properly aligned. In the debug case we make sure that there are
Christoph Lameter24922682007-07-17 04:03:18 -0700270 at least 4 bytes of padding. This allows the detection of writes
Christoph Lameterc1aee212007-05-31 00:40:47 -0700271 before the object.
272
Christoph Lameter24922682007-07-17 04:03:18 -07002733. A stackdump
Christoph Lameterc1aee212007-05-31 00:40:47 -0700274
Mike Rapoport0c143982018-03-21 21:22:37 +0200275 The stackdump describes the location where the error was detected. The cause
276 of the corruption is may be more likely found by looking at the function that
277 allocated or freed the object.
Christoph Lameter24922682007-07-17 04:03:18 -0700278
2794. Report on how the problem was dealt with in order to ensure the continued
Mike Rapoport0c143982018-03-21 21:22:37 +0200280 operation of the system.
Christoph Lameter24922682007-07-17 04:03:18 -0700281
Mike Rapoport0c143982018-03-21 21:22:37 +0200282 These are messages in the system log beginning with::
Christoph Lameter24922682007-07-17 04:03:18 -0700283
Mike Rapoport0c143982018-03-21 21:22:37 +0200284 FIX <slab cache affected>: <corrective action taken>
Christoph Lameter24922682007-07-17 04:03:18 -0700285
Mike Rapoport0c143982018-03-21 21:22:37 +0200286 In the above sample SLUB found that the Redzone of an active object has
287 been overwritten. Here a string of 8 characters was written into a slab that
288 has the length of 8 characters. However, a 8 character string needs a
289 terminating 0. That zero has overwritten the first byte of the Redzone field.
290 After reporting the details of the issue encountered the FIX SLUB message
291 tells us that SLUB has restored the Redzone to its proper value and then
292 system operations continue.
Christoph Lameter24922682007-07-17 04:03:18 -0700293
Mike Rapoport0c143982018-03-21 21:22:37 +0200294Emergency operations
295====================
Christoph Lameter24922682007-07-17 04:03:18 -0700296
Mike Rapoport0c143982018-03-21 21:22:37 +0200297Minimal debugging (sanity checks alone) can be enabled by booting with::
Christoph Lameter24922682007-07-17 04:03:18 -0700298
299 slub_debug=F
300
301This will be generally be enough to enable the resiliency features of slub
302which will keep the system running even if a bad kernel component will
303keep corrupting objects. This may be important for production systems.
304Performance will be impacted by the sanity checks and there will be a
305continual stream of error messages to the syslog but no additional memory
306will be used (unlike full debugging).
307
308No guarantees. The kernel component still needs to be fixed. Performance
309may be optimized further by locating the slab that experiences corruption
310and enabling debugging only for that cache
311
Mike Rapoport0c143982018-03-21 21:22:37 +0200312I.e.::
Christoph Lameter24922682007-07-17 04:03:18 -0700313
314 slub_debug=F,dentry
315
316If the corruption occurs by writing after the end of the object then it
317may be advisable to enable a Redzone to avoid corrupting the beginning
Mike Rapoport0c143982018-03-21 21:22:37 +0200318of other objects::
Christoph Lameter24922682007-07-17 04:03:18 -0700319
320 slub_debug=FZ,dentry
321
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900322Extended slabinfo mode and plotting
Mike Rapoport0c143982018-03-21 21:22:37 +0200323===================================
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900324
Mike Rapoport0c143982018-03-21 21:22:37 +0200325The ``slabinfo`` tool has a special 'extended' ('-X') mode that includes:
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900326 - Slabcache Totals
327 - Slabs sorted by size (up to -N <num> slabs, default 1)
328 - Slabs sorted by loss (up to -N <num> slabs, default 1)
329
Mike Rapoport0c143982018-03-21 21:22:37 +0200330Additionally, in this mode ``slabinfo`` does not dynamically scale
331sizes (G/M/K) and reports everything in bytes (this functionality is
332also available to other slabinfo modes via '-B' option) which makes
333reporting more precise and accurate. Moreover, in some sense the `-X'
334mode also simplifies the analysis of slabs' behaviour, because its
335output can be plotted using the ``slabinfo-gnuplot.sh`` script. So it
336pushes the analysis from looking through the numbers (tons of numbers)
337to something easier -- visual analysis.
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900338
339To generate plots:
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900340
Mike Rapoport0c143982018-03-21 21:22:37 +0200341a) collect slabinfo extended records, for example::
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900342
Mike Rapoport0c143982018-03-21 21:22:37 +0200343 while [ 1 ]; do slabinfo -X >> FOO_STATS; sleep 1; done
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900344
Mike Rapoport0c143982018-03-21 21:22:37 +0200345b) pass stats file(-s) to ``slabinfo-gnuplot.sh`` script::
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900346
Mike Rapoport0c143982018-03-21 21:22:37 +0200347 slabinfo-gnuplot.sh FOO_STATS [FOO_STATS2 .. FOO_STATSN]
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900348
Mike Rapoport0c143982018-03-21 21:22:37 +0200349 The ``slabinfo-gnuplot.sh`` script will pre-processes the collected records
350 and generates 3 png files (and 3 pre-processing cache files) per STATS
351 file:
352 - Slabcache Totals: FOO_STATS-totals.png
353 - Slabs sorted by size: FOO_STATS-slabs-by-size.png
354 - Slabs sorted by loss: FOO_STATS-slabs-by-loss.png
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900355
Mike Rapoport0c143982018-03-21 21:22:37 +0200356Another use case, when ``slabinfo-gnuplot.sh`` can be useful, is when you
357need to compare slabs' behaviour "prior to" and "after" some code
358modification. To help you out there, ``slabinfo-gnuplot.sh`` script
359can 'merge' the `Slabcache Totals` sections from different
360measurements. To visually compare N plots:
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900361
Mike Rapoport0c143982018-03-21 21:22:37 +0200362a) Collect as many STATS1, STATS2, .. STATSN files as you need::
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900363
Mike Rapoport0c143982018-03-21 21:22:37 +0200364 while [ 1 ]; do slabinfo -X >> STATS<X>; sleep 1; done
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900365
Mike Rapoport0c143982018-03-21 21:22:37 +0200366b) Pre-process those STATS files::
367
368 slabinfo-gnuplot.sh STATS1 STATS2 .. STATSN
369
370c) Execute ``slabinfo-gnuplot.sh`` in '-t' mode, passing all of the
371 generated pre-processed \*-totals::
372
373 slabinfo-gnuplot.sh -t STATS1-totals STATS2-totals .. STATSN-totals
374
375 This will produce a single plot (png file).
376
377 Plots, expectedly, can be large so some fluctuations or small spikes
378 can go unnoticed. To deal with that, ``slabinfo-gnuplot.sh`` has two
379 options to 'zoom-in'/'zoom-out':
380
Colin Ian King94ebdd22020-10-22 15:26:53 +0100381 a) ``-s %d,%d`` -- overwrites the default image width and height
Mike Rapoport0c143982018-03-21 21:22:37 +0200382 b) ``-r %d,%d`` -- specifies a range of samples to use (for example,
383 in ``slabinfo -X >> FOO_STATS; sleep 1;`` case, using a ``-r
384 40,60`` range will plot only samples collected between 40th and
385 60th seconds).
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900386
Christoph Lametercde53532008-07-04 09:59:22 -0700387Christoph Lameter, May 30, 2007
Sergey Senozhatsky05be9612015-10-23 08:51:45 +0900388Sergey Senozhatsky, October 23, 2015