xref: /OK3568_Linux_fs/kernel/Documentation/core-api/printk-formats.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=========================================
2*4882a593SmuzhiyunHow to get printk format specifiers right
3*4882a593Smuzhiyun=========================================
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun.. _printk-specifiers:
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun:Author: Randy Dunlap <rdunlap@infradead.org>
8*4882a593Smuzhiyun:Author: Andrew Murray <amurray@mpc-data.co.uk>
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunInteger types
12*4882a593Smuzhiyun=============
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun::
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun	If variable is of Type,		use printk format specifier:
17*4882a593Smuzhiyun	------------------------------------------------------------
18*4882a593Smuzhiyun		char			%d or %x
19*4882a593Smuzhiyun		unsigned char		%u or %x
20*4882a593Smuzhiyun		short int		%d or %x
21*4882a593Smuzhiyun		unsigned short int	%u or %x
22*4882a593Smuzhiyun		int			%d or %x
23*4882a593Smuzhiyun		unsigned int		%u or %x
24*4882a593Smuzhiyun		long			%ld or %lx
25*4882a593Smuzhiyun		unsigned long		%lu or %lx
26*4882a593Smuzhiyun		long long		%lld or %llx
27*4882a593Smuzhiyun		unsigned long long	%llu or %llx
28*4882a593Smuzhiyun		size_t			%zu or %zx
29*4882a593Smuzhiyun		ssize_t			%zd or %zx
30*4882a593Smuzhiyun		s8			%d or %x
31*4882a593Smuzhiyun		u8			%u or %x
32*4882a593Smuzhiyun		s16			%d or %x
33*4882a593Smuzhiyun		u16			%u or %x
34*4882a593Smuzhiyun		s32			%d or %x
35*4882a593Smuzhiyun		u32			%u or %x
36*4882a593Smuzhiyun		s64			%lld or %llx
37*4882a593Smuzhiyun		u64			%llu or %llx
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunIf <type> is dependent on a config option for its size (e.g., sector_t,
41*4882a593Smuzhiyunblkcnt_t) or is architecture-dependent for its size (e.g., tcflag_t), use a
42*4882a593Smuzhiyunformat specifier of its largest possible type and explicitly cast to it.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunExample::
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun	printk("test: sector number/total blocks: %llu/%llu\n",
47*4882a593Smuzhiyun		(unsigned long long)sector, (unsigned long long)blockcount);
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunReminder: sizeof() returns type size_t.
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunThe kernel's printf does not support %n. Floating point formats (%e, %f,
52*4882a593Smuzhiyun%g, %a) are also not recognized, for obvious reasons. Use of any
53*4882a593Smuzhiyununsupported specifier or length qualifier results in a WARN and early
54*4882a593Smuzhiyunreturn from vsnprintf().
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunPointer types
57*4882a593Smuzhiyun=============
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunA raw pointer value may be printed with %p which will hash the address
60*4882a593Smuzhiyunbefore printing. The kernel also supports extended specifiers for printing
61*4882a593Smuzhiyunpointers of different types.
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunSome of the extended specifiers print the data on the given address instead
64*4882a593Smuzhiyunof printing the address itself. In this case, the following error messages
65*4882a593Smuzhiyunmight be printed instead of the unreachable information::
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun	(null)	 data on plain NULL address
68*4882a593Smuzhiyun	(efault) data on invalid address
69*4882a593Smuzhiyun	(einval) invalid data on a valid address
70*4882a593Smuzhiyun
71*4882a593SmuzhiyunPlain Pointers
72*4882a593Smuzhiyun--------------
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun::
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun	%p	abcdef12 or 00000000abcdef12
77*4882a593Smuzhiyun
78*4882a593SmuzhiyunPointers printed without a specifier extension (i.e unadorned %p) are
79*4882a593Smuzhiyunhashed to prevent leaking information about the kernel memory layout. This
80*4882a593Smuzhiyunhas the added benefit of providing a unique identifier. On 64-bit machines
81*4882a593Smuzhiyunthe first 32 bits are zeroed. The kernel will print ``(ptrval)`` until it
82*4882a593Smuzhiyungathers enough entropy. If you *really* want the address see %px below.
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunError Pointers
85*4882a593Smuzhiyun--------------
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun::
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun	%pe	-ENOSPC
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunFor printing error pointers (i.e. a pointer for which IS_ERR() is true)
92*4882a593Smuzhiyunas a symbolic error name. Error values for which no symbolic name is
93*4882a593Smuzhiyunknown are printed in decimal, while a non-ERR_PTR passed as the
94*4882a593Smuzhiyunargument to %pe gets treated as ordinary %p.
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunSymbols/Function Pointers
97*4882a593Smuzhiyun-------------------------
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun::
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun	%pS	versatile_init+0x0/0x110
102*4882a593Smuzhiyun	%ps	versatile_init
103*4882a593Smuzhiyun	%pSR	versatile_init+0x9/0x110
104*4882a593Smuzhiyun		(with __builtin_extract_return_addr() translation)
105*4882a593Smuzhiyun	%pB	prev_fn_of_versatile_init+0x88/0x88
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunThe ``S`` and ``s`` specifiers are used for printing a pointer in symbolic
109*4882a593Smuzhiyunformat. They result in the symbol name with (S) or without (s)
110*4882a593Smuzhiyunoffsets. If KALLSYMS are disabled then the symbol address is printed instead.
111*4882a593Smuzhiyun
112*4882a593SmuzhiyunThe ``B`` specifier results in the symbol name with offsets and should be
113*4882a593Smuzhiyunused when printing stack backtraces. The specifier takes into
114*4882a593Smuzhiyunconsideration the effect of compiler optimisations which may occur
115*4882a593Smuzhiyunwhen tail-calls are used and marked with the noreturn GCC attribute.
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunProbed Pointers from BPF / tracing
118*4882a593Smuzhiyun----------------------------------
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun::
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun	%pks	kernel string
123*4882a593Smuzhiyun	%pus	user string
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunThe ``k`` and ``u`` specifiers are used for printing prior probed memory from
126*4882a593Smuzhiyuneither kernel memory (k) or user memory (u). The subsequent ``s`` specifier
127*4882a593Smuzhiyunresults in printing a string. For direct use in regular vsnprintf() the (k)
128*4882a593Smuzhiyunand (u) annotation is ignored, however, when used out of BPF's bpf_trace_printk(),
129*4882a593Smuzhiyunfor example, it reads the memory it is pointing to without faulting.
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunKernel Pointers
132*4882a593Smuzhiyun---------------
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun::
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun	%pK	01234567 or 0123456789abcdef
137*4882a593Smuzhiyun
138*4882a593SmuzhiyunFor printing kernel pointers which should be hidden from unprivileged
139*4882a593Smuzhiyunusers. The behaviour of %pK depends on the kptr_restrict sysctl - see
140*4882a593SmuzhiyunDocumentation/admin-guide/sysctl/kernel.rst for more details.
141*4882a593Smuzhiyun
142*4882a593SmuzhiyunUnmodified Addresses
143*4882a593Smuzhiyun--------------------
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun::
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun	%px	01234567 or 0123456789abcdef
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunFor printing pointers when you *really* want to print the address. Please
150*4882a593Smuzhiyunconsider whether or not you are leaking sensitive information about the
151*4882a593Smuzhiyunkernel memory layout before printing pointers with %px. %px is functionally
152*4882a593Smuzhiyunequivalent to %lx (or %lu). %px is preferred because it is more uniquely
153*4882a593Smuzhiyungrep'able. If in the future we need to modify the way the kernel handles
154*4882a593Smuzhiyunprinting pointers we will be better equipped to find the call sites.
155*4882a593Smuzhiyun
156*4882a593SmuzhiyunPointer Differences
157*4882a593Smuzhiyun-------------------
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun::
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun	%td	2560
162*4882a593Smuzhiyun	%tx	a00
163*4882a593Smuzhiyun
164*4882a593SmuzhiyunFor printing the pointer differences, use the %t modifier for ptrdiff_t.
165*4882a593Smuzhiyun
166*4882a593SmuzhiyunExample::
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun	printk("test: difference between pointers: %td\n", ptr2 - ptr1);
169*4882a593Smuzhiyun
170*4882a593SmuzhiyunStruct Resources
171*4882a593Smuzhiyun----------------
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun::
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun	%pr	[mem 0x60000000-0x6fffffff flags 0x2200] or
176*4882a593Smuzhiyun		[mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
177*4882a593Smuzhiyun	%pR	[mem 0x60000000-0x6fffffff pref] or
178*4882a593Smuzhiyun		[mem 0x0000000060000000-0x000000006fffffff pref]
179*4882a593Smuzhiyun
180*4882a593SmuzhiyunFor printing struct resources. The ``R`` and ``r`` specifiers result in a
181*4882a593Smuzhiyunprinted resource with (R) or without (r) a decoded flags member.
182*4882a593Smuzhiyun
183*4882a593SmuzhiyunPassed by reference.
184*4882a593Smuzhiyun
185*4882a593SmuzhiyunPhysical address types phys_addr_t
186*4882a593Smuzhiyun----------------------------------
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun::
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun	%pa[p]	0x01234567 or 0x0123456789abcdef
191*4882a593Smuzhiyun
192*4882a593SmuzhiyunFor printing a phys_addr_t type (and its derivatives, such as
193*4882a593Smuzhiyunresource_size_t) which can vary based on build options, regardless of the
194*4882a593Smuzhiyunwidth of the CPU data path.
195*4882a593Smuzhiyun
196*4882a593SmuzhiyunPassed by reference.
197*4882a593Smuzhiyun
198*4882a593SmuzhiyunDMA address types dma_addr_t
199*4882a593Smuzhiyun----------------------------
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun::
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun	%pad	0x01234567 or 0x0123456789abcdef
204*4882a593Smuzhiyun
205*4882a593SmuzhiyunFor printing a dma_addr_t type which can vary based on build options,
206*4882a593Smuzhiyunregardless of the width of the CPU data path.
207*4882a593Smuzhiyun
208*4882a593SmuzhiyunPassed by reference.
209*4882a593Smuzhiyun
210*4882a593SmuzhiyunRaw buffer as an escaped string
211*4882a593Smuzhiyun-------------------------------
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun::
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun	%*pE[achnops]
216*4882a593Smuzhiyun
217*4882a593SmuzhiyunFor printing raw buffer as an escaped string. For the following buffer::
218*4882a593Smuzhiyun
219*4882a593Smuzhiyun		1b 62 20 5c 43 07 22 90 0d 5d
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunA few examples show how the conversion would be done (excluding surrounding
222*4882a593Smuzhiyunquotes)::
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun		%*pE		"\eb \C\a"\220\r]"
225*4882a593Smuzhiyun		%*pEhp		"\x1bb \C\x07"\x90\x0d]"
226*4882a593Smuzhiyun		%*pEa		"\e\142\040\\\103\a\042\220\r\135"
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunThe conversion rules are applied according to an optional combination
229*4882a593Smuzhiyunof flags (see :c:func:`string_escape_mem` kernel documentation for the
230*4882a593Smuzhiyundetails):
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun	- a - ESCAPE_ANY
233*4882a593Smuzhiyun	- c - ESCAPE_SPECIAL
234*4882a593Smuzhiyun	- h - ESCAPE_HEX
235*4882a593Smuzhiyun	- n - ESCAPE_NULL
236*4882a593Smuzhiyun	- o - ESCAPE_OCTAL
237*4882a593Smuzhiyun	- p - ESCAPE_NP
238*4882a593Smuzhiyun	- s - ESCAPE_SPACE
239*4882a593Smuzhiyun
240*4882a593SmuzhiyunBy default ESCAPE_ANY_NP is used.
241*4882a593Smuzhiyun
242*4882a593SmuzhiyunESCAPE_ANY_NP is the sane choice for many cases, in particularly for
243*4882a593Smuzhiyunprinting SSIDs.
244*4882a593Smuzhiyun
245*4882a593SmuzhiyunIf field width is omitted then 1 byte only will be escaped.
246*4882a593Smuzhiyun
247*4882a593SmuzhiyunRaw buffer as a hex string
248*4882a593Smuzhiyun--------------------------
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun::
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun	%*ph	00 01 02  ...  3f
253*4882a593Smuzhiyun	%*phC	00:01:02: ... :3f
254*4882a593Smuzhiyun	%*phD	00-01-02- ... -3f
255*4882a593Smuzhiyun	%*phN	000102 ... 3f
256*4882a593Smuzhiyun
257*4882a593SmuzhiyunFor printing small buffers (up to 64 bytes long) as a hex string with a
258*4882a593Smuzhiyuncertain separator. For larger buffers consider using
259*4882a593Smuzhiyun:c:func:`print_hex_dump`.
260*4882a593Smuzhiyun
261*4882a593SmuzhiyunMAC/FDDI addresses
262*4882a593Smuzhiyun------------------
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun::
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun	%pM	00:01:02:03:04:05
267*4882a593Smuzhiyun	%pMR	05:04:03:02:01:00
268*4882a593Smuzhiyun	%pMF	00-01-02-03-04-05
269*4882a593Smuzhiyun	%pm	000102030405
270*4882a593Smuzhiyun	%pmR	050403020100
271*4882a593Smuzhiyun
272*4882a593SmuzhiyunFor printing 6-byte MAC/FDDI addresses in hex notation. The ``M`` and ``m``
273*4882a593Smuzhiyunspecifiers result in a printed address with (M) or without (m) byte
274*4882a593Smuzhiyunseparators. The default byte separator is the colon (:).
275*4882a593Smuzhiyun
276*4882a593SmuzhiyunWhere FDDI addresses are concerned the ``F`` specifier can be used after
277*4882a593Smuzhiyunthe ``M`` specifier to use dash (-) separators instead of the default
278*4882a593Smuzhiyunseparator.
279*4882a593Smuzhiyun
280*4882a593SmuzhiyunFor Bluetooth addresses the ``R`` specifier shall be used after the ``M``
281*4882a593Smuzhiyunspecifier to use reversed byte order suitable for visual interpretation
282*4882a593Smuzhiyunof Bluetooth addresses which are in the little endian order.
283*4882a593Smuzhiyun
284*4882a593SmuzhiyunPassed by reference.
285*4882a593Smuzhiyun
286*4882a593SmuzhiyunIPv4 addresses
287*4882a593Smuzhiyun--------------
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun::
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun	%pI4	1.2.3.4
292*4882a593Smuzhiyun	%pi4	001.002.003.004
293*4882a593Smuzhiyun	%p[Ii]4[hnbl]
294*4882a593Smuzhiyun
295*4882a593SmuzhiyunFor printing IPv4 dot-separated decimal addresses. The ``I4`` and ``i4``
296*4882a593Smuzhiyunspecifiers result in a printed address with (i4) or without (I4) leading
297*4882a593Smuzhiyunzeros.
298*4882a593Smuzhiyun
299*4882a593SmuzhiyunThe additional ``h``, ``n``, ``b``, and ``l`` specifiers are used to specify
300*4882a593Smuzhiyunhost, network, big or little endian order addresses respectively. Where
301*4882a593Smuzhiyunno specifier is provided the default network/big endian order is used.
302*4882a593Smuzhiyun
303*4882a593SmuzhiyunPassed by reference.
304*4882a593Smuzhiyun
305*4882a593SmuzhiyunIPv6 addresses
306*4882a593Smuzhiyun--------------
307*4882a593Smuzhiyun
308*4882a593Smuzhiyun::
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun	%pI6	0001:0002:0003:0004:0005:0006:0007:0008
311*4882a593Smuzhiyun	%pi6	00010002000300040005000600070008
312*4882a593Smuzhiyun	%pI6c	1:2:3:4:5:6:7:8
313*4882a593Smuzhiyun
314*4882a593SmuzhiyunFor printing IPv6 network-order 16-bit hex addresses. The ``I6`` and ``i6``
315*4882a593Smuzhiyunspecifiers result in a printed address with (I6) or without (i6)
316*4882a593Smuzhiyuncolon-separators. Leading zeros are always used.
317*4882a593Smuzhiyun
318*4882a593SmuzhiyunThe additional ``c`` specifier can be used with the ``I`` specifier to
319*4882a593Smuzhiyunprint a compressed IPv6 address as described by
320*4882a593Smuzhiyunhttps://tools.ietf.org/html/rfc5952
321*4882a593Smuzhiyun
322*4882a593SmuzhiyunPassed by reference.
323*4882a593Smuzhiyun
324*4882a593SmuzhiyunIPv4/IPv6 addresses (generic, with port, flowinfo, scope)
325*4882a593Smuzhiyun---------------------------------------------------------
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun::
328*4882a593Smuzhiyun
329*4882a593Smuzhiyun	%pIS	1.2.3.4		or 0001:0002:0003:0004:0005:0006:0007:0008
330*4882a593Smuzhiyun	%piS	001.002.003.004	or 00010002000300040005000600070008
331*4882a593Smuzhiyun	%pISc	1.2.3.4		or 1:2:3:4:5:6:7:8
332*4882a593Smuzhiyun	%pISpc	1.2.3.4:12345	or [1:2:3:4:5:6:7:8]:12345
333*4882a593Smuzhiyun	%p[Ii]S[pfschnbl]
334*4882a593Smuzhiyun
335*4882a593SmuzhiyunFor printing an IP address without the need to distinguish whether it's of
336*4882a593Smuzhiyuntype AF_INET or AF_INET6. A pointer to a valid struct sockaddr,
337*4882a593Smuzhiyunspecified through ``IS`` or ``iS``, can be passed to this format specifier.
338*4882a593Smuzhiyun
339*4882a593SmuzhiyunThe additional ``p``, ``f``, and ``s`` specifiers are used to specify port
340*4882a593Smuzhiyun(IPv4, IPv6), flowinfo (IPv6) and scope (IPv6). Ports have a ``:`` prefix,
341*4882a593Smuzhiyunflowinfo a ``/`` and scope a ``%``, each followed by the actual value.
342*4882a593Smuzhiyun
343*4882a593SmuzhiyunIn case of an IPv6 address the compressed IPv6 address as described by
344*4882a593Smuzhiyunhttps://tools.ietf.org/html/rfc5952 is being used if the additional
345*4882a593Smuzhiyunspecifier ``c`` is given. The IPv6 address is surrounded by ``[``, ``]`` in
346*4882a593Smuzhiyuncase of additional specifiers ``p``, ``f`` or ``s`` as suggested by
347*4882a593Smuzhiyunhttps://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07
348*4882a593Smuzhiyun
349*4882a593SmuzhiyunIn case of IPv4 addresses, the additional ``h``, ``n``, ``b``, and ``l``
350*4882a593Smuzhiyunspecifiers can be used as well and are ignored in case of an IPv6
351*4882a593Smuzhiyunaddress.
352*4882a593Smuzhiyun
353*4882a593SmuzhiyunPassed by reference.
354*4882a593Smuzhiyun
355*4882a593SmuzhiyunFurther examples::
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun	%pISfc		1.2.3.4		or [1:2:3:4:5:6:7:8]/123456789
358*4882a593Smuzhiyun	%pISsc		1.2.3.4		or [1:2:3:4:5:6:7:8]%1234567890
359*4882a593Smuzhiyun	%pISpfc		1.2.3.4:12345	or [1:2:3:4:5:6:7:8]:12345/123456789
360*4882a593Smuzhiyun
361*4882a593SmuzhiyunUUID/GUID addresses
362*4882a593Smuzhiyun-------------------
363*4882a593Smuzhiyun
364*4882a593Smuzhiyun::
365*4882a593Smuzhiyun
366*4882a593Smuzhiyun	%pUb	00010203-0405-0607-0809-0a0b0c0d0e0f
367*4882a593Smuzhiyun	%pUB	00010203-0405-0607-0809-0A0B0C0D0E0F
368*4882a593Smuzhiyun	%pUl	03020100-0504-0706-0809-0a0b0c0e0e0f
369*4882a593Smuzhiyun	%pUL	03020100-0504-0706-0809-0A0B0C0E0E0F
370*4882a593Smuzhiyun
371*4882a593SmuzhiyunFor printing 16-byte UUID/GUIDs addresses. The additional ``l``, ``L``,
372*4882a593Smuzhiyun``b`` and ``B`` specifiers are used to specify a little endian order in
373*4882a593Smuzhiyunlower (l) or upper case (L) hex notation - and big endian order in lower (b)
374*4882a593Smuzhiyunor upper case (B) hex notation.
375*4882a593Smuzhiyun
376*4882a593SmuzhiyunWhere no additional specifiers are used the default big endian
377*4882a593Smuzhiyunorder with lower case hex notation will be printed.
378*4882a593Smuzhiyun
379*4882a593SmuzhiyunPassed by reference.
380*4882a593Smuzhiyun
381*4882a593Smuzhiyundentry names
382*4882a593Smuzhiyun------------
383*4882a593Smuzhiyun
384*4882a593Smuzhiyun::
385*4882a593Smuzhiyun
386*4882a593Smuzhiyun	%pd{,2,3,4}
387*4882a593Smuzhiyun	%pD{,2,3,4}
388*4882a593Smuzhiyun
389*4882a593SmuzhiyunFor printing dentry name; if we race with :c:func:`d_move`, the name might
390*4882a593Smuzhiyunbe a mix of old and new ones, but it won't oops.  %pd dentry is a safer
391*4882a593Smuzhiyunequivalent of %s dentry->d_name.name we used to use, %pd<n> prints ``n``
392*4882a593Smuzhiyunlast components.  %pD does the same thing for struct file.
393*4882a593Smuzhiyun
394*4882a593SmuzhiyunPassed by reference.
395*4882a593Smuzhiyun
396*4882a593Smuzhiyunblock_device names
397*4882a593Smuzhiyun------------------
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun::
400*4882a593Smuzhiyun
401*4882a593Smuzhiyun	%pg	sda, sda1 or loop0p1
402*4882a593Smuzhiyun
403*4882a593SmuzhiyunFor printing name of block_device pointers.
404*4882a593Smuzhiyun
405*4882a593Smuzhiyunstruct va_format
406*4882a593Smuzhiyun----------------
407*4882a593Smuzhiyun
408*4882a593Smuzhiyun::
409*4882a593Smuzhiyun
410*4882a593Smuzhiyun	%pV
411*4882a593Smuzhiyun
412*4882a593SmuzhiyunFor printing struct va_format structures. These contain a format string
413*4882a593Smuzhiyunand va_list as follows::
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun	struct va_format {
416*4882a593Smuzhiyun		const char *fmt;
417*4882a593Smuzhiyun		va_list *va;
418*4882a593Smuzhiyun	};
419*4882a593Smuzhiyun
420*4882a593SmuzhiyunImplements a "recursive vsnprintf".
421*4882a593Smuzhiyun
422*4882a593SmuzhiyunDo not use this feature without some mechanism to verify the
423*4882a593Smuzhiyuncorrectness of the format string and va_list arguments.
424*4882a593Smuzhiyun
425*4882a593SmuzhiyunPassed by reference.
426*4882a593Smuzhiyun
427*4882a593SmuzhiyunDevice tree nodes
428*4882a593Smuzhiyun-----------------
429*4882a593Smuzhiyun
430*4882a593Smuzhiyun::
431*4882a593Smuzhiyun
432*4882a593Smuzhiyun	%pOF[fnpPcCF]
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun
435*4882a593SmuzhiyunFor printing device tree node structures. Default behaviour is
436*4882a593Smuzhiyunequivalent to %pOFf.
437*4882a593Smuzhiyun
438*4882a593Smuzhiyun	- f - device node full_name
439*4882a593Smuzhiyun	- n - device node name
440*4882a593Smuzhiyun	- p - device node phandle
441*4882a593Smuzhiyun	- P - device node path spec (name + @unit)
442*4882a593Smuzhiyun	- F - device node flags
443*4882a593Smuzhiyun	- c - major compatible string
444*4882a593Smuzhiyun	- C - full compatible string
445*4882a593Smuzhiyun
446*4882a593SmuzhiyunThe separator when using multiple arguments is ':'
447*4882a593Smuzhiyun
448*4882a593SmuzhiyunExamples::
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun	%pOF	/foo/bar@0			- Node full name
451*4882a593Smuzhiyun	%pOFf	/foo/bar@0			- Same as above
452*4882a593Smuzhiyun	%pOFfp	/foo/bar@0:10			- Node full name + phandle
453*4882a593Smuzhiyun	%pOFfcF	/foo/bar@0:foo,device:--P-	- Node full name +
454*4882a593Smuzhiyun	                                          major compatible string +
455*4882a593Smuzhiyun						  node flags
456*4882a593Smuzhiyun							D - dynamic
457*4882a593Smuzhiyun							d - detached
458*4882a593Smuzhiyun							P - Populated
459*4882a593Smuzhiyun							B - Populated bus
460*4882a593Smuzhiyun
461*4882a593SmuzhiyunPassed by reference.
462*4882a593Smuzhiyun
463*4882a593SmuzhiyunFwnode handles
464*4882a593Smuzhiyun--------------
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun::
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun	%pfw[fP]
469*4882a593Smuzhiyun
470*4882a593SmuzhiyunFor printing information on fwnode handles. The default is to print the full
471*4882a593Smuzhiyunnode name, including the path. The modifiers are functionally equivalent to
472*4882a593Smuzhiyun%pOF above.
473*4882a593Smuzhiyun
474*4882a593Smuzhiyun	- f - full name of the node, including the path
475*4882a593Smuzhiyun	- P - the name of the node including an address (if there is one)
476*4882a593Smuzhiyun
477*4882a593SmuzhiyunExamples (ACPI)::
478*4882a593Smuzhiyun
479*4882a593Smuzhiyun	%pfwf	\_SB.PCI0.CIO2.port@1.endpoint@0	- Full node name
480*4882a593Smuzhiyun	%pfwP	endpoint@0				- Node name
481*4882a593Smuzhiyun
482*4882a593SmuzhiyunExamples (OF)::
483*4882a593Smuzhiyun
484*4882a593Smuzhiyun	%pfwf	/ocp@68000000/i2c@48072000/camera@10/port/endpoint - Full name
485*4882a593Smuzhiyun	%pfwP	endpoint				- Node name
486*4882a593Smuzhiyun
487*4882a593SmuzhiyunTime and date
488*4882a593Smuzhiyun-------------
489*4882a593Smuzhiyun
490*4882a593Smuzhiyun::
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun	%pt[RT]			YYYY-mm-ddTHH:MM:SS
493*4882a593Smuzhiyun	%pt[RT]d		YYYY-mm-dd
494*4882a593Smuzhiyun	%pt[RT]t		HH:MM:SS
495*4882a593Smuzhiyun	%pt[RT][dt][r]
496*4882a593Smuzhiyun
497*4882a593SmuzhiyunFor printing date and time as represented by::
498*4882a593Smuzhiyun
499*4882a593Smuzhiyun	R  struct rtc_time structure
500*4882a593Smuzhiyun	T  time64_t type
501*4882a593Smuzhiyun
502*4882a593Smuzhiyunin human readable format.
503*4882a593Smuzhiyun
504*4882a593SmuzhiyunBy default year will be incremented by 1900 and month by 1.
505*4882a593SmuzhiyunUse %pt[RT]r (raw) to suppress this behaviour.
506*4882a593Smuzhiyun
507*4882a593SmuzhiyunPassed by reference.
508*4882a593Smuzhiyun
509*4882a593Smuzhiyunstruct clk
510*4882a593Smuzhiyun----------
511*4882a593Smuzhiyun
512*4882a593Smuzhiyun::
513*4882a593Smuzhiyun
514*4882a593Smuzhiyun	%pC	pll1
515*4882a593Smuzhiyun	%pCn	pll1
516*4882a593Smuzhiyun
517*4882a593SmuzhiyunFor printing struct clk structures. %pC and %pCn print the name of the clock
518*4882a593Smuzhiyun(Common Clock Framework) or a unique 32-bit ID (legacy clock framework).
519*4882a593Smuzhiyun
520*4882a593SmuzhiyunPassed by reference.
521*4882a593Smuzhiyun
522*4882a593Smuzhiyunbitmap and its derivatives such as cpumask and nodemask
523*4882a593Smuzhiyun-------------------------------------------------------
524*4882a593Smuzhiyun
525*4882a593Smuzhiyun::
526*4882a593Smuzhiyun
527*4882a593Smuzhiyun	%*pb	0779
528*4882a593Smuzhiyun	%*pbl	0,3-6,8-10
529*4882a593Smuzhiyun
530*4882a593SmuzhiyunFor printing bitmap and its derivatives such as cpumask and nodemask,
531*4882a593Smuzhiyun%*pb outputs the bitmap with field width as the number of bits and %*pbl
532*4882a593Smuzhiyunoutput the bitmap as range list with field width as the number of bits.
533*4882a593Smuzhiyun
534*4882a593SmuzhiyunPassed by reference.
535*4882a593Smuzhiyun
536*4882a593SmuzhiyunFlags bitfields such as page flags, gfp_flags
537*4882a593Smuzhiyun---------------------------------------------
538*4882a593Smuzhiyun
539*4882a593Smuzhiyun::
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun	%pGp	referenced|uptodate|lru|active|private
542*4882a593Smuzhiyun	%pGg	GFP_USER|GFP_DMA32|GFP_NOWARN
543*4882a593Smuzhiyun	%pGv	read|exec|mayread|maywrite|mayexec|denywrite
544*4882a593Smuzhiyun
545*4882a593SmuzhiyunFor printing flags bitfields as a collection of symbolic constants that
546*4882a593Smuzhiyunwould construct the value. The type of flags is given by the third
547*4882a593Smuzhiyuncharacter. Currently supported are [p]age flags, [v]ma_flags (both
548*4882a593Smuzhiyunexpect ``unsigned long *``) and [g]fp_flags (expects ``gfp_t *``). The flag
549*4882a593Smuzhiyunnames and print order depends on the particular	type.
550*4882a593Smuzhiyun
551*4882a593SmuzhiyunNote that this format should not be used directly in the
552*4882a593Smuzhiyun:c:func:`TP_printk()` part of a tracepoint. Instead, use the show_*_flags()
553*4882a593Smuzhiyunfunctions from <trace/events/mmflags.h>.
554*4882a593Smuzhiyun
555*4882a593SmuzhiyunPassed by reference.
556*4882a593Smuzhiyun
557*4882a593SmuzhiyunNetwork device features
558*4882a593Smuzhiyun-----------------------
559*4882a593Smuzhiyun
560*4882a593Smuzhiyun::
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun	%pNF	0x000000000000c000
563*4882a593Smuzhiyun
564*4882a593SmuzhiyunFor printing netdev_features_t.
565*4882a593Smuzhiyun
566*4882a593SmuzhiyunPassed by reference.
567*4882a593Smuzhiyun
568*4882a593SmuzhiyunThanks
569*4882a593Smuzhiyun======
570*4882a593Smuzhiyun
571*4882a593SmuzhiyunIf you add other %p extensions, please extend <lib/test_printf.c> with
572*4882a593Smuzhiyunone or more test cases, if at all feasible.
573*4882a593Smuzhiyun
574*4882a593SmuzhiyunThank you for your cooperation and attention.
575