From: Ingo Molnar <mingo@elte.hu>
To: Willy Tarreau <w@1wt.eu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andy Whitcroft <apw@shadowen.org>,
linux-kernel@vger.kernel.org
Subject: [patch] printk: add KERN_CONT annotation
Date: Tue, 2 Oct 2007 07:18:52 +0200 [thread overview]
Message-ID: <20071002051852.GC28345@elte.hu> (raw)
In-Reply-To: <20071002043408.GM10199@1wt.eu>
* Willy Tarreau <w@1wt.eu> wrote:
> Well, I think that we could do something like this :
>
> #define KERN_CONT ""
> ...
> printk(KERN_ERR "foo");
> <100 lines of whatever>
> printk(KERN_CONT "bar\n");
>
> It would indicate the author's *intent* which is to continue a line
> which has already been started. It would both permit us to remove
> false positives from automated scripts, and to read the code more
> easily. And this is not a big constaint for the author, given that
> such constructs are quite rare.
ah, this is even nicer than the raw_printk() thing i suggested, and it
also nicely documents the intention of the author. Patch attached below.
And i'd like to stress the principle that is followed here: in this
particular case the checkpatch.pl warning is very useful, but still
there are false positives. Fortunately they are so rare that it's worth
annotating those few exceptions in the source. Note that the goal is
still to be able to achieve 100% warning-free source code. _That_ should
be the driving principle behind checkpatch.pl warnings.
Ingo
------------------>
Subject: printk: add KERN_CONT annotation
From: Ingo Molnar <mingo@elte.hu>
printk: add the KERN_CONT annotation (which is empty string but via
which checkpatch.pl can notice that the lacking KERN_ level is fine).
This useful for multiple calls of hand-crafted printk output done by
early debug code or similar.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/linux/kernel.h | 7 +++++++
kernel/sched.c | 22 +++++++++++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
Index: linux/include/linux/kernel.h
===================================================================
--- linux.orig/include/linux/kernel.h
+++ linux/include/linux/kernel.h
@@ -61,6 +61,13 @@ extern const char linux_proc_banner[];
#define KERN_INFO "<6>" /* informational */
#define KERN_DEBUG "<7>" /* debug-level messages */
+/*
+ * Annotation for a "continued" line of log printout (only done after a
+ * line that had no enclosing \n). Only to be used by core/arch code
+ * during early bootup (a continued line is not SMP-safe otherwise).
+ */
+#define KERN_CONT ""
+
extern int console_printk[];
#define console_loglevel (console_printk[0])
Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -4770,18 +4770,18 @@ static void show_task(struct task_struct
unsigned state;
state = p->state ? __ffs(p->state) + 1 : 0;
- printk("%-13.13s %c", p->comm,
+ printk(KERN_INFO "%-13.13s %c", p->comm,
state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
#if BITS_PER_LONG == 32
if (state == TASK_RUNNING)
- printk(" running ");
+ printk(KERN_CONT " running ");
else
- printk(" %08lx ", thread_saved_pc(p));
+ printk(KERN_CONT " %08lx ", thread_saved_pc(p));
#else
if (state == TASK_RUNNING)
- printk(" running task ");
+ printk(KERN_CONT " running task ");
else
- printk(" %016lx ", thread_saved_pc(p));
+ printk(KERN_CONT " %016lx ", thread_saved_pc(p));
#endif
#ifdef CONFIG_DEBUG_STACK_USAGE
{
@@ -4791,7 +4791,7 @@ static void show_task(struct task_struct
free = (unsigned long)n - (unsigned long)end_of_stack(p);
}
#endif
- printk("%5lu %5d %6d\n", free, p->pid, p->parent->pid);
+ printk(KERN_CONT "%5lu %5d %6d\n", free, p->pid, p->parent->pid);
if (state != TASK_RUNNING)
show_stack(p, NULL);
@@ -5527,20 +5527,20 @@ static void sched_domain_debug(struct sc
}
if (!group->__cpu_power) {
- printk("\n");
+ printk(KERN_CONT "\n");
printk(KERN_ERR "ERROR: domain->cpu_power not "
"set\n");
break;
}
if (!cpus_weight(group->cpumask)) {
- printk("\n");
+ printk(KERN_CONT "\n");
printk(KERN_ERR "ERROR: empty group\n");
break;
}
if (cpus_intersects(groupmask, group->cpumask)) {
- printk("\n");
+ printk(KERN_CONT "\n");
printk(KERN_ERR "ERROR: repeated CPUs\n");
break;
}
@@ -5548,11 +5548,11 @@ static void sched_domain_debug(struct sc
cpus_or(groupmask, groupmask, group->cpumask);
cpumask_scnprintf(str, NR_CPUS, group->cpumask);
- printk(" %s", str);
+ printk(KERN_CONT " %s", str);
group = group->next;
} while (group != sd->groups);
- printk("\n");
+ printk(KERN_CONT "\n");
if (!cpus_equal(sd->span, groupmask))
printk(KERN_ERR "ERROR: groups don't span "
next prev parent reply other threads:[~2007-10-02 5:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070928105345.GC18163@shadowen.org>
2007-10-01 6:44 ` checkpatch and kernel/sched.c Ingo Molnar
2007-10-01 7:30 ` Andrew Morton
2007-10-01 7:48 ` Avi Kivity
2007-10-01 7:39 ` Andrew Morton
2007-10-01 10:39 ` Ingo Molnar
2007-10-01 7:50 ` Sam Ravnborg
2007-10-01 10:37 ` Ingo Molnar
2007-10-01 10:44 ` Ingo Molnar
2007-10-01 12:34 ` Andy Whitcroft
2007-10-02 4:34 ` Willy Tarreau
2007-10-02 5:18 ` Ingo Molnar [this message]
2007-10-02 10:04 ` [patch] printk: add KERN_CONT annotation Jörn Engel
2007-10-02 15:41 ` Joe Perches
2007-10-02 15:45 ` Jan Engelhardt
2007-10-02 16:03 ` Joe Perches
2007-10-02 16:07 ` Jan Engelhardt
2007-10-04 20:43 ` Andrew Morton
2007-10-04 20:52 ` Ingo Molnar
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=20071002051852.GC28345@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@linux-foundation.org \
--cc=apw@shadowen.org \
--cc=linux-kernel@vger.kernel.org \
--cc=w@1wt.eu \
/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