blob: 258b46435320a75c399854aaa2cb4027286029ec [file] [log] [blame]
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -03001=========================================
2How to get printk format specifiers right
3=========================================
4
5:Author: Randy Dunlap <rdunlap@infradead.org>
6:Author: Andrew Murray <amurray@mpc-data.co.uk>
7
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +11008
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -03009Integer types
10=============
11
12::
13
14 If variable is of Type, use printk format specifier:
15 ------------------------------------------------------------
Randy Dunlapb67ad182008-11-12 13:26:55 -080016 int %d or %x
17 unsigned int %u or %x
18 long %ld or %lx
19 unsigned long %lu or %lx
20 long long %lld or %llx
21 unsigned long long %llu or %llx
22 size_t %zu or %zx
23 ssize_t %zd or %zx
Geert Uytterhoevene8a7ba52015-04-15 16:17:17 -070024 s32 %d or %x
25 u32 %u or %x
26 s64 %lld or %llx
27 u64 %llu or %llx
28
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110029
30If <type> is dependent on a config option for its size (e.g., sector_t,
31blkcnt_t) or is architecture-dependent for its size (e.g., tcflag_t), use a
32format specifier of its largest possible type and explicitly cast to it.
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030033
34Example::
Geert Uytterhoevene8a7ba52015-04-15 16:17:17 -070035
36 printk("test: sector number/total blocks: %llu/%llu\n",
37 (unsigned long long)sector, (unsigned long long)blockcount);
38
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110039Reminder: sizeof() returns type size_t.
Geert Uytterhoevene8a7ba52015-04-15 16:17:17 -070040
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110041The kernel's printf does not support %n. Floating point formats (%e, %f,
42%g, %a) are also not recognized, for obvious reasons. Use of any
Rasmus Villemoesd7ec9a02015-11-06 16:30:35 -080043unsupported specifier or length qualifier results in a WARN and early
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110044return from vsnprintf().
Randy Dunlapb67ad182008-11-12 13:26:55 -080045
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110046Pointer types
Tobin C. Hardingad67b742017-11-01 15:32:23 +110047=============
48
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110049A raw pointer value may be printed with %p which will hash the address
50before printing. The kernel also supports extended specifiers for printing
51pointers of different types.
52
53Plain Pointers
54--------------
Tobin C. Hardingad67b742017-11-01 15:32:23 +110055
56::
57
58 %p abcdef12 or 00000000abcdef12
59
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110060Pointers printed without a specifier extension (i.e unadorned %p) are
61hashed to prevent leaking information about the kernel memory layout. This
62has the added benefit of providing a unique identifier. On 64-bit machines
63the first 32 bits are zeroed. If you *really* want the address see %px
64below.
65
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030066Symbols/Function Pointers
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110067-------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030068
69::
Andrew Murray04c55712011-06-15 12:57:09 -070070
71 %pF versatile_init+0x0/0x110
72 %pf versatile_init
73 %pS versatile_init+0x0/0x110
Joe Perchesb0d33c22012-12-12 10:18:50 -080074 %pSR versatile_init+0x9/0x110
75 (with __builtin_extract_return_addr() translation)
Andrew Murray04c55712011-06-15 12:57:09 -070076 %ps versatile_init
77 %pB prev_fn_of_versatile_init+0x88/0x88
78
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110079
Helge Dellerd6957f32017-08-15 11:34:19 +020080The ``F`` and ``f`` specifiers are for printing function pointers,
81for example, f->func, &gettimeofday. They have the same result as
82``S`` and ``s`` specifiers. But they do an extra conversion on
83ia64, ppc64 and parisc64 architectures where the function pointers
84are actually function descriptors.
85
86The ``S`` and ``s`` specifiers can be used for printing symbols
87from direct addresses, for example, __builtin_return_address(0),
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110088(void *)regs->ip. They result in the symbol name with (S) or
89without (s) offsets. If KALLSYMS are disabled then the symbol
Helge Dellerd6957f32017-08-15 11:34:19 +020090address is printed instead.
Andrew Murray04c55712011-06-15 12:57:09 -070091
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030092The ``B`` specifier results in the symbol name with offsets and should be
93used when printing stack backtraces. The specifier takes into
94consideration the effect of compiler optimisations which may occur
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110095when tail-calls are used and marked with the noreturn GCC attribute.
Andrew Murray04c55712011-06-15 12:57:09 -070096
Helge Dellerfd46cd52017-08-23 21:52:05 +020097Examples::
98
99 printk("Going to call: %pF\n", gettimeofday);
100 printk("Going to call: %pF\n", p->func);
101 printk("%s: called from %pS\n", __func__, (void *)_RET_IP_);
102 printk("%s: called from %pS\n", __func__,
103 (void *)__builtin_return_address(0));
104 printk("Faulted at %pS\n", (void *)regs->ip);
105 printk(" %s%pB\n", (reliable ? "" : "? "), (void *)*stack);
106
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300107Kernel Pointers
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100108---------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300109
110::
Andrew Murray04c55712011-06-15 12:57:09 -0700111
Tobin C. Harding553d8e82017-11-23 10:55:24 +1100112 %pK 01234567 or 0123456789abcdef
Andrew Murray04c55712011-06-15 12:57:09 -0700113
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300114For printing kernel pointers which should be hidden from unprivileged
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100115users. The behaviour of %pK depends on the kptr_restrict sysctl - see
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300116Documentation/sysctl/kernel.txt for more details.
Andrew Murray04c55712011-06-15 12:57:09 -0700117
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100118Unmodified Addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100119--------------------
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100120
121::
122
123 %px 01234567 or 0123456789abcdef
124
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100125For printing pointers when you *really* want to print the address. Please
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100126consider whether or not you are leaking sensitive information about the
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100127kernel memory layout before printing pointers with %px. %px is functionally
128equivalent to %lx (or %lu). %px is preferred because it is more uniquely
129grep'able. If in the future we need to modify the way the kernel handles
130printing pointers we will be better equipped to find the call sites.
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100131
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300132Struct Resources
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100133----------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300134
135::
Andrew Murray04c55712011-06-15 12:57:09 -0700136
137 %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
138 [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
139 %pR [mem 0x60000000-0x6fffffff pref] or
140 [mem 0x0000000060000000-0x000000006fffffff pref]
141
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300142For printing struct resources. The ``R`` and ``r`` specifiers result in a
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100143printed resource with (R) or without (r) a decoded flags member.
144
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300145Passed by reference.
Andrew Murray04c55712011-06-15 12:57:09 -0700146
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100147Physical address types phys_addr_t
148----------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300149
150::
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800151
Joe Perchesaaf07622014-01-23 15:54:17 -0800152 %pa[p] 0x01234567 or 0x0123456789abcdef
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800153
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100154For printing a phys_addr_t type (and its derivatives, such as
155resource_size_t) which can vary based on build options, regardless of the
156width of the CPU data path.
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800157
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100158Passed by reference.
159
160DMA address types dma_addr_t
161----------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300162
163::
Joe Perchesaaf07622014-01-23 15:54:17 -0800164
165 %pad 0x01234567 or 0x0123456789abcdef
166
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100167For printing a dma_addr_t type which can vary based on build options,
168regardless of the width of the CPU data path.
169
170Passed by reference.
Joe Perchesaaf07622014-01-23 15:54:17 -0800171
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300172Raw buffer as an escaped string
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100173-------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300174
175::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700176
177 %*pE[achnops]
178
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300179For printing raw buffer as an escaped string. For the following buffer::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700180
181 1b 62 20 5c 43 07 22 90 0d 5d
182
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100183A few examples show how the conversion would be done (excluding surrounding
184quotes)::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700185
186 %*pE "\eb \C\a"\220\r]"
187 %*pEhp "\x1bb \C\x07"\x90\x0d]"
188 %*pEa "\e\142\040\\\103\a\042\220\r\135"
189
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300190The conversion rules are applied according to an optional combination
191of flags (see :c:func:`string_escape_mem` kernel documentation for the
192details):
Andy Shevchenko71dca952014-10-13 15:55:18 -0700193
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100194 - a - ESCAPE_ANY
195 - c - ESCAPE_SPECIAL
196 - h - ESCAPE_HEX
197 - n - ESCAPE_NULL
198 - o - ESCAPE_OCTAL
199 - p - ESCAPE_NP
200 - s - ESCAPE_SPACE
Andy Shevchenko71dca952014-10-13 15:55:18 -0700201
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300202By default ESCAPE_ANY_NP is used.
Andy Shevchenko71dca952014-10-13 15:55:18 -0700203
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300204ESCAPE_ANY_NP is the sane choice for many cases, in particularly for
205printing SSIDs.
206
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100207If field width is omitted then 1 byte only will be escaped.
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300208
209Raw buffer as a hex string
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100210--------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300211
212::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800213
Andy Shevchenko31550a12012-07-30 14:40:27 -0700214 %*ph 00 01 02 ... 3f
215 %*phC 00:01:02: ... :3f
216 %*phD 00-01-02- ... -3f
217 %*phN 000102 ... 3f
218
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100219For printing small buffers (up to 64 bytes long) as a hex string with a
220certain separator. For larger buffers consider using
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300221:c:func:`print_hex_dump`.
Andy Shevchenko31550a12012-07-30 14:40:27 -0700222
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300223MAC/FDDI addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100224------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300225
226::
Andrew Murray04c55712011-06-15 12:57:09 -0700227
228 %pM 00:01:02:03:04:05
Andrei Emeltchenko76597ff92012-07-30 14:40:23 -0700229 %pMR 05:04:03:02:01:00
Andrew Murray04c55712011-06-15 12:57:09 -0700230 %pMF 00-01-02-03-04-05
231 %pm 000102030405
Andy Shevchenko7c591542012-10-04 17:12:33 -0700232 %pmR 050403020100
Andrew Murray04c55712011-06-15 12:57:09 -0700233
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300234For printing 6-byte MAC/FDDI addresses in hex notation. The ``M`` and ``m``
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100235specifiers result in a printed address with (M) or without (m) byte
236separators. The default byte separator is the colon (:).
Andrew Murray04c55712011-06-15 12:57:09 -0700237
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300238Where FDDI addresses are concerned the ``F`` specifier can be used after
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100239the ``M`` specifier to use dash (-) separators instead of the default
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300240separator.
Andrew Murray04c55712011-06-15 12:57:09 -0700241
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300242For Bluetooth addresses the ``R`` specifier shall be used after the ``M``
243specifier to use reversed byte order suitable for visual interpretation
244of Bluetooth addresses which are in the little endian order.
Andrei Emeltchenko76597ff92012-07-30 14:40:23 -0700245
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300246Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700247
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300248IPv4 addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100249--------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300250
251::
Andrew Murray04c55712011-06-15 12:57:09 -0700252
253 %pI4 1.2.3.4
254 %pi4 001.002.003.004
Daniel Borkmann8ecada12013-06-28 15:49:39 +0200255 %p[Ii]4[hnbl]
Andrew Murray04c55712011-06-15 12:57:09 -0700256
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300257For printing IPv4 dot-separated decimal addresses. The ``I4`` and ``i4``
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100258specifiers result in a printed address with (i4) or without (I4) leading
259zeros.
Andrew Murray04c55712011-06-15 12:57:09 -0700260
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300261The additional ``h``, ``n``, ``b``, and ``l`` specifiers are used to specify
262host, network, big or little endian order addresses respectively. Where
263no specifier is provided the default network/big endian order is used.
Andrew Murray04c55712011-06-15 12:57:09 -0700264
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300265Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700266
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300267IPv6 addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100268--------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300269
270::
Andrew Murray04c55712011-06-15 12:57:09 -0700271
272 %pI6 0001:0002:0003:0004:0005:0006:0007:0008
273 %pi6 00010002000300040005000600070008
274 %pI6c 1:2:3:4:5:6:7:8
275
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300276For printing IPv6 network-order 16-bit hex addresses. The ``I6`` and ``i6``
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100277specifiers result in a printed address with (I6) or without (i6)
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300278colon-separators. Leading zeros are always used.
Andrew Murray04c55712011-06-15 12:57:09 -0700279
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300280The additional ``c`` specifier can be used with the ``I`` specifier to
281print a compressed IPv6 address as described by
282http://tools.ietf.org/html/rfc5952
Andrew Murray04c55712011-06-15 12:57:09 -0700283
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300284Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700285
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300286IPv4/IPv6 addresses (generic, with port, flowinfo, scope)
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100287---------------------------------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300288
289::
Daniel Borkmann10679642013-06-28 19:49:39 +0200290
291 %pIS 1.2.3.4 or 0001:0002:0003:0004:0005:0006:0007:0008
292 %piS 001.002.003.004 or 00010002000300040005000600070008
293 %pISc 1.2.3.4 or 1:2:3:4:5:6:7:8
294 %pISpc 1.2.3.4:12345 or [1:2:3:4:5:6:7:8]:12345
295 %p[Ii]S[pfschnbl]
296
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100297For printing an IP address without the need to distinguish whether it's of
298type AF_INET or AF_INET6. A pointer to a valid struct sockaddr,
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300299specified through ``IS`` or ``iS``, can be passed to this format specifier.
Daniel Borkmann10679642013-06-28 19:49:39 +0200300
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300301The additional ``p``, ``f``, and ``s`` specifiers are used to specify port
302(IPv4, IPv6), flowinfo (IPv6) and scope (IPv6). Ports have a ``:`` prefix,
303flowinfo a ``/`` and scope a ``%``, each followed by the actual value.
Daniel Borkmann10679642013-06-28 19:49:39 +0200304
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300305In case of an IPv6 address the compressed IPv6 address as described by
306http://tools.ietf.org/html/rfc5952 is being used if the additional
307specifier ``c`` is given. The IPv6 address is surrounded by ``[``, ``]`` in
308case of additional specifiers ``p``, ``f`` or ``s`` as suggested by
309https://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07
Daniel Borkmann10679642013-06-28 19:49:39 +0200310
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300311In case of IPv4 addresses, the additional ``h``, ``n``, ``b``, and ``l``
312specifiers can be used as well and are ignored in case of an IPv6
313address.
Daniel Borkmann10679642013-06-28 19:49:39 +0200314
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300315Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700316
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300317Further examples::
Daniel Borkmann10679642013-06-28 19:49:39 +0200318
319 %pISfc 1.2.3.4 or [1:2:3:4:5:6:7:8]/123456789
320 %pISsc 1.2.3.4 or [1:2:3:4:5:6:7:8]%1234567890
321 %pISpfc 1.2.3.4:12345 or [1:2:3:4:5:6:7:8]:12345/123456789
322
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300323UUID/GUID addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100324-------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300325
326::
Andrew Murray04c55712011-06-15 12:57:09 -0700327
328 %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
329 %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
330 %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
331 %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
332
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100333For printing 16-byte UUID/GUIDs addresses. The additional ``l``, ``L``,
334``b`` and ``B`` specifiers are used to specify a little endian order in
335lower (l) or upper case (L) hex notation - and big endian order in lower (b)
336or upper case (B) hex notation.
Andrew Murray04c55712011-06-15 12:57:09 -0700337
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300338Where no additional specifiers are used the default big endian
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100339order with lower case hex notation will be printed.
Andrew Murray04c55712011-06-15 12:57:09 -0700340
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300341Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700342
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300343dentry names
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100344------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300345
346::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800347
Al Viro4b6ccca2013-09-03 12:00:44 -0400348 %pd{,2,3,4}
349 %pD{,2,3,4}
350
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100351For printing dentry name; if we race with :c:func:`d_move`, the name might
352be a mix of old and new ones, but it won't oops. %pd dentry is a safer
353equivalent of %s dentry->d_name.name we used to use, %pd<n> prints ``n``
354last components. %pD does the same thing for struct file.
Al Viro4b6ccca2013-09-03 12:00:44 -0400355
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300356Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700357
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300358block_device names
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100359------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300360
361::
Dmitry Monakhov1031bc52015-04-13 16:31:35 +0400362
363 %pg sda, sda1 or loop0p1
364
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300365For printing name of block_device pointers.
Dmitry Monakhov1031bc52015-04-13 16:31:35 +0400366
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300367struct va_format
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100368----------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300369
370::
Andrew Murray04c55712011-06-15 12:57:09 -0700371
372 %pV
373
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300374For printing struct va_format structures. These contain a format string
375and va_list as follows::
Andrew Murray04c55712011-06-15 12:57:09 -0700376
377 struct va_format {
378 const char *fmt;
379 va_list *va;
380 };
381
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300382Implements a "recursive vsnprintf".
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800383
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300384Do not use this feature without some mechanism to verify the
385correctness of the format string and va_list arguments.
Randy Dunlapb67ad182008-11-12 13:26:55 -0800386
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300387Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700388
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300389kobjects
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100390--------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300391
392::
393
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200394 %pOF[fnpPcCF]
395
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200396
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100397For printing kobject based structs (device nodes). Default behaviour is
398equivalent to %pOFf.
399
400 - f - device node full_name
401 - n - device node name
402 - p - device node phandle
403 - P - device node path spec (name + @unit)
404 - F - device node flags
405 - c - major compatible string
406 - C - full compatible string
407
408The separator when using multiple arguments is ':'
409
410Examples::
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200411
412 %pOF /foo/bar@0 - Node full name
413 %pOFf /foo/bar@0 - Same as above
414 %pOFfp /foo/bar@0:10 - Node full name + phandle
415 %pOFfcF /foo/bar@0:foo,device:--P- - Node full name +
416 major compatible string +
417 node flags
418 D - dynamic
419 d - detached
420 P - Populated
421 B - Populated bus
422
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100423Passed by reference.
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300424
425struct clk
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100426----------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300427
428::
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700429
430 %pC pll1
431 %pCn pll1
432 %pCr 1560000000
433
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100434For printing struct clk structures. %pC and %pCn print the name
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300435(Common Clock Framework) or address (legacy clock framework) of the
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100436structure; %pCr prints the current clock rate.
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700437
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300438Passed by reference.
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700439
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300440bitmap and its derivatives such as cpumask and nodemask
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100441-------------------------------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300442
443::
Wang Longd0724962015-02-26 03:28:25 +0000444
445 %*pb 0779
446 %*pbl 0,3-6,8-10
447
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300448For printing bitmap and its derivatives such as cpumask and nodemask,
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100449%*pb outputs the bitmap with field width as the number of bits and %*pbl
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300450output the bitmap as range list with field width as the number of bits.
Wang Longd0724962015-02-26 03:28:25 +0000451
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300452Passed by reference.
Randy Dunlapb67ad182008-11-12 13:26:55 -0800453
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300454Flags bitfields such as page flags, gfp_flags
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100455---------------------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300456
457::
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700458
459 %pGp referenced|uptodate|lru|active|private
460 %pGg GFP_USER|GFP_DMA32|GFP_NOWARN
461 %pGv read|exec|mayread|maywrite|mayexec|denywrite
462
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300463For printing flags bitfields as a collection of symbolic constants that
464would construct the value. The type of flags is given by the third
465character. Currently supported are [p]age flags, [v]ma_flags (both
466expect ``unsigned long *``) and [g]fp_flags (expects ``gfp_t *``). The flag
467names and print order depends on the particular type.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700468
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100469Note that this format should not be used directly in the
470:c:func:`TP_printk()` part of a tracepoint. Instead, use the show_*_flags()
471functions from <trace/events/mmflags.h>.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700472
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300473Passed by reference.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700474
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300475Network device features
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100476-----------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300477
478::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800479
480 %pNF 0x000000000000c000
481
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300482For printing netdev_features_t.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800483
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300484Passed by reference.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800485
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100486Thanks
487======
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800488
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100489If you add other %p extensions, please extend <lib/test_printf.c> with
490one or more test cases, if at all feasible.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800491
Randy Dunlapb67ad182008-11-12 13:26:55 -0800492Thank you for your cooperation and attention.