Thread (7 messages) 7 messages, 3 authors, 2018-04-18

Re: [PATCH] powerpc: platform: cell: spufs: Change return type to vm_fault_t

From: Souptick Joarder <hidden>
Date: 2018-04-18 19:04:20

On Wed, Apr 18, 2018 at 2:17 AM, Matthew Wilcox [off-list ref] wrote:
On Wed, Apr 18, 2018 at 12:50:38AM +0530, Souptick Joarder wrote:
quoted
Use new return type vm_fault_t for fault handler. For
now, this is just documenting that the function returns
a VM_FAULT value rather than an errno. Once all instances
are converted, vm_fault_t will become a distinct type.

Reference id -> 1c8f422059ae ("mm: change return type to
vm_fault_t")

Previously vm_insert_pfn() returns err but driver returns
VM_FAULT_NOPAGE as default. The new function vmf_insert_pfn()
will replace this inefficiency by returning correct VM_FAULT_*
type.

vmf_handle_error is a inline wrapper function which
will convert error number to vm_fault_t type err.
I think you sent the wrong version of this one ...

The commit message should mention that we're fixing a minor bug, that
the error from vm_insert_pfn() was being ignored and the effect of this
is likely to be only felt in OOM situations.
Ok, I will add this.
quoted
@@ -256,11 +257,11 @@ static ssize_t spufs_attr_write(struct file *file, const char __user *buf,
              vma->vm_page_prot = pgprot_noncached_wc(vma->vm_page_prot);
              pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT;
      }
-     vm_insert_pfn(vma, vmf->address, pfn);
+     ret = vmf_insert_pfn(vma, vmf->address, pfn);

      spu_release(ctx);

-     return VM_FAULT_NOPAGE;
+     return ret;
 }
I thought I said not to introduce vmf_handle_error(), because it's too
trivial and obfuscates what's actually going on.
quoted
-static int spufs_ps_fault(struct vm_fault *vmf,
+static inline vm_fault_t vmf_handle_error(int err)
+{
+     return VM_FAULT_NOPAGE;
+}
+
Re-reading spufs_ps_fault(), I wouldn't change anything inside it.  Just
change its return type to vm_fault_t and call it done.
In that case, return value of spufs_wait() has to changed
to VM_FAULT_ type and we end with changing all the
references where spufs_wait() is called. I think we shouldn't
go with that approach. That's the reason I introduce inline
vmf_handle_error() and convert err to VM_FAULT_ type.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help