From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by kanga.kvack.org (Postfix) with ESMTP id 1446B6B002C for ; Mon, 10 Oct 2011 09:59:11 -0400 (EDT) Received: by vcbfo14 with SMTP id fo14so6350093vcb.14 for ; Mon, 10 Oct 2011 06:59:08 -0700 (PDT) From: Bob Liu Subject: [RFC PATCH] mm: thp: make swap configurable Date: Mon, 10 Oct 2011 21:58:06 +0800 Message-Id: <1318255086-7393-1-git-send-email-lliubbo@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: aarcange@redhat.com Cc: linux-mm@kvack.org, akpm@linux-foundation.org, hannes@cmpxchg.org, riel@redhat.com, Bob Liu Currently THP do swap by default, user has no control of it. But some applications are swap sensitive, this patch add a boot param and sys file to make it configurable. Signed-off-by: Bob Liu --- Documentation/vm/transhuge.txt | 9 +++++++++ include/linux/huge_mm.h | 5 +++++ mm/huge_memory.c | 26 ++++++++++++++++++++++++++ mm/swap_state.c | 10 ++++++---- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt index 29bdf62..1c7d8e9 100644 --- a/Documentation/vm/transhuge.txt +++ b/Documentation/vm/transhuge.txt @@ -116,6 +116,12 @@ echo always >/sys/kernel/mm/transparent_hugepage/defrag echo madvise >/sys/kernel/mm/transparent_hugepage/defrag echo never >/sys/kernel/mm/transparent_hugepage/defrag +Swap for Transparent Hugepage default is enabled, you can disable it +by: +echo 1 > /sys/kernel/mm/transparent_hugepage/disable_swap +and reenable by: +echo 0 > /sys/kernel/mm/transparent_hugepage/disable_swap + 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". @@ -159,6 +165,9 @@ Support by passing the parameter "transparent_hugepage=always" or "transparent_hugepage=madvise" or "transparent_hugepage=never" (without "") to the kernel command line. +You can disable swap for Transparent Hugepage by passing parameter +"disable_transparent_hugepage_swap". + == Need of application restart == The transparent_hugepage/enabled values only affect future diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 48c32eb..229ef7b 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -31,6 +31,7 @@ enum transparent_hugepage_flag { TRANSPARENT_HUGEPAGE_DEFRAG_FLAG, TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG, + TRANSPARENT_HUGEPAGE_SWAP_DISABLE_FLAG, #ifdef CONFIG_DEBUG_VM TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG, #endif @@ -65,6 +66,9 @@ extern pmd_t *page_check_address_pmd(struct page *page, (transparent_hugepage_flags & \ (1<vm_flags & VM_HUGEPAGE)) +#define transparent_hugepage_swap_disable() \ + (transparent_hugepage_flags & \ + (1< #include #include +#include #include #include @@ -155,10 +156,11 @@ int add_to_swap(struct page *page) return 0; if (unlikely(PageTransHuge(page))) - if (unlikely(split_huge_page(page))) { - swapcache_free(entry, NULL); - return 0; - } + if(!transparent_hugepage_swap_disable()) + if (unlikely(split_huge_page(page))) { + swapcache_free(entry, NULL); + return 0; + } /* * Radix-tree node allocations from PF_MEMALLOC contexts could -- 1.5.6.3 -- 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: email@kvack.org