[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181004181736.GB20842@bombadil.infradead.org>
Date: Thu, 4 Oct 2018 11:17:36 -0700
From: Matthew Wilcox <willy@...radead.org>
To: Souptick Joarder <jrdr.linux@...il.com>
Cc: Russell King - ARM Linux <linux@...linux.org.uk>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
robin@...tonic.nl, stefanr@...6.in-berlin.de, hjc@...k-chips.com,
Heiko Stuebner <heiko@...ech.de>, airlied@...ux.ie,
robin.murphy@....com, iamjoonsoo.kim@....com,
Andrew Morton <akpm@...ux-foundation.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Kees Cook <keescook@...omium.org>, treding@...dia.com,
Michal Hocko <mhocko@...e.com>,
Dan Williams <dan.j.williams@...el.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Mark Rutland <mark.rutland@....com>, aryabinin@...tuozzo.com,
Dmitry Vyukov <dvyukov@...gle.com>,
Kate Stewart <kstewart@...uxfoundation.org>, tchibo@...gle.com,
riel@...hat.com, Minchan Kim <minchan@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
"Huang, Ying" <ying.huang@...el.com>, ak@...ux.intel.com,
rppt@...ux.vnet.ibm.com, linux@...inikbrodowski.net,
Arnd Bergmann <arnd@...db.de>, cpandya@...eaurora.org,
hannes@...xchg.org, Joe Perches <joe@...ches.com>,
mcgrof@...nel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux1394-devel@...ts.sourceforge.net,
dri-devel@...ts.freedesktop.org,
linux-rockchip@...ts.infradead.org, Linux-MM <linux-mm@...ck.org>
Subject: Re: [PATCH v2] mm: Introduce new function vm_insert_kmem_page
On Thu, Oct 04, 2018 at 11:42:18PM +0530, Souptick Joarder wrote:
> On Thu, Oct 4, 2018 at 6:04 PM Russell King - ARM Linux
> <linux@...linux.org.uk> wrote:
> > I'm confused, what are you trying to do?
> >
> > It seems that we already have:
> >
> > vm_insert_page() - returns an errno
> > vmf_insert_page() - returns a VM_FAULT_* code
> >
> > From what I _think_ you're saying, you're trying to provide
> > vm_insert_kmem_page() as a direct replacement for the existing
> > vm_insert_page(), and then make vm_insert_page() behave as per
> > vmf_insert_page(), so we end up with:
>
> yes, vm_insert_kmem_page() can be a direct replacement of vm_insert_page
> or might be a wrapper function written using vm_insert_page whichever
> suites better
> based on feedback.
>
> >
> > vm_insert_kmem_page() - returns an errno
> > vm_insert_page() - returns a VM_FAULT_* code
> > vmf_insert_page() - returns a VM_FAULT_* code and is identical to
> > vm_insert_page()
> >
>
> After completion of conversion we end up with
>
> vm_insert_kmem_page() - returns an errno
> vmf_insert_page() - returns a VM_FAULT_* code
>
>
> > Given that the documentation for vm_insert_page() says:
> >
> > * Usually this function is called from f_op->mmap() handler
> > * under mm->mmap_sem write-lock, so it can change vma->vm_flags.
> > * Caller must set VM_MIXEDMAP on vma if it wants to call this
> > * function from other places, for example from page-fault handler.
> >
> > this says that the "usual" use method for vm_insert_page() is
> > _outside_ of page fault handling - if it is used _inside_ page fault
> > handling, then it states that additional fixups are required on the
> > VMA. So I don't get why your patch commentry seems to be saying that
> > users of vm_insert_page() outside of page fault handling all need to
> > be patched - isn't this the use case that this function is defined
> > to be handling?
>
> The answer is yes best of my knowledge.
>
> But as mentioned in change log ->
>
> Going forward, the plan is to restrict future drivers not
> to use vm_insert_page ( *it will generate new errno to
> VM_FAULT_CODE mapping code for new drivers which were already
> cleaned up for existing drivers*) in #PF (page fault handler)
> context but to make use of vmf_insert_page which returns
> VMF_FAULT_CODE and that is not possible until both vm_insert_page
> and vmf_insert_page API exists.
>
> But there are some consumers of vm_insert_page which use it
> outside #PF context. straight forward conversion of vm_insert_page
> to vmf_insert_page won't work there as those function calls expects
> errno not vm_fault_t in return.
>
> If both {vm, vmf}_insert_page exists, vm_insert_page might be used for
> #PF context which we want to protect by removing/ replacing vm_insert_page
> with another similar/ wrapper API.
>
> Is that the right answer of your question ? no ?
I think this is a bad plan. What we should rather do is examine the current
users of vm_insert_page() and ask "What interface would better replace
vm_insert_page()?"
As I've said to you before, I believe the right answer is to have a
vm_insert_range() which takes an array of struct page pointers. That
fits the majority of remaining users.
----
If we do want to rename vm_insert_page() to vm_insert_kmem_page(), then
the right answer is to _just do that_. Not duplicate vm_insert_page()
in its entirety. I don't see the point to doing that.
Powered by blists - more mailing lists