Re: [PATCH] mm/page_alloc: Avoid KERN_CONT uses in warn_alloc

From: Michal Hocko
Date: Thu Nov 09 2017 - 05:05:48 EST


On Tue 07-11-17 08:03:27, Joe Perches wrote:
> On Tue, 2017-11-07 at 16:43 +0100, Michal Hocko wrote:
> > On Tue 07-11-17 07:34:25, Joe Perches wrote:
> []
> > > I believe, but have not tested, that using a specific width
> > > as an argument to %*pb[l] will constrain the number of
> > > spaces before the '(null)' output in any NULL pointer use.
> > >
> > > So how about a #define like
> > >
> > > /*
> > > * nodemask_pr_args is only used with a "%*pb[l]" format for a nodemask.
> > > * A NULL nodemask uses 6 to emit "(null)" without leading spaces.
> > > */
> > > #define nodemask_pr_args(maskp) \
> > > (maskp) ? MAX_NUMNODES : 6, \
> > > (maskp) ? (maskp)->bits : NULL
> >
> > Why not -1 then?
>
> I believe it's the field width and not the precision that
> needs to be set.

But the first of the two arguments is the field with specifier, not the
precision. /me confused...

Anyway, the following works as expected when printing the OOM report:
[ 47.005321] mem_eater invoked oom-killer: gfp_mask=0x14280ca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), nodemask=(null), order=0, oom_score_adj=0
[ 47.007183] mem_eater cpuset=/ mems_allowed=0-1
[ 47.007829] CPU: 3 PID: 3223 Comm: mem_eater Tainted: G W 4.13.0-pr1-dirty #11

I hope I haven't overlooked anything
---