From mboxrd@z Thu Jan 1 00:00:00 1970 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 587F0C77B76 for ; Sun, 23 Apr 2023 15:13:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E3086B0072; Sun, 23 Apr 2023 11:13:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 392F36B0074; Sun, 23 Apr 2023 11:13:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 233956B0075; Sun, 23 Apr 2023 11:13:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 11C8F6B0072 for ; Sun, 23 Apr 2023 11:13:05 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C8131402A4 for ; Sun, 23 Apr 2023 15:13:04 +0000 (UTC) X-FDA: 80712998688.12.7C03F6B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 0F96516000B for ; Sun, 23 Apr 2023 15:13:01 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BSRWhPBh; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of jarkko@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682262782; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XMjtTK4c2C6iNP6izKtHsTT1Azwf6BmebLFiGJeLjyI=; b=Np1zw6Ht7xYxlZVSEOAEufe/VWaVqHRZ/10q0UrQivr/ovYVHgVN6pD7LJkH6UMVnYO+zL 5Gs425v1Wne0UD+TY32mr8QfaL5Ii9+JMhHotDxnWGwzHqwAX/tQaCwF1sI9wc3/uivc7X VZi7midW3EbjL0q6cmeMohf5pYXZKP8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BSRWhPBh; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of jarkko@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682262782; a=rsa-sha256; cv=none; b=fC87oBacc+Jbq1IiBm9D3QYTVvW7/TI8SPUot2XAhEyPEjKnZeLDJ5FZxNu0lkEgH8QGqe 04C9zz/pKHSj6cbr6+DHkSwa/oQSn0hSScn0WoEFHwr2EU5u8fCupAouOI0U0PPMQIKgHz GNiqVraHE0b5zFxDaNvte1FqzDw6rd8= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 070AF60C89; Sun, 23 Apr 2023 15:13:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B041C433D2; Sun, 23 Apr 2023 15:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682262780; bh=AG9DJZKb5AXH2c0az9/0UlHgvcR2b85u+6yXwdK30HQ=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=BSRWhPBhfSM03HuvQb+y4p1ndshuPczQ3mHWCR+WA4fQ5nDNHEaWh8JqgK5D3rkgS 2DJE+sYAWgM0a7xj8Zx4jYjguuU6825y+HjVRV1Qc9UkEnOBFaEfBcNUrWXU+y3Qgq kgW7miXSbTIzjbjwUNrjqRDlfyc1qkiU8+MMAfcYBCYgiBwj9Yf/yEONL00FXIYo92 4lcZ6kvGY+DRGol+2jEuvIsw9daS/r8WkkToPoPvxxoLRFeoES9rlKs6l81BxYBjoe ypYWeO+bidGIy58+24pHa7wGcTJLrMzULDe8M2YyuGga4evpEa62pFaO4I76LM18e+ By/mijx/sgvtw== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 23 Apr 2023 18:12:54 +0300 Message-Id: Cc: "Matthew Wilcox" , "David Hildenbrand" , , , , , , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H . Peter Anvin" , "Xinhui Pan" , "David Airlie" , "Daniel Vetter" , "Dimitri Sivanich" , "Arnd Bergmann" , "Greg Kroah-Hartman" , "Paolo Bonzini" , "Jason Gunthorpe" Subject: Re: [PATCH v4 1/6] mm/gup: remove unused vmas parameter from get_user_pages() From: "Jarkko Sakkinen" To: "Lorenzo Stoakes" , , , "Andrew Morton" X-Mailer: aerc 0.14.0 References: In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0F96516000B X-Stat-Signature: 9ntch8xc7i9s1oq1b83w1u4ngu675psc X-HE-Tag: 1682262781-948177 X-HE-Meta: U2FsdGVkX1+S6W2l6+A8DoT43rpaNkASFj/LljNhIkKZHKo8XGrxQ/qVI6i8D9MRcxdsj4hH18xKZ8jJ0ja2QEAemF8F0m1IOgx1UDPqBbAGLFOZT/qBRA8grxGbMtm0uJGOeq+yRXUqvXA5VLzuHJJPO0hnM9oUNI5R5HqKXKBSBEdMtE/ZzzgB007ssII5V4YltbVvbueD5nTkY7hTzsdwv1sfUnU2D6LPEUIWEQDZ8wNdHdyY7EB1j/iAAkRhlv2Vg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LwUUBykMFV/yCXk4aTJ4CZ8v3OM1oNT7NfO1moRPhfR3wWetbYqaSRHByutp3yCyMNSOrzjA/rgLzgJMmRdfDqOmsvk1kM1wz0KcXcbd100BLPYY00cS+FJilw12MFErR8j+314FjWXRCfPGAPbDSB3OxdVWQFsLItP2YQGJgI1h8AVwWiS1HCftWexs6Akq/IGHGXJ9ahVVw5iDfPChM7NK0YHFZhyUAUK8hoJRdvlK82iKXHewGvW3IrW/WTOGdcb0VHlvhSjAXfVo= 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: On Tue Apr 18, 2023 at 6:49 PM EEST, Lorenzo Stoakes wrote: > No invocation of get_user_pages() uses the vmas parameter, so remove > it. > > The GUP API is confusing and caveated. Recent changes have done much to > improve that, however there is more we can do. Exporting vmas is a prime > target as the caller has to be extremely careful to preclude their use > after the mmap_lock has expired or otherwise be left with dangling > pointers. > > Removing the vmas parameter focuses the GUP functions upon their primary > purpose - pinning (and outputting) pages as well as performing the action= s > implied by the input flags. > > This is part of a patch series aiming to remove the vmas parameter > altogether. > > Suggested-by: Matthew Wilcox (Oracle) > Acked-by: Greg Kroah-Hartman > Acked-by: David Hildenbrand > Reviewed-by: Jason Gunthorpe > Signed-off-by: Lorenzo Stoakes > --- > arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- > drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- > drivers/misc/sgi-gru/grufault.c | 2 +- > include/linux/mm.h | 3 +-- > mm/gup.c | 9 +++------ > mm/gup_test.c | 5 ++--- > virt/kvm/kvm_main.c | 2 +- > 7 files changed, 10 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/io= ctl.c > index 21ca0a831b70..5d390df21440 100644 > --- a/arch/x86/kernel/cpu/sgx/ioctl.c > +++ b/arch/x86/kernel/cpu/sgx/ioctl.c > @@ -214,7 +214,7 @@ static int __sgx_encl_add_page(struct sgx_encl *encl, > if (!(vma->vm_flags & VM_MAYEXEC)) > return -EACCES; > =20 > - ret =3D get_user_pages(src, 1, 0, &src_page, NULL); > + ret =3D get_user_pages(src, 1, 0, &src_page); > if (ret < 1) > return -EFAULT; > =20 > diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon= /radeon_ttm.c > index 1e8e287e113c..0597540f0dde 100644 > --- a/drivers/gpu/drm/radeon/radeon_ttm.c > +++ b/drivers/gpu/drm/radeon/radeon_ttm.c > @@ -362,7 +362,7 @@ static int radeon_ttm_tt_pin_userptr(struct ttm_devic= e *bdev, struct ttm_tt *ttm > struct page **pages =3D ttm->pages + pinned; > =20 > r =3D get_user_pages(userptr, num_pages, write ? FOLL_WRITE : 0, > - pages, NULL); > + pages); > if (r < 0) > goto release_pages; > =20 > diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufa= ult.c > index b836936e9747..378cf02a2aa1 100644 > --- a/drivers/misc/sgi-gru/grufault.c > +++ b/drivers/misc/sgi-gru/grufault.c > @@ -185,7 +185,7 @@ static int non_atomic_pte_lookup(struct vm_area_struc= t *vma, > #else > *pageshift =3D PAGE_SHIFT; > #endif > - if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <=3D = 0) > + if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page) <=3D 0) > return -EFAULT; > *paddr =3D page_to_phys(page); > put_page(page); > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 37554b08bb28..b14cc4972d0b 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2380,8 +2380,7 @@ long pin_user_pages_remote(struct mm_struct *mm, > unsigned int gup_flags, struct page **pages, > struct vm_area_struct **vmas, int *locked); > long get_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 pin_user_pages(unsigned long start, unsigned long nr_pages, > unsigned int gup_flags, struct page **pages, > struct vm_area_struct **vmas); > diff --git a/mm/gup.c b/mm/gup.c > index 1f72a717232b..7e454d6b157e 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2251,8 +2251,6 @@ long get_user_pages_remote(struct mm_struct *mm, > * @pages: array that receives pointers to the pages pinned. > * Should be at least nr_pages long. Or NULL, if caller > * only intends to ensure the pages are faulted in. > - * @vmas: array of pointers to vmas corresponding to each page. > - * Or NULL if the caller does not require them. > * > * This is the same as get_user_pages_remote(), just with a less-flexibl= e > * calling convention where we assume that the mm being operated on belo= ngs to > @@ -2260,16 +2258,15 @@ long get_user_pages_remote(struct mm_struct *mm, > * 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, > - struct vm_area_struct **vmas) > + unsigned int gup_flags, struct page **pages) > { > int locked =3D 1; > =20 > - if (!is_valid_gup_args(pages, vmas, NULL, &gup_flags, FOLL_TOUCH)) > + if (!is_valid_gup_args(pages, NULL, NULL, &gup_flags, FOLL_TOUCH)) > return -EINVAL; > =20 > return __get_user_pages_locked(current->mm, start, nr_pages, pages, > - vmas, &locked, gup_flags); > + NULL, &locked, gup_flags); > } > EXPORT_SYMBOL(get_user_pages); > =20 > diff --git a/mm/gup_test.c b/mm/gup_test.c > index 8ae7307a1bb6..9ba8ea23f84e 100644 > --- a/mm/gup_test.c > +++ b/mm/gup_test.c > @@ -139,8 +139,7 @@ static int __gup_test_ioctl(unsigned int cmd, > pages + i); > break; > case GUP_BASIC_TEST: > - nr =3D get_user_pages(addr, nr, gup->gup_flags, pages + i, > - NULL); > + nr =3D get_user_pages(addr, nr, gup->gup_flags, pages + i); > break; > case PIN_FAST_BENCHMARK: > nr =3D pin_user_pages_fast(addr, nr, gup->gup_flags, > @@ -161,7 +160,7 @@ static int __gup_test_ioctl(unsigned int cmd, > pages + i, NULL); > else > nr =3D get_user_pages(addr, nr, gup->gup_flags, > - pages + i, NULL); > + pages + i); > break; > default: > ret =3D -EINVAL; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index d255964ec331..7f31e0a4adb5 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2474,7 +2474,7 @@ static inline int check_user_page_hwpoison(unsigned= long addr) > { > int rc, flags =3D FOLL_HWPOISON | FOLL_WRITE; > =20 > - rc =3D get_user_pages(addr, 1, flags, NULL, NULL); > + rc =3D get_user_pages(addr, 1, flags, NULL); > return rc =3D=3D -EHWPOISON; > } > =20 > --=20 > 2.40.0 Acked-by: Jarkko Sakkinen BR, Jarkko