All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Russell King - ARM Linux <linux@armlinux.org.uk>,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	robin@protonic.nl, stefanr@s5r6.in-berlin.de, hjc@rock-chips.com,
	Heiko Stuebner <heiko@sntech.de>,
	airlied@linux.ie, robin.murphy@arm.com, iamjoonsoo.kim@lge.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Kees Cook <keescook@chromium.org>,
	treding@nvidia.com, Michal Hocko <mhocko@suse.com>,
	Dan Williams <dan.j.williams@intel.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	aryabinin@virtuozzo.com, Dmitry Vyukov <dvyukov@google.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	tchibo@google.com, riel@redhat.com,
	Minchan Kim <minchan@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"Huang, Ying" <ying.huang@intel.com>,
	ak@linux.intel.com, rppt@linux.vnet.ibm.com,
	linux@dominikbrodowski.net, Arnd Bergmann <arnd@arndb.de>,
	cpandya@codeaurora.org, hannes@cmpxchg.org,
	Joe Perches <joe@perches.com>,
	mcgrof@kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	linux1394-devel@lists.sourceforge.net,
	dri-devel@lists.freedesktop.org,
	linux-rockchip@lists.infradead.org, Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH v2] mm: Introduce new function vm_insert_kmem_page
Date: Thu, 4 Oct 2018 11:17:36 -0700	[thread overview]
Message-ID: <20181004181736.GB20842@bombadil.infradead.org> (raw)
In-Reply-To: <CAFqt6zZPOM17QwmcWKF3F1gqkJm=2PxvuJ3naWuRXZGHc2HrEQ@mail.gmail.com>

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@armlinux.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.

WARNING: multiple messages have this Message-ID (diff)
From: Matthew Wilcox <willy@infradead.org>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Michal Hocko <mhocko@suse.com>, Heiko Stuebner <heiko@sntech.de>,
	airlied@linux.ie, linux@dominikbrodowski.net,
	linux-kernel@vger.kernel.org, Linux-MM <linux-mm@kvack.org>,
	cpandya@codeaurora.org, linux1394-devel@lists.sourceforge.net,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	ak@linux.intel.com, Minchan Kim <minchan@kernel.org>,
	linux-rockchip@lists.infradead.org,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-arm-kernel@lists.infradead.org, "Huang,
	Ying" <ying.huang@intel.com>,
	tchibo@google.com, aryabinin@virtuozzo.com, treding@nvidia.com,
	riel@redhat.com, Kees Cook <keescook@chromium.org>,
	Arnd Bergmann <arnd@arndb.de>,
	rppt@linux.vnet.ibm.com, dri-devel@lists.freedesktop.org,
	Dan Williams <dan.j.williams@intel.com>, Andrew Morton <akp>
Subject: Re: [PATCH v2] mm: Introduce new function vm_insert_kmem_page
Date: Thu, 4 Oct 2018 11:17:36 -0700	[thread overview]
Message-ID: <20181004181736.GB20842@bombadil.infradead.org> (raw)
In-Reply-To: <CAFqt6zZPOM17QwmcWKF3F1gqkJm=2PxvuJ3naWuRXZGHc2HrEQ@mail.gmail.com>

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@armlinux.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.

WARNING: multiple messages have this Message-ID (diff)
From: willy@infradead.org (Matthew Wilcox)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] mm: Introduce new function vm_insert_kmem_page
Date: Thu, 4 Oct 2018 11:17:36 -0700	[thread overview]
Message-ID: <20181004181736.GB20842@bombadil.infradead.org> (raw)
In-Reply-To: <CAFqt6zZPOM17QwmcWKF3F1gqkJm=2PxvuJ3naWuRXZGHc2HrEQ@mail.gmail.com>

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@armlinux.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.

  reply	other threads:[~2018-10-04 18:18 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03 18:58 [PATCH v2] mm: Introduce new function vm_insert_kmem_page Souptick Joarder
2018-10-03 18:58 ` Souptick Joarder
2018-10-03 19:58 ` Miguel Ojeda
2018-10-03 19:58   ` Miguel Ojeda
2018-10-03 19:58   ` Miguel Ojeda
2018-10-04 11:56   ` Souptick Joarder
2018-10-04 11:56     ` Souptick Joarder
2018-10-04 11:56     ` Souptick Joarder
2018-10-03 20:00 ` Matthew Wilcox
2018-10-03 20:00   ` Matthew Wilcox
2018-10-03 20:00   ` Matthew Wilcox
2018-10-03 22:14   ` Russell King - ARM Linux
2018-10-03 22:14     ` Russell King - ARM Linux
2018-10-03 22:14     ` Russell King - ARM Linux
2018-10-04  0:39     ` Matthew Wilcox
2018-10-04  0:39       ` Matthew Wilcox
2018-10-04  0:39       ` Matthew Wilcox
2018-10-04 12:15     ` Souptick Joarder
2018-10-04 12:15       ` Souptick Joarder
2018-10-04 12:15       ` Souptick Joarder
2018-10-04 12:34       ` Russell King - ARM Linux
2018-10-04 12:34         ` Russell King - ARM Linux
2018-10-04 12:34         ` Russell King - ARM Linux
2018-10-04 12:34         ` Russell King - ARM Linux
2018-10-04 12:34         ` Russell King - ARM Linux
2018-10-04 18:12         ` Souptick Joarder
2018-10-04 18:12           ` Souptick Joarder
2018-10-04 18:12           ` Souptick Joarder
2018-10-04 18:17           ` Matthew Wilcox [this message]
2018-10-04 18:17             ` Matthew Wilcox
2018-10-04 18:17             ` Matthew Wilcox
2018-10-04 18:53             ` Souptick Joarder
2018-10-04 18:53               ` Souptick Joarder
2018-10-04 18:53               ` Souptick Joarder
2018-10-04 19:46               ` Miguel Ojeda
2018-10-04 19:46                 ` Miguel Ojeda
2018-10-04 19:46                 ` Miguel Ojeda
2018-10-05  5:50                 ` Souptick Joarder
2018-10-05  5:50                   ` Souptick Joarder
2018-10-05  5:50                   ` Souptick Joarder
2018-10-05  8:52                   ` Miguel Ojeda
2018-10-05  8:52                     ` Miguel Ojeda
2018-10-05  8:52                     ` Miguel Ojeda
2018-10-05 10:01                     ` Souptick Joarder
2018-10-05 10:01                       ` Souptick Joarder
2018-10-05 10:01                       ` Souptick Joarder
2018-10-05 10:49                       ` Miguel Ojeda
2018-10-05 10:49                         ` Miguel Ojeda
2018-10-05 10:49                         ` Miguel Ojeda
2018-10-05 12:11                         ` Souptick Joarder
2018-10-05 12:11                           ` Souptick Joarder
2018-10-05 12:11                           ` Souptick Joarder
2018-10-05 18:09                           ` Miguel Ojeda
2018-10-05 18:09                             ` Miguel Ojeda
2018-10-05 18:09                             ` Miguel Ojeda
2018-10-06  5:14                             ` Souptick Joarder
2018-10-06  5:14                               ` Souptick Joarder
2018-10-06  5:14                               ` Souptick Joarder
2018-10-06 10:49                               ` Miguel Ojeda
2018-10-06 10:49                                 ` Miguel Ojeda
2018-10-06 10:49                                 ` Miguel Ojeda
2018-10-23 12:14                                 ` Souptick Joarder
2018-10-23 12:14                                   ` Souptick Joarder
2018-10-23 12:14                                   ` Souptick Joarder
2018-10-23 12:24                                   ` Matthew Wilcox
2018-10-23 12:24                                     ` Matthew Wilcox
2018-10-23 12:24                                     ` Matthew Wilcox
2018-10-23 12:33                                     ` Souptick Joarder
2018-10-23 12:33                                       ` Souptick Joarder
2018-10-23 12:33                                       ` Souptick Joarder
2018-10-23 12:59                                       ` Matthew Wilcox
2018-10-23 12:59                                         ` Matthew Wilcox
2018-10-23 12:59                                         ` Matthew Wilcox
2018-10-23 13:15                                         ` Souptick Joarder
2018-10-23 13:15                                           ` Souptick Joarder
2018-10-23 13:15                                           ` Souptick Joarder
2018-10-04 18:21   ` Souptick Joarder
2018-10-04 18:21     ` Souptick Joarder
2018-10-04 18:21     ` Souptick Joarder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181004181736.GB20842@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=airlied@linux.ie \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=aryabinin@virtuozzo.com \
    --cc=cpandya@codeaurora.org \
    --cc=dan.j.williams@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=joe@perches.com \
    --cc=jrdr.linux@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=linux@armlinux.org.uk \
    --cc=linux@dominikbrodowski.net \
    --cc=m.szyprowski@samsung.com \
    --cc=mark.rutland@arm.com \
    --cc=mcgrof@kernel.org \
    --cc=mhocko@suse.com \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=minchan@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=robin@protonic.nl \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=tchibo@google.com \
    --cc=treding@nvidia.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.