2011-02-06 00:16:03

by Andrew Murray

[permalink] [raw]
Subject: [PATCH] printk-formats.txt documentation update

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers.

Signed-off-by: Andrew Murray <[email protected]>
---
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..df14336 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -9,7 +9,42 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+ General:
+
+ %pF function pointer with offset, e.g. module_start
+ %pf function pointer without offset, e.g. module_start+0x0/0x62 [hello]
+ %pS text symbol with offset
+ %ps text symbol without offset
+ %pR struct resource with decoded flags, e.g. [mem 0x0-0x1f 64 bit pref]
+ %pr struct resource with raw flags, e.g. [mem 0x0-0x1f flags 0x201]
+
+ MAC/FDDI addresses:
+
+ %pM colon-seperated 6-byte MAC address in hex notation, e.g. 00:01:02:03:04:05
+ %pm non-colon-seperated 6-byte MAC address is hex notation, e.g. 000102030405
+ %pMF 6-byte dash-separated FDDI hex notation
+
+ IPv4 addresses:
+
+ %pI4 IPv4 dot-seperated decimal without leading 0's, e.g. 1.2.3.4
+ %pi4 IPv4 dot-seperated decimal with leading 0's, 001.002.003.004
+ %p[Ii]4[hl] IPv4 dot-seperated decimal with/without leading 0's for
+ host (h), little (l) or network/big (default) endian order
+
+ IPv6 addresses:
+ %pI6 IPv6 colon-seperated network-order 16 bit hex with leading 0's,
+ e.g. 0001:0203:...:0708
+ %pi6 IPv6 non-colon-seperated network-order 16 bit hex with leading 0's,
+ e.g. 000102...0f
+ %pI6c IPv6 address as described by
+ http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00,
+ e.g. 1::708
+
+ %pU[bBlL] 16 byte UUID/GUID in big or little endian using lower or upper case
+

u64 SHOULD be printed with %llu/%llx, (unsigned long long):


2011-02-06 00:27:54

by Tim Bird

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On 02/05/2011 04:15 PM, Andrew Murray wrote:
> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers.
>
> Signed-off-by: Andrew Murray <[email protected]>
> ---
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..df14336 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,42 @@ If variable is of Type, use printk format specifier:
> size_t %zu or %zx
> ssize_t %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:
> +
> + General:
> +
> + %pF function pointer with offset, e.g. module_start
> + %pf function pointer without offset, e.g. module_start+0x0/0x62 [hello]
> + %pS text symbol with offset
> + %ps text symbol without offset
> + %pR struct resource with decoded flags, e.g. [mem 0x0-0x1f 64 bit pref]
> + %pr struct resource with raw flags, e.g. [mem 0x0-0x1f flags 0x201]
> +
> + MAC/FDDI addresses:
> +
> + %pM colon-seperated 6-byte MAC address in hex notation, e.g. 00:01:02:03:04:05
> + %pm non-colon-seperated 6-byte MAC address is hex notation, e.g. 000102030405
> + %pMF 6-byte dash-separated FDDI hex notation
> +
> + IPv4 addresses:
> +
> + %pI4 IPv4 dot-seperated decimal without leading 0's, e.g. 1.2.3.4
> + %pi4 IPv4 dot-seperated decimal with leading 0's, 001.002.003.004
> + %p[Ii]4[hl] IPv4 dot-seperated decimal with/without leading 0's for
> + host (h), little (l) or network/big (default) endian order
> +
> + IPv6 addresses:
> + %pI6 IPv6 colon-seperated network-order 16 bit hex with leading 0's,
> + e.g. 0001:0203:...:0708
> + %pi6 IPv6 non-colon-seperated network-order 16 bit hex with leading 0's,
> + e.g. 000102...0f
> + %pI6c IPv6 address as described by
> + http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00,
> + e.g. 1::708
> +
> + %pU[bBlL] 16 byte UUID/GUID in big or little endian using lower or upper case
> +
>
> u64 SHOULD be printed with %llu/%llx, (unsigned long long):

I like this, as it has information that is not documented elsewhere.

Some feedback on the patch:

Some of these lines are longer than 80 chars. Can you please truncate
things to fit in an 80-column terminal window?

Thanks,
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Network Entertainment
=============================

2011-02-06 00:37:09

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Sun, 2011-02-06 at 00:15 +0000, Andrew Murray wrote:
> From: Andrew Murray <[email protected]>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers.
> Signed-off-by: Andrew Murray <[email protected]>
> ---
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
[]
> @@ -9,7 +9,42 @@ If variable is of Type, use printk format specifier:
> size_t %zu or %zx
> ssize_t %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:

I think it'd be better if each extension were individually described
with an example output.

> +
> + General:
> +
> + %pF function pointer with offset, e.g. module_start
> + %pf function pointer without offset, e.g. module_start+0x0/0x62 [hello]

with/without inversion?

> + %pS text symbol with offset
> + %ps text symbol without offset
> + %pR struct resource with decoded flags, e.g. [mem 0x0-0x1f 64 bit pref]
> + %pr struct resource with raw flags, e.g. [mem 0x0-0x1f flags 0x201]
> +
> + MAC/FDDI addresses:
> +
> + %pM colon-seperated 6-byte MAC address in hex notation, e.g. 00:01:02:03:04:05

spelling: separated

> + %pm non-colon-seperated 6-byte MAC address is hex notation, e.g. 000102030405
> + %pMF 6-byte dash-separated FDDI hex notation
> +
> + IPv4 addresses:
> +
> + %pI4 IPv4 dot-seperated decimal without leading 0's, e.g. 1.2.3.4
> + %pi4 IPv4 dot-seperated decimal with leading 0's, 001.002.003.004
> + %p[Ii]4[hl] IPv4 dot-seperated decimal with/without leading 0's for
> + host (h), little (l) or network/big (default) endian order
> +
> + IPv6 addresses:
> + %pI6 IPv6 colon-seperated network-order 16 bit hex with leading 0's,
> + e.g. 0001:0203:...:0708
> + %pi6 IPv6 non-colon-seperated network-order 16 bit hex with leading 0's,
> + e.g. 000102...0f
> + %pI6c IPv6 address as described by
> + http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00,
> + e.g. 1::708
> +
> + %pU[bBlL] 16 byte UUID/GUID in big or little endian using lower or upper case

Maybe a simple 2 line table without the e.g.:

%p<extension1> sample output1
description1
%p<extension2> sample output2
description2

2011-02-06 10:07:50

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

Thanks for the feedback - I will truncate to 80 characters and
implement Joe's advice.

Thanks,

Andrew Murray

