Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754715AbdLGOC1 (ORCPT ); Thu, 7 Dec 2017 09:02:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:38573 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754346AbdLGOCZ (ORCPT ); Thu, 7 Dec 2017 09:02:25 -0500 Date: Thu, 7 Dec 2017 15:02:21 +0100 From: Michal Hocko To: Cyril Hrubis Cc: John Hubbard , Michael Kerrisk , linux-man , linux-api@vger.kernel.org, Michael Ellerman , linux-mm@kvack.org, LKML , linux-arch@vger.kernel.org, Jann Horn , Matthew Wilcox Subject: Re: [PATCH v2] mmap.2: MAP_FIXED updated documentation Message-ID: <20171207140221.GJ20234@dhcp22.suse.cz> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171207125805.GA1210@rei.lan> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1604 Lines: 35 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. -- Michal Hocko SUSE Labs