Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753085AbbGMU23 (ORCPT ); Mon, 13 Jul 2015 16:28:29 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:34010 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752808AbbGMU21 (ORCPT ); Mon, 13 Jul 2015 16:28:27 -0400 From: Ebru Akagunduz To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, n-horiguchi@ah.jp.nec.com, aarcange@redhat.com, riel@redhat.com, iamjoonsoo.kim@lge.com, xiexiuqi@huawei.com, gorcunov@openvz.org, linux-kernel@vger.kernel.org, mgorman@suse.de, rientjes@google.com, vbabka@suse.cz, aneesh.kumar@linux.vnet.ibm.com, hughd@google.com, hannes@cmpxchg.org, mhocko@suse.cz, boaz@plexistor.com, raindel@mellanox.com, Ebru Akagunduz Subject: [RFC v3 2/3] mm: make optimistic check for swapin readahead Date: Mon, 13 Jul 2015 23:28:03 +0300 Message-Id: <1436819284-3964-3-git-send-email-ebru.akagunduz@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436819284-3964-1-git-send-email-ebru.akagunduz@gmail.com> References: <1436819284-3964-1-git-send-email-ebru.akagunduz@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4060 Lines: 133 This patch makes optimistic check for swapin readahead to increase thp collapse rate. Before getting swapped out pages to memory, checks them and allows up to a certain number. It also prints out using tracepoints amount of unmapped ptes. Signed-off-by: Ebru Akagunduz --- Changes in v2: - Nothing changed Changes in v3: - Define constant to specify exact tracepoint result (Vlastimil Babka) include/linux/mm.h | 1 + include/trace/events/huge_memory.h | 11 +++++++---- mm/huge_memory.c | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index bf341c0..eacf348 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -38,6 +38,7 @@ #define MM_ALLOC_HUGE_PAGE_FAIL 6 #define MM_CGROUP_CHARGE_FAIL 7 #define MM_COLLAPSE_ISOLATE_FAIL 5 +#define MM_EXCEED_SWAP_PTE 2 struct mempolicy; struct anon_vma; diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h index cbc56fc..b6bdcc4 100644 --- a/include/trace/events/huge_memory.h +++ b/include/trace/events/huge_memory.h @@ -9,9 +9,9 @@ TRACE_EVENT(mm_khugepaged_scan_pmd, TP_PROTO(struct mm_struct *mm, struct page *page, bool writable, - bool referenced, int none_or_zero, int ret), + bool referenced, int none_or_zero, int ret, int unmapped), - TP_ARGS(mm, page, writable, referenced, none_or_zero, ret), + TP_ARGS(mm, page, writable, referenced, none_or_zero, ret, unmapped), TP_STRUCT__entry( __field(struct mm_struct *, mm) @@ -20,6 +20,7 @@ TRACE_EVENT(mm_khugepaged_scan_pmd, __field(bool, referenced) __field(int, none_or_zero) __field(int, ret) + __field(int, unmapped) ), TP_fast_assign( @@ -29,15 +30,17 @@ TRACE_EVENT(mm_khugepaged_scan_pmd, __entry->referenced = referenced; __entry->none_or_zero = none_or_zero; __entry->ret = ret; + __entry->unmapped = unmapped; ), - TP_printk("mm=%p, page=%p, writable=%d, referenced=%d, none_or_zero=%d, ret=%d", + TP_printk("mm=%p, page=%p, writable=%d, referenced=%d, none_or_zero=%d, ret=%d, unmapped=%d", __entry->mm, __entry->page, __entry->writable, __entry->referenced, __entry->none_or_zero, - __entry->ret) + __entry->ret, + __entry->unmapped) ); TRACE_EVENT(mm_collapse_huge_page, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 595edd9..b4cef9d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -2671,11 +2672,11 @@ static int khugepaged_scan_pmd(struct mm_struct *mm, { pmd_t *pmd; pte_t *pte, *_pte; - int ret = 0, none_or_zero = 0; + int ret = 0, none_or_zero = 0, unmapped = 0; struct page *page = NULL; unsigned long _address; spinlock_t *ptl; - int node = NUMA_NO_NODE; + int node = NUMA_NO_NODE, max_ptes_swap = HPAGE_PMD_NR/8; bool writable = false, referenced = false; VM_BUG_ON(address & ~HPAGE_PMD_MASK); @@ -2691,6 +2692,14 @@ static int khugepaged_scan_pmd(struct mm_struct *mm, for (_address = address, _pte = pte; _pte < pte+HPAGE_PMD_NR; _pte++, _address += PAGE_SIZE) { pte_t pteval = *_pte; + if (is_swap_pte(pteval)) { + if (++unmapped <= max_ptes_swap) { + continue; + } else { + ret = MM_EXCEED_SWAP_PTE; + goto out_unmap; + } + } if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) { if (!userfaultfd_armed(vma) && ++none_or_zero <= khugepaged_max_ptes_none) { @@ -2755,7 +2764,7 @@ out_unmap: } out: trace_mm_khugepaged_scan_pmd(mm, page, writable, referenced, - none_or_zero, ret); + none_or_zero, ret, unmapped); return ret; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/