On 6 February 2011 00:37, Joe Perches <[email protected]> wrote:
> On Sun, 2011-02-06 at 00:15 +0000, Andrew Murray wrote:
>> From: Andrew Murray <[email protected]>
>> This patch updates the incomplete documentation concerning the printk
>> extended format specifiers.
>> Signed-off-by: Andrew Murray <[email protected]>
>> ---
>> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> []
>> @@ -9,7 +9,42 @@ If variable is of Type,              use printk format specifier:
>>               size_t                  %zu or %zx
>>               ssize_t                 %zd or %zx
>>
>> -Raw pointer value SHOULD be printed with %p.
>> +Raw pointer value SHOULD be printed with %p. The kernel supports
>> +the following extended format specifiers for pointer types:
>
> I think it'd be better if each extension were individually described
> with an example output.
>
>> +
>> +     General:
>> +
>> +     %pF     function pointer with offset, e.g. module_start
>> +     %pf     function pointer without offset, e.g. module_start+0x0/0x62 [hello]
>
> with/without inversion?
>
>> +     %pS     text symbol with offset
>> +     %ps     text symbol without offset
>> +     %pR     struct resource with decoded flags, e.g. [mem 0x0-0x1f 64 bit pref]
>> +     %pr     struct resource with raw flags, e.g. [mem 0x0-0x1f flags 0x201]
>> +
>> +     MAC/FDDI addresses:
>> +
>> +     %pM     colon-seperated 6-byte MAC address in hex notation, e.g. 00:01:02:03:04:05
>
> spelling: separated
>
>> +     %pm     non-colon-seperated 6-byte MAC address is hex notation, e.g. 000102030405
>> +     %pMF    6-byte dash-separated FDDI hex notation
>> +
>> +     IPv4 addresses:
>> +
>> +     %pI4    IPv4 dot-seperated decimal without leading 0's, e.g. 1.2.3.4
>> +     %pi4    IPv4 dot-seperated decimal with leading 0's, 001.002.003.004
>> +     %p[Ii]4[hl] IPv4 dot-seperated decimal with/without leading 0's for
>> +             host (h), little (l) or network/big (default) endian order
>> +
>> +     IPv6 addresses:
>> +     %pI6    IPv6 colon-seperated network-order 16 bit hex with leading 0's,
>> +             e.g. 0001:0203:...:0708
>> +     %pi6    IPv6 non-colon-seperated network-order 16 bit hex with leading 0's,
>> +             e.g. 000102...0f
>> +     %pI6c   IPv6 address as described by
>> +             http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00,
>> +             e.g. 1::708
>> +
>> +     %pU[bBlL] 16 byte UUID/GUID in big or little endian using lower or upper case
>
> Maybe a simple 2 line table without the e.g.:
>
>        %p<extension1>  sample output1
>                        description1
>        %p<extension2>  sample output2
>                        description2
>
>
>



--
Andrew Murray, Embedded Linux Group
MPC Data Limited
e-mail: [email protected]  web: http://www.mpc-data.co.uk
tel: +44 (0) 1225 710600               fax: +44 (0) 1225 710601
ddi: +44 (0) 1225 710665

MPC Data Limited is a company registered in England and Wales with
company number 05507446
Registered Address: County Gate, County Way, Trowbridge, Wiltshire, BA14 7FJ
VAT no: 850625238

The information in this email and in the attached documents is
confidential and may be
legally privileged. Any unauthorized review, copying, disclosure or
distribution is
prohibited and may be unlawful. It is intended solely for the
addressee. Access to this
email by anyone else is unauthorized. If you are not the intended
recipient, please
contact the sender by reply email and destroy all copies of the
original message. When
addressed to our clients any opinions or advice contained in this
email is subject to
the terms and conditions expressed in the governing contract.

2011-02-06 10:16:36

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Sun, Feb 6, 2011 at 01:15, Andrew Murray <[email protected]> wrote:
> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers.
>
> Signed-off-by: Andrew Murray <[email protected]>
> ---
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..df14336 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,42 @@ If variable is of Type,                use printk format specifier:
>                size_t                  %zu or %zx
>                ssize_t                 %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:
> +
> +       General:
> +
> +       %pF     function pointer with offset, e.g. module_start
> +       %pf     function pointer without offset, e.g. module_start+0x0/0x62 [hello]
> +       %pS     text symbol with offset
> +       %ps     text symbol without offset
> +       %pR     struct resource with decoded flags, e.g. [mem 0x0-0x1f 64 bit pref]
> +       %pr     struct resource with raw flags, e.g. [mem 0x0-0x1f flags 0x201]
> +
> +       MAC/FDDI addresses:
> +
> +       %pM     colon-seperated 6-byte MAC address in hex notation, e.g. 00:01:02:03:04:05
> +       %pm     non-colon-seperated 6-byte MAC address is hex notation, e.g. 000102030405
> +       %pMF    6-byte dash-separated FDDI hex notation
> +
> +       IPv4 addresses:
> +
> +       %pI4    IPv4 dot-seperated decimal without leading 0's, e.g. 1.2.3.4
> +       %pi4    IPv4 dot-seperated decimal with leading 0's, 001.002.003.004
> +       %p[Ii]4[hl] IPv4 dot-seperated decimal with/without leading 0's for
> +               host (h), little (l) or network/big (default) endian order
> +
> +       IPv6 addresses:
> +       %pI6    IPv6 colon-seperated network-order 16 bit hex with leading 0's,
> +               e.g. 0001:0203:...:0708
> +       %pi6    IPv6 non-colon-seperated network-order 16 bit hex with leading 0's,
> +               e.g. 000102...0f
> +       %pI6c   IPv6 address as described by
> +               http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00,
> +               e.g. 1::708
> +
> +       %pU[bBlL] 16 byte UUID/GUID in big or little endian using lower or upper case
> +

In the mean time, we also got %pV and %pK. Can you please add them as well? Thx!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

2011-02-06 16:14:53

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On 6 February 2011 10:16, Geert Uytterhoeven <[email protected]> wrote:
> In the mean time, we also got %pV and %pK. Can you please add them as well? Thx!

Ok how about this revised patch?

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers.

Signed-off-by: Andrew Murray <[email protected]>
---
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..cad0dda 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -1,4 +1,4 @@
-If variable is of Type, use printk format specifier:
+f variable is of Type, use printk format specifier:
---------------------------------------------------------
int %d or %x
unsigned int %u or %x
@@ -9,7 +9,111 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x0
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_resrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ seperators. The default byte seperator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') seperators instead of the default
+ seperator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-seperated decminal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-seperaters. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00.
+
+UUID/GUID addresses:
+
+ %pU 00010203-0506-0708-090a-0b0c0d0e0fff
+ %pU[bBlL]
+
+ For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specifiy a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_lost *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +136,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>

2011-02-06 16:23:12

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On 6 February 2011 16:14, Andrew Murray <[email protected]> wrote:
> On 6 February 2011 10:16, Geert Uytterhoeven <[email protected]> wrote:
>> In the mean time, we also got %pV and %pK. Can you please add them as well? Thx!
>
> Ok how about this revised patch?
>
I've just noticed a zillion spelling mistakes - find below another
revised patch.

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers.

Signed-off-by: Andrew Murray <[email protected]>
---
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..cad0dda 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -1,4 +1,4 @@
-If variable is of Type, use printk format specifier:
+f variable is of Type, use printk format specifier:
---------------------------------------------------------
int %d or %x
unsigned int %u or %x
@@ -9,7 +9,111 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x0
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_resrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ separators. The default byte separator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') separators instead of the default
+ separator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-separators. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00.
+
+UUID/GUID addresses:
+
+ %pU 00010203-0506-0708-090a-0b0c0d0e0fff
+ %pU[bBlL]
+
+ For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specify a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_lost *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +136,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>

