* [PATCH] printk: Optimize if statement logic where newline exists
@ 2012-06-29 15:40 Steven Rostedt
2012-06-29 15:42 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2012-06-29 15:40 UTC (permalink / raw)
To: LKML
Cc: Kay Sievers, Linus Torvalds, Greg Kroah-Hartman, Andrew Morton,
LKML, Ingo Molnar, Wu Fengguang, Joe Perches, Paul E. McKenney
In reviewing Kay's fix up patch: "printk: Have printk() never buffer its
data", I found two if statements that could be combined and optimized.
Put together the two 'cont.len && cont.owner == current' if statements
into a single one, and check if we need to call cont_add(). This also
removes the unneeded double cont_flush() calls.
Link: http://lkml.kernel.org/r/1340869133.876.10.camel@mop
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
[ This patch is dependent on Kay's patch, referenced at the above Link ]
Index: linux-trace.git/kernel/printk.c
===================================================================
--- linux-trace.git.orig/kernel/printk.c
+++ linux-trace.git/kernel/printk.c
@@ -1474,15 +1474,14 @@ asmlinkage int vprintk_emit(int facility
bool stored = false;
/*
- * Flush the conflicting buffer. An earlier newline was missing,
- * or we race with a continuation line from an interrupt.
+ * If an earlier newline was missing and it was the same task,
+ * either merge it with the current buffer and flush, or if
+ * there was a race with interrupts (prefix == true) then just
+ * flush it out and store this line separately.
*/
- if (cont.len && prefix && cont.owner == current)
- cont_flush();
-
- /* Merge with our buffer if possible; flush it in any case */
if (cont.len && cont.owner == current) {
- stored = cont_add(facility, level, text, text_len);
+ if (!prefix)
+ stored = cont_add(facility, level, text, text_len);
cont_flush();
}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] printk: Optimize if statement logic where newline exists
2012-06-29 15:40 [PATCH] printk: Optimize if statement logic where newline exists Steven Rostedt
@ 2012-06-29 15:42 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2012-06-29 15:42 UTC (permalink / raw)
To: LKML
Cc: Kay Sievers, Linus Torvalds, Greg Kroah-Hartman, Andrew Morton,
Ingo Molnar, Wu Fengguang, Joe Perches, Paul E. McKenney
On Fri, 2012-06-29 at 11:40 -0400, Steven Rostedt wrote:
> In reviewing Kay's fix up patch: "printk: Have printk() never buffer its
> data", I found two if statements that could be combined and optimized.
>
> Put together the two 'cont.len && cont.owner == current' if statements
> into a single one, and check if we need to call cont_add(). This also
> removes the unneeded double cont_flush() calls.
>
> Link: http://lkml.kernel.org/r/1340869133.876.10.camel@mop
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
>
> [ This patch is dependent on Kay's patch, referenced at the above Link ]
>
As the above link seems to time out, here's a more direct one:
http://marc.info/?l=linux-kernel&m=134084777330388
-- Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-29 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29 15:40 [PATCH] printk: Optimize if statement logic where newline exists Steven Rostedt
2012-06-29 15:42 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®