blob: aa0a776c817a7ceabb217c3eecc31ecdb32f59c7 [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
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -03008Integer types
9=============
10
11::
12
13 If variable is of Type, use printk format specifier:
14 ------------------------------------------------------------
Randy Dunlapb67ad182008-11-12 13:26:55 -080015 int %d or %x
16 unsigned int %u or %x
17 long %ld or %lx
18 unsigned long %lu or %lx
19 long long %lld or %llx
20 unsigned long long %llu or %llx
21 size_t %zu or %zx
22 ssize_t %zd or %zx
Geert Uytterhoevene8a7ba52015-04-15 16:17:17 -070023 s32 %d or %x
24 u32 %u or %x
25 s64 %lld or %llx
26 u64 %llu or %llx
27
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030028If <type> is dependent on a config option for its size (e.g., ``sector_t``,
29``blkcnt_t``) or is architecture-dependent for its size (e.g., ``tcflag_t``),
30use a format specifier of its largest possible type and explicitly cast to it.
31
32Example::
Geert Uytterhoevene8a7ba52015-04-15 16:17:17 -070033
34 printk("test: sector number/total blocks: %llu/%llu\n",
35 (unsigned long long)sector, (unsigned long long)blockcount);
36
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030037Reminder: ``sizeof()`` result is of type ``size_t``.
Geert Uytterhoevene8a7ba52015-04-15 16:17:17 -070038
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030039The kernel's printf does not support ``%n``. For obvious reasons, floating
40point formats (``%e, %f, %g, %a``) are also not recognized. Use of any
Rasmus Villemoesd7ec9a02015-11-06 16:30:35 -080041unsupported specifier or length qualifier results in a WARN and early
42return from vsnprintf.
Randy Dunlapb67ad182008-11-12 13:26:55 -080043
Andrew Murray04c55712011-06-15 12:57:09 -070044Raw pointer value SHOULD be printed with %p. The kernel supports
45the following extended format specifiers for pointer types:
46
Tobin C. Hardingad67b742017-11-01 15:32:23 +110047Pointer Types
48=============
49
50Pointers printed without a specifier extension (i.e unadorned %p) are
51hashed to give a unique identifier without leaking kernel addresses to user
Tobin C. Harding7b1924a2017-11-23 10:59:45 +110052space. On 64 bit machines the first 32 bits are zeroed. If you _really_
53want the address see %px below.
Tobin C. Hardingad67b742017-11-01 15:32:23 +110054
55::
56
57 %p abcdef12 or 00000000abcdef12
58
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030059Symbols/Function Pointers
60=========================
61
62::
Andrew Murray04c55712011-06-15 12:57:09 -070063
64 %pF versatile_init+0x0/0x110
65 %pf versatile_init
66 %pS versatile_init+0x0/0x110
Joe Perchesb0d33c22012-12-12 10:18:50 -080067 %pSR versatile_init+0x9/0x110
68 (with __builtin_extract_return_addr() translation)
Andrew Murray04c55712011-06-15 12:57:09 -070069 %ps versatile_init
70 %pB prev_fn_of_versatile_init+0x88/0x88
71
Helge Dellerd6957f332017-08-15 11:34:19 +020072The ``F`` and ``f`` specifiers are for printing function pointers,
73for example, f->func, &gettimeofday. They have the same result as
74``S`` and ``s`` specifiers. But they do an extra conversion on
75ia64, ppc64 and parisc64 architectures where the function pointers
76are actually function descriptors.
77
78The ``S`` and ``s`` specifiers can be used for printing symbols
79from direct addresses, for example, __builtin_return_address(0),
80(void *)regs->ip. They result in the symbol name with (``S``) or
81without (``s``) offsets. If KALLSYMS are disabled then the symbol
82address is printed instead.
Andrew Murray04c55712011-06-15 12:57:09 -070083
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030084The ``B`` specifier results in the symbol name with offsets and should be
85used when printing stack backtraces. The specifier takes into
86consideration the effect of compiler optimisations which may occur
87when tail-call``s are used and marked with the noreturn GCC attribute.
Andrew Murray04c55712011-06-15 12:57:09 -070088
Helge Dellerfd46cd52017-08-23 21:52:05 +020089Examples::
90
91 printk("Going to call: %pF\n", gettimeofday);
92 printk("Going to call: %pF\n", p->func);
93 printk("%s: called from %pS\n", __func__, (void *)_RET_IP_);
94 printk("%s: called from %pS\n", __func__,
95 (void *)__builtin_return_address(0));
96 printk("Faulted at %pS\n", (void *)regs->ip);
97 printk(" %s%pB\n", (reliable ? "" : "? "), (void *)*stack);
98
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -030099Kernel Pointers
100===============
101
102::
Andrew Murray04c55712011-06-15 12:57:09 -0700103
Tobin C. Harding553d8e82017-11-23 10:55:24 +1100104 %pK 01234567 or 0123456789abcdef
Andrew Murray04c55712011-06-15 12:57:09 -0700105
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300106For printing kernel pointers which should be hidden from unprivileged
107users. The behaviour of ``%pK`` depends on the ``kptr_restrict sysctl`` - see
108Documentation/sysctl/kernel.txt for more details.
Andrew Murray04c55712011-06-15 12:57:09 -0700109
Tobin C. Harding7b1924a2017-11-23 10:59:45 +1100110Unmodified Addresses
111====================
112
113::
114
115 %px 01234567 or 0123456789abcdef
116
117For printing pointers when you _really_ want to print the address. Please
118consider whether or not you are leaking sensitive information about the
119Kernel layout in memory before printing pointers with %px. %px is
120functionally equivalent to %lx. %px is preferred to %lx because it is more
121uniquely grep'able. If, in the future, we need to modify the way the Kernel
122handles printing pointers it will be nice to be able to find the call
123sites.
124
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300125Struct Resources
126================
127
128::
Andrew Murray04c55712011-06-15 12:57:09 -0700129
130 %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
131 [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
132 %pR [mem 0x60000000-0x6fffffff pref] or
133 [mem 0x0000000060000000-0x000000006fffffff pref]
134
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300135For printing struct resources. The ``R`` and ``r`` specifiers result in a
136printed resource with (``R``) or without (``r``) a decoded flags member.
137Passed by reference.
Andrew Murray04c55712011-06-15 12:57:09 -0700138
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300139Physical addresses types ``phys_addr_t``
140========================================
141
142::
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800143
Joe Perchesaaf07622014-01-23 15:54:17 -0800144 %pa[p] 0x01234567 or 0x0123456789abcdef
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800145
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300146For printing a ``phys_addr_t`` type (and its derivatives, such as
147``resource_size_t``) which can vary based on build options, regardless of
148the width of the CPU data path. Passed by reference.
Stepan Moskovchenko7d799212013-02-21 16:43:09 -0800149
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300150DMA addresses types ``dma_addr_t``
151==================================
152
153::
Joe Perchesaaf07622014-01-23 15:54:17 -0800154
155 %pad 0x01234567 or 0x0123456789abcdef
156
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300157For printing a ``dma_addr_t`` type which can vary based on build options,
158regardless of the width of the CPU data path. Passed by reference.
Joe Perchesaaf07622014-01-23 15:54:17 -0800159
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300160Raw buffer as an escaped string
161===============================
162
163::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700164
165 %*pE[achnops]
166
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300167For printing raw buffer as an escaped string. For the following buffer::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700168
169 1b 62 20 5c 43 07 22 90 0d 5d
170
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300171few examples show how the conversion would be done (the result string
172without surrounding quotes)::
Andy Shevchenko71dca952014-10-13 15:55:18 -0700173
174 %*pE "\eb \C\a"\220\r]"
175 %*pEhp "\x1bb \C\x07"\x90\x0d]"
176 %*pEa "\e\142\040\\\103\a\042\220\r\135"
177
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300178The conversion rules are applied according to an optional combination
179of flags (see :c:func:`string_escape_mem` kernel documentation for the
180details):
Andy Shevchenko71dca952014-10-13 15:55:18 -0700181
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300182 - ``a`` - ESCAPE_ANY
183 - ``c`` - ESCAPE_SPECIAL
184 - ``h`` - ESCAPE_HEX
185 - ``n`` - ESCAPE_NULL
186 - ``o`` - ESCAPE_OCTAL
187 - ``p`` - ESCAPE_NP
188 - ``s`` - ESCAPE_SPACE
Andy Shevchenko71dca952014-10-13 15:55:18 -0700189
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300190By default ESCAPE_ANY_NP is used.
Andy Shevchenko71dca952014-10-13 15:55:18 -0700191
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300192ESCAPE_ANY_NP is the sane choice for many cases, in particularly for
193printing SSIDs.
194
195If field width is omitted the 1 byte only will be escaped.
196
197Raw buffer as a hex string
198==========================
199
200::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800201
Andy Shevchenko31550a12012-07-30 14:40:27 -0700202 %*ph 00 01 02 ... 3f
203 %*phC 00:01:02: ... :3f
204 %*phD 00-01-02- ... -3f
205 %*phN 000102 ... 3f
206
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300207For printing a small buffers (up to 64 bytes long) as a hex string with
208certain separator. For the larger buffers consider to use
209:c:func:`print_hex_dump`.
Andy Shevchenko31550a12012-07-30 14:40:27 -0700210
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300211MAC/FDDI addresses
212==================
213
214::
Andrew Murray04c55712011-06-15 12:57:09 -0700215
216 %pM 00:01:02:03:04:05
Andrei Emeltchenko76597ff92012-07-30 14:40:23 -0700217 %pMR 05:04:03:02:01:00
Andrew Murray04c55712011-06-15 12:57:09 -0700218 %pMF 00-01-02-03-04-05
219 %pm 000102030405
Andy Shevchenko7c591542012-10-04 17:12:33 -0700220 %pmR 050403020100
Andrew Murray04c55712011-06-15 12:57:09 -0700221
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300222For printing 6-byte MAC/FDDI addresses in hex notation. The ``M`` and ``m``
223specifiers result in a printed address with (``M``) or without (``m``) byte
224separators. The default byte separator is the colon (``:``).
Andrew Murray04c55712011-06-15 12:57:09 -0700225
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300226Where FDDI addresses are concerned the ``F`` specifier can be used after
227the ``M`` specifier to use dash (``-``) separators instead of the default
228separator.
Andrew Murray04c55712011-06-15 12:57:09 -0700229
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300230For Bluetooth addresses the ``R`` specifier shall be used after the ``M``
231specifier to use reversed byte order suitable for visual interpretation
232of Bluetooth addresses which are in the little endian order.
Andrei Emeltchenko76597ff92012-07-30 14:40:23 -0700233
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300234Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700235
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300236IPv4 addresses
237==============
238
239::
Andrew Murray04c55712011-06-15 12:57:09 -0700240
241 %pI4 1.2.3.4
242 %pi4 001.002.003.004
Daniel Borkmann8ecada12013-06-28 15:49:39 +0200243 %p[Ii]4[hnbl]
Andrew Murray04c55712011-06-15 12:57:09 -0700244
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300245For printing IPv4 dot-separated decimal addresses. The ``I4`` and ``i4``
246specifiers result in a printed address with (``i4``) or without (``I4``)
247leading zeros.
Andrew Murray04c55712011-06-15 12:57:09 -0700248
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300249The additional ``h``, ``n``, ``b``, and ``l`` specifiers are used to specify
250host, network, big or little endian order addresses respectively. Where
251no specifier is provided the default network/big endian order is used.
Andrew Murray04c55712011-06-15 12:57:09 -0700252
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300253Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700254
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300255IPv6 addresses
256==============
257
258::
Andrew Murray04c55712011-06-15 12:57:09 -0700259
260 %pI6 0001:0002:0003:0004:0005:0006:0007:0008
261 %pi6 00010002000300040005000600070008
262 %pI6c 1:2:3:4:5:6:7:8
263
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300264For printing IPv6 network-order 16-bit hex addresses. The ``I6`` and ``i6``
265specifiers result in a printed address with (``I6``) or without (``i6``)
266colon-separators. Leading zeros are always used.
Andrew Murray04c55712011-06-15 12:57:09 -0700267
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300268The additional ``c`` specifier can be used with the ``I`` specifier to
269print a compressed IPv6 address as described by
270http://tools.ietf.org/html/rfc5952
Andrew Murray04c55712011-06-15 12:57:09 -0700271
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300272Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700273
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300274IPv4/IPv6 addresses (generic, with port, flowinfo, scope)
275=========================================================
276
277::
Daniel Borkmann10679642013-06-28 19:49:39 +0200278
279 %pIS 1.2.3.4 or 0001:0002:0003:0004:0005:0006:0007:0008
280 %piS 001.002.003.004 or 00010002000300040005000600070008
281 %pISc 1.2.3.4 or 1:2:3:4:5:6:7:8
282 %pISpc 1.2.3.4:12345 or [1:2:3:4:5:6:7:8]:12345
283 %p[Ii]S[pfschnbl]
284
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300285For printing an IP address without the need to distinguish whether it``s
286of type AF_INET or AF_INET6, a pointer to a valid ``struct sockaddr``,
287specified through ``IS`` or ``iS``, can be passed to this format specifier.
Daniel Borkmann10679642013-06-28 19:49:39 +0200288
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300289The additional ``p``, ``f``, and ``s`` specifiers are used to specify port
290(IPv4, IPv6), flowinfo (IPv6) and scope (IPv6). Ports have a ``:`` prefix,
291flowinfo a ``/`` and scope a ``%``, each followed by the actual value.
Daniel Borkmann10679642013-06-28 19:49:39 +0200292
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300293In case of an IPv6 address the compressed IPv6 address as described by
294http://tools.ietf.org/html/rfc5952 is being used if the additional
295specifier ``c`` is given. The IPv6 address is surrounded by ``[``, ``]`` in
296case of additional specifiers ``p``, ``f`` or ``s`` as suggested by
297https://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07
Daniel Borkmann10679642013-06-28 19:49:39 +0200298
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300299In case of IPv4 addresses, the additional ``h``, ``n``, ``b``, and ``l``
300specifiers can be used as well and are ignored in case of an IPv6
301address.
Daniel Borkmann10679642013-06-28 19:49:39 +0200302
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300303Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700304
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300305Further examples::
Daniel Borkmann10679642013-06-28 19:49:39 +0200306
307 %pISfc 1.2.3.4 or [1:2:3:4:5:6:7:8]/123456789
308 %pISsc 1.2.3.4 or [1:2:3:4:5:6:7:8]%1234567890
309 %pISpfc 1.2.3.4:12345 or [1:2:3:4:5:6:7:8]:12345/123456789
310
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300311UUID/GUID addresses
312===================
313
314::
Andrew Murray04c55712011-06-15 12:57:09 -0700315
316 %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
317 %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
318 %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
319 %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
320
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300321For printing 16-byte UUID/GUIDs addresses. The additional 'l', 'L',
322'b' and 'B' specifiers are used to specify a little endian order in
323lower ('l') or upper case ('L') hex characters - and big endian order
324in lower ('b') or upper case ('B') hex characters.
Andrew Murray04c55712011-06-15 12:57:09 -0700325
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300326Where no additional specifiers are used the default big endian
327order with lower case hex characters will be printed.
Andrew Murray04c55712011-06-15 12:57:09 -0700328
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300329Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700330
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300331dentry names
332============
333
334::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800335
Al Viro4b6ccca2013-09-03 12:00:44 -0400336 %pd{,2,3,4}
337 %pD{,2,3,4}
338
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300339For printing dentry name; if we race with :c:func:`d_move`, the name might be
340a mix of old and new ones, but it won't oops. ``%pd`` dentry is a safer
341equivalent of ``%s`` ``dentry->d_name.name`` we used to use, ``%pd<n>`` prints
342``n`` last components. ``%pD`` does the same thing for struct file.
Al Viro4b6ccca2013-09-03 12:00:44 -0400343
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300344Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700345
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300346block_device names
347==================
348
349::
Dmitry Monakhov1031bc52015-04-13 16:31:35 +0400350
351 %pg sda, sda1 or loop0p1
352
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300353For printing name of block_device pointers.
Dmitry Monakhov1031bc52015-04-13 16:31:35 +0400354
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300355struct va_format
356================
357
358::
Andrew Murray04c55712011-06-15 12:57:09 -0700359
360 %pV
361
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300362For printing struct va_format structures. These contain a format string
363and va_list as follows::
Andrew Murray04c55712011-06-15 12:57:09 -0700364
365 struct va_format {
366 const char *fmt;
367 va_list *va;
368 };
369
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300370Implements a "recursive vsnprintf".
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800371
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300372Do not use this feature without some mechanism to verify the
373correctness of the format string and va_list arguments.
Randy Dunlapb67ad182008-11-12 13:26:55 -0800374
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300375Passed by reference.
Geert Uytterhoeven73306602015-04-15 16:17:14 -0700376
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300377kobjects
378========
379
380::
381
Pantelis Antoniouce4fecf2015-01-21 19:06:14 +0200382 %pO
383
384 Base specifier for kobject based structs. Must be followed with
385 character for specific type of kobject as listed below:
386
387 Device tree nodes:
388
389 %pOF[fnpPcCF]
390
391 For printing device tree nodes. The optional arguments are:
392 f device node full_name
393 n device node name
394 p device node phandle
395 P device node path spec (name + @unit)
396 F device node flags
397 c major compatible string
398 C full compatible string
399 Without any arguments prints full_name (same as %pOFf)
400 The separator when using multiple arguments is ':'
401
402 Examples:
403
404 %pOF /foo/bar@0 - Node full name
405 %pOFf /foo/bar@0 - Same as above
406 %pOFfp /foo/bar@0:10 - Node full name + phandle
407 %pOFfcF /foo/bar@0:foo,device:--P- - Node full name +
408 major compatible string +
409 node flags
410 D - dynamic
411 d - detached
412 P - Populated
413 B - Populated bus
414
415 Passed by reference.
416
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300417
418struct clk
419==========
420
421::
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700422
423 %pC pll1
424 %pCn pll1
425 %pCr 1560000000
426
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300427For printing struct clk structures. ``%pC`` and ``%pCn`` print the name
428(Common Clock Framework) or address (legacy clock framework) of the
429structure; ``%pCr`` prints the current clock rate.
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700430
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300431Passed by reference.
Geert Uytterhoeven900cca22015-04-15 16:17:20 -0700432
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300433bitmap and its derivatives such as cpumask and nodemask
434=======================================================
435
436::
Wang Longd0724962015-02-26 03:28:25 +0000437
438 %*pb 0779
439 %*pbl 0,3-6,8-10
440
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300441For printing bitmap and its derivatives such as cpumask and nodemask,
442``%*pb`` output the bitmap with field width as the number of bits and ``%*pbl``
443output the bitmap as range list with field width as the number of bits.
Wang Longd0724962015-02-26 03:28:25 +0000444
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300445Passed by reference.
Randy Dunlapb67ad182008-11-12 13:26:55 -0800446
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300447Flags bitfields such as page flags, gfp_flags
448=============================================
449
450::
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700451
452 %pGp referenced|uptodate|lru|active|private
453 %pGg GFP_USER|GFP_DMA32|GFP_NOWARN
454 %pGv read|exec|mayread|maywrite|mayexec|denywrite
455
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300456For printing flags bitfields as a collection of symbolic constants that
457would construct the value. The type of flags is given by the third
458character. Currently supported are [p]age flags, [v]ma_flags (both
459expect ``unsigned long *``) and [g]fp_flags (expects ``gfp_t *``). The flag
460names and print order depends on the particular type.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700461
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300462Note that this format should not be used directly in :c:func:`TP_printk()` part
463of a tracepoint. Instead, use the ``show_*_flags()`` functions from
464<trace/events/mmflags.h>.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700465
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300466Passed by reference.
Vlastimil Babkaedf14cd2016-03-15 14:55:56 -0700467
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300468Network device features
469=======================
470
471::
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800472
473 %pNF 0x000000000000c000
474
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300475For printing netdev_features_t.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800476
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300477Passed by reference.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800478
Mauro Carvalho Chehab3b033382017-05-16 22:27:11 -0300479If you add other ``%p`` extensions, please extend lib/test_printf.c with
Rasmus Villemoesd7ec9a02015-11-06 16:30:35 -0800480one or more test cases, if at all feasible.
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800481
Martin Kletzander5e4ee7b2015-11-06 16:30:17 -0800482
Randy Dunlapb67ad182008-11-12 13:26:55 -0800483Thank you for your cooperation and attention.