Multiple secessive calls to printk can be interleaved. Avoid this possible interleaving by using %pV
Joe Perches (9): drivers/gpu/drm/drm_stub.c: Use printf extension %pV drivers/isdn/mISDN: Use printf extension %pV drivers/net/wireless/ath/debug.c: Use printf extension %pV drivers/net/wireless/b43/main.c: Use printf extension %pV drivers/net/wireless/b43legacy/main.c: Use printf extension %pV fs/gfs2/glock.c: Use printf extension %pV fs/nilfs2/super.c: Use printf extension %pV fs/quota/dquot.c: Use printf extension %pV net/sunrpc/svc.c: Use printf extension %pV
drivers/gpu/drm/drm_stub.c | 14 +++++++-- drivers/isdn/mISDN/layer1.c | 10 +++++-- drivers/isdn/mISDN/layer2.c | 12 ++++++-- drivers/isdn/mISDN/tei.c | 23 +++++++++++---- drivers/net/wireless/ath/debug.c | 9 +++++- drivers/net/wireless/b43/main.c | 48 ++++++++++++++++++++++++-------- drivers/net/wireless/b43legacy/main.c | 47 ++++++++++++++++++++++++-------- fs/gfs2/glock.c | 9 +++++- fs/nilfs2/super.c | 23 +++++++++++----- fs/quota/dquot.c | 12 +++++--- net/sunrpc/svc.c | 12 +++++--- 11 files changed, 161 insertions(+), 58 deletions(-)
Using %pV reduces the number of printk calls and eliminates any possible message interleaving from other printk calls.
Signed-off-by: Joe Perches joe@perches.com --- drivers/gpu/drm/drm_stub.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index cdc89ee..e632527 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -57,13 +57,21 @@ void drm_ut_debug_printk(unsigned int request_level, const char *function_name, const char *format, ...) { + struct va_format vaf; va_list args;
if (drm_debug & request_level) { - if (function_name) - printk(KERN_DEBUG "[%s:%s], ", prefix, function_name); va_start(args, format); - vprintk(format, args); + + vaf.fmt = format; + vaf.va = &args; + + if (function_name) + printk(KERN_DEBUG "[%s:%s], %pV", + prefix, function_name, &vaf); + else + printk(KERN_DEBUG "%pV", &vaf); + va_end(args); } }
On Tue, Nov 9, 2010 at 7:35 PM, Joe Perches joe@perches.com wrote:
Wouldn't it be easier and more convenient to just make the %pV format specifier just expect a format string and the va_arg list? Like this
printk(KERN_DEBUG "%pV", format, &args);
I mean, the %pV is kernel specific and we can just change how it works.
Kristian
On Tue, Nov 9, 2010 at 4:35 PM, Joe Perches joe@perches.com wrote:
When was this added upstream BTW? I ask for backport considerations.
Luis
On Wed, 2010-11-10 at 14:48 -0800, Luis R. Rodriguez wrote:
When was this added upstream BTW? I ask for backport considerations.
commit 7db6f5fb65a82af03229eef104dc9899c5eecf33 Author: Joe Perches joe@perches.com Date: Sun Jun 27 01:02:33 2010 +0000
vsprintf: Recursive vsnprintf: Add "%pV", struct va_format
Add the ability to print a format and va_list from a structure pointer
Allows __dev_printk to be implemented as a single printk while minimizing string space duplication.
%pV should not be used without some mechanism to verify the format and argument use ala __attribute__(format (printf(...))).
Signed-off-by: Joe Perches joe@perches.com Acked-by: Greg Kroah-Hartman gregkh@suse.de Signed-off-by: David S. Miller davem@davemloft.net
dri-devel@lists.freedesktop.org