blob: 25dc591cb1108790229e18e33da2291eb0317c74 [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
Joel Stanley156383b2018-03-22 15:53:36 +103063the first 32 bits are zeroed. The kernel will print ``(ptrval)`` until it
64gathers enough entropy. If you *really* want the address see %px below.
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110065
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
Sergey Senozhatsky04b8eb72017-12-06 13:36:49 +090071 %pS versatile_init+0x0/0x110
72 %ps versatile_init
Andrew Murray04c55712011-06-15 12:57:09 -070073 %pF versatile_init+0x0/0x110
74 %pf versatile_init
Joe Perchesb0d33c22012-12-12 10:18:50 -080075 %pSR versatile_init+0x9/0x110
76 (with __builtin_extract_return_addr() translation)
Andrew Murray04c55712011-06-15 12:57:09 -070077 %pB prev_fn_of_versatile_init+0x88/0x88
78
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110079
Sergey Senozhatsky04b8eb72017-12-06 13:36:49 +090080The ``S`` and ``s`` specifiers are used for printing a pointer in symbolic
Linus Torvaldsab486bc2018-02-01 13:36:15 -080081format. They result in the symbol name with (S) or without (s)
Sergey Senozhatsky04b8eb72017-12-06 13:36:49 +090082offsets. If KALLSYMS are disabled then the symbol address is printed instead.
Helge Dellerd6957f32017-08-15 11:34:19 +020083
Sergey Senozhatsky04b8eb72017-12-06 13:36:49 +090084Note, that the ``F`` and ``f`` specifiers are identical to ``S`` (``s``)
85and thus deprecated. We have ``F`` and ``f`` because on ia64, ppc64 and
86parisc64 function pointers are indirect and, in fact, are function
87descriptors, which require additional dereferencing before we can lookup
88the symbol. As of now, ``S`` and ``s`` perform dereferencing on those
89platforms (when needed), so ``F`` and ``f`` exist for compatibility
90reasons only.
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
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030097Kernel Pointers
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +110098---------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030099
100::
Andrew Murray04c55712011-06-15 12:57:09 -0700101
Tobin C. Harding553d8e82017-11-23 10:55:24 +1100102 %pK 01234567 or 0123456789abcdef
Andrew Murray04c55712011-06-15 12:57:09 -0700103
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300104For printing kernel pointers which should be hidden from unprivileged
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100105users. The behaviour of %pK depends on the kptr_restrict sysctl - see
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300106Documentation/sysctl/kernel.txt for more details.
Andrew Murray04c55712011-06-15 12:57:09 -0700107
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100108Unmodified Addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100109--------------------
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100110
111::
112
113 %px 01234567 or 0123456789abcdef
114
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100115For printing pointers when you *really* want to print the address. Please
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100116consider whether or not you are leaking sensitive information about the
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100117kernel memory layout before printing pointers with %px. %px is functionally
118equivalent to %lx (or %lu). %px is preferred because it is more uniquely
119grep'able. If in the future we need to modify the way the kernel handles
120printing pointers we will be better equipped to find the call sites.
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100121
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300122Struct Resources
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100123----------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300124
125::
Andrew Murray04c55712011-06-15 12:57:09 -0700126
127 %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
128 [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
129 %pR [mem 0x60000000-0x6fffffff pref] or
130 [mem 0x0000000060000000-0x000000006fffffff pref]
131
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300132For printing struct resources. The ``R`` and ``r`` specifiers result in a
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100133printed resource with (R) or without (r) a decoded flags member.
134
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300135Passed by reference.
Andrew Murray04c55712011-06-15 12:57:09 -0700136
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100137Physical address types phys_addr_t
138----------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300139
140::
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800141
Joe Perchesaaf07622014-01-23 15:54:17 -0800142 %pa[p] 0x01234567 or 0x0123456789abcdef
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800143
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100144For printing a phys_addr_t type (and its derivatives, such as
145resource_size_t) which can vary based on build options, regardless of the
146width of the CPU data path.
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800147
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100148Passed by reference.
149
150DMA address types dma_addr_t
151----------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300152
153::
Joe Perchesaaf07622014-01-23 15:54:17 -0800154
155 %pad 0x01234567 or 0x0123456789abcdef
156
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100157For printing a dma_addr_t type which can vary based on build options,
158regardless of the width of the CPU data path.
159
160Passed by reference.
Joe Perchesaaf07622014-01-23 15:54:17 -0800161
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300162Raw buffer as an escaped string
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100163-------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300164
165::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700166
167 %*pE[achnops]
168
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300169For printing raw buffer as an escaped string. For the following buffer::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700170
171 1b 62 20 5c 43 07 22 90 0d 5d
172
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100173A few examples show how the conversion would be done (excluding surrounding
174quotes)::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700175
176 %*pE "\eb \C\a"\220\r]"
177 %*pEhp "\x1bb \C\x07"\x90\x0d]"
178 %*pEa "\e\142\040\\\103\a\042\220\r\135"
179
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300180The conversion rules are applied according to an optional combination
181of flags (see :c:func:`string_escape_mem` kernel documentation for the
182details):
Andy Shevchenko71dca952014-10-13 15:55:18 -0700183
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100184 - a - ESCAPE_ANY
185 - c - ESCAPE_SPECIAL
186 - h - ESCAPE_HEX
187 - n - ESCAPE_NULL
188 - o - ESCAPE_OCTAL
189 - p - ESCAPE_NP
190 - s - ESCAPE_SPACE
Andy Shevchenko71dca952014-10-13 15:55:18 -0700191
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300192By default ESCAPE_ANY_NP is used.
Andy Shevchenko71dca952014-10-13 15:55:18 -0700193
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300194ESCAPE_ANY_NP is the sane choice for many cases, in particularly for
195printing SSIDs.
196
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100197If field width is omitted then 1 byte only will be escaped.
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300198
199Raw buffer as a hex string
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100200--------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300201
202::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800203
Andy Shevchenko31550a12012-07-30 14:40:27 -0700204 %*ph 00 01 02 ... 3f
205 %*phC 00:01:02: ... :3f
206 %*phD 00-01-02- ... -3f
207 %*phN 000102 ... 3f
208
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100209For printing small buffers (up to 64 bytes long) as a hex string with a
210certain separator. For larger buffers consider using
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300211:c:func:`print_hex_dump`.
Andy Shevchenko31550a12012-07-30 14:40:27 -0700212
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300213MAC/FDDI addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100214------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300215
216::
Andrew Murray04c55712011-06-15 12:57:09 -0700217
218 %pM 00:01:02:03:04:05
Andrei Emeltchenko76597ff92012-07-30 14:40:23 -0700219 %pMR 05:04:03:02:01:00
Andrew Murray04c55712011-06-15 12:57:09 -0700220 %pMF 00-01-02-03-04-05
221 %pm 000102030405
Andy Shevchenko7c591542012-10-04 17:12:33 -0700222 %pmR 050403020100
Andrew Murray04c55712011-06-15 12:57:09 -0700223
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300224For printing 6-byte MAC/FDDI addresses in hex notation. The ``M`` and ``m``
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100225specifiers result in a printed address with (M) or without (m) byte
226separators. The default byte separator is the colon (:).
Andrew Murray04c55712011-06-15 12:57:09 -0700227
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300228Where FDDI addresses are concerned the ``F`` specifier can be used after
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100229the ``M`` specifier to use dash (-) separators instead of the default
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300230separator.
Andrew Murray04c55712011-06-15 12:57:09 -0700231
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300232For Bluetooth addresses the ``R`` specifier shall be used after the ``M``
233specifier to use reversed byte order suitable for visual interpretation
234of Bluetooth addresses which are in the little endian order.
Andrei Emeltchenko76597ff92012-07-30 14:40:23 -0700235
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300236Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700237
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300238IPv4 addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100239--------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300240
241::
Andrew Murray04c55712011-06-15 12:57:09 -0700242
243 %pI4 1.2.3.4
244 %pi4 001.002.003.004
Daniel Borkmann8ecada12013-06-28 15:49:39 +0200245 %p[Ii]4[hnbl]
Andrew Murray04c55712011-06-15 12:57:09 -0700246
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300247For printing IPv4 dot-separated decimal addresses. The ``I4`` and ``i4``
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100248specifiers result in a printed address with (i4) or without (I4) leading
249zeros.
Andrew Murray04c55712011-06-15 12:57:09 -0700250
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300251The additional ``h``, ``n``, ``b``, and ``l`` specifiers are used to specify
252host, network, big or little endian order addresses respectively. Where
253no specifier is provided the default network/big endian order is used.
Andrew Murray04c55712011-06-15 12:57:09 -0700254
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300255Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700256
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300257IPv6 addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100258--------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300259
260::
Andrew Murray04c55712011-06-15 12:57:09 -0700261
262 %pI6 0001:0002:0003:0004:0005:0006:0007:0008
263 %pi6 00010002000300040005000600070008
264 %pI6c 1:2:3:4:5:6:7:8
265
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300266For printing IPv6 network-order 16-bit hex addresses. The ``I6`` and ``i6``
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100267specifiers result in a printed address with (I6) or without (i6)
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300268colon-separators. Leading zeros are always used.
Andrew Murray04c55712011-06-15 12:57:09 -0700269
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300270The additional ``c`` specifier can be used with the ``I`` specifier to
271print a compressed IPv6 address as described by
272http://tools.ietf.org/html/rfc5952
Andrew Murray04c55712011-06-15 12:57:09 -0700273
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300274Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700275
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300276IPv4/IPv6 addresses (generic, with port, flowinfo, scope)
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100277---------------------------------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300278
279::
Daniel Borkmann10679642013-06-28 19:49:39 +0200280
281 %pIS 1.2.3.4 or 0001:0002:0003:0004:0005:0006:0007:0008
282 %piS 001.002.003.004 or 00010002000300040005000600070008
283 %pISc 1.2.3.4 or 1:2:3:4:5:6:7:8
284 %pISpc 1.2.3.4:12345 or [1:2:3:4:5:6:7:8]:12345
285 %p[Ii]S[pfschnbl]
286
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100287For printing an IP address without the need to distinguish whether it's of
288type AF_INET or AF_INET6. A pointer to a valid struct sockaddr,
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300289specified through ``IS`` or ``iS``, can be passed to this format specifier.
Daniel Borkmann10679642013-06-28 19:49:39 +0200290
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300291The additional ``p``, ``f``, and ``s`` specifiers are used to specify port
292(IPv4, IPv6), flowinfo (IPv6) and scope (IPv6). Ports have a ``:`` prefix,
293flowinfo a ``/`` and scope a ``%``, each followed by the actual value.
Daniel Borkmann10679642013-06-28 19:49:39 +0200294
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300295In case of an IPv6 address the compressed IPv6 address as described by
296http://tools.ietf.org/html/rfc5952 is being used if the additional
297specifier ``c`` is given. The IPv6 address is surrounded by ``[``, ``]`` in
298case of additional specifiers ``p``, ``f`` or ``s`` as suggested by
299https://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07
Daniel Borkmann10679642013-06-28 19:49:39 +0200300
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300301In case of IPv4 addresses, the additional ``h``, ``n``, ``b``, and ``l``
302specifiers can be used as well and are ignored in case of an IPv6
303address.
Daniel Borkmann10679642013-06-28 19:49:39 +0200304
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300305Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700306
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300307Further examples::
Daniel Borkmann10679642013-06-28 19:49:39 +0200308
309 %pISfc 1.2.3.4 or [1:2:3:4:5:6:7:8]/123456789
310 %pISsc 1.2.3.4 or [1:2:3:4:5:6:7:8]%1234567890
311 %pISpfc 1.2.3.4:12345 or [1:2:3:4:5:6:7:8]:12345/123456789
312
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300313UUID/GUID addresses
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100314-------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300315
316::
Andrew Murray04c55712011-06-15 12:57:09 -0700317
318 %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
319 %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
320 %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
321 %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
322
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100323For printing 16-byte UUID/GUIDs addresses. The additional ``l``, ``L``,
324``b`` and ``B`` specifiers are used to specify a little endian order in
325lower (l) or upper case (L) hex notation - and big endian order in lower (b)
326or upper case (B) hex notation.
Andrew Murray04c55712011-06-15 12:57:09 -0700327
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300328Where no additional specifiers are used the default big endian
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100329order with lower case hex notation will be printed.
Andrew Murray04c55712011-06-15 12:57:09 -0700330
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300331Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700332
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300333dentry names
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100334------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300335
336::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800337
Al Viro4b6ccca2013-09-03 12:00:44 -0400338 %pd{,2,3,4}
339 %pD{,2,3,4}
340
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100341For printing dentry name; if we race with :c:func:`d_move`, the name might
342be a mix of old and new ones, but it won't oops. %pd dentry is a safer
343equivalent of %s dentry->d_name.name we used to use, %pd<n> prints ``n``
344last components. %pD does the same thing for struct file.
Al Viro4b6ccca2013-09-03 12:00:44 -0400345
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300346Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700347
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300348block_device names
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100349------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300350
351::
Dmitry Monakhov1031bc52015-04-13 16:31:35 +0400352
353 %pg sda, sda1 or loop0p1
354
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300355For printing name of block_device pointers.
Dmitry Monakhov1031bc52015-04-13 16:31:35 +0400356
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300357struct va_format
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100358----------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300359
360::
Andrew Murray04c55712011-06-15 12:57:09 -0700361
362 %pV
363
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300364For printing struct va_format structures. These contain a format string
365and va_list as follows::
Andrew Murray04c55712011-06-15 12:57:09 -0700366
367 struct va_format {
368 const char *fmt;
369 va_list *va;
370 };
371
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300372Implements a "recursive vsnprintf".
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800373
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300374Do not use this feature without some mechanism to verify the
375correctness of the format string and va_list arguments.
Randy Dunlapb67ad182008-11-12 13:26:55 -0800376
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300377Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700378
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300379kobjects
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100380--------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300381
382::
383
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200384 %pOF[fnpPcCF]
385
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200386
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100387For printing kobject based structs (device nodes). Default behaviour is
388equivalent to %pOFf.
389
390 - f - device node full_name
391 - n - device node name
392 - p - device node phandle
393 - P - device node path spec (name + @unit)
394 - F - device node flags
395 - c - major compatible string
396 - C - full compatible string
397
398The separator when using multiple arguments is ':'
399
400Examples::
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200401
402 %pOF /foo/bar@0 - Node full name
403 %pOFf /foo/bar@0 - Same as above
404 %pOFfp /foo/bar@0:10 - Node full name + phandle
405 %pOFfcF /foo/bar@0:foo,device:--P- - Node full name +
406 major compatible string +
407 node flags
408 D - dynamic
409 d - detached
410 P - Populated
411 B - Populated bus
412
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100413Passed by reference.
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300414
415struct clk
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100416----------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300417
418::
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700419
420 %pC pll1
421 %pCn pll1
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700422
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100423For printing struct clk structures. %pC and %pCn print the name
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300424(Common Clock Framework) or address (legacy clock framework) of the
Geert Uytterhoeven666902e2018-06-01 11:28:22 +0200425structure.
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700426
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300427Passed by reference.
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700428
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300429bitmap and its derivatives such as cpumask and nodemask
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100430-------------------------------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300431
432::
Wang Longd0724962015-02-26 03:28:25 +0000433
434 %*pb 0779
435 %*pbl 0,3-6,8-10
436
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300437For printing bitmap and its derivatives such as cpumask and nodemask,
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100438%*pb outputs the bitmap with field width as the number of bits and %*pbl
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300439output the bitmap as range list with field width as the number of bits.
Wang Longd0724962015-02-26 03:28:25 +0000440
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300441Passed by reference.
Randy Dunlapb67ad182008-11-12 13:26:55 -0800442
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300443Flags bitfields such as page flags, gfp_flags
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100444---------------------------------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300445
446::
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700447
448 %pGp referenced|uptodate|lru|active|private
449 %pGg GFP_USER|GFP_DMA32|GFP_NOWARN
450 %pGv read|exec|mayread|maywrite|mayexec|denywrite
451
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300452For printing flags bitfields as a collection of symbolic constants that
453would construct the value. The type of flags is given by the third
454character. Currently supported are [p]age flags, [v]ma_flags (both
455expect ``unsigned long *``) and [g]fp_flags (expects ``gfp_t *``). The flag
456names and print order depends on the particular type.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700457
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100458Note that this format should not be used directly in the
459:c:func:`TP_printk()` part of a tracepoint. Instead, use the show_*_flags()
460functions from <trace/events/mmflags.h>.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700461
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300462Passed by reference.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700463
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300464Network device features
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100465-----------------------
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300466
467::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800468
469 %pNF 0x000000000000c000
470
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300471For printing netdev_features_t.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800472
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300473Passed by reference.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800474
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100475Thanks
476======
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800477
Tobin C. Hardingb3ed2322017-12-20 08:17:15 +1100478If you add other %p extensions, please extend <lib/test_printf.c> with
479one or more test cases, if at all feasible.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800480
Randy Dunlapb67ad182008-11-12 13:26:55 -0800481Thank you for your cooperation and attention.