mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Tejun Heo <htejun@gmail.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: Mon, 21 Jan 2008 19:28:11 -0600	[thread overview]
Message-ID: <1200965291.3860.38.camel@cinder.waste.org> (raw)
In-Reply-To: <47954047.90609@gmail.com>


On Tue, 2008-01-22 at 10:00 +0900, Tejun Heo wrote:
> Matt Mackall wrote:
> > 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 pondered on this a bit but the thing is we already use several
> hundreds bytes in a function which builds complex messages.

Well there are lots of current and potential future users of this
function, many of them down at the end of long call chains. So I'm more
worried about the new cases that embrace this approach and suddenly add
300 bytes of stack. In fact, if this is at all popular, we can expect to
have more than one of these frames on the stack in various paths. 

Given that it only exists to make output prettier, it doesn't -really-
justify increased stack usage.

> > 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");
> > mprintk_end(mp);
> > 
> > That keeps all the "normal" printks short and makes the flush more
> > explict.
> 
> I like that the more used function is shorter.  Hmmm... The reason why I
> first used mprintk_push() is to make it clear that the function
> accumulates messages unlike mprintk() which flushes what's accumulated
> and prints its own message.
> 
> > 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.
> 
> If you wanna do that implicitly, you need GFP_ flag in mprintk_begin()
> and atomic allocation should be used from interrupt handlers and friends
> and they fail easily under the right (or wrong) conditions.  Forcing
> kmalloc isn't a good idea.  Having multiple initializers is one way to
> do it.  Any suggestions?

Adding a gfp_flags arg isn't too painful. And we've generally avoided
having separate function calls for atomic vs non-atomic allocation.

Btw, we can also easily hide Willy or Rusty's stringbuf implementation
under the covers here and still have a scheme that automatically falls
back to direct printk..

-- 
Mathematics is the supreme nostalgia of our time.


      reply	other threads:[~2008-01-22  1:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-16  1:00 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
2008-01-21 21:42     ` Matt Mackall
2008-01-22  1:00       ` Tejun Heo
2008-01-22  1:28         ` Matt Mackall [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=1200965291.3860.38.camel@cinder.waste.org \
    --to=mpm@selenic.com \
    --cc=daniel.ritz-ml@swissonline.ch \
    --cc=htejun@gmail.com \
    --cc=jeff@garzik.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --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

all inboxes | Powered by JetHome®