From: Andrew Morton <akpm@linux-foundation.org>
To: Robin Getz <rgetz@blackfin.uclinux.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: early_printk accessing __log_buf
Date: Wed, 18 Jul 2007 15:16:17 -0700 [thread overview]
Message-ID: <20070718151617.fe6a2943.akpm@linux-foundation.org> (raw)
In-Reply-To: <200707181756.44074.rgetz@blackfin.uclinux.org>
On Wed, 18 Jul 2007 17:56:43 -0400
Robin Getz <rgetz@blackfin.uclinux.org> wrote:
> Quick question:
>
> I am currently setting up an early_printk for the Blackfin - & I'm populating
> an early fault interrupt handler at the same time. This allows things like
> catching interrupts, or faults before the kernel has had a chance to
> enable it's standard interrupt/fault handlers which happen midway
> through the boot process.
>
> I would like to be able to print out the standard __log_buf from my early
> fault handler - so everyone can see where things are when they died. In
> most situations - printk has dumped some info to the log_buf, and it is
> normally handy to see figure out what is going on.
>
> However - __log_buf & associated pointers are declared as static in
> kernel/printk.c - so they can't be accessed by external files.
>
> I would normally use do_syslog([23],...) to read from the buffer -
> but these crashes happens before the kernel is fully initialized,
> so spin_lock_irq, cond_resched, or wait_event_interruptible
> will cause problems...
>
> Although there are other solutions - I would prefer to just don't declare them
> as static when EARLY_PRINTK is defined. This way if something bad happens -
> everyone can dump out the standard buffers to assist in debugging...
Being able to get at the log buffer from external debug-style code is a
fairly common requirement.
> ===================================================================
> --- linux-2.6.x/kernel/printk.c (revision 3400)
> +++ linux-2.6.x/kernel/printk.c (working copy)
> @@ -117,7 +117,12 @@
>
> #ifdef CONFIG_PRINTK
>
> +#ifdef CONFIG_EARLY_PRINTK
> +char __log_buf[__LOG_BUF_LEN];
> +#else
> static char __log_buf[__LOG_BUF_LEN];
> +#endif
> +
> static char *log_buf = __log_buf;
> static int log_buf_len = __LOG_BUF_LEN;
> static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
>
erk. There isn't much point in making something externally accessible
without also declaring it in a header file. And callers will need to be
able to get at log_buf_len too, I guess.
I'd suggest that any interface into here should be via function calls, not
via direct access to printk internals: think up some nice
copy_me_some_of_the_log_buffer() interface.
next prev parent reply other threads:[~2007-07-18 22:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-18 21:56 early_printk accessing __log_buf Robin Getz
2007-07-18 22:16 ` Andrew Morton [this message]
2007-07-18 23:39 ` Robin Getz
2007-07-18 23:53 ` Mike Frysinger
2007-07-19 3:37 ` Robin Getz
2007-07-19 3:47 ` Andrew Morton
2007-07-19 0:26 ` Andrew Morton
2007-07-19 2:26 ` Stephane Couture
2007-07-19 3:58 ` Robin Getz
2007-07-22 23:50 ` Mike Frysinger
2007-07-23 0:14 ` Paul Mundt
2007-07-23 18:19 ` Robin Getz
2007-07-23 20:15 ` Andrew Morton
2007-07-23 20:54 ` Mike Frysinger
2007-07-23 21:05 ` Andrew Morton
2007-07-23 22:10 ` Mike Frysinger
2007-07-23 22:15 ` Robin Getz
2007-07-23 22:34 ` Andrew Morton
2007-07-24 17:50 ` Robin Getz
2007-07-24 18:12 ` Andrew Morton
2007-07-24 20:12 ` Robin Getz
2007-07-24 21:30 ` Andrew Morton
2007-07-31 7:47 ` Mike Frysinger
2007-07-31 7:59 ` Bryan Wu
2007-07-31 8:11 ` Mike Frysinger
2007-07-31 18:36 ` Andrew Morton
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=20070718151617.fe6a2943.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rgetz@blackfin.uclinux.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 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.