Commit 5b2ebce4 authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman

dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix

Multiple printks with KERN_CONT can be interleaved by
other printks.  Reduce the likelihood of that interleaving
by consolidating multiple calls to printk.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6c2140ee
...@@ -430,23 +430,35 @@ static int ddebug_exec_query(char *query_string) ...@@ -430,23 +430,35 @@ static int ddebug_exec_query(char *query_string)
static int dynamic_emit_prefix(const struct _ddebug *descriptor) static int dynamic_emit_prefix(const struct _ddebug *descriptor)
{ {
int res; char tid[sizeof(int) + sizeof(int)/2 + 4];
char lineno[sizeof(int) + sizeof(int)/2];
res = printk(KERN_DEBUG);
if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) { if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
if (in_interrupt()) if (in_interrupt())
res += printk(KERN_CONT "<intr> "); snprintf(tid, sizeof(tid), "%s", "<intr> ");
else else
res += printk(KERN_CONT "[%d] ", task_pid_vnr(current)); snprintf(tid, sizeof(tid), "[%d] ",
task_pid_vnr(current));
} else {
tid[0] = 0;
} }
if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
res += printk(KERN_CONT "%s:", descriptor->modname);
if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
res += printk(KERN_CONT "%s:", descriptor->function);
if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
res += printk(KERN_CONT "%d ", descriptor->lineno);
return res; if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
snprintf(lineno, sizeof(lineno), "%d", descriptor->lineno);
else
lineno[0] = 0;
return printk(KERN_DEBUG "%s%s%s%s%s%s",
tid,
(descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) ?
descriptor->modname : "",
(descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) ?
":" : "",
(descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) ?
descriptor->function : "",
(descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) ?
":" : "",
lineno);
} }
int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment