linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Michal Hocko <mhocko@kernel.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	David Rientjes <rientjes@google.com>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH v3 12/17] mm, compaction: more reliably increase direct compaction priority
Date: Mon, 18 Jul 2016 13:41:13 +0900	[thread overview]
Message-ID: <20160718044112.GA9460@js1304-P5Q-DELUXE> (raw)
In-Reply-To: <78b8fc60-ddd8-ae74-4f1a-f4bcb9933016@suse.cz>

On Fri, Jul 15, 2016 at 03:37:52PM +0200, Vlastimil Babka wrote:
> On 07/06/2016 07:39 AM, Joonsoo Kim wrote:
> > On Fri, Jun 24, 2016 at 11:54:32AM +0200, Vlastimil Babka wrote:
> >> During reclaim/compaction loop, compaction priority can be increased by the
> >> should_compact_retry() function, but the current code is not optimal. Priority
> >> is only increased when compaction_failed() is true, which means that compaction
> >> has scanned the whole zone. This may not happen even after multiple attempts
> >> with the lower priority due to parallel activity, so we might needlessly
> >> struggle on the lower priority and possibly run out of compaction retry
> >> attempts in the process.
> >>
> >> We can remove these corner cases by increasing compaction priority regardless
> >> of compaction_failed(). Examining further the compaction result can be
> >> postponed only after reaching the highest priority. This is a simple solution
> >> and we don't need to worry about reaching the highest priority "too soon" here,
> >> because hen should_compact_retry() is called it means that the system is
> >> already struggling and the allocation is supposed to either try as hard as
> >> possible, or it cannot fail at all. There's not much point staying at lower
> >> priorities with heuristics that may result in only partial compaction.
> >> Also we now count compaction retries only after reaching the highest priority.
> > 
> > I'm not sure that this patch is safe. Deferring and skip-bit in
> > compaction is highly related to reclaim/compaction. Just ignoring them and (almost)
> > unconditionally increasing compaction priority will result in less
> > reclaim and less success rate on compaction.
> 
> I don't see why less reclaim? Reclaim is always attempted before
> compaction and compaction priority doesn't affect it. And as long as
> reclaim wants to retry, should_compact_retry() isn't even called, so the
> priority stays. I wanted to change that in v1, but Michal suggested I
> shouldn't.

I assume the situation that there is no !costly highorder freepage
because of fragmentation. In this case, should_reclaim_retry() would
return false since watermark cannot be met due to absence of high
order freepage. Now, please see should_compact_retry() with assumption
that there are enough order-0 free pages. Reclaim/compaction is only
retried two times (SYNC_LIGHT and SYNC_FULL) with your patchset since
compaction_withdrawn() return false with enough freepages and
!COMPACT_SKIPPED.

But, before your patchset, COMPACT_PARTIAL_SKIPPED and
COMPACT_DEFERRED is considered as withdrawn so will retry
reclaim/compaction more times.

As I said before, more reclaim (more freepage) increase migration
scanner's scan range and then increase compaction success probability.
Therefore, your patchset which makes reclaim/compaction retry less times
deterministically would not be safe.

> 
> > And, as a necessarily, it
> > would trigger OOM more frequently.
> 
> OOM is only allowed for costly orders. If reclaim itself doesn't want to
> retry for non-costly orders anymore, and we finally start calling
> should_compact_retry(), then I guess the system is really struggling
> already and eventual OOM wouldn't be premature?

Premature is really subjective so I don't know. Anyway, I tested
your patchset with simple test case and it causes a regression.

My test setup is:

Mem: 512 MB
vm.compact_unevictable_allowed = 0
Mlocked Mem: 225 MB by using mlock(). With some tricks, mlocked pages are
spread so memory is highly fragmented.

fork 500

This test causes OOM with your patchset but not without your patchset.

Thanks.

> > It would not be your fault. This patch is reasonable in current
> > situation. It just makes current things more deterministic
> > although I dislike that current things and this patch would amplify
> > those problem.
> > 
> > Thanks.
> > 
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-07-18  4:37 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24  9:54 [PATCH v3 00/17] make direct compaction more deterministic Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 01/17] mm, compaction: don't isolate PageWriteback pages in MIGRATE_SYNC_LIGHT mode Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 02/17] mm, page_alloc: set alloc_flags only once in slowpath Vlastimil Babka
2016-06-30 14:44   ` Michal Hocko
2016-06-24  9:54 ` [PATCH v3 03/17] mm, page_alloc: don't retry initial attempt " Vlastimil Babka
2016-06-30 15:03   ` Michal Hocko
2016-06-24  9:54 ` [PATCH v3 04/17] mm, page_alloc: restructure direct compaction handling " Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 05/17] mm, page_alloc: make THP-specific decisions more generic Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 06/17] mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 07/17] mm, compaction: introduce direct compaction priority Vlastimil Babka
2016-06-24 11:39   ` kbuild test robot
2016-06-24 11:51     ` Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 08/17] mm, compaction: simplify contended compaction handling Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 09/17] mm, compaction: make whole_zone flag ignore cached scanner positions Vlastimil Babka
2016-07-06  5:09   ` Joonsoo Kim
2016-07-18  9:12     ` Vlastimil Babka
2016-07-19  6:44       ` Joonsoo Kim
2016-07-19  6:54         ` Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 10/17] mm, compaction: cleanup unused functions Vlastimil Babka
2016-06-24 11:53   ` Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 11/17] mm, compaction: add the ultimate direct compaction priority Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 12/17] mm, compaction: more reliably increase " Vlastimil Babka
2016-07-06  5:39   ` Joonsoo Kim
2016-07-15 13:37     ` Vlastimil Babka
2016-07-18  4:41       ` Joonsoo Kim [this message]
2016-07-18 12:21         ` Vlastimil Babka
2016-07-19  4:53           ` Joonsoo Kim
2016-07-19  7:42             ` Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 13/17] mm, compaction: use correct watermark when checking allocation success Vlastimil Babka
2016-07-06  5:47   ` Joonsoo Kim
2016-07-18  9:23     ` Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 14/17] mm, compaction: create compact_gap wrapper Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 15/17] mm, compaction: use proper alloc_flags in __compaction_suitable() Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 16/17] mm, compaction: require only min watermarks for non-costly orders Vlastimil Babka
2016-06-24  9:54 ` [PATCH v3 17/17] mm, vmscan: make compaction_ready() more accurate and readable Vlastimil Babka
2016-07-06  5:55   ` Joonsoo Kim
2016-07-18 11:48     ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160718044112.GA9460@js1304-P5Q-DELUXE \
    --to=iamjoonsoo.kim@lge.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).