lkml.org 
[lkml]   [2013]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: Question about printking
From
Hi Joe,

On Sat, Feb 2, 2013 at 4:43 PM, Joe Perches <joe@perches.com> wrote:
> On Sat, 2013-02-02 at 16:30 -0300, Ezequiel Garcia wrote:
>> ptr = kmalloc(sizeof(foo));
>> if (!ptr) {
>> pr_err("Cannot allocate memory for foo\n");
>> return -ENOMEM;
>> }
>> His argue against it was that kmalloc already takes care of reporting/printking
>> a good deal of interesting information when this happens.
>
>> Can someone expand a bit on this whole idea? (of abuse of printing,
>> or futility of printing).
>
> k.alloc() takes a GFP_ flag as an arg.
>
> One of those GFP flags is __GFP_NOWARN.
>
> For all failed allocs without GFP_NOWARN
> a message is emitted and a dump_stack is
> done.
>
> (see: mm/page_alloc.c warn_alloc_failed())
>
> So, most all of these printks after
> k.alloc()'s are not necessary.
>
>

Thanks for the explanation.

BTW, I see you've made some patches to fix exactly this.
Nice job.

Regards,

--
Ezequiel


\
 
 \ /
  Last update: 2013-02-04 22:45    [W:0.058 / U:4.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site