From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751091AbdEHP6J (ORCPT ); Mon, 8 May 2017 11:58:09 -0400 Received: from mga03.intel.com ([134.134.136.65]:39307 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750803AbdEHP6I (ORCPT ); Mon, 8 May 2017 11:58:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,309,1491289200"; d="scan'208";a="84110430" Subject: Re: [PATCH RFC] hugetlbfs 'noautofill' mount option To: Prakash Sangappa , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <326e38dd-b4a8-e0ca-6ff7-af60e8045c74@oracle.com> <7ff6fb32-7d16-af4f-d9d5-698ab7e9e14b@intel.com> <03127895-3c5a-5182-82de-3baa3116749e@oracle.com> <22557bf3-14bb-de02-7b1b-a79873c583f1@intel.com> <7677d20e-5d53-1fb7-5dac-425edda70b7b@oracle.com> From: Dave Hansen Message-ID: <48a544c4-61b3-acaf-0386-649f073602b6@intel.com> Date: Mon, 8 May 2017 08:58:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <7677d20e-5d53-1fb7-5dac-425edda70b7b@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/03/2017 12:02 PM, Prakash Sangappa wrote: >>> If we do consider a new madvise()option, will it be acceptable >>> since this will be specifically for hugetlbfs file mappings? >> Ideally, it would be something that is *not* specifically for >> hugetlbfs. MADV_NOAUTOFILL, for instance, could be defined to >> SIGSEGV whenever memory is touched that was not populated with >> MADV_WILLNEED, mlock(), etc... > > If this is a generic advice type, necessary support will have to be > implemented in various filesystems which can support this. Yep. > The proposed behavior for 'noautofill' was to not fill holes in > files(like sparse files). In the page fault path, mm would not know > if the mmapped address on which the fault occurred, is over a hole in > the file or just that the page is not available in the page cache. It depends on how you define the feature. I think you have three choices: 1. "Error" on page fault. Require all access to be pre-faulted. 2. Allow faults, but "Error" if page cache has to be allocated 3. Allow faults and page cache allocations, but error on filesystem backing storage allocation. All of those are useful in some cases. But the implementations probably happen in different places: #1 can be implemented in core mm code #2 can be implemented in the VFS #3 needs filesystem involvement > The underlying filesystem would be called and it determines if it is > a hole and that is where it would fail and not fill the hole, if this > support is added. Normally, filesystem which support sparse > files(holes in file) automatically fill the hole when accessed. Then > there is the issue of file system block size and page size. If the > block sizes are smaller then page size, it could mean the noautofill > would only work if the hole size is equal to or a multiple of, page > size? It depends on how you define the feature whether this is true. > In case of hugetlbfs it is much straight forward. Since this > filesystem is not like a normal filesystems and and the file sizes > are multiple of huge pages. The hole will be a multiple of the huge > page size. For this reason then should the advise be specific to > hugetlbfs? Let me paraphrase: it's simpler to implement it if it's specific to hugetlbfs, thus we should implement it only for hugetlbfs, and keep it specific to hugetlbfs. The bigger question is: do we want to continue adding to the complexity of hugetlbfs and increase its divergence from the core mm?