From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbdJIEI2 (ORCPT ); Mon, 9 Oct 2017 00:08:28 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34606 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751724AbdJIEI1 (ORCPT ); Mon, 9 Oct 2017 00:08:27 -0400 X-Google-Smtp-Source: AOwi7QDIeJQbiX1H4B9syEnTgRqfIT0+YdTeQ+lc0gPZ/u5UnlduSZMwHvvtawqIn430keoyBVCMPw== Date: Mon, 9 Oct 2017 07:03:08 +0300 From: "Kirill A. Shutemov" To: Yang Shi Cc: kirill.shutemov@linux.intel.com, hughd@google.com, mhocko@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] mm: shm: round up tmpfs size to huge page size when huge=always Message-ID: <20171009040308.qz6ufjrfvyv2hygm@node.shutemov.name> References: <1507321330-22525-1-git-send-email-yang.s@alibaba-inc.com> <20171008125651.3mxiayuvuqi2hiku@node.shutemov.name> <9357e3f2-6e49-b47a-20a6-ec7791c28fbd@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9357e3f2-6e49-b47a-20a6-ec7791c28fbd@alibaba-inc.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 09, 2017 at 03:51:06AM +0800, Yang Shi wrote: > > > On 10/8/17 5:56 AM, Kirill A. Shutemov wrote: > > On Sat, Oct 07, 2017 at 04:22:10AM +0800, Yang Shi wrote: > > > When passing "huge=always" option for mounting tmpfs, THP is supposed to > > > be allocated all the time when it can fit, but when the available space is > > > smaller than the size of THP (2MB on x86), shmem fault handler still tries > > > to allocate huge page every time, then fallback to regular 4K page > > > allocation, i.e.: > > > > > > # mount -t tmpfs -o huge,size=3000k tmpfs /tmp > > > # dd if=/dev/zero of=/tmp/test bs=1k count=2048 > > > # dd if=/dev/zero of=/tmp/test1 bs=1k count=2048 > > > > > > The last dd command will handle 952 times page fault handler, then exit > > > with -ENOSPC. > > > > > > Rounding up tmpfs size to THP size in order to use THP with "always" > > > more efficiently. And, it will not wast too much memory (just allocate > > > 511 extra pages in worst case). > > > > Hm. I don't think it's good idea to silently increase size of fs. > > How about printing a warning to say the filesystem is resized? > > > > > Maybe better just refuse to mount with huge=always for too small fs? > > It sounds fine too. When mounting tmpfs with "huge=always", if the size is > not THP size aligned, it just can refuse to mount, then show warning about > alignment restriction. Honestly, I wouldn't bother. Using filesystem at near-full capacity is not best practice. Performance penalty for doing is fair enough. And forcing alignment doesn't really fixes anything: user still allowed to fill the filesystem with files less than 2M in size. -- Kirill A. Shutemov