RDMA/usnic: remove FOLL_FORCE usage
authorDavid Hildenbrand <david@redhat.com>
Wed, 16 Nov 2022 10:26:50 +0000 (11:26 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 30 Nov 2022 23:58:58 +0000 (15:58 -0800)
GUP now supports reliable R/O long-term pinning in COW mappings, such
that we break COW early. MAP_SHARED VMAs only use the shared zeropage so
far in one corner case (DAXFS file with holes), which can be ignored
because GUP does not support long-term pinning in fsdax (see
check_vma_flags()).

Consequently, FOLL_FORCE | FOLL_WRITE | FOLL_LONGTERM is no longer required
for reliable R/O long-term pinning: FOLL_LONGTERM is sufficient. So stop
using FOLL_FORCE, which is really only for ptrace access.

Link: https://lkml.kernel.org/r/20221116102659.70287-12-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Cc: Christian Benvenuti <benve@cisco.com>
Cc: Nelson Escobar <neescoba@cisco.com>
Cc: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/infiniband/hw/usnic/usnic_uiom.c

index 67923ce..c301b3b 100644 (file)
@@ -85,6 +85,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
                                int dmasync, struct usnic_uiom_reg *uiomr)
 {
        struct list_head *chunk_list = &uiomr->chunk_list;
+       unsigned int gup_flags = FOLL_LONGTERM;
        struct page **page_list;
        struct scatterlist *sg;
        struct usnic_uiom_chunk *chunk;
@@ -96,7 +97,6 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
        int off;
        int i;
        dma_addr_t pa;
-       unsigned int gup_flags;
        struct mm_struct *mm;
 
        /*
@@ -131,8 +131,8 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
                goto out;
        }
 
-       gup_flags = FOLL_WRITE;
-       gup_flags |= (writable) ? 0 : FOLL_FORCE;
+       if (writable)
+               gup_flags |= FOLL_WRITE;
        cur_base = addr & PAGE_MASK;
        ret = 0;
 
@@ -140,8 +140,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
                ret = pin_user_pages(cur_base,
                                     min_t(unsigned long, npages,
                                     PAGE_SIZE / sizeof(struct page *)),
-                                    gup_flags | FOLL_LONGTERM,
-                                    page_list, NULL);
+                                    gup_flags, page_list, NULL);
 
                if (ret < 0)
                        goto out;