mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Pekka Enberg" <penberg@cs.helsinki.fi>
To: "Rusty Russell" <rusty@rustcorp.com.au>
Cc: "Matthew Wilcox" <matthew@wil.cx>,
	"Linus Torvalds" <torvalds@osdl.org>,
	"Andrew Morton" <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	"Matthew Wilcox" <willy@linux.intel.com>
Subject: Re: [PATCH 1/4] stringbuf: A string buffer implementation
Date: Sat, 27 Oct 2007 19:34:47 +0300	[thread overview]
Message-ID: <84144f020710270934j54153c8bibb2d1fb48abd8dca@mail.gmail.com> (raw)
In-Reply-To: <200710272250.16323.rusty@rustcorp.com.au>

Hi Rusty,

On Saturday 27 October 2007 21:47:09 Pekka Enberg wrote:
> > > +               kfree(oldsb);
> > > +               *sb = (struct stringbuf *)enomem_string;
> >
> > Why don't we just return -ENOMEM here just like all other APIs in the
> > kernel?

On 10/27/07, Rusty Russell <rusty@rustcorp.com.au> wrote:
> I think Willy did it because this is for printk.  It makes more sense than
> everyone opencoding an -ENOMEM handler, which will have to be replaced by
> some mildly amusing string like "I want to printk but I have no memory!".
> Next think you know 70% of the kernel will be bad limericks as everyone tries
> to one-up each other.

My point was, of course, that the caller gets to decide what to do on
OOM. For the most part, you probably want to ignore it but for things
like pseudo filesystems where you generate a human-readable string,
returning -ENOMEM from read(2) is preferable.

On Saturday 27 October 2007 21:47:09 Pekka Enberg wrote:
> > And I wonder if it makes more sense to store gfp_flags in
> > struct stringbuf and always use that? I mean, why would you want to
> > sometimes do GFP_ATOMIC and GFP_KERNEL allocations for the same
> > buffer?

On 10/27/07, Rusty Russell <rusty@rustcorp.com.au> wrote:
> Firstly we don't have a buffer on first call (NULL), though we could introduce
> an sb_init() for that.  Secondly, since the purpose of this code is because
> they can't do the printk all at once: who's to say that isn't because they
> need to grab a lock for some of it?  Finally, we generally choose to expose
> the alloc flags to the caller to make them think about whether they really
> want to do allocation at this point.

Yeah, makes sense. Thanks.

                                   Pekka

  reply	other threads:[~2007-10-27 16:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 19:58 Stringbuf, v2 Matthew Wilcox
2007-10-24 19:59 ` [PATCH 1/4] stringbuf: A string buffer implementation Matthew Wilcox
2007-10-24 19:59   ` [PATCH 2/4] isdn: Use stringbuf Matthew Wilcox
2007-10-24 19:59     ` [PATCH 3/4] sound: " Matthew Wilcox
2007-10-24 19:59       ` [PATCH 4/4] partitions: Fix non-atomic printk Matthew Wilcox
2007-10-24 20:59   ` [PATCH 1/4] stringbuf: A string buffer implementation Kyle Moffett
2007-10-24 21:21     ` Matthew Wilcox
2007-10-25  0:07       ` Kyle Moffett
2007-10-25  3:23         ` Matthew Wilcox
2007-10-26  2:11   ` Rusty Russell
2007-10-26  3:41     ` Joe Perches
2007-10-26  5:05       ` Joe Perches
2007-10-26 11:57     ` Matthew Wilcox
2007-10-26 20:57       ` Matt Mackall
2007-10-27 10:09         ` Rusty Russell
2007-10-29  3:03           ` Matt Mackall
2007-10-29  5:38             ` Rusty Russell
2007-10-27 11:47     ` Pekka Enberg
2007-10-27 12:50       ` Rusty Russell
2007-10-27 16:34         ` Pekka Enberg [this message]
2007-10-27 16:48           ` Matthew Wilcox
2007-10-24 20:51 ` Stringbuf, v2 Joe Perches
2007-10-24 20:57   ` Matthew Wilcox
2007-10-24 21:06     ` Joe Perches
2007-10-24 21:34       ` Matthew Wilcox
  -- strict thread matches above, loose matches on Subject: below --
2007-10-23 21:12 [PATCH 1/4] stringbuf: A string buffer implementation Matthew Wilcox
2007-10-23 22:11 ` Matt Mackall
2007-10-24  1:49   ` Matthew Wilcox
2007-10-24 15:20     ` Matt Mackall
2007-10-24 15:30       ` Matthew Wilcox
2007-10-23 23:43 ` Linus Torvalds
2007-10-24  2:30   ` Matthew Wilcox
2007-10-24  2:45     ` Andrew Morton
2007-10-24  2:19 ` Eric St-Laurent
2007-10-24  2:35   ` Matthew Wilcox
2007-10-24  2:48     ` Eric St-Laurent
2007-10-24 13:21 ` Florian Weimer
2007-10-24 14:02   ` Matthew Wilcox
2007-10-26 12:05 ` Pekka Enberg
2007-10-27  7:31 ` Pavel Machek
2007-10-30 15:26 ` Denys Vlasenko

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=84144f020710270934j54153c8bibb2d1fb48abd8dca@mail.gmail.com \
    --to=penberg@cs.helsinki.fi \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@osdl.org \
    --cc=willy@linux.intel.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

Powered by JetHome