From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerome Glisse Subject: Re: [RFC PATCH RESEND 2/3] mm: Add an apply_to_pfn_range interface Date: Thu, 21 Mar 2019 16:24:46 -0400 Message-ID: <20190321202445.GA15074@redhat.com> References: <20190321132140.114878-1-thellstrom@vmware.com> <20190321132140.114878-3-thellstrom@vmware.com> <20190321135202.GC2904@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Thomas Hellstrom Cc: "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "willy@infradead.org" , "linux-mm@kvack.org" , "jrdr.linux@gmail.com" , "akpm@linux-foundation.org" , "minchan@kernel.org" , "dri-devel@lists.freedesktop.org" , "will.deacon@arm.com" , Linux-graphics-maintainer , "mhocko@suse.com" , "ying.huang@intel.com" , "riel@surriel.com" List-Id: dri-devel@lists.freedesktop.org On Thu, Mar 21, 2019 at 07:59:35PM +0000, Thomas Hellstrom wrote: > On Thu, 2019-03-21 at 09:52 -0400, Jerome Glisse wrote: > > On Thu, Mar 21, 2019 at 01:22:35PM +0000, Thomas Hellstrom wrote: > > > This is basically apply_to_page_range with added functionality: > > > Allocating missing parts of the page table becomes optional, which > > > means that the function can be guaranteed not to error if > > > allocation > > > is disabled. Also passing of the closure struct and callback > > > function > > > becomes different and more in line with how things are done > > > elsewhere. > > > > > > Finally we keep apply_to_page_range as a wrapper around > > > apply_to_pfn_range > > > > The apply_to_page_range() is dangerous API it does not follow other > > mm patterns like mmu notifier. It is suppose to be use in arch code > > or vmalloc or similar thing but not in regular driver code. I see > > it has crept out of this and is being use by few device driver. I am > > not sure we should encourage that. > > I can certainly remove the EXPORT of the new apply_to_pfn_range() which > will make sure its use stays within the mm code. I don't expect any > additional usage except for the two address-space utilities. > > I'm looking for examples to see how it could be more in line with the > rest of the mm code. The main difference from the pattern in, for > example, page_mkclean() seems to be that it's lacking the > mmu_notifier_invalidate_start() and mmu_notifier_invalidate_end()? > Perhaps the intention is to have the pte leaf functions notify on pte > updates? How does this relate to arch_enter_lazy_mmu() which is called > outside of the page table locks? The documentation appears a bit > scarce... Best is to use something like walk_page_range() and have proper mmu notifier in the callback. The apply_to_page_range() is broken for huge page (THP) and other things like that. Thought you should not have THP within mmap of a device file (at least i do not thing any driver does that). Cheers, Jérôme