Re: [PATCH 1/2] break out page allocation warning code

From: Dave Hansen
Date: Fri Apr 08 2011 - 16:43:42 EST


On Fri, 2011-04-08 at 13:37 -0700, David Rientjes wrote:
> > +static DEFINE_RATELIMIT_STATE(nopage_rs,
> > + DEFAULT_RATELIMIT_INTERVAL,
> > + DEFAULT_RATELIMIT_BURST);
> > +
> > +void nopage_warning(gfp_t gfp_mask, int order, const char *fmt, ...)
>
> I suggest a different name for this, something like warn_alloc_failure()
> or such.

That works for me.

> I guess this isn't general enough where it could be used in the oom killer
> as well?

Nope, don't think so. I took a look at it, but it isn't horribly close
to this.

> > +{
> > + va_list args;
> > + int r;
> > + unsigned int filter = SHOW_MEM_FILTER_NODES;
> > + const gfp_t wait = gfp_mask & __GFP_WAIT;
> > +
> > + if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs))
> > + return;
> > +
> > + /*
> > + * This documents exceptions given to allocations in certain
> > + * contexts that are allowed to allocate outside current's set
> > + * of allowed nodes.
> > + */
> > + if (!(gfp_mask & __GFP_NOMEMALLOC))
> > + if (test_thread_flag(TIF_MEMDIE) ||
> > + (current->flags & (PF_MEMALLOC | PF_EXITING)))
> > + filter &= ~SHOW_MEM_FILTER_NODES;
> > + if (in_interrupt() || !wait)
> > + filter &= ~SHOW_MEM_FILTER_NODES;
> > +
> > + if (fmt) {
> > + printk(KERN_WARNING);
> > + va_start(args, fmt);
> > + r = vprintk(fmt, args);
> > + va_end(args);
> > + }
> > +
> > + printk(KERN_WARNING);
> > + printk("%s: page allocation failure: order:%d, mode:0x%x\n",
> > + current->comm, order, gfp_mask);
>
> This shouldn't be here, it should have been printed already.

The "page allocation failure" might have been, if it was specified (it
isn't from the allocator), but order and mode haven't been. My thought
here is that _all_ allocator failures will want to output mode and gfp,
so it might as well be common code instead of making everybody specify
it.

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/