From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751654AbdJXIeF (ORCPT ); Tue, 24 Oct 2017 04:34:05 -0400 Received: from mout.gmx.net ([212.227.17.22]:63188 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751323AbdJXId6 (ORCPT ); Tue, 24 Oct 2017 04:33:58 -0400 Subject: Re: PROBLEM: Remapping hugepages mappings causes kernel to return EINVAL To: Michal Hocko Cc: Mike Kravetz , linux-mm@kvack.org, linux-kernel , Andrea Arcangeli , "Kirill A. Shutemov" , Vlastimil Babka References: <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> <20171024081232.6to62flr7h3qgxvv@dhcp22.suse.cz> From: "C.Wehrmeyer" Message-ID: Date: Tue, 24 Oct 2017 10:32:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20171024081232.6to62flr7h3qgxvv@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:3mt3PdMZcWoGiNWKxfCiqQL8L0MeKRfsjxoOVW+D35BlGYo/ppj 3U9nqOmJZFD6xawri9o1UcVaYdmNcTswdmprp1+aNQmjzj/FotU7lUY2m3AkM7mUlXR20cx wxlfgMKPatVPu4qUSQR/oGIX/Rn84Dvpgl5ouYb/z3tPnZKRj5Mcd0BkcBmgxOEyuhDvhBf Xuzh0HZ+RM0AfI9oXy6dw== X-UI-Out-Filterresults: notjunk:1;V01:K0:MCFZVMgP0OM=:HuPst+vy5IOzH3TY/HlugH 9QZmqxKS8dlsIwZkr5Wmm2uk5Vp9b+Qzr37sAqChzuaHERddbUmpO10rPC+RId3p0uV2AjBya F4m37a0YbYNX6fgrQIse6CAIX4N/SWiKDmaumuRwXUyYMFjRZSMA+nj+k+ANPLt4IgYckbixD WWuu+ERyMlwwBq5lk6yvH+91lUxtmQaE+S/i9gWt8duAvIaVONoK1gU5g25691d+U1aGWiwt5 OB0RN4mebkINBC680Jm4a1IE5q9xF/MWVKl8IAMENwSiJIdHuWQQpWSU4o82ESJR3GEhXkH3A l3RKGxzszyrajzf+H0Z0P58j+02b+ikzhK2byxh5+0M4rWxI25Kk+BSmQKXJMyu+iBB/+oDem 5zkrJ40Rh+Id+Jk9f+J3kTz9cpOIzxVFFrsIRS+RWCUkzDMFVhxc6gqOU+rbchPcQb9DhrBnF Pn6hMu8yvPrGoyA19xWatB0pc0PytA1j4Q1bL8iErWvVCwy+HkHE5BwiXar3wO/QfwijJ3XPb ucdGnWCCM98hRpavsnYmxD4XRk/V/Nrl1w9n8pp8v424LgGsCvOdiGn4QFH8M1PkO8gNETaYx 7du6R0o6LJfe7JKqAg3Tt9O9KhwtG3NLfPhN5KLTs2RA0ctoq/uekQU1cNq17AWY6geTFCw4S nnJTNnkKFXIyxti5bvphW5kNw+pIu8yrc/vD/WbWjodYTs9ITV2jB1VOBBvGSrtG7n6A5H1lj 8gJu2KLKp6SQyc77Jc5et9pAb1zw1Bz3XpKMqpr9hcjbbXz2/mULSMRecmgDtEUbzCJFeS9wd sd/+2P+ya1N9+tC1SAob+WjxQXyJ43cQBPgtRHvhOH8pSURmm4= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017-10-24 10:12, Michal Hocko wrote: > On Tue 24-10-17 09:41:46, C.Wehrmeyer wrote: > [...] >> 1. Provide mmap with some sort of flag (which would be redundant IMHO) in >> order to churn out properly aligned pages (not transparent, but the current >> MAP_HUGETLB flag isn't either). > > You can easily implement such a thing in userspace. In fact glibc has > already done that for you. That's not the point. The point is that it's not *transparent*. Let me paraphrase your statements: "Yes, you can have hugepages by just allocating things normally. THPs will then be used - maybe. Even though you might know best how much memory you actually require it requires you to fiddle with the mappings in order to get complete hugepages coverage, because mmap does not provide a mechanism for that. Or you can just live with your mappings only being half-hugepaged. How is that not transparent?" Unfortunately the ratio (512) is big enough that I'm not completely OK with that. And in the distant future, when we all use 1-GiB pages, that ratio becomes even bigger. > [...] > I think there is still some confusion here. Kernel will try to fault in > THP pages on properly aligned addresses. So if you create a larger > mapping than the THP size then you will get a THP (assuming the memory > is not fragmented). It is just the unaligned addresses will get regular > pages. OK, I wasn't sure about that one as well - which is why I didn't dare to lay hands on the kernel. It DOES support variable-sized-pages. That does not change the fact, however, that when THPs are enabled mmap should give userspace properly aligned pages exactly to avoid those smaller pages.