Re: [PATCH v4 26/26] mm/gup: Remove task_struct pointer for all gup code

2020-07-02 Thread Peter Xu
On Wed, Jul 01, 2020 at 02:55:40PM -0700, John Hubbard wrote:
> On 2020-06-30 13:46, Peter Xu wrote:
> > After the cleanup of page fault accounting, gup does not need to pass
> > task_struct around any more.  Remove that parameter in the whole gup stack.
> > 
> > Signed-off-by: Peter Xu 
> > ---
> >   arch/arc/kernel/process.c   |  2 +-
> >   arch/s390/kvm/interrupt.c   |  2 +-
> >   arch/s390/kvm/kvm-s390.c|  2 +-
> >   arch/s390/kvm/priv.c|  8 +-
> >   arch/s390/mm/gmap.c |  4 +-
> >   drivers/gpu/drm/i915/gem/i915_gem_userptr.c |  2 +-
> >   drivers/infiniband/core/umem_odp.c  |  2 +-
> >   drivers/vfio/vfio_iommu_type1.c |  4 +-
> >   fs/exec.c   |  2 +-
> >   include/linux/mm.h  |  9 +-
> >   kernel/events/uprobes.c |  6 +-
> >   kernel/futex.c  |  2 +-
> >   mm/gup.c| 92 +
> >   mm/memory.c |  2 +-
> >   mm/process_vm_access.c  |  2 +-
> >   security/tomoyo/domain.c|  2 +-
> >   virt/kvm/async_pf.c |  2 +-
> >   virt/kvm/kvm_main.c |  2 +-
> >   18 files changed, 65 insertions(+), 82 deletions(-)
> > 
> 
> Looks good:
> 
> Reviewed-by: John Hubbard 
> 
> One minor refinement: in gup.c, if you add the following hunk on top of your
> changes, that will eradicate the last reference to struct task, in that file:
> 
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 8ddc48022d74..75c4b305828b 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1902,10 +1902,9 @@ static long __get_user_pages_remote(struct mm_struct 
> *mm,
>   *  Or NULL if the caller does not require them.
>   *
>   * This is the same as get_user_pages_remote(), just with a
> - * less-flexible calling convention where we assume that the task
> - * and mm being operated on are the current task's and don't allow
> - * passing of a locked parameter.  We also obviously don't pass
> - * FOLL_REMOTE in here.
> + * less-flexible calling convention where we assume that the mm being 
> operated
> + * on belongs to the current task, and doesn't allow passing of a locked
> + * parameter. We also obviously don't pass FOLL_REMOTE in here.
>   */
>  long get_user_pages(unsigned long start, unsigned long nr_pages,
> unsigned int gup_flags, struct page **pages,

Right.  Fixed it up, and with the r-b kept.  Thanks!

-- 
Peter Xu



Re: [PATCH v4 26/26] mm/gup: Remove task_struct pointer for all gup code

2020-07-01 Thread John Hubbard

On 2020-06-30 13:46, Peter Xu wrote:

After the cleanup of page fault accounting, gup does not need to pass
task_struct around any more.  Remove that parameter in the whole gup stack.

Signed-off-by: Peter Xu 
---
  arch/arc/kernel/process.c   |  2 +-
  arch/s390/kvm/interrupt.c   |  2 +-
  arch/s390/kvm/kvm-s390.c|  2 +-
  arch/s390/kvm/priv.c|  8 +-
  arch/s390/mm/gmap.c |  4 +-
  drivers/gpu/drm/i915/gem/i915_gem_userptr.c |  2 +-
  drivers/infiniband/core/umem_odp.c  |  2 +-
  drivers/vfio/vfio_iommu_type1.c |  4 +-
  fs/exec.c   |  2 +-
  include/linux/mm.h  |  9 +-
  kernel/events/uprobes.c |  6 +-
  kernel/futex.c  |  2 +-
  mm/gup.c| 92 +
  mm/memory.c |  2 +-
  mm/process_vm_access.c  |  2 +-
  security/tomoyo/domain.c|  2 +-
  virt/kvm/async_pf.c |  2 +-
  virt/kvm/kvm_main.c |  2 +-
  18 files changed, 65 insertions(+), 82 deletions(-)



Looks good:

Reviewed-by: John Hubbard 

One minor refinement: in gup.c, if you add the following hunk on top of your
changes, that will eradicate the last reference to struct task, in that file:


diff --git a/mm/gup.c b/mm/gup.c
index 8ddc48022d74..75c4b305828b 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1902,10 +1902,9 @@ static long __get_user_pages_remote(struct mm_struct *mm,
  *  Or NULL if the caller does not require them.
  *
  * This is the same as get_user_pages_remote(), just with a
- * less-flexible calling convention where we assume that the task
- * and mm being operated on are the current task's and don't allow
- * passing of a locked parameter.  We also obviously don't pass
- * FOLL_REMOTE in here.
+ * less-flexible calling convention where we assume that the mm being operated
+ * on belongs to the current task, and doesn't allow passing of a locked
+ * parameter. We also obviously don't pass FOLL_REMOTE in here.
  */
 long get_user_pages(unsigned long start, unsigned long nr_pages,
unsigned int gup_flags, struct page **pages,




thanks,
--
John Hubbard
NVIDIA



diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index 8c8e5172fecd..1ef6b78ff9c7 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -91,7 +91,7 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, 
int, new)
 goto fail;
  
  	mmap_read_lock(current->mm);

-   ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
+   ret = fixup_user_fault(current->mm, (unsigned long) uaddr,
   FAULT_FLAG_WRITE, NULL);
mmap_read_unlock(current->mm);
  
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c

index 1608fd99bbee..2f177298c663 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -2768,7 +2768,7 @@ static struct page *get_map_page(struct kvm *kvm, u64 
uaddr)
struct page *page = NULL;
  
  	mmap_read_lock(kvm->mm);

-   get_user_pages_remote(NULL, kvm->mm, uaddr, 1, FOLL_WRITE,
+   get_user_pages_remote(kvm->mm, uaddr, 1, FOLL_WRITE,
  &page, NULL, NULL);
mmap_read_unlock(kvm->mm);
return page;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 08e6cf6cb454..f78921bc11b3 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1892,7 +1892,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct 
kvm_s390_skeys *args)
  
  		r = set_guest_storage_key(current->mm, hva, keys[i], 0);

if (r) {
-   r = fixup_user_fault(current, current->mm, hva,
+   r = fixup_user_fault(current->mm, hva,
 FAULT_FLAG_WRITE, &unlocked);
if (r)
break;
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 96ae368aa0a2..0fd94e86a28d 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -274,7 +274,7 @@ static int handle_iske(struct kvm_vcpu *vcpu)
rc = get_guest_storage_key(current->mm, vmaddr, &key);
  
  	if (rc) {

-   rc = fixup_user_fault(current, current->mm, vmaddr,
+   rc = fixup_user_fault(current->mm, vmaddr,
  FAULT_FLAG_WRITE, &unlocked);
if (!rc) {
mmap_read_unlock(current->mm);
@@ -320,7 +320,7 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)
mmap_read_lock(current->mm);
rc = reset_guest_reference_bit(current->mm, vmaddr);
if (rc < 0) {
-   rc = fixup_user_fault(current, current->mm, vmaddr,
+   rc =