From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbdEBQHH (ORCPT ); Tue, 2 May 2017 12:07:07 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:37737 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbdEBQHF (ORCPT ); Tue, 2 May 2017 12:07:05 -0400 Subject: Re: [PATCH RFC] hugetlbfs 'noautofill' mount option To: Anshuman Khandual , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <326e38dd-b4a8-e0ca-6ff7-af60e8045c74@oracle.com> <06c4eb97-1545-7958-7694-3645d317666b@linux.vnet.ibm.com> From: Prakash Sangappa Message-ID: <07f3fde3-b296-f205-377d-1b4c3bbedb70@oracle.com> Date: Tue, 2 May 2017 09:07:00 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <06c4eb97-1545-7958-7694-3645d317666b@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/2/17 3:53 AM, Anshuman Khandual wrote: > On 05/01/2017 11:30 PM, Prakash Sangappa wrote: >> Some applications like a database use hugetblfs for performance >> reasons. Files on hugetlbfs filesystem are created and huge pages >> allocated using fallocate() API. Pages are deallocated/freed using >> fallocate() hole punching support that has been added to hugetlbfs. >> These files are mmapped and accessed by many processes as shared memory. >> Such applications keep track of which offsets in the hugetlbfs file have >> pages allocated. >> >> Any access to mapped address over holes in the file, which can occur due > s/mapped/unmapped/ ^ ? It is 'mapped' address. > >> to bugs in the application, is considered invalid and expect the process >> to simply receive a SIGBUS. However, currently when a hole in the file is >> accessed via the mapped address, kernel/mm attempts to automatically >> allocate a page at page fault time, resulting in implicitly filling the >> hole > But this is expected when you try to control the file allocation from > a mapped address. Any changes while walking past or writing the range > in the memory mapped should reflect exactly in the file on the disk. > Why its not a valid behavior ? Sure, that is a valid behavior. However, hugetlbfs is a pesudo filesystem and the purpose is for applications to use hugepage memory. The contents of these filesystem are not backed by disk nor are they swapped out. The proposed new behavior is only applicable for hugetlbfs filesystem mounted with the new 'noautofill' mount option. The file's page allocation/free are managed using the 'fallocate()' API. For hugetlbfs filesystems mounted without this option, there is no change in behavior. >> in the file. This may not be the desired behavior for applications like the >> database that want to explicitly manage page allocations of hugetlbfs >> files. >> >> This patch adds a new hugetlbfs mount option 'noautofill', to indicate that >> pages should not be allocated at page fault time when accessed thru mmapped >> address. > When the page should be allocated for mapping ? The application would allocate/free file pages using the fallocate() API.