From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Kay Sievers <kay@vrfy.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Wu Fengguang <fengguang.wu@intel.com>,
Joe Perches <joe@perches.com>,
"Paul E. McKenney" <paulmck@us.ibm.com>
Subject: [PATCH] printk: Optimize if statement logic where newline exists
Date: Fri, 29 Jun 2012 11:40:11 -0400 [thread overview]
Message-ID: <1340984411.16702.127.camel@gandalf.stny.rr.com> (raw)
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();
}
next reply other threads:[~2012-06-29 15:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 15:40 Steven Rostedt [this message]
2012-06-29 15:42 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340984411.16702.127.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@us.ibm.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®