2011-02-07 09:29:36

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Sun, Feb 06, 2011 at 04:23:09PM +0000, Andrew Murray wrote:
> On 6 February 2011 16:14, Andrew Murray <[email protected]> wrote:
> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers.

Good one, thanks!

> +Kernel Pointers:
> +
> + %pK 0x0
> +
> + For printing kernel pointers which should be hidden from unprivileged
> + users. The behaviour of %pK depends on the kptr_resrict sysctl - see

Typo: Should be kptr_restrict.

Regards,

Wolfram

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |


Attachments:
(No filename) (702.00 B)
signature.asc (198.00 B)
Digital signature
Download all attachments

2011-02-07 18:14:00

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On 7 February 2011 09:29, Wolfram Sang <[email protected]> wrote:
> On Sun, Feb 06, 2011 at 04:23:09PM +0000, Andrew Murray wrote:
>> +
>> +     For printing kernel pointers which should be hidden from unprivileged
>> +     users. The behaviour of %pK depends on the kptr_resrict sysctl - see
>
> Typo: Should be kptr_restrict.

Updated patch:

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers.

Signed-off-by: Andrew Murray <[email protected]>
---
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..cad0dda 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -1,4 +1,4 @@
-If variable is of Type, use printk format specifier:
+f variable is of Type, use printk format specifier:
---------------------------------------------------------
int %d or %x
unsigned int %u or %x
@@ -9,7 +9,111 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x0
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_restrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ separators. The default byte separator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') separators instead of the default
+ separator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-separators. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00.
+
+UUID/GUID addresses:
+
+ %pU 00010203-0506-0708-090a-0b0c0d0e0fff
+ %pU[bBlL]
+
+ For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specify a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_lost *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +136,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>

2011-02-07 19:33:27

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Mon, 2011-02-07 at 18:12 +0000, Andrew Murray wrote:
> On 7 February 2011 09:29, Wolfram Sang <[email protected]> wrote:
> > On Sun, Feb 06, 2011 at 04:23:09PM +0000, Andrew Murray wrote:
> >> +
> >> + For printing kernel pointers which should be hidden from unprivileged
> >> + users. The behaviour of %pK depends on the kptr_resrict sysctl - see
> >
> > Typo: Should be kptr_restrict.
> Updated patch:

trivia:

> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
[]
> +Kernel Pointers:
> +
> + %pK 0x0

Bad example, leading zeros are emitted.

%pK 0x01234567 or 0x01234567890abcdef

depending on 32/64 bit. For 2.6.38, output should be 0x00000000
for a 0 if kptr_restrict is set, "(null)" or value otherwise.

> + For printing kernel pointers which should be hidden from unprivileged
> + users. The behaviour of %pK depends on the kptr_restrict sysctl - see
> + Documentation/sysctl/kernel.txt for more details.
> +
> +Struct Resources:
> +
> + %pr [mem 0x60000000-0x6fffffff flags 0x2200]
> + %pR [mem 0x60000000-0x6fffffff pref]
> +
> + For printing struct resources. The 'R' and 'r' specifiers result in a
> + printed resource with ('R') or without ('r') a decoded flags member.

Same issue, mem resources are printed using sizeof(resource_size_t) * 2

> +IPv6 addresses:
> +
> + %pI6 0001:0002:0003:0004:0005:0006:0007:0008
> + %pi6 00010002000300040005000600070008
> + %pI6c 1:2:3:4:5:6:7:8
> +
> + For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
> + specifiers result in a printed address with ('I6') or without ('i6')
> + colon-separators. Leading zeros are always used.
> +
> + The additional 'c' specifier can be used with the 'I' specifier to
> + print a compressed IPv6 address as described by
> + http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00.

It's probably better to use:

http://tools.ietf.org/html/rfc5952

> +
> +UUID/GUID addresses:
> +
> + %pU 00010203-0506-0708-090a-0b0c0d0e0fff

What happened to 04?

It's probably easier/simpler to just show all possible
output styles. Assuming an in memory incrementing
16 byte array, output is:

%pU 00010203-0405-0607-08090a0b0c0d0e0f

> + %pU[bBlL]

%pUb 00010203-0405-0607-08090a0b0c0d0e0f
%pUB 00010203-0405-0607-08090A0B0C0D0E0F
%pUl 03020100-0504-0706-08090a0b0c0d0e0f
%pUL 03020100-0504-0706-08090A0B0E0D0E0F

> + For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',
> + 'b' and 'B' specifiers are used to specify a little endian order in
> + lower ('l') or upper case ('L') hex characters - and big endian order
> + in lower ('b') or upper case ('B') hex characters.
> +
> + Where no additional specifiers are used the default little endian
> + order with lower case hex characters will be printed.
> +
> +struct va_format:
> +
> + %pV
> +
> + For printing struct va_format structures. These contain a format string
> + and va_list as follows:
> +
> + struct va_format {
> + const char *fmt;
> + va_lost *va;

va_list

2011-02-11 08:15:24

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On 7 February 2011 19:33, Joe Perches <[email protected]> wrote:
>
> On Mon, 2011-02-07 at 18:12 +0000, Andrew Murray wrote:
> > On 7 February 2011 09:29, Wolfram Sang <[email protected]> wrote:
> > > On Sun, Feb 06, 2011 at 04:23:09PM +0000, Andrew Murray wrote:
> > >> +
>

Thanks for the feedback - I'll be on holiday shortly - so will have to
continue this when in return.

Andrew Murray

2011-06-09 17:34:04

by Andrew Murray

[permalink] [raw]
Subject: [PATCH] Revised patch

Hi,

I've updated this patch based on your feedback. This covers all the recent feedback.

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers.

Signed-off-by: Andrew Murray <[email protected]>

---
Documentation/printk-formats.txt | 113 +++++++++++++++++++++++++++++++++++++-
1 files changed, 111 insertions(+), 2 deletions(-)

diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..2968cbf 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -9,7 +9,115 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x01234567 or 0x0123456789abcdef
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_restrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
+ [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref] or
+ [mem 0x0000000060000000-0x000000006fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ separators. The default byte separator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') separators instead of the default
+ separator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-separators. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/rfc5952
+
+UUID/GUID addresses:
+
+ %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
+ %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
+ %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
+ %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
+
+ For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specify a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_list *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +140,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>
--
1.7.4.1

2011-06-09 17:40:06

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] Revised patch

On Thu, 2011-06-09 at 18:33 +0100, Andrew Murray wrote:
> Hi,
> I've updated this patch based on your feedback. This covers all the recent feedback.

Hey Andrew.

You're missing the "%pB" backtrace extension.

It's be better if the "Hi, I've updated" comment stuff
came after the --- content separator in the patch so that
the commit log is a bit neater.

Otherwise, looks great, thanks.

cheers, Joe

2011-06-09 17:47:25

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] Revised patch

On Thu, 9 Jun 2011 18:33:46 +0100 Andrew Murray wrote:

> Hi,
>
> I've updated this patch based on your feedback. This covers all the recent feedback.
>
> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers.

