Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935664AbcJUWqf (ORCPT ); Fri, 21 Oct 2016 18:46:35 -0400 Received: from mga14.intel.com ([192.55.52.115]:47201 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932774AbcJUWqe (ORCPT ); Fri, 21 Oct 2016 18:46:34 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,527,1473145200"; d="scan'208";a="1057351673" Date: Sat, 22 Oct 2016 01:46:29 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins , Andrea Arcangeli , Andrew Morton Cc: Andi Kleen , Dave Chinner , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv4] shmem: avoid huge pages for small files Message-ID: <20161021224629.tnwuvruhblkg22qj@black.fi.intel.com> References: <20161021185103.117938-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161021185103.117938-1-kirill.shutemov@linux.intel.com> User-Agent: NeoMutt/20160916 (1.7.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2150 Lines: 63 On Fri, Oct 21, 2016 at 09:51:03PM +0300, Kirill A. Shutemov wrote: > + case SHEME_HUGE_ALWAYS: Oops. Forgot to commit the fixup :-/ >From 79b0a3bf4503225d0e6ba553b8496f0c4d55514e Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Mon, 17 Oct 2016 14:44:47 +0300 Subject: [PATCHv4] shmem: avoid huge pages for small files Huge pages are detrimental for small file: they causes noticible overhead on both allocation performance and memory footprint. This patch aimed to address this issue by avoiding huge pages until file grown to size of huge page. This would cover most of the cases where huge pages causes regressions in performance. Couple notes: - if shmem_enabled is set to 'force', the limit is ignored. We still want to generate as many pages as possible for functional testing. - the limit doesn't affect khugepaged behaviour: it still can collapse pages based on its settings; Signed-off-by: Kirill A. Shutemov --- Documentation/vm/transhuge.txt | 3 +++ mm/shmem.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt index 2ec6adb5a4ce..d1889c7c8c46 100644 --- a/Documentation/vm/transhuge.txt +++ b/Documentation/vm/transhuge.txt @@ -238,6 +238,9 @@ values: - "force": Force the huge option on for all - very useful for testing; +To avoid overhead for small files, we don't allocate huge pages for a file +until it grows to size of huge pages. + == Need of application restart == The transparent_hugepage/enabled values and tmpfs mount option only affect diff --git a/mm/shmem.c b/mm/shmem.c index ad7813d73ea7..49618d2d6330 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1692,6 +1692,11 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, goto alloc_huge; /* TODO: implement fadvise() hints */ goto alloc_nohuge; + case SHMEM_HUGE_ALWAYS: + i_size = i_size_read(inode); + if (index < HPAGE_PMD_NR && i_size < HPAGE_PMD_SIZE) + goto alloc_nohuge; + break; } alloc_huge: -- Kirill A. Shutemov