Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752714AbbBWTQY (ORCPT ); Mon, 23 Feb 2015 14:16:24 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43098 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959AbbBWTQX (ORCPT ); Mon, 23 Feb 2015 14:16:23 -0500 Date: Mon, 23 Feb 2015 11:16:21 -0800 From: Andrew Morton To: Rik van Riel Cc: Ebru Akagunduz , linux-mm@kvack.org, kirill@shutemov.name, mhocko@suse.cz, mgorman@suse.de, rientjes@google.com, sasha.levin@oracle.com, hughd@google.com, hannes@cmpxchg.org, vbabka@suse.cz, linux-kernel@vger.kernel.org, aarcange@redhat.com, keithr@alum.mit.edu, dvyukov@google.com Subject: Re: [PATCH v2] mm: incorporate zero pages into transparent huge pages Message-Id: <20150223111621.bc73004f51af2ca8e2847944@linux-foundation.org> In-Reply-To: <54E5296C.5040806@redhat.com> References: <1423688635-4306-1-git-send-email-ebru.akagunduz@gmail.com> <20150218153119.0bcd0bf8b4e7d30d99f00a3b@linux-foundation.org> <54E5296C.5040806@redhat.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2233 Lines: 53 On Wed, 18 Feb 2015 19:08:12 -0500 Rik van Riel wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 02/18/2015 06:31 PM, Andrew Morton wrote: > > On Wed, 11 Feb 2015 23:03:55 +0200 Ebru Akagunduz > > wrote: > > > >> This patch improves THP collapse rates, by allowing zero pages. > >> > >> Currently THP can collapse 4kB pages into a THP when there are up > >> to khugepaged_max_ptes_none pte_none ptes in a 2MB range. This > >> patch counts pte none and mapped zero pages with the same > >> variable. > > > > So if I'm understanding this correctly, with the default value of > > khugepaged_max_ptes_none (HPAGE_PMD_NR-1), if an application > > creates a 2MB area which contains 511 mappings of the zero page and > > one real page, the kernel will proceed to turn that area into a > > real, physical huge page. So it consumes 2MB of memory which would > > not have previously been allocated? > > This is equivalent to an application doing a write fault > to a 2MB area that was previously untouched, going into > do_huge_pmd_anonymous_page() and receiving a 2MB page. > > > If so, this might be rather undesirable behaviour in some > > situations (and ditto the current behaviour for pte_none ptes)? > > > > This can be tuned by adjusting khugepaged_max_ptes_none, > > The example of directly going into do_huge_pmd_anonymous_page() > is not influenced by the tunable. > > It may indeed be undesirable in some situations, but I am > not sure how to detect those... Here's a live one: https://bugzilla.kernel.org/show_bug.cgi?id=93111 Application does MADV_DONTNEED to free up a load of memory and then khugepaged comes along and pages that memory back in again. It seems a bit silly to do this after userspace has deliberately discarded those pages! Presumably MADV_NOHUGEPAGE can be used to prevent this, but it's a bit of a hand-grenade. I guess the MADV_DONTNEED manpage should be updated to explain all this? -- 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/