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]
Message-ID: <56DEA0CF.2070902@suse.cz>
Date:	Tue, 8 Mar 2016 10:52:15 +0100
From:	Vlastimil Babka <vbabka@...e.cz>
To:	Michal Hocko <mhocko@...nel.org>
Cc:	Hugh Dickins <hughd@...gle.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Johannes Weiner <hannes@...xchg.org>,
	Mel Gorman <mgorman@...e.de>,
	David Rientjes <rientjes@...gle.com>,
	Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
	Hillf Danton <hillf.zj@...baba-inc.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	linux-mm@...ck.org, LKML <linux-kernel@...r.kernel.org>,
	Joonsoo Kim <js1304@...il.com>
Subject: Re: [PATCH] mm, oom: protect !costly allocations some more

On 03/08/2016 10:46 AM, Michal Hocko wrote:
> On Tue 08-03-16 10:24:56, Vlastimil Babka wrote:
> [...]
>>> @@ -2819,28 +2819,22 @@ static struct page *
>>>  __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>>>  		int alloc_flags, const struct alloc_context *ac,
>>>  		enum migrate_mode mode, int *contended_compaction,
>>> -		bool *deferred_compaction)
>>> +		unsigned long *compact_result)
>>>  {
>>> -	unsigned long compact_result;
>>>  	struct page *page;
>>>  
>>> -	if (!order)
>>> +	if (!order) {
>>> +		*compact_result = COMPACT_NONE;
>>>  		return NULL;
>>> +	}
>>>  
>>>  	current->flags |= PF_MEMALLOC;
>>> -	compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>>> +	*compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>>>  						mode, contended_compaction);
>>>  	current->flags &= ~PF_MEMALLOC;
>>>  
>>> -	switch (compact_result) {
>>> -	case COMPACT_DEFERRED:
>>> -		*deferred_compaction = true;
>>> -		/* fall-through */
>>> -	case COMPACT_SKIPPED:
>>> +	if (*compact_result <= COMPACT_SKIPPED)
>>
>> COMPACT_NONE is -1 and compact_result is unsigned long, so this won't
>> work as expected.
> 
> Well, COMPACT_NONE is documented as /* compaction disabled */ so we
> should never get it from try_to_compact_pages.

Right.

>
> [...]
>>> @@ -3294,6 +3289,18 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>>>  				 did_some_progress > 0, no_progress_loops))
>>>  		goto retry;
>>>  
>>> +	/*
>>> +	 * !costly allocations are really important and we have to make sure
>>> +	 * the compaction wasn't deferred or didn't bail out early due to locks
>>> +	 * contention before we go OOM.
>>> +	 */
>>> +	if (order && order <= PAGE_ALLOC_COSTLY_ORDER) {
>>> +		if (compact_result <= COMPACT_CONTINUE)
>>
>> Same here.
>> I was going to say that this didn't have effect on Sergey's test, but
>> turns out it did :)
> 
> This should work as expected because compact_result is unsigned long
> and so this is the unsigned arithmetic. I can make
> #define COMPACT_NONE            -1UL
> 
> to make the intention more obvious if you prefer, though.

Well, what wasn't obvious to me is actually that here (unlike in the
test above) it was actually intended that COMPACT_NONE doesn't result in
a retry. But it makes sense, otherwise we would retry endlessly if
reclaim couldn't form a higher-order page, right.

> Thanks for the review.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