Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371AbdLJHof (ORCPT ); Sun, 10 Dec 2017 02:44:35 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:19944 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbdLJHoa (ORCPT ); Sun, 10 Dec 2017 02:44:30 -0500 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sat, 09 Dec 2017 23:44:30 -0800 Subject: Re: [PATCH v2] mmap.2: MAP_FIXED updated documentation To: Pavel Machek , Michal Hocko CC: Cyril Hrubis , Michael Kerrisk , linux-man , , Michael Ellerman , , LKML , , Jann Horn , Matthew Wilcox References: <20171204021411.4786-1-jhubbard@nvidia.com> <20171204105549.GA31332@rei> <20171205070510.aojohhvixijk3i27@dhcp22.suse.cz> <2cff594a-b481-269d-dd91-ff2cc2f4100a@nvidia.com> <20171206100118.GA13979@rei> <20171207125805.GA1210@rei.lan> <20171207140221.GJ20234@dhcp22.suse.cz> <20171209171958.GB19862@localhost> X-Nvconfidentiality: public From: John Hubbard Message-ID: <8b9de658-81f4-f09b-cc7d-cef8ea0bd1ff@nvidia.com> Date: Sat, 9 Dec 2017 23:44:29 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171209171958.GB19862@localhost> X-Originating-IP: [10.2.173.131] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2683 Lines: 67 On 12/09/2017 09:19 AM, Pavel Machek wrote: > On Thu 2017-12-07 15:02:21, Michal Hocko wrote: >> On Thu 07-12-17 13:58:05, Cyril Hrubis wrote: >>> Hi! >>>>>> (It does seem unfortunate that the man page cannot help the programmer >>>>>> actually write correct code here. He or she is forced to read the kernel >>>>>> implementation, in order to figure out the true alignment rules. I was >>>>>> hoping we could avoid that.) >>>>> >>>>> It would be nice if we had this information exported somehere so that we >>>>> do not have to rely on per-architecture ifdefs. >>>>> >>>>> What about adding MapAligment or something similar to the /proc/meminfo? >>>>> >>>> >>>> What's the use case you envision for that? I don't see how that would be >>>> better than using SHMLBA, which is available at compiler time. Because >>>> unless someone expects to be able to run an app that was compiled for >>>> Arch X, on Arch Y (surely that's not requirement here?), I don't see how >>>> the run-time check is any better. >>> >>> I guess that some kind of compile time constant in uapi headers will do >>> as well, I'm really open to any solution that would expose this constant >>> as some kind of official API. >> >> I am not sure this is really feasible. It is not only a simple alignment >> thing. Look at ppc for example (slice_get_unmapped_area). Other >> architectures might have even more complicated rules e.g. arm and its >> cache_is_vipt_aliasing. Also this applies only on MAP_SHARED || file >> backed mappings. >> >> I would really leave dogs sleeping... Trying to document all this in the >> man page has chances to confuse more people than it has chances to help >> those who already know all these nasty details. > > You don't have to provide all the details, but warning that there's arch- > specific magic would be nice... Hi Pavel, In version 4 of this patch (which oddly enough, I have trouble finding via google, it only seems to show up in patchwork.kernel.org [1]), I phrased it like this: Don't interpret addr as a hint: place the mapping at exactly that address. addr must be suitably aligned: for most architectures a multiple of page size is sufficient; however, some architectures may impose additional restrictions. ...which is basically what Cyril was asking for, in his early feedback. Does that work for you? (Maybe I need to repost that patch. In any case the CC's need updating, at least.) [1] https://patchwork.kernel.org/patch/10094905/ thanks, -- John Hubbard NVIDIA > Pavel > > (english) http://www.livejournal.com/~pavelmachek > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html >