linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memory.c: Convert to use vmf_error()
@ 2019-09-05 18:43 Souptick Joarder
  2019-09-05 18:59 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Souptick Joarder @ 2019-09-05 18:43 UTC (permalink / raw)
  To: akpm, willy, rcampbell, jglisse, mhocko, aneesh.kumar, peterz,
	airlied, thellstrom
  Cc: linux-mm, linux-kernel, Souptick Joarder

Convert to use vmf_error() here.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 mm/memory.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index e2bb51b..1302be32 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1750,13 +1750,10 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
 	} else {
 		return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
 	}
-
-	if (err == -ENOMEM)
-		return VM_FAULT_OOM;
-	if (err < 0 && err != -EBUSY)
-		return VM_FAULT_SIGBUS;
-
-	return VM_FAULT_NOPAGE;
+	if (!err || err == -EBUSY)
+		return VM_FAULT_NOPAGE;
+	else
+		return vmf_error(err);
 }
 
 vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/memory.c: Convert to use vmf_error()
  2019-09-05 18:43 [PATCH] mm/memory.c: Convert to use vmf_error() Souptick Joarder
@ 2019-09-05 18:59 ` Matthew Wilcox
  2019-09-06 12:24   ` Souptick Joarder
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2019-09-05 18:59 UTC (permalink / raw)
  To: Souptick Joarder
  Cc: akpm, rcampbell, jglisse, mhocko, aneesh.kumar, peterz, airlied,
	thellstrom, linux-mm, linux-kernel

On Fri, Sep 06, 2019 at 12:13:00AM +0530, Souptick Joarder wrote:
> +++ b/mm/memory.c
> @@ -1750,13 +1750,10 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
>  	} else {
>  		return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
>  	}
> -
> -	if (err == -ENOMEM)
> -		return VM_FAULT_OOM;
> -	if (err < 0 && err != -EBUSY)
> -		return VM_FAULT_SIGBUS;
> -
> -	return VM_FAULT_NOPAGE;
> +	if (!err || err == -EBUSY)
> +		return VM_FAULT_NOPAGE;
> +	else
> +		return vmf_error(err);
>  }

My plan is to convert insert_page() to return a VM_FAULT error code like
insert_pfn() does.  Need to finish off the vm_insert_page() conversions
first ;-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/memory.c: Convert to use vmf_error()
  2019-09-05 18:59 ` Matthew Wilcox
@ 2019-09-06 12:24   ` Souptick Joarder
  0 siblings, 0 replies; 3+ messages in thread
From: Souptick Joarder @ 2019-09-06 12:24 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Ralph Campbell, Jérôme Glisse,
	Michal Hocko, Aneesh Kumar K.V, Peter Zijlstra, airlied,
	Thomas Hellstrom, Linux-MM, linux-kernel

On Fri, Sep 6, 2019 at 12:29 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Fri, Sep 06, 2019 at 12:13:00AM +0530, Souptick Joarder wrote:
> > +++ b/mm/memory.c
> > @@ -1750,13 +1750,10 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> >       } else {
> >               return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
> >       }
> > -
> > -     if (err == -ENOMEM)
> > -             return VM_FAULT_OOM;
> > -     if (err < 0 && err != -EBUSY)
> > -             return VM_FAULT_SIGBUS;
> > -
> > -     return VM_FAULT_NOPAGE;
> > +     if (!err || err == -EBUSY)
> > +             return VM_FAULT_NOPAGE;
> > +     else
> > +             return vmf_error(err);
> >  }
>
> My plan is to convert insert_page() to return a VM_FAULT error code like
> insert_pfn() does.  Need to finish off the vm_insert_page() conversions
> first ;-)

Previously we have problem while converting vm_insert_page() to return
vm_fault_t.

vm_insert_page() is called from different drivers. Some of them are
already converted
to use vm_map_pages()/ vm_map_pages_zero(). But still we left with few users.

drivers/media/usb/usbvision/usbvision-video.c#L1045
mm/vmalloc.c#L2969

These 2 can be converted with something like vm_map_vmalloc_pages().
I am working on it. Will post it in sometime.

drivers/android/binder_alloc.c#L259 (have objection)
drivers/infiniband/hw/efa/efa_verbs.c#L1701
drivers/infiniband/hw/mlx5/main.c#L2085 (have objection as using
vm_map_pages_zero() doesn't make sense)
drivers/xen/gntalloc.c#L548 (have limitation)
kernel/kcov.c#L297 (have objection)
net/ipv4/tcp.c#L1799
net/packet/af_packet.c#L4453

But these are the places where replacing vm_insert_page() is bit
difficult/ have objection.
In some cases, maintainers/ reviewers will not agree to replace
vm_insert_page().

In  other scenario, if we change return type of vm_insert_page() to vm_fault_t,
we end up with adding few lines of conversion code from vm_fault_t to errno
in drivers which is not a correct way to go with.

Any suggestion, how to solve this ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-06 12:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 18:43 [PATCH] mm/memory.c: Convert to use vmf_error() Souptick Joarder
2019-09-05 18:59 ` Matthew Wilcox
2019-09-06 12:24   ` Souptick Joarder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).