From: Tejun Heo <htejun@gmail.com>
To: Matt Mackall <mpm@selenic.com>
Cc: linux-kernel@vger.kernel.org, daniel.ritz-ml@swissonline.ch,
randy.dunlap@oracle.com, jeff@garzik.org,
linux-ide@vger.kernel.org, Matthew Wilcox <matthew@wil.cx>
Subject: Re: [PATCHSET] printk: implement printk_header() and merging printk
Date: Sat, 19 Jan 2008 07:58:10 +0900 [thread overview]
Message-ID: <47912F02.6070801@gmail.com> (raw)
In-Reply-To: <1200681668.25782.9.camel@cinder.waste.org>
Matt Mackall wrote:
> On Wed, 2008-01-16 at 10:00 +0900, Tejun Heo wrote:
>> And mprintk the following.
>>
>> code:
>> DEFINE_MPRINTK(mp, 2 * 80);
>>
>> mprintk_set_header(&mp, KERN_INFO "ata%u.%2u: ", 1, 0);
>> mprintk_push(&mp, "ATA %d", 7);
>> mprintk_push(&mp, ", %u sectors\n", 1024);
>> mprintk(&mp, "everything seems dandy\n");
>
> I prefer Matthew Wilcox's stringbuf approach which does proper memory
> management and isn't specific to printk:
>
> http://www.ussg.iu.edu/hypermail/linux/kernel/0710.3/0517.html
Yeap, that's generic and nice but I think both 'generic' and 'proper
memory management' are weakness if what you're trying to do is to
support collecting messages in pieces and putting it out via printk.
Please consider the following scenario.
You're in an interrupt handler and detected a severe error condition
which should be notified to the user but the information is rather
complex and best built in pieces, so you create a stringbuf and does
sb_printf() to it w/ GFP_ATOMIC but alas memory allocation failed and
you end up printing "out of memory" unless you detect the failure and go
back and printk messages piece-by-piece manually. I would rather
assemble the message manually from the get-go into an on-stack buffer.
By being specifially 'printk' and let the user supply buffer, which in
most cases can be on-stack (messages shouldn't be too long anyway),
mprintk either can avoid those problems from the beginning or can
automatically work around when problem arises (initialized with NULL
buffer from allocation failure) without losing any message, so it's
essentially as simple as using printk. There is no error handling (both
mprintk and kfree can handle NULL pointer) and the message is guaranteed
to go out no matter what.
Auto-expanding string buffer is nice but I don't think it fits the bill
here.
Thanks.
--
tejun
next prev parent reply other threads:[~2008-01-18 22:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-16 1:00 [PATCHSET] printk: implement printk_header() and merging printk Tejun Heo
2008-01-16 1:00 ` [PATCH 1/4] printk: keep log level on multiline messages Tejun Heo
2008-01-16 1:00 ` [PATCH 2/4] printk: implement [v]printk_header() Tejun Heo
2008-01-16 1:00 ` [PATCH 3/4] printk: implement merging printk Tejun Heo
2008-01-16 3:02 ` Randy Dunlap
2008-01-16 3:08 ` Tejun Heo
2008-01-16 1:00 ` [PATCH 4/4] libata: make libata use printk_header() and mprintk Tejun Heo
2008-01-16 2:48 ` Randy Dunlap
2008-01-16 2:53 ` Tejun Heo
2008-01-16 1:07 ` [PATCHSET] printk: implement printk_header() and merging printk Tejun Heo
2008-01-16 2:48 ` Randy Dunlap
2008-01-16 2:58 ` Tejun Heo
2008-01-18 18:41 ` Matt Mackall
2008-01-18 18:44 ` Matthew Wilcox
2008-01-18 19:06 ` Matt Mackall
2008-01-18 22:58 ` Tejun Heo [this message]
2008-01-21 21:42 ` Matt Mackall
2008-01-22 1:00 ` Tejun Heo
2008-01-22 1:28 ` Matt Mackall
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=47912F02.6070801@gmail.com \
--to=htejun@gmail.com \
--cc=daniel.ritz-ml@swissonline.ch \
--cc=jeff@garzik.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mpm@selenic.com \
--cc=randy.dunlap@oracle.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;
as well as URLs for NNTP newsgroup(s).