From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbdJ0RGR (ORCPT ); Fri, 27 Oct 2017 13:06:17 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:38656 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbdJ0RGQ (ORCPT ); Fri, 27 Oct 2017 13:06:16 -0400 Subject: Re: PROBLEM: Remapping hugepages mappings causes kernel to return EINVAL To: Vlastimil Babka , "C.Wehrmeyer" , Michal Hocko Cc: linux-mm@kvack.org, linux-kernel , Andrea Arcangeli , "Kirill A. Shutemov" References: <6b639da5-ad9a-158c-ad4a-7a4e44bd98fc@gmx.de> <5fb8955d-23af-ec85-a19f-3a5b26cc04d1@oracle.com> <20171023114210.j7ip75ewoy2tiqs4@dhcp22.suse.cz> <20171023124122.tjmrbcwo2btzk3li@dhcp22.suse.cz> <20171023161316.ajrxgd2jzo3u52eu@dhcp22.suse.cz> <93ffc1c8-3401-2bea-732a-17d373d2f24c@gmx.de> <20171023165717.qx5qluryshz62zv5@dhcp22.suse.cz> <20171023180232.luayzqacnkepnm57@dhcp22.suse.cz> <0c934e18-5436-792f-2b2c-ebca3ae2d786@gmx.de> From: Mike Kravetz Message-ID: <2dad26cf-f37c-aada-053a-957c59c9858d@oracle.com> Date: Fri, 27 Oct 2017 10:06:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/27/2017 07:29 AM, Vlastimil Babka wrote: > On 10/24/2017 09:41 AM, C.Wehrmeyer wrote: >> On 2017-10-23 20:02, Michal Hocko wrote: >>> On Mon 23-10-17 19:52:27, C.Wehrmeyer wrote: >>> [...] >> >> 1. Provide a flag to mmap, which might be something different from >> MAP_HUGETLB. After all your question revolved merely around properly >> aligned pages - we don't want to *force* the kernel to reserve >> hugepages, we just want it to provide the proper alignment in this case. >> That wouldn't be very transparent, but it would be the easiest route to >> go (and mmap already kind-of supports such a thing). > > Maybe just have mmap() detect that the requested size is a multiple of > huge page size, and then align it automatically? I.e. a heuristic that > should work in 99% of the cases? We already do this for DAX (see thp_get_unmapped_area). So, not much code to write. But could potentially fragment address spaces more. We could also check to determine if the system/process/mapping is even THP enabled before doing the alignment. I like the idea, but still am concerned about fragmentation. In addition, even though applications shouldn't care where new mappings are placed it would not surprise me that such a change will be noticeable to some. -- Mike Kravetz