Thanks. A few comments below...

> Signed-off-by: Andrew Murray <[email protected]>
>
> ---
> Documentation/printk-formats.txt | 113 +++++++++++++++++++++++++++++++++++++-
> 1 files changed, 111 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..2968cbf 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,115 @@ If variable is of Type, use printk format specifier:
> size_t %zu or %zx
> ssize_t %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:
> +
> +Symbols/Function Pointers:
> +
> + %pF versatile_init+0x0/0x110
> + %pf versatile_init
> + %pS versatile_init+0x0/0x110
> + %ps versatile_init
> +
> + For printing symbols and function pointers. The 'S' and 's' specifiers
> + result in the symbol name with ('S') or without ('s') offsets. Where
> + this is used on a kernel without KALLSYMS - the symbol address is
> + printed instead.
> +
> + On ia64, ppc64 and parisc64 architectures function pointers are
> + actually function descriptors which must first be resolved. The 'F' and
> + 'f' specifiers perform this resolution and then provide the same
> + functionality as the 'S' and 's' specifiers.
> +
> +Kernel Pointers:
> +
> + %pK 0x01234567 or 0x0123456789abcdef
> +
> + For printing kernel pointers which should be hidden from unprivileged
> + users. The behaviour of %pK depends on the kptr_restrict sysctl - see
> + Documentation/sysctl/kernel.txt for more details.
> +
> +Struct Resources:
> +
> + %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
> + [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
> + %pR [mem 0x60000000-0x6fffffff pref] or
> + [mem 0x0000000060000000-0x000000006fffffff pref]
> +
> + For printing struct resources. The 'R' and 'r' specifiers result in a
> + printed resource with ('R') or without ('r') a decoded flags member.
> +
> +MAC/FDDI addresses:
> +
> + %pM 00:01:02:03:04:05
> + %pMF 00-01-02-03-04-05
> + %pm 000102030405
> +
> + For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
> + specifiers result in a printed address with ('M') or without ('m') byte
> + separators. The default byte separator is the colon (':').
> +
> + Where FDDI addresses are concerned the 'F' specifier can be used after
> + the 'M' specifier to use dash ('-') separators instead of the default
> + separator.
> +
> +IPv4 addresses:
> +
> + %pI4 1.2.3.4
> + %pi4 001.002.003.004
> + %p[Ii][hnbl]
> +
> + For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
> + specifiers result in a printed address with ('i4') or without ('I4')
> + leading zeros.
> +
> + The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
> + host, network, big or little endian order addresses respectively. Where
> + no specifier is provided the default network/big endian order is used.
> +

I would hyphenate the -endian types, but won't insist on that.

> +IPv6 addresses:
> +
> + %pI6 0001:0002:0003:0004:0005:0006:0007:0008
> + %pi6 00010002000300040005000600070008
> + %pI6c 1:2:3:4:5:6:7:8
> +
> + For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'

16-bit

> + specifiers result in a printed address with ('I6') or without ('i6')
> + colon-separators. Leading zeros are always used.
> +
> + The additional 'c' specifier can be used with the 'I' specifier to
> + print a compressed IPv6 address as described by
> + http://tools.ietf.org/html/rfc5952
> +
> +UUID/GUID addresses:
> +
> + %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
> + %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
> + %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
> + %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
> +
> + For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',

16-byte

> + 'b' and 'B' specifiers are used to specify a little endian order in
> + lower ('l') or upper case ('L') hex characters - and big endian order
> + in lower ('b') or upper case ('B') hex characters.
> +
> + Where no additional specifiers are used the default little endian
> + order with lower case hex characters will be printed.
> +
> +struct va_format:
> +
> + %pV
> +
> + For printing struct va_format structures. These contain a format string
> + and va_list as follows:
> +
> + struct va_format {
> + const char *fmt;
> + va_list *va;
> + };
> +
> + Do not use this feature without some mechanism to verify the
> + correctness of the format string and va_list arguments.
>
> u64 SHOULD be printed with %llu/%llx, (unsigned long long):


%pB is missing?
* - 'B' For backtraced symbolic direct pointers with offset


> @@ -32,4 +140,5 @@ Reminder: sizeof() result is of type size_t.
> Thank you for your cooperation and attention.
>
>
> -By Randy Dunlap <[email protected]>
> +By Randy Dunlap <[email protected]> and
> +Andrew Murray <[email protected]>
> --


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-09 17:47:40

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH] Revised patch

2011-06-09 (목), 10:40 -0700, Joe Perches:
> On Thu, 2011-06-09 at 18:33 +0100, Andrew Murray wrote:
> > Hi,
> > I've updated this patch based on your feedback. This covers all the recent feedback.
>
> Hey Andrew.
>
> You're missing the "%pB" backtrace extension.
>

http://marc.info/?l=linux-kernel&m=130093458112438&w=2

Just for your information. :)
Thanks.


--
Regards,
Namhyung Kim

2011-06-09 17:48:49

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] Revised patch

Thanks - I've actually written the %pB documentation but just getting
in a mess with Git and my work flow - standby...

On 9 June 2011 18:47, Namhyung Kim <[email protected]> wrote:
> 2011-06-09 (목), 10:40 -0700, Joe Perches:
>> On Thu, 2011-06-09 at 18:33 +0100, Andrew Murray wrote:
>> > Hi,
>> > I've updated this patch based on your feedback. This covers all the recent feedback.
>>
>> Hey Andrew.
>>
>> You're missing the "%pB" backtrace extension.
>>
>
> http://marc.info/?l=linux-kernel&m=130093458112438&w=2
>
> Just for your information. :)
> Thanks.
>
>
> --
> Regards,
> Namhyung Kim
>
>
>



--
Andrew Murray, Embedded Linux Group
MPC Data Limited
e-mail: [email protected]  web: http://www.mpc-data.co.uk
tel: +44 (0) 1225 710600               fax: +44 (0) 1225 710601
ddi: +44 (0) 1225 710665

MPC Data Limited is a company registered in England and Wales with
company number 05507446
Registered Address: County Gate, County Way, Trowbridge, Wiltshire, BA14 7FJ
VAT no: 850625238

The information in this email and in the attached documents is
confidential and may be
legally privileged. Any unauthorized review, copying, disclosure or
distribution is
prohibited and may be unlawful. It is intended solely for the
addressee. Access to this
email by anyone else is unauthorized. If you are not the intended
recipient, please
contact the sender by reply email and destroy all copies of the
original message. When
addressed to our clients any opinions or advice contained in this
email is subject to
the terms and conditions expressed in the governing contract.

2011-06-09 17:53:56

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] Revised patch

On Thu, 2011-06-09 at 10:47 -0700, Randy Dunlap wrote:
> On Thu, 9 Jun 2011 18:33:46 +0100 Andrew Murray wrote:
> > + For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
> 16-bit

byte. octet if pedantry is desired.

2011-06-09 18:06:19

by Andrew Murray

[permalink] [raw]
Subject: [PATCH] printk-formats.txt documentation update

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers.

