From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Joe Perches <joe@perches.com>, Rob Landley <rob@landley.net>,
Dick Streefland <dick.streefland@altium.nl>
Subject: Re: [RFC] New kernel-message logging API
Date: Mon, 24 Sep 2007 11:22:22 +0200 [thread overview]
Message-ID: <1190625742.12666.30.camel@localhost.localdomain> (raw)
In-Reply-To: <19f34abd0709221227v67443c0bg2cd2010e5bd5a6c1@mail.gmail.com>
Hi Vegard,
On Sat, 2007-09-22 at 21:27 +0200, Vegard Nossum wrote:
> After recent discussions on LKML and a general dissatisfaction at the
> current printk() kernel-message logging interface, I've decided to
> write down some of the ideas for a better system.
Good luck :-)
[snip]
> Example: {
> struct kprint_buffer buf;
>
> kprint_buffer_init(&buf, KPRINT_DEBUG);
> kprint_buffer(&buf, "Stack trace:");
>
> while(unwind_stack()) {
> kprint_buffer(&buf, "%p %s", address, symbol);
> }
>
> kprint_buffer_flush(&buf);
> }
>
Together with the idea of not allowing multiple lines in the kprint_xxx
functions, that would go with our approach having message numbers to
identify a message. Multiple lines are combined explicitly to one
message. I think it is a good idea to be able to identify, which lines
of a message belong together.
[snip]
> With such a modular interface, message attributes (for example the
> current time) and arguments can be recorded separately from the actual
> format string, instead of written formatted to a ring buffer as a
> sequence of characters. Parameters would be formatted to their own
> strings (regardless of the original type) and saved in an array.
>
> Example: {
> struct kprint_message {
> const char *format;
>
> unsigned int argc;
> char **argv;
>
> #ifdef KPRINT_TIMESTAMP
> unsigned long long timestamp;
> #endif
>
> #ifndef KPRINT_LOCATION
> const char *file;
> unsigned int line;
>
> const char *function;
> #endif
> };
> }
[snip]
> The message entry and a message's arguments are kept separately. Most
> likely, there will be a huge number of tiny allocations. I am not sure
> how well this is handled in the kernel. Or we could try to merge the
> allocation of the struct kprint_message and its arguments into a
> single allocation by looking at the arguments before they're
> formatted. After all, the arguments cannot exist without the message
> or vice versa. Alternatively, a statically-sized ring buffer of struct
> kprint_message objects could be used, and then only arguments would
> need to be allocated dynamically. Either way, I think it should be
> possible to come up with a fairly memory-efficient system even for
> this method of storing the kernel log.
Would be nice to have some code here. How do you want to implement that?
You have to allocate / preallocate memory for the argv array. Something
like:
kprint_err(const char* fmt, ...)
{
va_list ap;
struct kprint_message *msg;
msg = &message_arry[current];
va_start(ap, fmt);
msg->argv = kmalloc(sizeof(long) * argc, GFP_KERNEL);
...
for (i = 0; i < argc, i++) {
msg->argv[i] = va_arg(ap, long);
}
If you do it like that, you can't support "%s", since then you would
store only the pointer and not the whole string. I think, that we can't
live without %s.
Michael
next prev parent reply other threads:[~2007-09-24 9:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-22 19:27 [RFC] New kernel-message logging API Vegard Nossum
2007-09-23 0:13 ` Joe Perches
2007-09-23 0:40 ` Kyle Moffett
2007-09-23 0:47 ` Joe Perches
2007-09-23 3:43 ` Kyle Moffett
2007-09-23 8:39 ` Vegard Nossum
2007-09-23 8:45 ` Jan Engelhardt
2007-09-23 9:20 ` Vegard Nossum
2007-09-23 9:38 ` Jan Engelhardt
2007-09-23 19:23 ` Joe Perches
2007-09-23 19:25 ` Joe Perches
2007-09-23 1:05 ` Miguel Ojeda
2007-09-25 5:27 ` Vegard Nossum
2007-09-25 17:24 ` Miguel Ojeda
2007-09-23 20:05 ` Rob Landley
2007-09-24 9:22 ` Michael Holzheu [this message]
2007-09-24 15:19 ` Joe Perches
2007-09-24 16:43 ` Vegard Nossum
2007-09-24 17:00 ` Joe Perches
2007-09-24 20:37 ` Vegard Nossum
2007-09-25 1:18 ` Rob Landley
2007-09-24 23:51 ` Rob Landley
2007-09-25 0:10 ` Joe Perches
2007-09-25 1:46 ` Rob Landley
2007-09-25 8:57 ` Michael Holzheu
2007-09-24 18:26 ` Jesse Barnes
-- strict thread matches above, loose matches on Subject: below --
2007-09-25 4:58 linux
2007-09-25 6:54 ` Joe Perches
2007-09-25 7:50 ` linux
2007-09-25 8:06 ` Vegard Nossum
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=1190625742.12666.30.camel@localhost.localdomain \
--to=holzheu@linux.vnet.ibm.com \
--cc=dick.streefland@altium.nl \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rob@landley.net \
--cc=vegard.nossum@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox