* [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-07-03 12:39 [PATCH 1/3] mm: Introduce vmf_insert_pfn_prot Matthew Wilcox
@ 2018-07-03 12:39 ` Matthew Wilcox
2018-07-16 9:17 ` Thomas Gleixner
2018-07-03 12:39 ` [PATCH 3/3] mm: Make vm_insert_pfn_prot static Matthew Wilcox
2018-07-26 11:34 ` [PATCH 1/3] mm: Introduce vmf_insert_pfn_prot Souptick Joarder
2 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2018-07-03 12:39 UTC (permalink / raw)
To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
Cc: Matthew Wilcox, Souptick Joarder, x86, linux-kernel,
brajeswar.linux, Sabyasachi Gupta
Return vm_fault_t codes directly from the appropriate mm routines instead
of converting from errnos ourselves. Fixes a minor bug where we'd return
SIGBUS instead of the correct OOM code if we ran out of memory allocating
page tables.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
---
arch/x86/entry/vdso/vma.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 5b8b556dbb12..d1daa53215a4 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -39,7 +39,7 @@ void __init init_vdso_image(const struct vdso_image *image)
struct linux_binprm;
-static int vdso_fault(const struct vm_special_mapping *sm,
+static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf)
{
const struct vdso_image *image = vma->vm_mm->context.vdso_image;
@@ -84,12 +84,11 @@ static int vdso_mremap(const struct vm_special_mapping *sm,
return 0;
}
-static int vvar_fault(const struct vm_special_mapping *sm,
+static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf)
{
const struct vdso_image *image = vma->vm_mm->context.vdso_image;
long sym_offset;
- int ret = -EFAULT;
if (!image)
return VM_FAULT_SIGBUS;
@@ -108,29 +107,24 @@ static int vvar_fault(const struct vm_special_mapping *sm,
return VM_FAULT_SIGBUS;
if (sym_offset == image->sym_vvar_page) {
- ret = vm_insert_pfn(vma, vmf->address,
- __pa_symbol(&__vvar_page) >> PAGE_SHIFT);
+ return vmf_insert_pfn(vma, vmf->address,
+ __pa_symbol(&__vvar_page) >> PAGE_SHIFT);
} else if (sym_offset == image->sym_pvclock_page) {
struct pvclock_vsyscall_time_info *pvti =
pvclock_get_pvti_cpu0_va();
if (pvti && vclock_was_used(VCLOCK_PVCLOCK)) {
- ret = vm_insert_pfn_prot(
- vma,
- vmf->address,
- __pa(pvti) >> PAGE_SHIFT,
- pgprot_decrypted(vma->vm_page_prot));
+ return vmf_insert_pfn_prot(vma, vmf->address,
+ __pa(pvti) >> PAGE_SHIFT,
+ pgprot_decrypted(vma->vm_page_prot));
}
} else if (sym_offset == image->sym_hvclock_page) {
struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page();
if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK))
- ret = vm_insert_pfn(vma, vmf->address,
- vmalloc_to_pfn(tsc_pg));
+ return vmf_insert_pfn(vma, vmf->address,
+ vmalloc_to_pfn(tsc_pg));
}
- if (ret == 0 || ret == -EBUSY)
- return VM_FAULT_NOPAGE;
-
return VM_FAULT_SIGBUS;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-07-03 12:39 ` [PATCH 2/3] x86: Convert vdso to use vm_fault_t Matthew Wilcox
@ 2018-07-16 9:17 ` Thomas Gleixner
2018-08-03 12:34 ` Souptick Joarder
0 siblings, 1 reply; 11+ messages in thread
From: Thomas Gleixner @ 2018-07-16 9:17 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Andy Lutomirski, Ingo Molnar, H. Peter Anvin, Souptick Joarder,
x86, linux-kernel, brajeswar.linux, Sabyasachi Gupta
On Tue, 3 Jul 2018, Matthew Wilcox wrote:
> Return vm_fault_t codes directly from the appropriate mm routines instead
> of converting from errnos ourselves. Fixes a minor bug where we'd return
> SIGBUS instead of the correct OOM code if we ran out of memory allocating
> page tables.
>
> Signed-off-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-07-16 9:17 ` Thomas Gleixner
@ 2018-08-03 12:34 ` Souptick Joarder
2018-08-03 13:14 ` Thomas Gleixner
0 siblings, 1 reply; 11+ messages in thread
From: Souptick Joarder @ 2018-08-03 12:34 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Matthew Wilcox, Andy Lutomirski, Ingo Molnar, H. Peter Anvin,
X86 ML, linux-kernel, Brajeswar Ghosh, Sabyasachi Gupta
On Mon, Jul 16, 2018 at 2:47 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Tue, 3 Jul 2018, Matthew Wilcox wrote:
>
>> Return vm_fault_t codes directly from the appropriate mm routines instead
>> of converting from errnos ourselves. Fixes a minor bug where we'd return
>> SIGBUS instead of the correct OOM code if we ran out of memory allocating
>> page tables.
>>
>> Signed-off-by: Matthew Wilcox <willy@infradead.org>
>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
>
Thomas, are these 3 patches part of this series will be queued
for 4.19 ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-08-03 12:34 ` Souptick Joarder
@ 2018-08-03 13:14 ` Thomas Gleixner
2018-08-27 15:31 ` Souptick Joarder
0 siblings, 1 reply; 11+ messages in thread
From: Thomas Gleixner @ 2018-08-03 13:14 UTC (permalink / raw)
To: Souptick Joarder
Cc: Matthew Wilcox, Andy Lutomirski, Ingo Molnar, H. Peter Anvin,
X86 ML, LKML, Brajeswar Ghosh, Sabyasachi Gupta, linux-mm,
Michal Hocko, Andrew Morton
On Fri, 3 Aug 2018, Souptick Joarder wrote:
> On Mon, Jul 16, 2018 at 2:47 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > On Tue, 3 Jul 2018, Matthew Wilcox wrote:
> >
> >> Return vm_fault_t codes directly from the appropriate mm routines instead
> >> of converting from errnos ourselves. Fixes a minor bug where we'd return
> >> SIGBUS instead of the correct OOM code if we ran out of memory allocating
> >> page tables.
> >>
> >> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> >
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> >
>
> Thomas, are these 3 patches part of this series will be queued
> for 4.19 ?
I don't know. I expected that these go through the mm tree, but if nobody
feels responsible, I could pick up the whole lot. But I'd like to see acks
from the mm folks for [1/3] and [3/3]
https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
Thanks,
tglx
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-08-03 13:14 ` Thomas Gleixner
@ 2018-08-27 15:31 ` Souptick Joarder
2018-08-27 18:05 ` Matthew Wilcox
0 siblings, 1 reply; 11+ messages in thread
From: Souptick Joarder @ 2018-08-27 15:31 UTC (permalink / raw)
To: Thomas Gleixner, Michal Hocko, Matthew Wilcox, Andrew Morton
Cc: Andy Lutomirski, Ingo Molnar, H. Peter Anvin, X86 ML,
linux-kernel, Brajeswar Ghosh, Sabyasachi Gupta, Linux-MM
On Fri, Aug 3, 2018 at 6:44 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Fri, 3 Aug 2018, Souptick Joarder wrote:
> > On Mon, Jul 16, 2018 at 2:47 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > > On Tue, 3 Jul 2018, Matthew Wilcox wrote:
> > >
> > >> Return vm_fault_t codes directly from the appropriate mm routines instead
> > >> of converting from errnos ourselves. Fixes a minor bug where we'd return
> > >> SIGBUS instead of the correct OOM code if we ran out of memory allocating
> > >> page tables.
> > >>
> > >> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> > >
> > > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > >
> >
> > Thomas, are these 3 patches part of this series will be queued
> > for 4.19 ?
>
> I don't know. I expected that these go through the mm tree, but if nobody
> feels responsible, I could pick up the whole lot. But I'd like to see acks
> from the mm folks for [1/3] and [3/3]
>
> https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
>
> Thanks,
>
> tglx
>
Any comment from mm reviewers for patch [1/3] and [3/3] ??
https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-08-27 15:31 ` Souptick Joarder
@ 2018-08-27 18:05 ` Matthew Wilcox
2018-08-28 6:18 ` Souptick Joarder
0 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2018-08-27 18:05 UTC (permalink / raw)
To: Souptick Joarder
Cc: Thomas Gleixner, Michal Hocko, Andrew Morton, Andy Lutomirski,
Ingo Molnar, H. Peter Anvin, X86 ML, linux-kernel,
Brajeswar Ghosh, Sabyasachi Gupta, Linux-MM
On Mon, Aug 27, 2018 at 09:01:48PM +0530, Souptick Joarder wrote:
> On Fri, Aug 3, 2018 at 6:44 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> > On Fri, 3 Aug 2018, Souptick Joarder wrote:
> > > On Mon, Jul 16, 2018 at 2:47 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > > > On Tue, 3 Jul 2018, Matthew Wilcox wrote:
> > > >
> > > >> Return vm_fault_t codes directly from the appropriate mm routines instead
> > > >> of converting from errnos ourselves. Fixes a minor bug where we'd return
> > > >> SIGBUS instead of the correct OOM code if we ran out of memory allocating
> > > >> page tables.
> > > >>
> > > >> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> > > >
> > > > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > > >
> > >
> > > Thomas, are these 3 patches part of this series will be queued
> > > for 4.19 ?
> >
> > I don't know. I expected that these go through the mm tree, but if nobody
> > feels responsible, I could pick up the whole lot. But I'd like to see acks
> > from the mm folks for [1/3] and [3/3]
> >
> > https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
> >
> > Thanks,
> >
> > tglx
> >
>
> Any comment from mm reviewers for patch [1/3] and [3/3] ??
>
> https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
I think at this point, it would probably be best to ask Andrew to pick
up all three of these patches.
In addition to these three, I see the following places that need to be changed:
Documentation/gpu/drm-mm.rst:300: int (*fault)(struct vm_fault *vmf);
drivers/gpu/drm/virtio/virtgpu_ttm.c:117:static int virtio_gpu_ttm_fault(struct vm_fault *vmf)
- #if 0 code. convert anyway.
drivers/gpu/drm/vkms/vkms_drv.h:68:int vkms_gem_fault(struct vm_fault *vmf);
drivers/gpu/drm/vkms/vkms_gem.c:46:int vkms_gem_fault(struct vm_fault *vmf)
fs/ext4/ext4.h:2472:extern int ext4_page_mkwrite(struct vm_fault *vmf);
fs/ext4/ext4.h:2473:extern int ext4_filemap_fault(struct vm_fault *vmf);
fs/ext4/inode.c:6154:int ext4_page_mkwrite(struct vm_fault *vmf)
fs/ext4/inode.c:6251:int ext4_filemap_fault(struct vm_fault *vmf)
fs/iomap.c:1059:int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops)
include/linux/iomap.h:144:int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops);
- I saw you just resent this patch.
mm/filemap.c:2751:int filemap_page_mkwrite(struct vm_fault *vmf)
- This is the NOMMU case, so I suspect your testing didn't catch it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] x86: Convert vdso to use vm_fault_t
2018-08-27 18:05 ` Matthew Wilcox
@ 2018-08-28 6:18 ` Souptick Joarder
0 siblings, 0 replies; 11+ messages in thread
From: Souptick Joarder @ 2018-08-28 6:18 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Thomas Gleixner, Michal Hocko, Andrew Morton, Andy Lutomirski,
Ingo Molnar, H. Peter Anvin, X86 ML, linux-kernel,
Brajeswar Ghosh, Sabyasachi Gupta, Linux-MM
On Mon, Aug 27, 2018 at 11:35 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Mon, Aug 27, 2018 at 09:01:48PM +0530, Souptick Joarder wrote:
> > On Fri, Aug 3, 2018 at 6:44 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> > >
> > > On Fri, 3 Aug 2018, Souptick Joarder wrote:
> > > > On Mon, Jul 16, 2018 at 2:47 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > > > > On Tue, 3 Jul 2018, Matthew Wilcox wrote:
> > > > >
> > > > >> Return vm_fault_t codes directly from the appropriate mm routines instead
> > > > >> of converting from errnos ourselves. Fixes a minor bug where we'd return
> > > > >> SIGBUS instead of the correct OOM code if we ran out of memory allocating
> > > > >> page tables.
> > > > >>
> > > > >> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> > > > >
> > > > > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > > > >
> > > >
> > > > Thomas, are these 3 patches part of this series will be queued
> > > > for 4.19 ?
> > >
> > > I don't know. I expected that these go through the mm tree, but if nobody
> > > feels responsible, I could pick up the whole lot. But I'd like to see acks
> > > from the mm folks for [1/3] and [3/3]
> > >
> > > https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
> > >
> > > Thanks,
> > >
> > > tglx
> > >
> >
> > Any comment from mm reviewers for patch [1/3] and [3/3] ??
> >
> > https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
>
> I think at this point, it would probably be best to ask Andrew to pick
> up all three of these patches.
Do we need to repost these three patches or lkml link
https://lkml.kernel.org/r/20180703123910.2180-1-willy@infradead.org
is fine to request Andrew ??
> In addition to these three, I see the following places that need to be changed:
>
> Documentation/gpu/drm-mm.rst:300: int (*fault)(struct vm_fault *vmf);
ok, I will add this.
>
> drivers/gpu/drm/virtio/virtgpu_ttm.c:117:static int virtio_gpu_ttm_fault(struct vm_fault *vmf)
> - #if 0 code. convert anyway.
https://lkml.org/lkml/2018/7/2/795
Gerd Hoffmann, agreed to remove this dead code, but queued for 4.20.
I think, this shouldn't be a blocker for us.
>
> drivers/gpu/drm/vkms/vkms_drv.h:68:int vkms_gem_fault(struct vm_fault *vmf);
> drivers/gpu/drm/vkms/vkms_gem.c:46:int vkms_gem_fault(struct vm_fault *vmf)
This was not queued for 4.19. Would you like to see this patch in 4.19-rc-x ?
https://lkml.org/lkml/2018/7/30/767
>
> fs/ext4/ext4.h:2472:extern int ext4_page_mkwrite(struct vm_fault *vmf);
> fs/ext4/ext4.h:2473:extern int ext4_filemap_fault(struct vm_fault *vmf);
> fs/ext4/inode.c:6154:int ext4_page_mkwrite(struct vm_fault *vmf)
> fs/ext4/inode.c:6251:int ext4_filemap_fault(struct vm_fault *vmf)
I have this patch ready in my local tree based on review comment
from Ted. Ted was planning to take it in next merge window.
I will post it on mailing list.
>
> fs/iomap.c:1059:int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops)
> include/linux/iomap.h:144:int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops);
> - I saw you just resent this patch.
Now added to mm-tree.
> mm/filemap.c:2751:int filemap_page_mkwrite(struct vm_fault *vmf)
> - This is the NOMMU case, so I suspect your testing didn't catch it.
Sorry, I missed it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/3] mm: Make vm_insert_pfn_prot static
2018-07-03 12:39 [PATCH 1/3] mm: Introduce vmf_insert_pfn_prot Matthew Wilcox
2018-07-03 12:39 ` [PATCH 2/3] x86: Convert vdso to use vm_fault_t Matthew Wilcox
@ 2018-07-03 12:39 ` Matthew Wilcox
2018-07-26 11:35 ` Souptick Joarder
2018-07-26 11:34 ` [PATCH 1/3] mm: Introduce vmf_insert_pfn_prot Souptick Joarder
2 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2018-07-03 12:39 UTC (permalink / raw)
To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
Cc: Matthew Wilcox, Souptick Joarder, x86, linux-kernel,
brajeswar.linux, Sabyasachi Gupta
Now this is no longer used outside mm/memory.c, make it static.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
---
include/linux/mm.h | 2 --
mm/memory.c | 50 +++++++++++++++++++++++-----------------------
2 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3cb763a38642..703a9962103e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2439,8 +2439,6 @@ int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *);
int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
unsigned long pfn);
-int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
- unsigned long pfn, pgprot_t pgprot);
vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
unsigned long pfn, pgprot_t pgprot);
int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
diff --git a/mm/memory.c b/mm/memory.c
index caecb4d995ac..73c5682310c7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1828,31 +1828,7 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr,
return retval;
}
-/**
- * vm_insert_pfn - insert single pfn into user vma
- * @vma: user vma to map to
- * @addr: target user address of this page
- * @pfn: source kernel pfn
- *
- * Similar to vm_insert_page, this allows drivers to insert individual pages
- * they've allocated into a user vma. Same comments apply.
- *
- * This function should only be called from a vm_ops->fault handler, and
- * in that case the handler should return NULL.
- *
- * vma cannot be a COW mapping.
- *
- * As this is called only for pages that do not currently exist, we
- * do not need to flush old virtual caches or the TLB.
- */
-int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
- unsigned long pfn)
-{
- return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
-}
-EXPORT_SYMBOL(vm_insert_pfn);
-
-int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
+static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
unsigned long pfn, pgprot_t pgprot)
{
int ret;
@@ -1879,6 +1855,30 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
return ret;
}
+/**
+ * vm_insert_pfn - insert single pfn into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pfn: source kernel pfn
+ *
+ * Similar to vm_insert_page, this allows drivers to insert individual pages
+ * they've allocated into a user vma. Same comments apply.
+ *
+ * This function should only be called from a vm_ops->fault handler, and
+ * in that case the handler should return NULL.
+ *
+ * vma cannot be a COW mapping.
+ *
+ * As this is called only for pages that do not currently exist, we
+ * do not need to flush old virtual caches or the TLB.
+ */
+int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
+ unsigned long pfn)
+{
+ return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
+}
+EXPORT_SYMBOL(vm_insert_pfn);
+
/**
* vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot
* @vma: user vma to map to
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] mm: Make vm_insert_pfn_prot static
2018-07-03 12:39 ` [PATCH 3/3] mm: Make vm_insert_pfn_prot static Matthew Wilcox
@ 2018-07-26 11:35 ` Souptick Joarder
0 siblings, 0 replies; 11+ messages in thread
From: Souptick Joarder @ 2018-07-26 11:35 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
X86 ML, linux-kernel, Brajeswar Ghosh, Sabyasachi Gupta
On Tue, Jul 3, 2018 at 6:09 PM, Matthew Wilcox <willy@infradead.org> wrote:
> Now this is no longer used outside mm/memory.c, make it static.
>
> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> ---
Any comment on this patch ?
> include/linux/mm.h | 2 --
> mm/memory.c | 50 +++++++++++++++++++++++-----------------------
> 2 files changed, 25 insertions(+), 27 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 3cb763a38642..703a9962103e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2439,8 +2439,6 @@ int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
> int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *);
> int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> unsigned long pfn);
> -int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> - unsigned long pfn, pgprot_t pgprot);
> vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> unsigned long pfn, pgprot_t pgprot);
> int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> diff --git a/mm/memory.c b/mm/memory.c
> index caecb4d995ac..73c5682310c7 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1828,31 +1828,7 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> return retval;
> }
>
> -/**
> - * vm_insert_pfn - insert single pfn into user vma
> - * @vma: user vma to map to
> - * @addr: target user address of this page
> - * @pfn: source kernel pfn
> - *
> - * Similar to vm_insert_page, this allows drivers to insert individual pages
> - * they've allocated into a user vma. Same comments apply.
> - *
> - * This function should only be called from a vm_ops->fault handler, and
> - * in that case the handler should return NULL.
> - *
> - * vma cannot be a COW mapping.
> - *
> - * As this is called only for pages that do not currently exist, we
> - * do not need to flush old virtual caches or the TLB.
> - */
> -int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> - unsigned long pfn)
> -{
> - return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
> -}
> -EXPORT_SYMBOL(vm_insert_pfn);
> -
> -int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> +static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> unsigned long pfn, pgprot_t pgprot)
> {
> int ret;
> @@ -1879,6 +1855,30 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> return ret;
> }
>
> +/**
> + * vm_insert_pfn - insert single pfn into user vma
> + * @vma: user vma to map to
> + * @addr: target user address of this page
> + * @pfn: source kernel pfn
> + *
> + * Similar to vm_insert_page, this allows drivers to insert individual pages
> + * they've allocated into a user vma. Same comments apply.
> + *
> + * This function should only be called from a vm_ops->fault handler, and
> + * in that case the handler should return NULL.
> + *
> + * vma cannot be a COW mapping.
> + *
> + * As this is called only for pages that do not currently exist, we
> + * do not need to flush old virtual caches or the TLB.
> + */
> +int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> + unsigned long pfn)
> +{
> + return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
> +}
> +EXPORT_SYMBOL(vm_insert_pfn);
> +
> /**
> * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot
> * @vma: user vma to map to
> --
> 2.18.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] mm: Introduce vmf_insert_pfn_prot
2018-07-03 12:39 [PATCH 1/3] mm: Introduce vmf_insert_pfn_prot Matthew Wilcox
2018-07-03 12:39 ` [PATCH 2/3] x86: Convert vdso to use vm_fault_t Matthew Wilcox
2018-07-03 12:39 ` [PATCH 3/3] mm: Make vm_insert_pfn_prot static Matthew Wilcox
@ 2018-07-26 11:34 ` Souptick Joarder
2 siblings, 0 replies; 11+ messages in thread
From: Souptick Joarder @ 2018-07-26 11:34 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
X86 ML, linux-kernel, Brajeswar Ghosh, Sabyasachi Gupta
On Tue, Jul 3, 2018 at 6:09 PM, Matthew Wilcox <willy@infradead.org> wrote:
> Like vm_insert_pfn_prot(), but returns a vm_fault_t instead of an errno.
> Also unexport vm_insert_pfn_prot as it has no modular users.
>
> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> ---
Any comment on this patch ?
> include/linux/mm.h | 2 ++
> mm/memory.c | 47 ++++++++++++++++++++++++++++++----------------
> 2 files changed, 33 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 1a9d6bd97f00..3cb763a38642 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2441,6 +2441,8 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> unsigned long pfn);
> int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> unsigned long pfn, pgprot_t pgprot);
> +vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> + unsigned long pfn, pgprot_t pgprot);
> int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> pfn_t pfn);
> vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> diff --git a/mm/memory.c b/mm/memory.c
> index b9ebd883e27c..caecb4d995ac 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1852,21 +1852,6 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> }
> EXPORT_SYMBOL(vm_insert_pfn);
>
> -/**
> - * vm_insert_pfn_prot - insert single pfn into user vma with specified pgprot
> - * @vma: user vma to map to
> - * @addr: target user address of this page
> - * @pfn: source kernel pfn
> - * @pgprot: pgprot flags for the inserted page
> - *
> - * This is exactly like vm_insert_pfn, except that it allows drivers to
> - * to override pgprot on a per-page basis.
> - *
> - * This only makes sense for IO mappings, and it makes no sense for
> - * cow mappings. In general, using multiple vmas is preferable;
> - * vm_insert_pfn_prot should only be used if using multiple VMAs is
> - * impractical.
> - */
> int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> unsigned long pfn, pgprot_t pgprot)
> {
> @@ -1893,7 +1878,37 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
>
> return ret;
> }
> -EXPORT_SYMBOL(vm_insert_pfn_prot);
> +
> +/**
> + * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot
> + * @vma: user vma to map to
> + * @addr: target user address of this page
> + * @pfn: source kernel pfn
> + * @pgprot: pgprot flags for the inserted page
> + *
> + * This is exactly like vmf_insert_pfn(), except that it allows drivers to
> + * to override pgprot on a per-page basis.
> + *
> + * This only makes sense for IO mappings, and it makes no sense for
> + * COW mappings. In general, using multiple vmas is preferable;
> + * vm_insert_pfn_prot should only be used if using multiple VMAs is
> + * impractical.
> + *
> + * Return: vm_fault_t value.
> + */
> +vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> + unsigned long pfn, pgprot_t pgprot)
> +{
> + int err = vm_insert_pfn_prot(vma, addr, pfn, pgprot);
> +
> + if (err == -ENOMEM)
> + return VM_FAULT_OOM;
> + if (err < 0 && err != -EBUSY)
> + return VM_FAULT_SIGBUS;
> +
> + return VM_FAULT_NOPAGE;
> +}
> +EXPORT_SYMBOL(vmf_insert_pfn_prot);
>
> static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn)
> {
> --
> 2.18.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread