lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 9 Jul 2012 21:50:48 +0900
From:	Minchan Kim <minchan@...nel.org>
To:	Mel Gorman <mgorman@...e.de>
Cc:	Minchan Kim <minchan@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Rik van Riel <riel@...hat.com>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Kamezawa Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Subject: Re: [PATCH] mm: Warn about costly page allocation

On Mon, Jul 09, 2012 at 10:12:03AM +0100, Mel Gorman wrote:
> On Mon, Jul 09, 2012 at 05:46:57PM +0900, Minchan Kim wrote:
> > > > <SNIP>
> > > > +#if defined(CONFIG_DEBUG_VM) && !defined(CONFIG_COMPACTION)
> > > > +static inline void check_page_alloc_costly_order(unsigned int order)
> > > > +{
> > > > +	if (unlikely(order > PAGE_ALLOC_COSTLY_ORDER)) {
> > > > +		printk_once("WARNING: You are tring to allocate %d-order page."
> > > > +		" You might need to turn on CONFIG_COMPACTION\n", order);
> > > > +	}
> > > 
> > > WARN_ON_ONCE would tell you what is trying to satisfy the allocation.
> > 
> > Do you mean that it would be better to use WARN_ON_ONCE rather than raw printk?
> 
> Yes.
> 
> > If so, I would like to insist raw printk because WARN_ON_ONCE could be disabled
> > by !CONFIG_BUG.
> > If I miss something, could you elaborate it more?
> > 
> 
> Ok, but all this will tell you is that *something* tried a high-order
> allocation. It will not tell you who and because it's a printk_once, it
> will also not tell you how often it's happening. You could add a
> dump_stack to capture that information.

That's a good idea.

> 
> > > 
> > > It should further check if this is a GFP_MOVABLE allocation or not and if
> > > not, then it should either be documented that compaction may only delay
> > > allocation failures and that they may need to consider reserving the memory
> > > in advance or doing something like forcing MIGRATE_RESERVE to only be used
> > > for high-order allocations.
> > 
> > Okay. but I got confused you want to add above description in code directly
> > like below or write it down in comment of check_page_alloc_costly_order?
> > 
> 
> You're aiming this at embedded QA people according to your changelog so
> do whatever you think is going to be the most effective. It's already
> "known" that high-order kernel allocations are meant to be unreliable and
> apparently this is being ignored. The in-code warning could look
> something like
> 
> if (unlikely(order > PAGE_ALLOC_COSTLY_ORDER)) {
> 	printk_once("%s: page allocation high-order stupidity: order:%d, mode:0x%x\n",
>                    current->comm, order, gfp_mask);
> 	if (gfp_flags & __GFP_MOVABLE) {
> 		printk_once("Enable compaction or whatever\n");
> 		dump_stack();
> 	} else {
> 		printk_once("Regular high-order kernel allocations like this will eventually start failing.");
> 		dump_stack();
> 	}
> }

I'm not sure we have to check further for __GFP_MOVABLE because I have not seen driver
uses __GFP_MOVABLE for high order allocation. Although it uses the flag, it's never
compactable since it's out of LRU list. So I think it's rather overkill.

> 
> There should be a comment above it giving more information if you think
> the embedded people will actually read it. Of course, if this warning
> triggers during driver initialisation then it might be a completely useless.
> You could rate limit the warning (printk_ratelimit()) instead to be more
> effective. As I don't know what sort of device drivers you are seeing this
> problem with I can't judge what the best style of warning would be.

Okay.
I will send patch like below tomorrow if there isn't any objection.

if (unlikely(order > PAGE_ALLOC_COSTLY_ORDER)) {
	if (printk_ratelimit()) {
		printk("%s: page allocation high-order stupidity: order:%d, mode:0x%x\n",
			current->comm, order, gfp_mask);
		printk_once("Enable compaction or whatever\n");
		printk_once("Regular high-order kernel allocations like this will eventually start failing.\n");
		dump_stack();
	}
}

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