Signed-off-by: Andrew Murray <[email protected]>
---
Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
1 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..69713d6 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+ %pB versatile_init+0x0/0x110
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ The 'B' specifier results in the symbol name with offsets and should be
+ used when printing stack backtraces. The specifier takes into
+ consideration the effect of compiler optimisations which may occur
+ when tail-call's are used and marked with the noreturn GCC attribute.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x01234567 or 0x0123456789abcdef
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_restrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
+ [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref] or
+ [mem 0x0000000060000000-0x000000006fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ separators. The default byte separator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') separators instead of the default
+ separator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16-bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-separators. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/rfc5952
+
+UUID/GUID addresses:
+
+ %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
+ %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
+ %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
+ %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
+
+ For printing 16-byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specify a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_list *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>
--
1.7.4.1

2011-06-09 18:21:00

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

2011-06-09 (목), 19:04 +0100, Andrew Murray:
> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers.
>
> Signed-off-by: Andrew Murray <[email protected]>
> ---
> Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
> 1 files changed, 117 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..69713d6 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
> size_t %zu or %zx
> ssize_t %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:
> +
> +Symbols/Function Pointers:
> +
> + %pF versatile_init+0x0/0x110
> + %pf versatile_init
> + %pS versatile_init+0x0/0x110
> + %ps versatile_init
> + %pB versatile_init+0x0/0x110
> +

-EBADEXAMPLE :)

If %pB is used, the offset part in the output could not be 0. That's the
key (and the only) difference of the %pB specifier than others. Thus the
output would be something like:

%pB prev_fn_of_versatile_init+0x88/0x88

Thanks.


--
Regards,
Namhyung Kim

2011-06-09 18:23:40

by Joe Perches

[permalink] [raw]
Subject: [PATCH] vsprintf: Update %pI6c to not compress a single 0

RFC 5952 http://tools.ietf.org/html/rfc5952
mandates that 2 or more consecutive 0's are
required before using :: compression.

Update ip6_compressed_string to match the RFC and
update the http reference as well.

Signed-off-by: Joe Perches <[email protected]>
---
lib/vsprintf.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c112056..4365df3 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -666,6 +666,8 @@ char *ip6_compressed_string(char *p, const char *addr)
colonpos = i;
}
}
+ if (longest == 1) /* don't compress a single 0 */
+ colonpos = -1;

