From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hubbard Subject: Re: [PATCH 0/2] mm: introduce MAP_FIXED_SAFE Date: Wed, 6 Dec 2017 00:06:52 -0800 Message-ID: <27ee1755-76d8-f086-5760-9c973b31108a@nvidia.com> References: <20171129144219.22867-1-mhocko@kernel.org> <20171130065835.dbw4ajh5q5whikhf@dhcp22.suse.cz> <20171201152640.GA3765@rei> <87wp20e9wf.fsf@concordia.ellerman.id.au> <20171206045433.GQ26021@bombadil.infradead.org> <20171206070355.GA32044@bombadil.infradead.org> <5f4fc834-274a-b8f1-bda0-5bcddc5902ed@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Language: en-US Sender: owner-linux-mm@kvack.org To: Florian Weimer , Matthew Wilcox , Michael Ellerman Cc: Cyril Hrubis , Michal Hocko , Kees Cook , Linux API , Khalid Aziz , Andrew Morton , Russell King - ARM Linux , Andrea Arcangeli , Linux-MM , LKML , linux-arch , Abdul Haleem , Joel Stanley List-Id: linux-api@vger.kernel.org On 12/05/2017 11:35 PM, Florian Weimer wrote: > On 12/06/2017 08:33 AM, John Hubbard wrote: >> In that case, maybe: >> >> =C2=A0=C2=A0=C2=A0=C2=A0 MAP_EXACT >> >> ? ...because that's the characteristic behavior. >=20 > Is that true?=C2=A0 mmap still silently rounding up the length to the pag= e size, I assume, so even that name is misleading. Hi Florian, Not as far as I can tell, it's not doing that. For both MAP_FIXED, and this new flag, the documented (and actual) behavior is *not* to do any such rounding. Instead, the requested input address is required to be page-aligned itself, and mmap() should be honoring the exact addr. >>From the mmap(2) man page: MAP_FIXED Don't interpret addr as a hint: place the mapping at exactly that address. addr must be a multiple of the page size.=20 And from what I can see, the do_mmap() implementation leaves addr unchanged, in the MAP_FIXED case: do_mmap(...) { /* ... */ if (!(flags & MAP_FIXED)) addr =3D round_hint_to_min(addr); ...although it does look like device drivers have the opportunity to break that: mmap_region(...) { /* Can addr have changed?? * * Answer: Yes, several device drivers can do it in their * f_op->mmap method. -DaveM * Bug: If addr is changed, prev, rb_link, rb_parent should * be updated for vma_link() */ WARN_ON_ONCE(addr !=3D vma->vm_start); addr =3D vma->vm_start; =20 -- thanks, John Hubbard NVIDIA >=20 > Thanks, > Florian -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org