From patchwork Tue Apr 18 15:49:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13215868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C720C77B75 for ; Tue, 18 Apr 2023 15:49:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB2C38E0005; Tue, 18 Apr 2023 11:49:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E61548E0001; Tue, 18 Apr 2023 11:49:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB3E08E0005; Tue, 18 Apr 2023 11:49:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B91D38E0001 for ; Tue, 18 Apr 2023 11:49:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7D4841A037D for ; Tue, 18 Apr 2023 15:49:23 +0000 (UTC) X-FDA: 80694946206.17.6423B85 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by imf12.hostedemail.com (Postfix) with ESMTP id 8CC294001E for ; Tue, 18 Apr 2023 15:49:20 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=ntPGEolI; spf=pass (imf12.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681832960; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bb9irq9nW0pE8CSgWK7K74C7UlngMlVehaGXPHyB9ic=; b=QSFil5/ClGfAETP+1L9o14C1fr96L3j8Gs+ipOEmlT4x90zWF3SRVVjRQhaEK4U8Dud8s2 NV3N2P1BuYIIFau2dVzAniLDMVBFWk7ebAZx1jdxSV9r7hh0blFapHgtFAROtcCHcxJOn1 tWIVjvTsd1OIKxnLUTJ+Ck5MCQDPRvk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=ntPGEolI; spf=pass (imf12.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681832960; a=rsa-sha256; cv=none; b=ad4ViLypLhMFgRggxHA5wAkCLoIqf4PIHmW9s4H7oN8mpSTEXdqcIIkYFllf7Vf+HD0WKh sAsNOj9kr539vdgt8adc5rGHTeA9tYRVie0fq+nKYwFBN/PD7rryKrmbkZwMPPgZT9ktsJ dmKidPAVAj2VAIQUcwpk1Wj1f3b8O7A= Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-3f16b99b990so23356465e9.0 for ; Tue, 18 Apr 2023 08:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681832959; x=1684424959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bb9irq9nW0pE8CSgWK7K74C7UlngMlVehaGXPHyB9ic=; b=ntPGEolIZioWsoNupmOxdO7kt9WWHTCzJGRt3JeOtVCC+SVzkwa/NyZv9ukI232TBR /SaCFFfiuP+yU+Tf4o6hIp9U3tMU7b5AGvSvrrMr/kY7AUvOlJsfmn/RQNibRrHgleWU Q0at44oFe6V5iGpVwBJFEZ3d5+4yn9KmVpC5vgqz7XRwVwkxwq8sWQ2UENZIsQIky+JT qXGN3nxRBzi/n1aZEOK/lypItYhx6fff2XHtr4sPyCmoOrbTguhoA2ytCDf6KlYdpsSq cW2A33nEC11LJt6wWbm/o8z0hOIUZVu16DMDL5s3z6+SJ06YGDg5S72COZQ6YFGJuGon x+uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681832959; x=1684424959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bb9irq9nW0pE8CSgWK7K74C7UlngMlVehaGXPHyB9ic=; b=VBxWWScTY3EMJG3Rizfug3cNWYoXIarhRPosQYYrc97bZyx+k/rbakzKD3h1DC4ePl cMMnZhtX5+6huuJz5EvUYhYOHFARMKgMA2cRhEGqvK53f7X0a5bwmqzUcttDS6dQQwFW 9MxJD5H4lYQBrHopREcOzPb5pAoejPNk/Bk1sCUicO1VMrtuJheXt+f01UMgOtWPnptU zWD8tFuQ5Fcyw2evFCi9LlE3d84fVC/Of3Sp/ibZj7vMohc/ugHqxydF9Bdg3MP8JS9Q HKZ0nK1cnRjqAPs5aAHA9Dzbh5tEWZGiUMXVpPzjjHQFl6ODKBlS01lXHkdi717OeUHx w6qw== X-Gm-Message-State: AAQBX9dhpZdvzQZoWEVesVwER94s6+GZ7EYvlqklC8dxT3rgJNeluMi4 6kj/fvJy9JyC/J/2zVLCyIxMjgRJTzT8+g== X-Google-Smtp-Source: AKy350aikpx9A03wx1BpHW1zS7E+sdV29dDZkTBMa7IL0AbouX1s8BmVCcsrkL1ZD5YHaD7cPB+wCQ== X-Received: by 2002:a5d:5001:0:b0:2d1:e517:4992 with SMTP id e1-20020a5d5001000000b002d1e5174992mr2266976wrt.69.1681832958700; Tue, 18 Apr 2023 08:49:18 -0700 (PDT) Received: from lucifer.home (host86-156-84-164.range86-156.btcentralplus.com. [86.156.84.164]) by smtp.googlemail.com with ESMTPSA id z16-20020a5d4c90000000b002c7163660a9sm13381191wrs.105.2023.04.18.08.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 08:49:18 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Cc: Matthew Wilcox , David Hildenbrand , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Mauro Carvalho Chehab , "Michael S . Tsirkin" , Jason Wang , Jens Axboe , Pavel Begunkov , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, netdev@vger.kernel.org, io-uring@vger.kernel.org, bpf@vger.kernel.org, Lorenzo Stoakes Subject: [PATCH v4 5/6] mm/gup: remove vmas parameter from pin_user_pages() Date: Tue, 18 Apr 2023 16:49:14 +0100 Message-Id: <765b2fdba141b40f72d389e942286456bf5c9f7c.1681831798.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8CC294001E X-Stat-Signature: eqmosacysgfhdr75gf5x145tim7qy5a1 X-Rspam-User: X-HE-Tag: 1681832960-69984 X-HE-Meta: U2FsdGVkX1+4AtyUiuqB5WsTlwdglyzRA26gGjpL2b0DM72cUouPJW1Uujw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ilYprx+Rd3c1NubKjdVE5HmmJEJ0FKpX6+R3ysV44g/RUyw3hxyP9vV6KLVfQBbsA/gAz2fgEDShP4jXV4aCdJaL0W72KXoOedUyumNEDCoBVKp85Q8MXQrtRCkaKnPxD6aXrKCS8XChK8zyXN2+QBuVCjmQiutGjoc/crWiRCHZsRc7CoQ+6AiNnqxGKiQNy4Ve7/pRFYYj5Y60rs0OkrSig2Y96Dsu/LSJHT3V9TebiwhgU4BtNKDxhh/KFBnNr9dBOno21q93v+xvSDOlQ0O0yyhtdzTlrKnPe5NUXwAD8s5RgzjgoekJxdv10FOI8ZOBHcO/Og704hprRdbyTu5IcVcvlldsgOoxHXLHHFg6rlRDOJ/ecx84AB9uGMv1/ifFyc9EdMIGpGjFKLtN/YTstXjELFUaQ63OycLcF9YibWih1B7oTJUBuo+adpOG7YYWxyCsk9LumbwhNazsWSQEyIHDAw08aU39pk5+9HBiqECj2wDUA7XvATszkulDzKR0Le6tLILfWnE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We are now in a position where no caller of pin_user_pages() requires the vmas parameter at all, so eliminate this parameter from the function and all callers. This clears the way to removing the vmas parameter from GUP altogether. Acked-by: David Hildenbrand Acked-by: Dennis Dalessandro (for qib) Signed-off-by: Lorenzo Stoakes --- arch/powerpc/mm/book3s64/iommu_api.c | 2 +- drivers/infiniband/hw/qib/qib_user_pages.c | 2 +- drivers/infiniband/hw/usnic/usnic_uiom.c | 2 +- drivers/infiniband/sw/siw/siw_mem.c | 2 +- drivers/media/v4l2-core/videobuf-dma-sg.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vhost/vdpa.c | 2 +- include/linux/mm.h | 3 +-- io_uring/rsrc.c | 4 +--- mm/gup.c | 9 +++------ mm/gup_test.c | 9 ++++----- net/xdp/xdp_umem.c | 2 +- 12 files changed, 17 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/mm/book3s64/iommu_api.c b/arch/powerpc/mm/book3s64/iommu_api.c index 81d7185e2ae8..d19fb1f3007d 100644 --- a/arch/powerpc/mm/book3s64/iommu_api.c +++ b/arch/powerpc/mm/book3s64/iommu_api.c @@ -105,7 +105,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, ret = pin_user_pages(ua + (entry << PAGE_SHIFT), n, FOLL_WRITE | FOLL_LONGTERM, - mem->hpages + entry, NULL); + mem->hpages + entry); if (ret == n) { pinned += n; continue; diff --git a/drivers/infiniband/hw/qib/qib_user_pages.c b/drivers/infiniband/hw/qib/qib_user_pages.c index f693bc753b6b..1bb7507325bc 100644 --- a/drivers/infiniband/hw/qib/qib_user_pages.c +++ b/drivers/infiniband/hw/qib/qib_user_pages.c @@ -111,7 +111,7 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages, ret = pin_user_pages(start_page + got * PAGE_SIZE, num_pages - got, FOLL_LONGTERM | FOLL_WRITE, - p + got, NULL); + p + got); if (ret < 0) { mmap_read_unlock(current->mm); goto bail_release; diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c index 2a5cac2658ec..84e0f41e7dfa 100644 --- a/drivers/infiniband/hw/usnic/usnic_uiom.c +++ b/drivers/infiniband/hw/usnic/usnic_uiom.c @@ -140,7 +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, page_list, NULL); + gup_flags, page_list); if (ret < 0) goto out; diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c index f51ab2ccf151..e6e25f15567d 100644 --- a/drivers/infiniband/sw/siw/siw_mem.c +++ b/drivers/infiniband/sw/siw/siw_mem.c @@ -422,7 +422,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) umem->page_chunk[i].plist = plist; while (nents) { rv = pin_user_pages(first_page_va, nents, foll_flags, - plist, NULL); + plist); if (rv < 0) goto out_sem_up; diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c index 53001532e8e3..405b89ea1054 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -180,7 +180,7 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, data, size, dma->nr_pages); err = pin_user_pages(data & PAGE_MASK, dma->nr_pages, gup_flags, - dma->pages, NULL); + dma->pages); if (err != dma->nr_pages) { dma->nr_pages = (err >= 0) ? err : 0; diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 0c3b48616a9f..1f80254604f0 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -995,7 +995,7 @@ static int vduse_dev_reg_umem(struct vduse_dev *dev, goto out; pinned = pin_user_pages(uaddr, npages, FOLL_LONGTERM | FOLL_WRITE, - page_list, NULL); + page_list); if (pinned != npages) { ret = pinned < 0 ? pinned : -ENOMEM; goto out; diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 7be9d9d8f01c..4317128c1c62 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -952,7 +952,7 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, while (npages) { sz2pin = min_t(unsigned long, npages, list_size); pinned = pin_user_pages(cur_base, sz2pin, - gup_flags, page_list, NULL); + gup_flags, page_list); if (sz2pin != pinned) { if (pinned < 0) { ret = pinned; diff --git a/include/linux/mm.h b/include/linux/mm.h index 0c236e2f25e2..d02c42d37bfc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2410,8 +2410,7 @@ static inline struct page *get_user_page_vma_remote(struct mm_struct *mm, long get_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages); long pin_user_pages(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - struct vm_area_struct **vmas); + unsigned int gup_flags, struct page **pages); long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags); long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 3a927df9d913..82d90b97c17b 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -1180,10 +1180,8 @@ struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages) ret = 0; mmap_read_lock(current->mm); - pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM, - pages, NULL); - + pages); if (pret == nr_pages) { ret = check_vmas_locked(ubuf, len); *npages = nr_pages; diff --git a/mm/gup.c b/mm/gup.c index 9440aa54c741..dffbfa623aae 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3124,8 +3124,6 @@ EXPORT_SYMBOL(pin_user_pages_remote); * @gup_flags: flags modifying lookup behaviour * @pages: array that receives pointers to the pages pinned. * Should be at least nr_pages long. - * @vmas: array of pointers to vmas corresponding to each page. - * Or NULL if the caller does not require them. * * Nearly the same as get_user_pages(), except that FOLL_TOUCH is not set, and * FOLL_PIN is set. @@ -3134,15 +3132,14 @@ EXPORT_SYMBOL(pin_user_pages_remote); * see Documentation/core-api/pin_user_pages.rst for details. */ long pin_user_pages(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - struct vm_area_struct **vmas) + unsigned int gup_flags, struct page **pages) { int locked = 1; - if (!is_valid_gup_args(pages, vmas, NULL, &gup_flags, FOLL_PIN)) + if (!is_valid_gup_args(pages, NULL, NULL, &gup_flags, FOLL_PIN)) return 0; return __gup_longterm_locked(current->mm, start, nr_pages, - pages, vmas, &locked, gup_flags); + pages, NULL, &locked, gup_flags); } EXPORT_SYMBOL(pin_user_pages); diff --git a/mm/gup_test.c b/mm/gup_test.c index 9ba8ea23f84e..1668ce0e0783 100644 --- a/mm/gup_test.c +++ b/mm/gup_test.c @@ -146,18 +146,17 @@ static int __gup_test_ioctl(unsigned int cmd, pages + i); break; case PIN_BASIC_TEST: - nr = pin_user_pages(addr, nr, gup->gup_flags, pages + i, - NULL); + nr = pin_user_pages(addr, nr, gup->gup_flags, pages + i); break; case PIN_LONGTERM_BENCHMARK: nr = pin_user_pages(addr, nr, gup->gup_flags | FOLL_LONGTERM, - pages + i, NULL); + pages + i); break; case DUMP_USER_PAGES_TEST: if (gup->test_flags & GUP_TEST_FLAG_DUMP_PAGES_USE_PIN) nr = pin_user_pages(addr, nr, gup->gup_flags, - pages + i, NULL); + pages + i); else nr = get_user_pages(addr, nr, gup->gup_flags, pages + i); @@ -270,7 +269,7 @@ static inline int pin_longterm_test_start(unsigned long arg) gup_flags, pages); else cur_pages = pin_user_pages(addr, remaining_pages, - gup_flags, pages, NULL); + gup_flags, pages); if (cur_pages < 0) { pin_longterm_test_stop(); ret = cur_pages; diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 02207e852d79..06cead2b8e34 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -103,7 +103,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address) mmap_read_lock(current->mm); npgs = pin_user_pages(address, umem->npgs, - gup_flags | FOLL_LONGTERM, &umem->pgs[0], NULL); + gup_flags | FOLL_LONGTERM, &umem->pgs[0]); mmap_read_unlock(current->mm); if (npgs != umem->npgs) {