linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Huang Ying <ying.huang@intel.com>,
	Hugh Dickins <hughd@google.com>, Shaohua Li <shli@kernel.org>,
	Minchan Kim <minchan@kernel.org>, Rik van Riel <riel@redhat.com>
Subject: [PATCH -mm -v7 1/9] mm, swap: Make swap cluster size same of THP size on x86_64
Date: Tue, 28 Mar 2017 13:32:01 +0800	[thread overview]
Message-ID: <20170328053209.25876-2-ying.huang@intel.com> (raw)
In-Reply-To: <20170328053209.25876-1-ying.huang@intel.com>

From: Huang Ying <ying.huang@intel.com>

In this patch, the size of the swap cluster is changed to that of the
THP (Transparent Huge Page) on x86_64 architecture (512).  This is for
the THP swap support on x86_64.  Where one swap cluster will be used to
hold the contents of each THP swapped out.  And some information of the
swapped out THP (such as compound map count) will be recorded in the
swap_cluster_info data structure.

For other architectures which want THP swap support,
ARCH_USES_THP_SWAP_CLUSTER need to be selected in the Kconfig file for
the architecture.

In effect, this will enlarge swap cluster size by 2 times on x86_64.
Which may make it harder to find a free cluster when the swap space
becomes fragmented.  So that, this may reduce the continuous swap space
allocation and sequential write in theory.  The performance test in 0day
shows no regressions caused by this.

Cc: Hugh Dickins <hughd@google.com>
Cc: Shaohua Li <shli@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
---
 arch/x86/Kconfig |  1 +
 mm/Kconfig       | 13 +++++++++++++
 mm/swapfile.c    |  4 ++++
 3 files changed, 18 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index abfc31fb0bee..852d13878793 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -178,6 +178,7 @@ config X86
 	select USER_STACKTRACE_SUPPORT
 	select VIRT_TO_BUS
 	select X86_FEATURE_NAMES		if PROC_FS
+	select ARCH_USES_THP_SWAP_CLUSTER	if X86_64
 
 config INSTRUCTION_DECODER
 	def_bool y
diff --git a/mm/Kconfig b/mm/Kconfig
index 9b8fccb969dc..7b708e200c29 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -499,6 +499,19 @@ config FRONTSWAP
 
 	  If unsure, say Y to enable frontswap.
 
+config ARCH_USES_THP_SWAP_CLUSTER
+	bool
+	default n
+
+config THP_SWAP_CLUSTER
+	bool
+	depends on SWAP && TRANSPARENT_HUGEPAGE && ARCH_USES_THP_SWAP_CLUSTER
+	default y
+	help
+	  Use one swap cluster to hold the contents of the THP
+	  (Transparent Huge Page) swapped out.  The size of the swap
+	  cluster will be same as that of THP.
+
 config CMA
 	bool "Contiguous Memory Allocator"
 	depends on HAVE_MEMBLOCK && MMU
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 53b5881ee0d6..abc401f72a0a 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -199,7 +199,11 @@ static void discard_swap_cluster(struct swap_info_struct *si,
 	}
 }
 
+#ifdef CONFIG_THP_SWAP_CLUSTER
+#define SWAPFILE_CLUSTER	HPAGE_PMD_NR
+#else
 #define SWAPFILE_CLUSTER	256
+#endif
 #define LATENCY_LIMIT		256
 
 static inline void cluster_set_flag(struct swap_cluster_info *info,
-- 
2.11.0

--
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:[~2017-03-28  5:32 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28  5:32 [PATCH -mm -v7 0/9] THP swap: Delay splitting THP during swapping out Huang, Ying
2017-03-28  5:32 ` Huang, Ying [this message]
2017-03-28 23:30   ` [PATCH -mm -v7 1/9] mm, swap: Make swap cluster size same of THP size on x86_64 Kirill A. Shutemov
2017-03-29  1:10     ` Huang, Ying
2017-03-29 16:55   ` Johannes Weiner
2017-03-30  0:45     ` Huang, Ying
2017-03-31 14:56       ` Johannes Weiner
2017-04-01  3:29         ` Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries Huang, Ying
2017-03-29 16:57   ` Johannes Weiner
2017-03-30  0:53     ` Huang, Ying
2017-03-31 14:59       ` Johannes Weiner
2017-03-28  5:32 ` [PATCH -mm -v7 3/9] mm, THP, swap: Add swap cluster allocate/free functions Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 4/9] mm, THP, swap: Add get_huge_swap_page() Huang, Ying
2017-03-29 17:08   ` Johannes Weiner
2017-03-30  4:28     ` Huang, Ying
2017-03-31 15:24       ` Johannes Weiner
2017-04-01  3:32         ` Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 5/9] mm, THP, swap: Support to clear SWAP_HAS_CACHE for huge page Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 6/9] mm, THP, swap: Support to add/delete THP to/from swap cache Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 7/9] mm, THP: Add can_split_huge_page() Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 8/9] mm, THP, swap: Support to split THP in swap cache Huang, Ying
2017-03-28  5:32 ` [PATCH -mm -v7 9/9] mm, THP, swap: Delay splitting THP during swap out Huang, Ying
2017-03-29 17:16   ` Johannes Weiner
2017-03-30  4:15     ` Huang, Ying
2017-03-31 14:49       ` Johannes Weiner
2017-04-01  2:54         ` Huang, Ying
2017-03-28 22:13 ` [PATCH -mm -v7 0/9] THP swap: Delay splitting THP during swapping out Andrew Morton
2017-03-29  8:52   ` Huang, Ying

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=20170328053209.25876-2-ying.huang@intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=shli@kernel.org \
    /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).