/* emit address */
for (i = 0; i < range; i++) {
@@ -826,7 +828,7 @@ int kptr_restrict __read_mostly;
* IPv4 uses dot-separated decimal with leading 0's (010.123.045.006)
* - '[Ii]4[hnbl]' IPv4 addresses in host, network, big or little endian order
* - 'I6c' for IPv6 addresses printed as specified by
- * http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00
+ * http://tools.ietf.org/html/rfc5952
* - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form
* "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
* Options for %pU are:
--
1.7.6.rc0


2011-06-09 18:55:55

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers

Signed-off-by: Andrew Murray <[email protected]>
---
Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
1 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..85a06aa 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+ %pB prev_fn_of_versatile_init+0x88/0x88
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ The 'B' specifier results in the symbol name with offsets and should be
+ used when printing stack backtraces. The specifier takes into
+ consideration the effect of compiler optimisations which may occur
+ when tail-call's are used and marked with the noreturn GCC attribute.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x01234567 or 0x0123456789abcdef
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_restrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
+ [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref] or
+ [mem 0x0000000060000000-0x000000006fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ separators. The default byte separator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') separators instead of the default
+ separator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-separators. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/rfc5952
+
+UUID/GUID addresses:
+
+ %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
+ %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
+ %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
+ %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
+
+ For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specify a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_list *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>
--
1.7.4.1

2011-06-09 19:59:28

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 9 Jun 2011 19:55:35 +0100 Andrew Murray wrote:

> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers
>
> Signed-off-by: Andrew Murray <[email protected]>
> ---
> Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
> 1 files changed, 117 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..85a06aa 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
> size_t %zu or %zx
> ssize_t %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:
> +
> +Symbols/Function Pointers:
> +
> + %pF versatile_init+0x0/0x110
> + %pf versatile_init
> + %pS versatile_init+0x0/0x110
> + %ps versatile_init
> + %pB prev_fn_of_versatile_init+0x88/0x88
> +
> + For printing symbols and function pointers. The 'S' and 's' specifiers
> + result in the symbol name with ('S') or without ('s') offsets. Where
> + this is used on a kernel without KALLSYMS - the symbol address is
> + printed instead.
> +
> + The 'B' specifier results in the symbol name with offsets and should be
> + used when printing stack backtraces. The specifier takes into
> + consideration the effect of compiler optimisations which may occur
> + when tail-call's are used and marked with the noreturn GCC attribute.
> +
> + On ia64, ppc64 and parisc64 architectures function pointers are
> + actually function descriptors which must first be resolved. The 'F' and
> + 'f' specifiers perform this resolution and then provide the same
> + functionality as the 'S' and 's' specifiers.
> +
> +Kernel Pointers:
> +
> + %pK 0x01234567 or 0x0123456789abcdef
> +
> + For printing kernel pointers which should be hidden from unprivileged
> + users. The behaviour of %pK depends on the kptr_restrict sysctl - see
> + Documentation/sysctl/kernel.txt for more details.
> +
> +Struct Resources:
> +
> + %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
> + [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
> + %pR [mem 0x60000000-0x6fffffff pref] or
> + [mem 0x0000000060000000-0x000000006fffffff pref]
> +
> + For printing struct resources. The 'R' and 'r' specifiers result in a
> + printed resource with ('R') or without ('r') a decoded flags member.
> +
> +MAC/FDDI addresses:
> +
> + %pM 00:01:02:03:04:05
> + %pMF 00-01-02-03-04-05
> + %pm 000102030405
> +
> + For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
> + specifiers result in a printed address with ('M') or without ('m') byte
> + separators. The default byte separator is the colon (':').
> +
> + Where FDDI addresses are concerned the 'F' specifier can be used after
> + the 'M' specifier to use dash ('-') separators instead of the default
> + separator.
> +
> +IPv4 addresses:
> +
> + %pI4 1.2.3.4
> + %pi4 001.002.003.004
> + %p[Ii][hnbl]
> +
> + For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
> + specifiers result in a printed address with ('i4') or without ('I4')
> + leading zeros.
> +
> + The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
> + host, network, big or little endian order addresses respectively. Where
> + no specifier is provided the default network/big endian order is used.
> +
> +IPv6 addresses:
> +
> + %pI6 0001:0002:0003:0004:0005:0006:0007:0008
> + %pi6 00010002000300040005000600070008
> + %pI6c 1:2:3:4:5:6:7:8
> +
> + For printing IPv6 network-order 16 bit hex addresses. The 'I6' and 'i6'

You lost the hyphen in 16-bit. The previous patch version had it... :(

> + specifiers result in a printed address with ('I6') or without ('i6')
> + colon-separators. Leading zeros are always used.
> +
> + The additional 'c' specifier can be used with the 'I' specifier to
> + print a compressed IPv6 address as described by
> + http://tools.ietf.org/html/rfc5952
> +
> +UUID/GUID addresses:
> +
> + %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
> + %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
> + %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
> + %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
> +
> + For printing 16 byte UUID/GUIDs addresses. The additional 'l', 'L',

same for 16-byte

> + 'b' and 'B' specifiers are used to specify a little endian order in
> + lower ('l') or upper case ('L') hex characters - and big endian order
> + in lower ('b') or upper case ('B') hex characters.
> +
> + Where no additional specifiers are used the default little endian
> + order with lower case hex characters will be printed.
> +
> +struct va_format:
> +
> + %pV
> +
> + For printing struct va_format structures. These contain a format string
> + and va_list as follows:
> +
> + struct va_format {
> + const char *fmt;
> + va_list *va;
> + };
> +
> + Do not use this feature without some mechanism to verify the
> + correctness of the format string and va_list arguments.
>
> u64 SHOULD be printed with %llu/%llx, (unsigned long long):
>
> @@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
> Thank you for your cooperation and attention.
>
>
> -By Randy Dunlap <[email protected]>
> +By Randy Dunlap <[email protected]> and
> +Andrew Murray <[email protected]>
> --
> 1.7.4.1
>


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-09 21:25:01

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

From: Andrew Murray <[email protected]>

This patch updates the incomplete documentation concerning the printk
extended format specifiers

Signed-off-by: Andrew Murray <[email protected]>
---
Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
1 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5dd..6455e5b 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
size_t %zu or %zx
ssize_t %zd or %zx

-Raw pointer value SHOULD be printed with %p.
+Raw pointer value SHOULD be printed with %p. The kernel supports
+the following extended format specifiers for pointer types:
+
+Symbols/Function Pointers:
+
+ %pF versatile_init+0x0/0x110
+ %pf versatile_init
+ %pS versatile_init+0x0/0x110
+ %ps versatile_init
+ %pB prev_fn_of_versatile_init+0x88/0x88
+
+ For printing symbols and function pointers. The 'S' and 's' specifiers
+ result in the symbol name with ('S') or without ('s') offsets. Where
+ this is used on a kernel without KALLSYMS - the symbol address is
+ printed instead.
+
+ The 'B' specifier results in the symbol name with offsets and should be
+ used when printing stack backtraces. The specifier takes into
+ consideration the effect of compiler optimisations which may occur
+ when tail-call's are used and marked with the noreturn GCC attribute.
+
+ On ia64, ppc64 and parisc64 architectures function pointers are
+ actually function descriptors which must first be resolved. The 'F' and
+ 'f' specifiers perform this resolution and then provide the same
+ functionality as the 'S' and 's' specifiers.
+
+Kernel Pointers:
+
+ %pK 0x01234567 or 0x0123456789abcdef
+
+ For printing kernel pointers which should be hidden from unprivileged
+ users. The behaviour of %pK depends on the kptr_restrict sysctl - see
+ Documentation/sysctl/kernel.txt for more details.
+
+Struct Resources:
+
+ %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
+ [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
+ %pR [mem 0x60000000-0x6fffffff pref] or
+ [mem 0x0000000060000000-0x000000006fffffff pref]
+
+ For printing struct resources. The 'R' and 'r' specifiers result in a
+ printed resource with ('R') or without ('r') a decoded flags member.
+
+MAC/FDDI addresses:
+
+ %pM 00:01:02:03:04:05
+ %pMF 00-01-02-03-04-05
+ %pm 000102030405
+
+ For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
+ specifiers result in a printed address with ('M') or without ('m') byte
+ separators. The default byte separator is the colon (':').
+
+ Where FDDI addresses are concerned the 'F' specifier can be used after
+ the 'M' specifier to use dash ('-') separators instead of the default
+ separator.
+
+IPv4 addresses:
+
+ %pI4 1.2.3.4
+ %pi4 001.002.003.004
+ %p[Ii][hnbl]
+
+ For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
+ specifiers result in a printed address with ('i4') or without ('I4')
+ leading zeros.
+
+ The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
+ host, network, big or little endian order addresses respectively. Where
+ no specifier is provided the default network/big endian order is used.
+
+IPv6 addresses:
+
+ %pI6 0001:0002:0003:0004:0005:0006:0007:0008
+ %pi6 00010002000300040005000600070008
+ %pI6c 1:2:3:4:5:6:7:8
+
+ For printing IPv6 network-order 16-bit hex addresses. The 'I6' and 'i6'
+ specifiers result in a printed address with ('I6') or without ('i6')
+ colon-separators. Leading zeros are always used.
+
+ The additional 'c' specifier can be used with the 'I' specifier to
+ print a compressed IPv6 address as described by
+ http://tools.ietf.org/html/rfc5952
+
+UUID/GUID addresses:
+
+ %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
+ %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
+ %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
+ %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
+
+ For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',
+ 'b' and 'B' specifiers are used to specify a little endian order in
+ lower ('l') or upper case ('L') hex characters - and big endian order
+ in lower ('b') or upper case ('B') hex characters.
+
+ Where no additional specifiers are used the default little endian
+ order with lower case hex characters will be printed.
+
+struct va_format:
+
+ %pV
+
+ For printing struct va_format structures. These contain a format string
+ and va_list as follows:
+
+ struct va_format {
+ const char *fmt;
+ va_list *va;
+ };
+
+ Do not use this feature without some mechanism to verify the
+ correctness of the format string and va_list arguments.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

@@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
Thank you for your cooperation and attention.


-By Randy Dunlap <[email protected]>
+By Randy Dunlap <[email protected]> and
+Andrew Murray <[email protected]>
--
1.7.4.1

2011-06-09 21:51:35

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 9 Jun 2011 22:24:48 +0100 Andrew Murray wrote:

> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers
>
> Signed-off-by: Andrew Murray <[email protected]>
> ---
> Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
> 1 files changed, 117 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..6455e5b 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:

> +UUID/GUID addresses:
> +
> + %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
> + %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
> + %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
> + %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
> +
> + For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',

For printing 16-byte

You want to resend or shall I just fix it?

> + 'b' and 'B' specifiers are used to specify a little endian order in
> + lower ('l') or upper case ('L') hex characters - and big endian order
> + in lower ('b') or upper case ('B') hex characters.
> +
> + Where no additional specifiers are used the default little endian
> + order with lower case hex characters will be printed.


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-09 22:00:36

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 2011-06-09 at 14:51 -0700, Randy Dunlap wrote:
> On Thu, 9 Jun 2011 22:24:48 +0100 Andrew Murray wrote:
> > + For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',
> For printing 16-byte
> You want to resend or shall I just fix it?

Hey Randy.

I find your seeming insistence on using a dash
between the numeric count and the word byte to
be a bit odd.

Stylistically, why do you want it there?

cheers, Joe

2011-06-09 22:21:10

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On 9 June 2011 23:00, Joe Perches <[email protected]> wrote:
> On Thu, 2011-06-09 at 14:51 -0700, Randy Dunlap wrote:
>> On Thu,  9 Jun 2011 22:24:48 +0100 Andrew Murray wrote:
>> > +   For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',
>>       For printing 16-byte
>> You want to resend or shall I just fix it?

Yes Randy please fix it - may be quicker for us both!


>
> Hey Randy.
>
> I find your seeming insistence on using a dash
> between the numeric count and the word byte to
> be a bit odd.
>
> Stylistically, why do you want it there?
>
> cheers, Joe
>
>

2011-06-09 22:44:26

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 09 Jun 2011 15:00:29 -0700 Joe Perches wrote:

> On Thu, 2011-06-09 at 14:51 -0700, Randy Dunlap wrote:
> > On Thu, 9 Jun 2011 22:24:48 +0100 Andrew Murray wrote:
> > > + For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',
> > For printing 16-byte
> > You want to resend or shall I just fix it?
>
> Hey Randy.
>
> I find your seeming insistence on using a dash
> between the numeric count and the word byte to
> be a bit odd.
>
> Stylistically, why do you want it there?

Mostly to make it clear. It's too easy to be ambiguous.


> cheers, Joe

Without hyphen:

For printing 16 byte UUID/GUIDs addresses.

Those adjectives are confusing. I don't know what that phrase means.
It could easily mean 16 UUID/GUIDs, but it's ambiguous.

But

For printing 16-byte UUID/GUIDs addresses.

That means (clearly to me) that UUID/GUIDs are 16-byte entities.

Or see http://www.incredibleenglish.com/pdf/Hyphens.pdf, section 1,
"Hyphenate unit modifiers."

Or see http://www.ehow.com/how_4473498_use-hyphen-sentence.html, section 1,
"Link compound modifiers with hyphens."

Or see http://www.getitwriteonline.com/archive/040201HyphAdj.htm


HTH.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-09 22:53:51

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 2011-06-09 at 15:37 -0700, Randy Dunlap wrote:
> On Thu, 09 Jun 2011 15:00:29 -0700 Joe Perches wrote:
> see http://www.incredibleenglish.com/pdf/Hyphens.pdf, section 1,
> "Hyphenate unit modifiers."
>
> Or see http://www.ehow.com/how_4473498_use-hyphen-sentence.html, section 1,
> "Link compound modifiers with hyphens."
>
> Or see http://www.getitwriteonline.com/archive/040201HyphAdj.htm

Whatever floats your boat but my 5th grade English teacher
Sr. Mary likely would have been appalled by those articles.

cheers, Joe

2011-06-09 22:57:28

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 09 Jun 2011 15:53:38 -0700 Joe Perches wrote:

> On Thu, 2011-06-09 at 15:37 -0700, Randy Dunlap wrote:
> > On Thu, 09 Jun 2011 15:00:29 -0700 Joe Perches wrote:
> > see http://www.incredibleenglish.com/pdf/Hyphens.pdf, section 1,
> > "Hyphenate unit modifiers."
> >
> > Or see http://www.ehow.com/how_4473498_use-hyphen-sentence.html, section 1,
> > "Link compound modifiers with hyphens."
> >
> > Or see http://www.getitwriteonline.com/archive/040201HyphAdj.htm
>
> Whatever floats your boat but my 5th grade English teacher
> Sr. Mary likely would have been appalled by those articles.
>
> cheers, Joe

Thanks.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-10 17:50:21

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

On Thu, 9 Jun 2011 22:24:48 +0100 Andrew Murray wrote:

> From: Andrew Murray <[email protected]>
>
> This patch updates the incomplete documentation concerning the printk
> extended format specifiers
>
> Signed-off-by: Andrew Murray <[email protected]>

Applied with minor tweaks (including dropping trailing whitespace).

Thanks.

> ---
> Documentation/printk-formats.txt | 119 +++++++++++++++++++++++++++++++++++++-
> 1 files changed, 117 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 1b5a5dd..6455e5b 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
> size_t %zu or %zx
> ssize_t %zd or %zx
>
> -Raw pointer value SHOULD be printed with %p.
> +Raw pointer value SHOULD be printed with %p. The kernel supports
> +the following extended format specifiers for pointer types:
> +
> +Symbols/Function Pointers:
> +
> + %pF versatile_init+0x0/0x110
> + %pf versatile_init
> + %pS versatile_init+0x0/0x110
> + %ps versatile_init
> + %pB prev_fn_of_versatile_init+0x88/0x88
> +
> + For printing symbols and function pointers. The 'S' and 's' specifiers
> + result in the symbol name with ('S') or without ('s') offsets. Where
> + this is used on a kernel without KALLSYMS - the symbol address is
> + printed instead.
> +
> + The 'B' specifier results in the symbol name with offsets and should be
> + used when printing stack backtraces. The specifier takes into
> + consideration the effect of compiler optimisations which may occur
> + when tail-call's are used and marked with the noreturn GCC attribute.
> +
> + On ia64, ppc64 and parisc64 architectures function pointers are
> + actually function descriptors which must first be resolved. The 'F' and
> + 'f' specifiers perform this resolution and then provide the same
> + functionality as the 'S' and 's' specifiers.
> +
> +Kernel Pointers:
> +
> + %pK 0x01234567 or 0x0123456789abcdef
> +
> + For printing kernel pointers which should be hidden from unprivileged
> + users. The behaviour of %pK depends on the kptr_restrict sysctl - see
> + Documentation/sysctl/kernel.txt for more details.
> +
> +Struct Resources:
> +
> + %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
> + [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
> + %pR [mem 0x60000000-0x6fffffff pref] or
> + [mem 0x0000000060000000-0x000000006fffffff pref]
> +
> + For printing struct resources. The 'R' and 'r' specifiers result in a
> + printed resource with ('R') or without ('r') a decoded flags member.
> +
> +MAC/FDDI addresses:
> +
> + %pM 00:01:02:03:04:05
> + %pMF 00-01-02-03-04-05
> + %pm 000102030405
> +
> + For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
> + specifiers result in a printed address with ('M') or without ('m') byte
> + separators. The default byte separator is the colon (':').
> +
> + Where FDDI addresses are concerned the 'F' specifier can be used after
> + the 'M' specifier to use dash ('-') separators instead of the default
> + separator.
> +
> +IPv4 addresses:
> +
> + %pI4 1.2.3.4
> + %pi4 001.002.003.004
> + %p[Ii][hnbl]
> +
> + For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
> + specifiers result in a printed address with ('i4') or without ('I4')
> + leading zeros.
> +
> + The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
> + host, network, big or little endian order addresses respectively. Where
> + no specifier is provided the default network/big endian order is used.
> +
> +IPv6 addresses:
> +
> + %pI6 0001:0002:0003:0004:0005:0006:0007:0008
> + %pi6 00010002000300040005000600070008
> + %pI6c 1:2:3:4:5:6:7:8
> +
> + For printing IPv6 network-order 16-bit hex addresses. The 'I6' and 'i6'
> + specifiers result in a printed address with ('I6') or without ('i6')
> + colon-separators. Leading zeros are always used.
> +
> + The additional 'c' specifier can be used with the 'I' specifier to
> + print a compressed IPv6 address as described by
> + http://tools.ietf.org/html/rfc5952
> +
> +UUID/GUID addresses:
> +
> + %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
> + %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
> + %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
> + %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
> +
> + For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',
> + 'b' and 'B' specifiers are used to specify a little endian order in
> + lower ('l') or upper case ('L') hex characters - and big endian order
> + in lower ('b') or upper case ('B') hex characters.
> +
> + Where no additional specifiers are used the default little endian
> + order with lower case hex characters will be printed.
> +
> +struct va_format:
> +
> + %pV
> +
> + For printing struct va_format structures. These contain a format string
> + and va_list as follows:
> +
> + struct va_format {
> + const char *fmt;
> + va_list *va;
> + };
> +
> + Do not use this feature without some mechanism to verify the
> + correctness of the format string and va_list arguments.
>
> u64 SHOULD be printed with %llu/%llx, (unsigned long long):
>
> @@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
> Thank you for your cooperation and attention.
>
>
> -By Randy Dunlap <[email protected]>
> +By Randy Dunlap <[email protected]> and
> +Andrew Murray <[email protected]>
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-10 17:56:38

by Andrew Murray

[permalink] [raw]
Subject: Re: [PATCH] printk-formats.txt documentation update

Great! Thanks for the help.

On 10 June 2011 18:50, Randy Dunlap <[email protected]> wrote:
> On Thu,  9 Jun 2011 22:24:48 +0100 Andrew Murray wrote:
>
>> From: Andrew Murray <[email protected]>
>>
>> This patch updates the incomplete documentation concerning the printk
>> extended format specifiers
>>
>> Signed-off-by: Andrew Murray <[email protected]>
>
> Applied with minor tweaks (including dropping trailing whitespace).
>
> Thanks.
>
>> ---
>>  Documentation/printk-formats.txt |  119 +++++++++++++++++++++++++++++++++++++-
>>  1 files changed, 117 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
>> index 1b5a5dd..6455e5b 100644
>> --- a/Documentation/printk-formats.txt
>> +++ b/Documentation/printk-formats.txt
>> @@ -9,7 +9,121 @@ If variable is of Type,             use printk format specifier:
>>               size_t                  %zu or %zx
>>               ssize_t                 %zd or %zx
>>
>> -Raw pointer value SHOULD be printed with %p.
>> +Raw pointer value SHOULD be printed with %p. The kernel supports
>> +the following extended format specifiers for pointer types:
>> +
>> +Symbols/Function Pointers:
>> +
>> +     %pF     versatile_init+0x0/0x110
>> +     %pf     versatile_init
>> +     %pS     versatile_init+0x0/0x110
>> +     %ps     versatile_init
>> +     %pB     prev_fn_of_versatile_init+0x88/0x88
>> +
>> +     For printing symbols and function pointers. The 'S' and 's' specifiers
>> +     result in the symbol name with ('S') or without ('s') offsets. Where
>> +     this is used on a kernel without KALLSYMS - the symbol address is
>> +     printed instead.
>> +
>> +     The 'B' specifier results in the symbol name with offsets and should be
>> +     used when printing stack backtraces. The specifier takes into
>> +     consideration the effect of compiler optimisations which may occur
>> +     when tail-call's are used and marked with the noreturn GCC attribute.
>> +
>> +     On ia64, ppc64 and parisc64 architectures function pointers are
>> +     actually function descriptors which must first be resolved. The 'F' and
>> +     'f' specifiers perform this resolution and then provide the same
>> +     functionality as the 'S' and 's' specifiers.
>> +
>> +Kernel Pointers:
>> +
>> +     %pK     0x01234567 or 0x0123456789abcdef
>> +
>> +     For printing kernel pointers which should be hidden from unprivileged
>> +     users. The behaviour of %pK depends on the kptr_restrict sysctl - see
>> +     Documentation/sysctl/kernel.txt for more details.
>> +
>> +Struct Resources:
>> +
>> +     %pr     [mem 0x60000000-0x6fffffff flags 0x2200] or
>> +             [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
>> +     %pR     [mem 0x60000000-0x6fffffff pref] or
>> +             [mem 0x0000000060000000-0x000000006fffffff pref]
>> +
>> +     For printing struct resources. The 'R' and 'r' specifiers result in a
>> +     printed resource with ('R') or without ('r') a decoded flags member.
>> +
>> +MAC/FDDI addresses:
>> +
>> +     %pM     00:01:02:03:04:05
>> +     %pMF    00-01-02-03-04-05
>> +     %pm     000102030405
>> +
>> +     For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
>> +     specifiers result in a printed address with ('M') or without ('m') byte
>> +     separators. The default byte separator is the colon (':').
>> +
>> +     Where FDDI addresses are concerned the 'F' specifier can be used after
>> +     the 'M' specifier to use dash ('-') separators instead of the default
>> +     separator.
>> +
>> +IPv4 addresses:
>> +
>> +     %pI4    1.2.3.4
>> +     %pi4    001.002.003.004
>> +     %p[Ii][hnbl]
>> +
>> +     For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
>> +     specifiers result in a printed address with ('i4') or without ('I4')
>> +     leading zeros.
>> +
>> +     The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
>> +     host, network, big or little endian order addresses respectively. Where
>> +     no specifier is provided the default network/big endian order is used.
>> +
>> +IPv6 addresses:
>> +
>> +     %pI6    0001:0002:0003:0004:0005:0006:0007:0008
>> +     %pi6    00010002000300040005000600070008
>> +     %pI6c   1:2:3:4:5:6:7:8
>> +
>> +     For printing IPv6 network-order 16-bit hex addresses. The 'I6' and 'i6'
>> +     specifiers result in a printed address with ('I6') or without ('i6')
>> +     colon-separators. Leading zeros are always used.
>> +
>> +     The additional 'c' specifier can be used with the 'I' specifier to
>> +     print a compressed IPv6 address as described by
>> +     http://tools.ietf.org/html/rfc5952
>> +
>> +UUID/GUID addresses:
>> +
>> +     %pUb    00010203-0405-0607-0809-0a0b0c0d0e0f
>> +     %pUB    00010203-0405-0607-0809-0A0B0C0D0E0F
>> +     %pUl    03020100-0504-0706-0809-0a0b0c0e0e0f
>> +     %pUL    03020100-0504-0706-0809-0A0B0C0E0E0F
>> +
>> +     For printing-16 byte UUID/GUIDs addresses. The additional 'l', 'L',
>> +     'b' and 'B' specifiers are used to specify a little endian order in
>> +     lower ('l') or upper case ('L') hex characters - and big endian order
>> +     in lower ('b') or upper case ('B') hex characters.
>> +
>> +     Where no additional specifiers are used the default little endian
>> +     order with lower case hex characters will be printed.
>> +
>> +struct va_format:
>> +
>> +     %pV
>> +
>> +     For printing struct va_format structures. These contain a format string
>> +     and va_list as follows:
>> +
>> +     struct va_format {
>> +             const char *fmt;
>> +             va_list *va;
>> +     };
>> +
>> +     Do not use this feature without some mechanism to verify the
>> +     correctness of the format string and va_list arguments.
>>
>>  u64 SHOULD be printed with %llu/%llx, (unsigned long long):
>>
>> @@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
>>  Thank you for your cooperation and attention.
>>
>>
>> -By Randy Dunlap <[email protected]>
>> +By Randy Dunlap <[email protected]> and
>> +Andrew Murray <[email protected]>
>> --
>> 1.7.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
>> the body of a message to [email protected]
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>