linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Mel Gorman <mgorman@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Minchan Kim <minchan.kim@gmail.com>, Jan Kara <jack@suse.cz>,
	Andy Isaacson <adi@hexapodia.org>,
	Johannes Weiner <jweiner@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: Do not stall in synchronous compaction for THP allocations
Date: Tue, 15 Nov 2011 16:07:08 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1111151554190.3781@chino.kir.corp.google.com> (raw)
In-Reply-To: <20111115234845.GK27150@suse.de>

On Tue, 15 Nov 2011, Mel Gorman wrote:

> Adding sync here could obviously be implemented although it may
> require both always-sync and madvise-sync. Alternatively, something
> like an options file could be created to create a bitmap similar to
> what ftrace does. Whatever the mechanism, it exposes the fact that
> "sync compaction" is used. If that turns out to be not enough, then
> you may want to add other steps like aggressively reclaiming memory
> which also potentially may need to be controlled via the sysfs file
> and this is the slippery slope.
> 

So what's being proposed here in this patch is the fifth time this line 
has been changed and its always been switched between true and !(gfp_mask 
& __GFP_NO_KSWAPD).  Instead of changing it every few months, I'd suggest 
that we tie the semantics of the tunable directly to sync_compaction since 
we're primarily targeting thp hugepages with this change anyway for the 
"always" case.  Comments?

diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt
--- a/Documentation/vm/transhuge.txt
+++ b/Documentation/vm/transhuge.txt
@@ -116,6 +116,13 @@ echo always >/sys/kernel/mm/transparent_hugepage/defrag
 echo madvise >/sys/kernel/mm/transparent_hugepage/defrag
 echo never >/sys/kernel/mm/transparent_hugepage/defrag
 
+If defrag is set to "always", then all hugepage allocations also attempt
+synchronous memory compaction which makes the allocation as aggressive
+as possible.  The overhead of attempting to allocate the hugepage is
+considered acceptable because of the longterm benefits of the hugepage
+itself at runtime.  If the VM should fallback to using regular pages
+instead, then you should use "madvise" or "never".
+
 khugepaged will be automatically started when
 transparent_hugepage/enabled is set to "always" or "madvise, and it'll
 be automatically shutdown if it's set to "never".

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2168,7 +2168,17 @@ rebalance:
 					sync_migration);
 	if (page)
 		goto got_pg;
-	sync_migration = true;
+
+	/*
+	 * Do not use synchronous migration for transparent hugepages unless
+	 * defragmentation is always attempted for such allocations since it
+	 * can stall in writeback, which is far worse than simply failing to
+	 * promote a page.  Otherwise, we really do want a hugepage and are as
+	 * aggressive as possible to allocate it.
+	 */
+	sync_migration = !(gfp_mask & __GFP_NO_KSWAPD) ||
+			(transparent_hugepage_flags &
+				(1 << TRANSPARENT_HUGEPAGE_DEFRAG_FLAG));
 
 	/* Try direct reclaim and then allocating */
 	page = __alloc_pages_direct_reclaim(gfp_mask, order,

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-11-16  0:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-10 10:06 Mel Gorman
2011-11-10 10:38 ` Johannes Weiner
2011-11-10 10:51 ` Alan Cox
2011-11-10 12:06   ` Johannes Weiner
2011-11-10 14:00 ` Andrea Arcangeli
2011-11-10 14:22 ` Mel Gorman
2011-11-10 15:12   ` Minchan Kim
2011-11-10 16:13     ` Mel Gorman
2011-11-10 16:30       ` Minchan Kim
2011-11-10 16:48         ` Mel Gorman
2011-11-10 23:12       ` Andrew Morton
2011-11-10 23:37         ` David Rientjes
2011-11-11 10:14           ` Mel Gorman
2011-11-11 10:39             ` David Rientjes
2011-11-11 11:17               ` Mel Gorman
2011-11-11 14:21               ` Andrea Arcangeli
2011-11-14 23:44             ` Andrew Morton
2011-11-15 13:25               ` Mel Gorman
2011-11-15 21:07                 ` David Rientjes
2011-11-15 23:48                   ` Mel Gorman
2011-11-16  0:07                     ` David Rientjes [this message]
2011-11-16  4:13                       ` Andrea Arcangeli
2011-11-16 13:30                         ` Andrea Arcangeli
2011-11-16 15:07                           ` Mel Gorman
2011-11-18 17:59                           ` Andrea Arcangeli
2011-11-16 14:14                         ` Mel Gorman
2011-11-11 10:01         ` Mel Gorman
2011-11-15  0:03           ` Andrew Morton
2011-11-15  2:00             ` Andrea Arcangeli
2011-11-15  2:08               ` Andrea Arcangeli
2011-11-15 15:01                 ` Mel Gorman
2011-11-15 15:00               ` Mel Gorman
2011-11-15 13:07             ` Mel Gorman
2011-11-15 15:47               ` Andrea Arcangeli

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=alpine.DEB.2.00.1111151554190.3781@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=aarcange@redhat.com \
    --cc=adi@hexapodia.org \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=jweiner@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=minchan.kim@gmail.com \
    /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