Re: [PATCH v2 8/9] mm, page_alloc: print symbolic gfp_flags on allocation failure

Michal Hocko
2015-11-25T14:33:58Z

On Tue 24-11-15 13:36:20, Vlastimil Babka wrote:
> It would be useful to translate gfp_flags into string representation when
> printing in case of an allocation failure, especially as the flags have been
> undergoing some changes recently and the script ./scripts/gfp-translate needs
> a matching source version to be accurate.
>
> Example output:
>
> stapio: page allocation failure: order:9, mode:0x2080020(GFP_ATOMIC)

I like this _very much_

> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

If this can be done with a printk formatter it would be even nicer but
this is good enough for the OOM purpose.

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
> mm/page_alloc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index f806a1a..80349ac 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2711,9 +2711,9 @@ void warn_alloc_failed(gfp_t gfp_mask, unsigned int order, const char *fmt, ...)
> va_end(args);
> }
>
> - pr_warn("%s: page allocation failure: order:%u, mode:0x%x\n",
> + pr_warn("%s: page allocation failure: order:%u, mode:0x%x",
> current->comm, order, gfp_mask);
> -
> + dump_gfpflag_names(gfp_mask);
> dump_stack();
> if (!should_suppress_show_mem())
> show_mem(filter);
> --
> 2.6.3

--
Michal Hocko
SUSE Labs