From: Andrew Morton <akpm@linux-foundation.org>
To: "Mike Frysinger" <vapier.adi@gmail.com>
Cc: "Robin Getz" <rgetz@blackfin.uclinux.org>,
linux-kernel@vger.kernel.org, "Greg Ungerer" <gerg@snapgear.com>,
"Russell King" <rmk@arm.linux.org.uk>,
"Paul Mundt" <lethal@linux-sh.org>,
"Tim Bird" <tim.bird@am.sony.com>,
bryan.wu@analog.com
Subject: Re: early_printk accessing __log_buf
Date: Tue, 31 Jul 2007 11:36:08 -0700 [thread overview]
Message-ID: <20070731113608.f2c5d8b6.akpm@linux-foundation.org> (raw)
In-Reply-To: <8bd0f97a0707310047u51c6e46l7e57e8f7bfc4e858@mail.gmail.com>
On Tue, 31 Jul 2007 03:47:59 -0400
"Mike Frysinger" <vapier.adi@gmail.com> wrote:
> attached
> -mike
>
>
> [linux-log_buf_read.patch application/octet-stream (2.4KB)]
Please sort out the email thing if you plan on sending more kernel patches?
Incremental:
From: Andrew Morton <akpm@linux-foundation.org>
- compile fix
- Race fix: oops_in_progress can change at any time
- coding-style fixlets.
Cc: Greg Ungerer <gerg@snapgear.com>
Cc: Mike Frysinger <vapier.adi@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Robin Getz <rgetz@blackfin.uclinux.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Tim Bird <tim.bird@am.sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/kernel.h | 2 +-
kernel/printk.c | 12 ++++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff -puN include/linux/kernel.h~early_printk-accessing-__log_buf-fix include/linux/kernel.h
--- a/include/linux/kernel.h~early_printk-accessing-__log_buf-fix
+++ a/include/linux/kernel.h
@@ -168,7 +168,7 @@ static inline int printk(const char *s,
__attribute__ ((format (printf, 1, 2)));
static inline int __cold printk(const char *s, ...) { return 0; }
static inline int log_buf_get_len(void) { return 0; }
-static inline int log_buf_read(int idx); { return 0; }
+static inline int log_buf_read(int idx) { return 0; }
static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
#endif
diff -puN kernel/printk.c~early_printk-accessing-__log_buf-fix kernel/printk.c
--- a/kernel/printk.c~early_printk-accessing-__log_buf-fix
+++ a/kernel/printk.c
@@ -233,14 +233,17 @@ int log_buf_get_len(void)
int log_buf_copy(char *dest, int idx, int len)
{
int ret, max;
+ bool took_lock = false;
- if (!oops_in_progress)
+ if (!oops_in_progress) {
spin_lock_irq(&logbuf_lock);
+ took_lock = true;
+ }
max = log_buf_get_len();
- if (idx < 0 || idx >= max)
+ if (idx < 0 || idx >= max) {
ret = -1;
- else {
+ } else {
if (len > max)
len = max;
ret = len;
@@ -250,7 +253,7 @@ int log_buf_copy(char *dest, int idx, in
}
}
- if (!oops_in_progress)
+ if (took_lock)
spin_unlock_irq(&logbuf_lock);
return ret;
@@ -262,6 +265,7 @@ int log_buf_copy(char *dest, int idx, in
int log_buf_read(int idx)
{
char ret;
+
if (log_buf_copy(&ret, idx, 1) == 1)
return ret;
else
_
prev parent reply other threads:[~2007-07-31 18:37 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
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 [this message]
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=20070731113608.f2c5d8b6.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bryan.wu@analog.com \
--cc=gerg@snapgear.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rgetz@blackfin.uclinux.org \
--cc=rmk@arm.linux.org.uk \
--cc=tim.bird@am.sony.com \
--cc=vapier.adi@gmail.com \
/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.