From: John Hubbard <jhubbard@nvidia.com>
Hi,
This consolidates everything into a "here's what's remaining for Andrew
to add to his tree (for now)" series:
* The first patch is an updated version of one that is already in the akpm tree.
* The next two patches are already in the akpm tree, included here for
completeness.
* The last 5 patches are new to this series, but were previously posted.
Changes since v2:
* Updated patch 1
* Review feedback from Ira. (This only affected the code comments.)
Added Ira's Reviewed-by.
* Review feedback: Further collapsed the siw_umem code: siw_free_plist() is
gone entirely.
* Added 7 patches:
* 3 patches from the "mm/: 3 more put_user_page() conversions" series:
"mm/ksm: convert put_page() to put_user_page*()"
"mm/mempolicy.c: convert put_page() to put_user_page*()"
"mm/mlock.c: convert put_page() to put_user_page*()"
* "security/tomoyo: convert put_page() to put_user_page*()", now that
Tetsuo has ACK'd it for going in via Andrew's tree.
* "powerpc: convert put_page() to put_user_page*()": no reviews yet.
* two patches that were already accepted:
"drivers/gpu/drm/via: convert put_page() to put_user_page*()"
"net/xdp: convert put_page() to put_user_page*()"
* Continued to omit 1 patch ("fs/io_uring.c: convert put_page() to
put_user_page*()"), sent separately, because Jens Axboe is putting it into his
tree.
* Added Rodrigo Vivi's ACK for the i915 patch.
* Added Tetsuo Handa's ACK for the security/tomoyo patch
* Juergen Gross has verified that his Signed-off-by is valid.
* Added Calum Mackay's Reviewed-by.
Changes since v1:
* 9 out of 34 patches have been reviewed or ack'd or changed:
* Picked up Keith's Reviewed-by for patch 26 (gup_benchmark).
* Picked up ACKs for patches 3, 10, 15, 16 (ceph, genwqe,
staging/vc04_services, drivers/tee).
* Patch 6 (i915): adjusted drivers/gpu/drm/i915/gem/i915_gem_userptr.c to
match the latest linux.git: the code has already been fixed in linux.git,
as of the latest -rc, to do a set_page_dirty_lock(), instead of
set_page_dirty(). So all that it needs now is a conversion to
put_user_page(). I've done that in a way (avoiding the changed API call)
that allows patch 6 to go up via either Andrew's -mm tree, or the drm
tree, just in case. See that patch's comments for slightly more detail.
* Patch 20 (xen): applied Juergen's recommended fix, and speculatively
(pending his approval) added his Signed-off-by (also noted in the patch
comments).
* Improved patch 31 (NFS) as recommended by Calum Mackay.
* Includes the latest version of patch 1. (Patch 1 has been separately
reposted [3], with those updates. And it's included here in order to
make this series apply directly to linux.git, as noted in the original
cover letter below.)
Cover letter from v1:
These are best characterized as miscellaneous conversions: many (not all)
call sites that don't involve biovec or iov_iter, nor mm/. It also leaves
out a few call sites that require some more work. These are mostly pretty
simple ones.
It's probably best to send all of these via Andrew's -mm tree, assuming
that there are no significant merge conflicts with ongoing work in other
trees (which I doubt, given that these are small changes).
These patches apply to the latest linux.git. Patch #1 is also already in
Andrew's tree, but given the broad non-linux-mm Cc list, I thought it
would be more convenient to just include that patch here, so that people
can use linux.git as the base--even though these are probably destined
for linux-mm.
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions"). That commit
has an extensive description of the problem and the planned steps to
solve it, but the highlites are:
1) Provide put_user_page*() routines, intended to be used
for releasing pages that were pinned via get_user_pages*().
2) Convert all of the call sites for get_user_pages*(), to
invoke put_user_page*(), instead of put_page(). This involves dozens of
call sites, and will take some time.
3) After (2) is complete, use get_user_pages*() and put_user_page*() to
implement tracking of these pages. This tracking will be separate from
the existing struct page refcounting.
4) Use the tracking and identification of these pages, to implement
special handling (especially in writeback paths) when the pages are
backed by a filesystem.
And a few references, also from that commit:
[1] https://lwn.net/Articles/774411/ : "DMA and get_user_pages()"
[2] https://lwn.net/Articles/753027/ : "The Trouble with get_user_pages()"
[3] "mm/gup: add make_dirty arg to put_user_pages_dirty_lock()"
https://lore.kernel.org/r/20190804214042.4564-1-jhubbard@nvidia.com
Ira Weiny (1):
fs/binfmt_elf: convert put_page() to put_user_page*()
John Hubbard (38):
mm/gup: add make_dirty arg to put_user_pages_dirty_lock()
net/rds: convert put_page() to put_user_page*()
net/ceph: convert put_page() to put_user_page*()
x86/kvm: convert put_page() to put_user_page*()
drm/etnaviv: convert release_pages() to put_user_pages()
drm/i915: convert put_page() to put_user_page*()
drm/radeon: convert put_page() to put_user_page*()
media/ivtv: convert put_page() to put_user_page*()
media/v4l2-core/mm: convert put_page() to put_user_page*()
genwqe: convert put_page() to put_user_page*()
scif: convert put_page() to put_user_page*()
vmci: convert put_page() to put_user_page*()
rapidio: convert put_page() to put_user_page*()
oradax: convert put_page() to put_user_page*()
staging/vc04_services: convert put_page() to put_user_page*()
drivers/tee: convert put_page() to put_user_page*()
vfio: convert put_page() to put_user_page*()
fbdev/pvr2fb: convert put_page() to put_user_page*()
fsl_hypervisor: convert put_page() to put_user_page*()
xen: convert put_page() to put_user_page*()
fs/exec.c: convert put_page() to put_user_page*()
orangefs: convert put_page() to put_user_page*()
uprobes: convert put_page() to put_user_page*()
futex: convert put_page() to put_user_page*()
mm/frame_vector.c: convert put_page() to put_user_page*()
mm/gup_benchmark.c: convert put_page() to put_user_page*()
mm/memory.c: convert put_page() to put_user_page*()
mm/madvise.c: convert put_page() to put_user_page*()
mm/process_vm_access.c: convert put_page() to put_user_page*()
crypt: convert put_page() to put_user_page*()
fs/nfs: convert put_page() to put_user_page*()
goldfish_pipe: convert put_page() to put_user_page*()
kernel/events/core.c: convert put_page() to put_user_page*()
security/tomoyo: convert put_page() to put_user_page*()
powerpc: convert put_page() to put_user_page*()
mm/mlock.c: convert put_page() to put_user_page*()
mm/mempolicy.c: convert put_page() to put_user_page*()
mm/ksm: convert put_page() to put_user_page*()
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 +-
arch/powerpc/kvm/book3s_64_mmu_radix.c | 19 ++-
arch/powerpc/kvm/e500_mmu.c | 3 +-
arch/powerpc/mm/book3s64/iommu_api.c | 11 +-
arch/x86/kvm/svm.c | 4 +-
crypto/af_alg.c | 7 +-
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 4 +-
drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 6 +-
drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
drivers/infiniband/core/umem.c | 5 +-
drivers/infiniband/hw/hfi1/user_pages.c | 5 +-
drivers/infiniband/hw/qib/qib_user_pages.c | 13 +--
drivers/infiniband/hw/usnic/usnic_uiom.c | 5 +-
drivers/infiniband/sw/siw/siw_mem.c | 19 +--
drivers/media/pci/ivtv/ivtv-udma.c | 14 +--
drivers/media/pci/ivtv/ivtv-yuv.c | 11 +-
drivers/media/v4l2-core/videobuf-dma-sg.c | 3 +-
drivers/misc/genwqe/card_utils.c | 17 +--
drivers/misc/mic/scif/scif_rma.c | 17 ++-
drivers/misc/vmw_vmci/vmci_context.c | 2 +-
drivers/misc/vmw_vmci/vmci_queue_pair.c | 11 +-
drivers/platform/goldfish/goldfish_pipe.c | 9 +-
drivers/rapidio/devices/rio_mport_cdev.c | 9 +-
drivers/sbus/char/oradax.c | 2 +-
.../interface/vchiq_arm/vchiq_2835_arm.c | 10 +-
drivers/tee/tee_shm.c | 10 +-
drivers/vfio/vfio_iommu_type1.c | 8 +-
drivers/video/fbdev/pvr2fb.c | 3 +-
drivers/virt/fsl_hypervisor.c | 7 +-
drivers/xen/privcmd.c | 32 ++---
fs/binfmt_elf.c | 2 +-
fs/binfmt_elf_fdpic.c | 2 +-
fs/exec.c | 2 +-
fs/nfs/direct.c | 11 +-
fs/orangefs/orangefs-bufmap.c | 7 +-
include/linux/mm.h | 5 +-
kernel/events/core.c | 2 +-
kernel/events/uprobes.c | 6 +-
kernel/futex.c | 10 +-
mm/frame_vector.c | 4 +-
mm/gup.c | 109 +++++++-----------
mm/gup_benchmark.c | 2 +-
mm/ksm.c | 14 +--
mm/madvise.c | 2 +-
mm/memory.c | 2 +-
mm/mempolicy.c | 2 +-
mm/mlock.c | 6 +-
mm/process_vm_access.c | 18 +--
net/ceph/pagevec.c | 8 +-
net/rds/info.c | 5 +-
net/rds/message.c | 2 +-
net/rds/rdma.c | 15 ++-
security/tomoyo/domain.c | 2 +-
virt/kvm/kvm_main.c | 4 +-
54 files changed, 191 insertions(+), 323 deletions(-)
--
2.22.0
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <redacted>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
kernel/events/uprobes.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -1981,7 +1981,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)returnresult;copy_from_page(page,vaddr,&opcode,UPROBE_SWBP_INSN_SIZE);-put_page(page);+put_user_page(page);out:/* This needs to return true for any variant of the trap insn */returnis_trap_insn(&opcode);
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Aneesh Kumar K.V <redacted>
Cc: Huang Ying <redacted>
Cc: Jérôme Glisse <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Souptick Joarder <redacted>
Cc: Will Deacon <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
crypto/af_alg.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Dan Williams <redacted>
Cc: Daniel Black <redacted>
Cc: Jan Kara <jack@suse.cz>
Cc: Jérôme Glisse <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Kravetz <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/ksm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Andrea Arcangeli <redacted>
Cc: Anshuman Khandual <redacted>
Cc: David Rientjes <rientjes@google.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Kirill A. Shutemov <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <redacted>
Cc: zhong jiang <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/mempolicy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Note that this effectively changes the code's behavior in
mm_iommu_unpin(): it now ultimately calls set_page_dirty_lock(),
instead of set_page_dirty(). This is probably more accurate.
As Christoph Hellwig put it, "set_page_dirty() is only safe if we are
dealing with a file backed page where we have reference on the inode it
hangs off." [1]
[1] https://lore.kernel.org/r/20190723153640.GB720@lst.de
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--
arch/powerpc/kvm/book3s_64_mmu_radix.c | 19 ++++++++++++++-----
arch/powerpc/kvm/e500_mmu.c | 3 +--
arch/powerpc/mm/book3s64/iommu_api.c | 11 +++++------
4 files changed, 22 insertions(+), 15 deletions(-)
@@ -821,8 +821,12 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,*/if(!ptep){local_irq_enable();-if(page)-put_page(page);+if(page){+if(upgrade_write)+put_user_page(page);+else+put_page(page);+}returnRESUME_GUEST;}pte=*ptep;
@@ -870,9 +874,14 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,*levelp=level;if(page){-if(!ret&&(pte_val(pte)&_PAGE_WRITE))-set_page_dirty_lock(page);-put_page(page);+booldirty=!ret&&(pte_val(pte)&_PAGE_WRITE);+if(upgrade_write)+put_user_pages_dirty_lock(&page,1,dirty);+else{+if(dirty)+set_page_dirty_lock(page);+put_page(page);+}}/* Increment number of large pages if we (successfully) inserted one */
@@ -170,9 +170,8 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua,return0;free_exit:-/* free the reference taken */-for(i=0;i<pinned;i++)-put_page(mem->hpages[i]);+/* free the references taken */+put_user_pages(mem->hpages,pinned);vfree(mem->hpas);kfree(mem);
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Acked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Kentaro Takeda <takedakn@nttdata.co.jp>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
security/tomoyo/domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -931,7 +931,7 @@ bool tomoyo_dump_page(struct linux_binprm *bprm, unsigned long pos,}/* Same with put_arg_page(page) in fs/exec.c */#ifdef CONFIG_MMU-put_page(page);+put_user_page(page);#endifreturntrue;}
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Dan Williams <redacted>
Cc: Daniel Black <redacted>
Cc: Jan Kara <jack@suse.cz>
Cc: Jérôme Glisse <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Kravetz <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/mlock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Ira Weiny <redacted>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
get_dump_page calls get_user_page so put_user_page must be used
to match.
Signed-off-by: Ira Weiny <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
fs/binfmt_elf.c | 2 +-
fs/binfmt_elf_fdpic.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <redacted>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
kernel/events/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Reviewed-by: Calum Mackay <redacted>
Cc: Trond Myklebust <redacted>
Cc: Anna Schumaker <redacted>
Cc: linux-nfs@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
fs/nfs/direct.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Note that this effectively changes the code's behavior in
qp_release_pages(): it now ultimately calls set_page_dirty_lock(),
instead of set_page_dirty(). This is probably more accurate.
As Christoph Hellwig put it, "set_page_dirty() is only safe if we are
dealing with a file backed page where we have reference on the inode it
hangs off." [1]
[1] https://lore.kernel.org/r/20190723153640.GB720@lst.de
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Roman Kiryanov <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/platform/goldfish/goldfish_pipe.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
@@ -288,15 +288,12 @@ static int pin_user_pages(unsigned long first_page,staticvoidrelease_user_pages(structpage**pages,intpages_count,intis_write,s32consumed_size){-inti;+booldirty=!is_write&&consumed_size>0;-for(i=0;i<pages_count;i++){-if(!is_write&&consumed_size>0)-set_page_dirty(pages[i]);-put_page(pages[i]);-}+put_user_pages_dirty_lock(pages,pages_count,dirty);}+/* Populate the call parameters, merging adjacent pages together */staticvoidpopulate_rw_params(structpage**pages,intpages_count,
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrea Arcangeli <redacted>
Cc: Christopher Yeoh <redacted>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Heiko Carstens <redacted>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jann Horn <redacted>
Cc: Lorenzo Stoakes <redacted>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Mike Rapoport <redacted>
Cc: Rashika Kheria <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/process_vm_access.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
@@ -96,7 +96,7 @@ static int process_vm_rw_single_vec(unsigned long addr,flags|=FOLL_WRITE;while(!rc&&nr_pages&&iov_iter_count(iter)){-intpages=min(nr_pages,max_pages_per_loop);+intpinned_pages=min(nr_pages,max_pages_per_loop);intlocked=1;size_tbytes;
@@ -106,14 +106,15 @@ static int process_vm_rw_single_vec(unsigned long addr,*current/current->mm*/down_read(&mm->mmap_sem);-pages=get_user_pages_remote(task,mm,pa,pages,flags,-process_pages,NULL,&locked);+pinned_pages=get_user_pages_remote(task,mm,pa,pinned_pages,+flags,process_pages,NULL,+&locked);if(locked)up_read(&mm->mmap_sem);-if(pages<=0)+if(pinned_pages<=0)return-EFAULT;-bytes=pages*PAGE_SIZE-start_offset;+bytes=pinned_pages*PAGE_SIZE-start_offset;if(bytes>len)bytes=len;
@@ -122,10 +123,9 @@ static int process_vm_rw_single_vec(unsigned long addr,vm_write);len-=bytes;start_offset=0;-nr_pages-=pages;-pa+=pages*PAGE_SIZE;-while(pages)-put_page(process_pages[--pages]);+nr_pages-=pinned_pages;+pa+=pinned_pages*PAGE_SIZE;+put_user_pages(process_pages,pinned_pages);}returnrc;
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Dan Williams <redacted>
Cc: Daniel Black <redacted>
Cc: Jan Kara <jack@suse.cz>
Cc: Jérôme Glisse <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Kravetz <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/madvise.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Reviewed-by: Keith Busch <redacted>
Cc: Dan Carpenter <redacted>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Keith Busch <redacted>
Cc: Kirill A. Shutemov <redacted>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: YueHaibing <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/gup_benchmark.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -79,7 +79,7 @@ static int __gup_benchmark_ioctl(unsigned int cmd,for(i=0;i<nr_pages;i++){if(!pages[i])break;-put_page(pages[i]);+put_user_page(pages[i]);}end_time=ktime_get();gup->put_delta_usec=ktime_us_delta(end_time,start_time);
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Dan Williams <redacted>
Cc: Jan Kara <jack@suse.cz>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Vlastimil Babka <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
mm/frame_vector.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Thomas Gleixner <redacted>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Darren Hart <dvhart@infradead.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
kernel/futex.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Mike Marshall <hubcap@omnibond.com>
Cc: Martin Brandenburg <martin@omnibond.com>
Cc: devel@lists.orangefs.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
fs/orangefs/orangefs-bufmap.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
fs/exec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
This also handles pages[i] == NULL cases, thanks to an approach
that is actually written by Juergen Gross.
Signed-off-by: Juergen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/xen/privcmd.c | 32 +++++++++++---------------------
1 file changed, 11 insertions(+), 21 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
This changes the release code slightly, because each page slot in the
page_list[] array is no longer checked for NULL. However, that check
was wrong anyway, because the get_user_pages() pattern of usage here
never allowed for NULL entries within a range of pinned pages.
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Kees Cook <redacted>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/virt/fsl_hypervisor.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Bartlomiej Zolnierkiewicz <redacted>
Cc: Kees Cook <redacted>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Bhumika Goyal <redacted>
Cc: Arvind Yadav <redacted>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/video/fbdev/pvr2fb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Note that this effectively changes the code's behavior in
qp_release_pages(): it now ultimately calls set_page_dirty_lock(),
instead of set_page_dirty(). This is probably more accurate.
As Christoph Hellwig put it, "set_page_dirty() is only safe if we are
dealing with a file backed page where we have reference on the inode it
hangs off." [1]
[1] https://lore.kernel.org/r/20190723153640.GB720@lst.de
Cc: Alex Williamson <redacted>
Cc: kvm@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/vfio/vfio_iommu_type1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -320,9 +320,9 @@ static int put_pfn(unsigned long pfn, int prot){if(!is_invalid_reserved_pfn(pfn)){structpage*page=pfn_to_page(pfn);-if(prot&IOMMU_WRITE)-SetPageDirty(page);-put_page(page);+booldirty=prot&IOMMU_WRITE;++put_user_pages_dirty_lock(&page,1,dirty);return1;}return0;
@@ -356,7 +356,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,*/if(ret>0&&vma_is_fsdax(vmas[0])){ret=-EOPNOTSUPP;-put_page(page[0]);+put_user_page(page[0]);}}up_read(&mm->mmap_sem);
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Eric Anholt <redacted>
Cc: Stefan Wahren <redacted>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mihaela Muraru <redacted>
Cc: Suniel Mahesh <redacted>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Sidong Yang <redacted>
Cc: Kishore KP <redacted>
Cc: linux-rpi-kernel@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: devel@driverdev.osuosl.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
.../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
@@ -454,10 +451,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)__func__,actual_pages,num_pages);/* This is probably due to the process being killed */-while(actual_pages>0){-actual_pages--;-put_page(pages[actual_pages]);-}+put_user_pages(pages,actual_pages);cleanup_pagelistinfo(pagelistinfo);returnNULL;}
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Acked-by: Jens Wiklander <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/tee/tee_shm.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: David S. Miller <davem@davemloft.net>
Cc: Jonathan Helman <redacted>
Cc: Rob Gardner <redacted>
Cc: Andy Shevchenko <redacted>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Wei Yongjun <redacted>
Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Cc: sparclinux@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/sbus/char/oradax.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: Christophe JAILLET <redacted>
Cc: Ioan Nicu <redacted>
Cc: Kees Cook <redacted>
Cc: Tvrtko Ursulin <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/rapidio/devices/rio_mport_cdev.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Sudeep Dutt <redacted>
Cc: Ashutosh Dixit <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Joerg Roedel <redacted>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Zhen Lei <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/misc/mic/scif/scif_rma.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
@@ -113,13 +113,14 @@ static int scif_destroy_pinned_pages(struct scif_pinned_pages *pin)intwriteable=pin->prot&SCIF_PROT_WRITE;intkernel=SCIF_MAP_KERNEL&pin->map_flags;-for(j=0;j<pin->nr_pages;j++){-if(pin->pages[j]&&!kernel){+if(kernel){+for(j=0;j<pin->nr_pages;j++){if(writeable)-SetPageDirty(pin->pages[j]);+set_page_dirty_lock(pin->pages[j]);put_page(pin->pages[j]);}-}+}else+put_user_pages_dirty_lock(pin->pages,pin->nr_pages,writeable);scif_free(pin->pages,pin->nr_pages*sizeof(*pin->pages));
@@ -1385,11 +1386,9 @@ int __scif_pin_pages(void *addr, size_t len, int *out_prot,if(ulimit)__scif_dec_pinned_vm_lock(mm,nr_pages);/* Roll back any pinned pages */-for(i=0;i<pinned_pages->nr_pages;i++){-if(pinned_pages->pages[i])-put_page(-pinned_pages->pages[i]);-}+put_user_pages(pinned_pages->pages,+pinned_pages->nr_pages);+prot&=~SCIF_PROT_WRITE;try_upgrade=false;gotoretry;
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Note that this effectively changes the code's behavior in
qp_release_pages(): it now ultimately calls set_page_dirty_lock(),
instead of set_page_dirty(). This is probably more accurate.
As Christoph Hellwig put it, "set_page_dirty() is only safe if we are
dealing with a file backed page where we have reference on the inode it
hangs off." [1]
[1] https://lore.kernel.org/r/20190723153640.GB720@lst.de
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Gustavo A. R. Silva <redacted>
Cc: Kees Cook <redacted>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/misc/vmw_vmci/vmci_context.c | 2 +-
drivers/misc/vmw_vmci/vmci_queue_pair.c | 11 ++---------
2 files changed, 3 insertions(+), 10 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Kees Cook <redacted>
Cc: Hans Verkuil <redacted>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Souptick Joarder <redacted>
Cc: Dan Williams <redacted>
Cc: linux-media@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/media/v4l2-core/videobuf-dma-sg.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
This changes the release code slightly, because each page slot in the
page_list[] array is no longer checked for NULL. However, that check
was wrong anyway, because the get_user_pages() pattern of usage here
never allowed for NULL entries within a range of pinned pages.
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Frank Haverkamp <redacted>
Cc: Guilherme G. Piccoli <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/misc/genwqe/card_utils.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David (ChunMing) Zhou <redacted>
Cc: David Airlie <redacted>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/media/pci/ivtv/ivtv-udma.c | 14 ++++----------
drivers/media/pci/ivtv/ivtv-yuv.c | 11 +++--------
2 files changed, 7 insertions(+), 18 deletions(-)
@@ -92,7 +92,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,{structivtv_dma_page_infouser_dma;structivtv_user_dma*dma=&itv->udma;-inti,err;+interr;IVTV_DEBUG_DMA("ivtv_udma_setup, dst: 0x%08x\n",(unsignedint)ivtv_dest_addr);
@@ -119,8 +119,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,IVTV_DEBUG_WARN("failed to map user pages, returned %d instead of %d\n",err,user_dma.page_count);if(err>=0){-for(i=0;i<err;i++)-put_page(dma->map[i]);+put_user_pages(dma->map,err);return-EINVAL;}returnerr;
@@ -130,9 +129,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,/* Fill SG List with new values */if(ivtv_udma_fill_sg_list(dma,&user_dma,0)<0){-for(i=0;i<dma->page_count;i++){-put_page(dma->map[i]);-}+put_user_pages(dma->map,dma->page_count);dma->page_count=0;return-ENOMEM;}
@@ -153,7 +150,6 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,voidivtv_udma_unmap(structivtv*itv){structivtv_user_dma*dma=&itv->udma;-inti;IVTV_DEBUG_INFO("ivtv_unmap_user_dma\n");
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
This is a merge-able version of the fix, because it restricts
itself to put_user_page() and put_user_pages(), both of which
have not changed their APIs. Later, i915_gem_userptr_put_pages()
can be simplified to use put_user_pages_dirty_lock().
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: David Airlie <redacted>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <redacted>
Cc: Thomas Gleixner <redacted>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
arch/x86/kvm/svm.c | 4 ++--
virt/kvm/kvm_main.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <redacted>
Cc: Thomas Gleixner <redacted>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Acked-by: Jeff Layton <jlayton@kernel.org>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Sage Weil <redacted>
Cc: David S. Miller <davem@davemloft.net>
Cc: ceph-devel@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
net/ceph/pagevec.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Acked-by: Björn Töpel <redacted>
Cc: Magnus Karlsson <magnus.karlsson@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
net/xdp/xdp_umem.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Santosh Shilimkar <redacted>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Cc: rds-devel@oss.oracle.com
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
net/rds/info.c | 5 ++---
net/rds/message.c | 2 +-
net/rds/rdma.c | 15 +++++++--------
3 files changed, 10 insertions(+), 12 deletions(-)
@@ -162,8 +162,7 @@ static int rds_pin_pages(unsigned long user_addr, unsigned int nr_pages,pages);if(ret>=0&&ret<nr_pages){-while(ret--)-put_page(pages[ret]);+put_user_pages(pages,ret);ret=-EFAULT;}
@@ -481,8 +481,7 @@ void rds_atomic_free_op(struct rm_atomic_op *ao)/* Mark page dirty if it was possibly modified, which*isthecaseforaRDMA_READwhichcopiesfromremote*tolocalmemory*/-set_page_dirty(page);-put_page(page);+put_user_pages_dirty_lock(&page,1,true);kfree(ao->op_notifier);ao->op_notifier=NULL;
From: John Hubbard <jhubbard@nvidia.com>
Provide a more capable variation of put_user_pages_dirty_lock(),
and delete put_user_pages_dirty(). This is based on the
following:
1. Lots of call sites become simpler if a bool is passed
into put_user_page*(), instead of making the call site
choose which put_user_page*() variant to call.
2. Christoph Hellwig's observation that set_page_dirty_lock()
is usually correct, and set_page_dirty() is usually a
bug, or at least questionable, within a put_user_page*()
calling chain.
This leads to the following API choices:
* put_user_pages_dirty_lock(page, npages, make_dirty)
* There is no put_user_pages_dirty(). You have to
hand code that, in the rare case that it's
required.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ira Weiny <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Ira Weiny <redacted>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/infiniband/core/umem.c | 5 +-
drivers/infiniband/hw/hfi1/user_pages.c | 5 +-
drivers/infiniband/hw/qib/qib_user_pages.c | 13 +--
drivers/infiniband/hw/usnic/usnic_uiom.c | 5 +-
drivers/infiniband/sw/siw/siw_mem.c | 19 +---
include/linux/mm.h | 5 +-
mm/gup.c | 109 ++++++++-------------
7 files changed, 54 insertions(+), 107 deletions(-)
@@ -118,10 +118,7 @@ int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t npvoidhfi1_release_user_pages(structmm_struct*mm,structpage**p,size_tnpages,booldirty){-if(dirty)-put_user_pages_dirty_lock(p,npages);-else-put_user_pages(p,npages);+put_user_pages_dirty_lock(p,npages,dirty);if(mm){/* during close after signal, mm can be NULL */atomic64_sub(npages,&mm->pinned_vm);
@@ -124,7 +115,7 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages,return0;bail_release:-__qib_release_user_pages(p,got,0);+put_user_pages_dirty_lock(p,got,false);bail:atomic64_sub(num_pages,¤t->mm->pinned_vm);returnret;
@@ -132,7 +123,7 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages,voidqib_release_user_pages(structpage**p,size_tnum_pages){-__qib_release_user_pages(p,num_pages,1);+put_user_pages_dirty_lock(p,num_pages,true);/* during close after signal, mm can be NULL */if(current->mm)
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Also reverse the order of a comparison, in order to placate
checkpatch.pl.
Cc: David Airlie <redacted>
Cc: Daniel Vetter <redacted>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/gpu/drm/via/via_dmablit.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
@@ -186,13 +185,8 @@ via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)kfree(vsg->desc_pages);/* fall through */casedr_via_pages_locked:-for(i=0;i<vsg->num_pages;++i){-if(NULL!=(page=vsg->pages[i])){-if(!PageReserved(page)&&(DMA_FROM_DEVICE==vsg->direction))-SetPageDirty(page);-put_page(page);-}-}+put_user_pages_dirty_lock(vsg->pages,vsg->num_pages,+(vsg->direction==DMA_FROM_DEVICE));/* fall through */casedr_via_pages_alloc:vfree(vsg->pages);
ahem, yes, apparently this is what happens if I add a few patches while editing
the cover letter... :)
The subject line should read "00/41", and the list of files affected here is
therefore under-reported in this cover letter. However, the patch series itself is
intact and ready for submission.
thanks,
--
John Hubbard
NVIDIA
From: Sakari Ailus <sakari.ailus@linux.intel.com> Date: 2019-08-07 07:21:07
On Tue, Aug 06, 2019 at 06:33:10PM -0700, john.hubbard@gmail.com wrote:
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Kees Cook <redacted>
Cc: Hans Verkuil <redacted>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Souptick Joarder <redacted>
Cc: Dan Williams <redacted>
Cc: linux-media@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Sakari Ailus
sakari.ailus@linux.intel.com
From: Hans Verkuil <hidden> Date: 2019-08-07 08:07:26
On 8/7/19 3:33 AM, john.hubbard@gmail.com wrote:
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Kees Cook <redacted>
Cc: Hans Verkuil <redacted>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Souptick Joarder <redacted>
Cc: Dan Williams <redacted>
Cc: linux-media@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
From: Hans Verkuil <hidden> Date: 2019-08-07 08:51:32
On 8/7/19 3:33 AM, john.hubbard@gmail.com wrote:
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
@@ -92,7 +92,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,{structivtv_dma_page_infouser_dma;structivtv_user_dma*dma=&itv->udma;-inti,err;+interr;IVTV_DEBUG_DMA("ivtv_udma_setup, dst: 0x%08x\n",(unsignedint)ivtv_dest_addr);
@@ -119,8 +119,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,IVTV_DEBUG_WARN("failed to map user pages, returned %d instead of %d\n",err,user_dma.page_count);if(err>=0){-for(i=0;i<err;i++)-put_page(dma->map[i]);+put_user_pages(dma->map,err);return-EINVAL;}returnerr;
@@ -130,9 +129,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,/* Fill SG List with new values */if(ivtv_udma_fill_sg_list(dma,&user_dma,0)<0){-for(i=0;i<dma->page_count;i++){-put_page(dma->map[i]);-}+put_user_pages(dma->map,dma->page_count);dma->page_count=0;return-ENOMEM;}
@@ -153,7 +150,6 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr,voidivtv_udma_unmap(structivtv*itv){structivtv_user_dma*dma=&itv->udma;-inti;IVTV_DEBUG_INFO("ivtv_unmap_user_dma\n");
I don't think you need that initialisation do you?
Nope, it can go. Fixed locally, thanks.
Did you get a chance to look at enough of the other bits to feel comfortable
with the patch, overall?
thanks,
--
John Hubbard
NVIDIA
From: John Hubbard <jhubbard@nvidia.com>
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
Cc: Bartlomiej Zolnierkiewicz <redacted>
Cc: Kees Cook <redacted>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Bhumika Goyal <redacted>
Cc: Arvind Yadav <redacted>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Acked-by: Bartlomiej Zolnierkiewicz <redacted>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
I don't think you need that initialisation do you?
Nope, it can go. Fixed locally, thanks.
Thanks.
Did you get a chance to look at enough of the other bits to feel comfortable
with the patch, overall?
Mostly :) It's not really my area, but all the conversions looked
correct to me as best as I could tell.
So I'm fine for it to go in as part of the series:
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
cheers
From: Mike Marshall <hubcap@omnibond.com> Date: 2019-08-30 01:30:10
Hi John...
I added this patch series on top of Linux 5.3rc6 and ran
xfstests with no regressions...
Acked-by: Mike Marshall <hubcap@omnibond.com>
-Mike
On Tue, Aug 6, 2019 at 9:50 PM John Hubbard [off-list ref] wrote:
On 8/6/19 6:32 PM, john.hubbard@gmail.com wrote:
quoted
From: John Hubbard <jhubbard@nvidia.com>
...
John Hubbard (38):
mm/gup: add make_dirty arg to put_user_pages_dirty_lock()
ahem, yes, apparently this is what happens if I add a few patches while editing
the cover letter... :)
The subject line should read "00/41", and the list of files affected here is
therefore under-reported in this cover letter. However, the patch series itself is
intact and ready for submission.
thanks,
--
John Hubbard
NVIDIA
From: John Hubbard <jhubbard@nvidia.com> Date: 2019-08-30 02:21:08
On 8/29/2019 6:29 PM, Mike Marshall wrote:
Hi John...
I added this patch series on top of Linux 5.3rc6 and ran
xfstests with no regressions...
Acked-by: Mike Marshall <hubcap@omnibond.com>
Hi Mike (and I hope Ira and others are reading as well, because
I'm making a bunch of claims further down),
That's great news, thanks for running that test suite and for
the report and the ACK.
There is an interesting pause right now, due to the fact that
we've made some tentative decisions about gup pinning, that affect
the call sites. A key decision is that only pages that were
requested via FOLL_PIN, will require put_user_page*() to release
them. There are 4 main cases, which were first explained by Jan
Kara and Vlastimil Babka, and are now written up in my FOLL_PIN
patch [1].
So, what that means for this series is that:
1. Some call sites (mlock.c for example, and a lot of the mm/ files
in fact, and more) will not be converted: some of these patches will
get dropped, especially in mm/.
2. Call sites that do DirectIO or RDMA will need to set FOLL_PIN, and
will also need to call put_user_page().
3. Call sites that do RDMA will need to set FOLL_LONGTERM *and* FOLL_PIN,
3.a. ...and will at least in some cases need to provide a link to a
vaddr_pin object, and thus back to a struct file*...maybe. Still
under discussion.
4. It's desirable to keep FOLL_* flags (or at least FOLL_PIN) internal
to the gup() calls. That implies using a wrapper call such as Ira's
vaddr_pin_[user]_pages(), instead of gup(), and vaddr_unpin_[user]_pages()
instead of put_user_page*().
5. We don't want to churn the call sites unnecessarily.
With that in mind, I've taken another pass through all these patches
and narrowed it down to:
a) 12 call sites that I'd like to convert soon, but even those
really look cleaner with a full conversion to a wrapper call
similar to (identical to?) vaddr_pin_[user]_pages(), probably
just the FOLL_PIN only variant (not FOLL_LONGTERM). That
wrapper call is not ready yet, though.
b) Some more call sites that require both FOLL_PIN and FOLL_LONGTERM.
Definitely will wait to use the wrapper calls for these, because
they may also require hooking up to a struct file*.
c) A few more that were already applied, which is fine, because they
show where to convert, and simplify a few sites anyway. But they'll
need follow-on changes to, one way or another, set FOLL_PIN.
d) And of course a few sites whose patches get dropped, as mentioned
above.
[1] https://lore.kernel.org/r/20190821040727.19650-3-jhubbard@nvidia.com
thanks,
--
John Hubbard
NVIDIA