[lkml]   [2008]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCHSET] printk: implement printk_header() and merging printk

    On Sat, 2008-01-19 at 07:58 +0900, Tejun Heo wrote:
    > 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:
    > >
    > >
    > 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.

    I suppose. I still find this approach less than ideal, especially
    putting something potentially large on the stack. The dangers are
    perhaps worse than a malloc, really.

    I also don't like your interface much. Consider this alternative:

    struct mprintk *mp = mprintk_begin(KERN_INFO "ata%u.%2u: ", 1, 0);
    mprintk(mp, "ATA %d", 7);
    mprintk(mp, ", %u sectors\n", 1024);
    mprintk(mp, "everything seems dandy\n");

    That keeps all the "normal" printks short and makes the flush more

    Now we make mprintk_begin attempt to do a kmalloc of a moderate size
    (512 bytes?) and failing that, return null. Then mprintk can fall
    through to printk in the NULL case.

    Mathematics is the supreme nostalgia of our time.

     \ /
      Last update: 2008-01-21 22:47    [W:0.021 / U:0.072 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site