From: Andrew Morton <akpm@zip.com.au>
To: Serguei Miridonov <mirsev@cicese.mx>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Console output for debugging
Date: Tue, 22 Jan 2002 15:42:47 -0800 [thread overview]
Message-ID: <3C4DF8F7.C50486EC@zip.com.au> (raw)
In-Reply-To: <3C4DF2AD.66BC3F6C@cicese.mx>
Serguei Miridonov wrote:
>
> Q: Is there any function in the kernel which I can call
> safely from a module to print debug message on the console
> screen?
>
> I don't want to use printk for some reasons. One of them is
> that I want messages to appear on the screen immediately,
> even from interrupt processing routines. Another is to be
> able to see messages until the system freezes completely in
> case of software or hardware bug.
>
printk does all this, usually. It is synchronous, so when
it returns to your code, the text is on the screen.
The only exception to this is when you perform a printk
from within an interrupt handler *while* printk itself
is executing in non-interrupt context. When this rare
situation occurs, the text is buffered, to be emitted
by the non-interrupt code before it returns to its caller.
If the printk-within-printk buffering is a problem for you,
(which I doubt) then you could disable interrupts while
running printk. Something like this:
--- linux-2.4.18-pre6/kernel/printk.c Tue Jan 22 12:38:31 2002
+++ linux-akpm/kernel/printk.c Tue Jan 22 15:40:57 2002
@@ -412,6 +412,10 @@ asmlinkage int printk(const char *fmt, .
char *p;
static char printk_buf[1024];
static int log_level_unknown = 1;
+ static spinlock_t printk_lock = SPIN_LOCK_UNLOCKED;
+ unsigned long xflags;
+
+ spin_lock_irqsave(&printk_lock, xflags);
if (oops_in_progress) {
/* If a crash is occurring, make sure we can't deadlock */
@@ -471,6 +475,7 @@ asmlinkage int printk(const char *fmt, .
spin_unlock_irqrestore(&logbuf_lock, flags);
}
out:
+ spin_unlock_irqrestore(&printk_lock, xflags);
return printed_len;
}
EXPORT_SYMBOL(printk);
next prev parent reply other threads:[~2002-01-22 23:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-22 23:15 Console output for debugging Serguei Miridonov
2002-01-22 23:31 ` Dave Jones
2002-01-22 23:34 ` H. Peter Anvin
2002-01-23 18:09 ` root
2002-01-22 23:42 ` Andrew Morton [this message]
2002-01-23 18:02 ` Serguei Miridonov
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=3C4DF8F7.C50486EC@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mirsev@cicese.mx \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.