Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755314AbbB0Uxm (ORCPT ); Fri, 27 Feb 2015 15:53:42 -0500 Received: from mail-ig0-f177.google.com ([209.85.213.177]:34616 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754794AbbB0Uxk (ORCPT ); Fri, 27 Feb 2015 15:53:40 -0500 Date: Fri, 27 Feb 2015 12:53:37 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Ebru Akagunduz cc: linux-mm@kvack.org, akpm@linux-foundation.org, kirill@shutemov.name, mhocko@suse.cz, mgorman@suse.de, sasha.levin@oracle.com, hughd@google.com, hannes@cmpxchg.org, vbabka@suse.cz, linux-kernel@vger.kernel.org, riel@redhat.com, aarcange@redhat.com Subject: Re: [PATCH] mm: set khugepaged_max_ptes_none by 1/8 of HPAGE_PMD_NR In-Reply-To: <1425061608-15811-1-git-send-email-ebru.akagunduz@gmail.com> Message-ID: References: <1425061608-15811-1-git-send-email-ebru.akagunduz@gmail.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2713 Lines: 64 On Fri, 27 Feb 2015, Ebru Akagunduz wrote: > Using THP, programs can access memory faster, by having the > kernel collapse small pages into large pages. The parameter > max_ptes_none specifies how many extra small pages (that are > not already mapped) can be allocated when collapsing a group > of small pages into one large page. > Not exactly, khugepaged isn't "allocating" small pages to collapse into a hugepage, rather it is allocating a hugepage and then remapping the pageblock's mapped pages. > A larger value of max_ptes_none can cause the kernel > to collapse more incomplete areas into THPs, speeding > up memory access at the cost of increased memory use. > A smaller value of max_ptes_none will reduce memory > waste, at the expense of collapsing fewer areas into > THPs. > This changelog only describes what max_ptes_none does, it doesn't state why you want to change it from HPAGE_PMD_NR-1, which is 511 on x86_64 (largest value, more thp), to HPAGE_PMD_NR/8, which is 64 (smaller value, less thp, less rss as a result of collapsing). This has particular performance implications on users who already have thp enabled, so it's difficult to change the default. This is tuanble that you could easily set in an initscript, so I don't think we need to change the value for everybody. > The problem was reported here: > https://bugzilla.kernel.org/show_bug.cgi?id=93111 > > Signed-off-by: Ebru Akagunduz > Reviewed-by: Rik van Riel > --- > mm/huge_memory.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index e08e37a..497fb5a 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -59,11 +59,10 @@ static DEFINE_MUTEX(khugepaged_mutex); > static DEFINE_SPINLOCK(khugepaged_mm_lock); > static DECLARE_WAIT_QUEUE_HEAD(khugepaged_wait); > /* > - * default collapse hugepages if there is at least one pte mapped like > - * it would have happened if the vma was large enough during page > - * fault. > + * The default value should be a compromise between memory use and THP speedup. > + * To collapse hugepages, unmapped ptes should not exceed 1/8 of HPAGE_PMD_NR. > */ > -static unsigned int khugepaged_max_ptes_none __read_mostly = HPAGE_PMD_NR-1; > +static unsigned int khugepaged_max_ptes_none __read_mostly = HPAGE_PMD_NR/8; > > static int khugepaged(void *none); > static int khugepaged_slab_init(void); -- 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/