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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C78CC77B7F for ; Tue, 16 May 2023 09:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oEnZlT6PfE15iKQ2OPHuOi01VEMfMB2FvdwiXvSA5dw=; b=CNMakyno/4ICbu 8ZTJtsa8+4Bcfmnbm6RKHhlxqvyf7u/z7AzcBAP5UbthZlUxe2Selu9YafS3jifLFDXRXBJSdRYEF a5xhzUXKO7YVJddi5kwcdBoEGntfuOxiZqoPVDjHgzrlimCkxbIuo2jnZfde+E2XnIqSVYs8zHs+4 5TQ9xspc6iU4UDMX2xlNe8cY4fsto/sfdiFBq7VqPL98ErMMFdKVh7o94HxO39nzeihrnwSnBTk2B NXxkEL5sDcbgtnLx7ZTNlWf0iicfw3oyOBs7yBRXnRkTdXak2oIJK+16/PRMYJAWNV3+4aCcVQhc+ Zd43HMXh76GIheLjOCEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyrJC-0058RO-21; Tue, 16 May 2023 09:49:30 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyrJ9-0058Oz-0E for linux-arm-kernel@lists.infradead.org; Tue, 16 May 2023 09:49:28 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f24ddf514eso12309551e87.0 for ; Tue, 16 May 2023 02:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684230563; x=1686822563; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ZU/9Bd1F4v4AQI4XYwGvMKtVUVhP+Ta/KlDV/Ofhgvw=; b=DLO9Sp+4W+z5eLJ4OplpY56KL7dsXPxPyKzZN31e24ZgWla/8bs4IkvAtRU1sNrr4d M/zIAUZjhZlW4P2rkk7T+6W0UVsyD90WG+YdGYFrH/Glii/KUDZq0IpUmntg707CdF5n i37UB3Tbbcas87bL0/efYfe6w3ZnC5XyG3qMqn02SGpfBU+8hNkNlrN1nhw2lKAkzq5B CRMAVzp4RUPFc/3/QZ675+4TlLXQLlc1iMNrOb5F/K4RaFPvTUMi9nJBxjhqICMZPBab XEfOKIgxNn+kxSFXUOWAg+ZiVcGCmn7Ho0MHbSwpND8R8HARcto93DQrGrEkUYhsomoF 2BmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684230563; x=1686822563; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZU/9Bd1F4v4AQI4XYwGvMKtVUVhP+Ta/KlDV/Ofhgvw=; b=Y/R/RmwMOZewwOIEyi1UDWp9EfxtZ+HTQwWfmOGc7qeXlpEam9f2VZVugXLdJfCbqZ wAbLJitt9jQc+N9O0rQuBgBDIqVqh4cLHSpQlKk3WTDAoSYoQ5VGjT8khW7YJz5pE37r wEhOULv/R0LquoVw8PSJzXZ5sPOlvxJFVCisWowF2dbTnPqAi9YWPUs9TviUgvabDtrV j839YkNNnGp6yvYOXL9Zj1UxzOaHwqY5T2ZZWeyjo2fyf4OOI21mV0k1maHiAMdFm2E+ X+N/UIGHgPU8PXhmwkdHipjwZQ9rjWmQ4ZZlCO5iZMi14Z6tmh2miU5g8sgxwMnWnflP UXtQ== X-Gm-Message-State: AC+VfDyVlyuOt95kOIY4Bffy5Co8eC7fzI/i44JX4T5Osi8vt4WJqqc8 prZl8MyAH9ROKUVl2Ztiul3SbA== X-Google-Smtp-Source: ACHHUZ4l3TyALRDEaGcVcIkdK7q9mH/ov5OVGGAezktN7u9QG834/IDjSuCD7zTf56ZU9ouww0Hd6Q== X-Received: by 2002:a05:6512:2181:b0:4e8:4a21:9c92 with SMTP id b1-20020a056512218100b004e84a219c92mr7419897lft.4.1684230562687; Tue, 16 May 2023 02:49:22 -0700 (PDT) Received: from mutt (c-9b0ee555.07-21-73746f28.bbcust.telenor.se. [85.229.14.155]) by smtp.gmail.com with ESMTPSA id w11-20020a19c50b000000b004f251cf3d31sm2908003lfe.153.2023.05.16.02.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 02:49:21 -0700 (PDT) Date: Tue, 16 May 2023 11:49:19 +0200 From: Anders Roxell To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Matthew Wilcox , David Hildenbrand , linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-security-module@vger.kernel.org, Catalin Marinas , Will Deacon , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Eric Biederman , Kees Cook , Alexander Viro , Christian Brauner , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kentaro Takeda , Tetsuo Handa , Paul Moore , James Morris , "Serge E . Hallyn" , Paolo Bonzini , Jens Axboe , Pavel Begunkov , Jason Gunthorpe , John Hubbard Subject: Re: [PATCH v5 3/6] mm/gup: remove vmas parameter from get_user_pages_remote() Message-ID: <20230516094919.GA411@mutt> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230516_024927_160988_6496CF7E X-CRM114-Status: GOOD ( 30.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2023-05-14 22:26, Lorenzo Stoakes wrote: > The only instances of get_user_pages_remote() invocations which used the > vmas parameter were for a single page which can instead simply look up the > VMA directly. In particular:- > > - __update_ref_ctr() looked up the VMA but did nothing with it so we simply > remove it. > > - __access_remote_vm() was already using vma_lookup() when the original > lookup failed so by doing the lookup directly this also de-duplicates the > code. > > We are able to perform these VMA operations as we already hold the > mmap_lock in order to be able to call get_user_pages_remote(). > > As part of this work we add get_user_page_vma_remote() which abstracts the > VMA lookup, error handling and decrementing the page reference count should > the VMA lookup fail. > > This forms part of a broader set of patches intended to eliminate the vmas > parameter altogether. > > Reviewed-by: Catalin Marinas (for arm64) > Acked-by: David Hildenbrand > Reviewed-by: Janosch Frank (for s390) > Signed-off-by: Lorenzo Stoakes > --- > arch/arm64/kernel/mte.c | 17 +++++++++-------- > arch/s390/kvm/interrupt.c | 2 +- > fs/exec.c | 2 +- > include/linux/mm.h | 34 +++++++++++++++++++++++++++++++--- > kernel/events/uprobes.c | 13 +++++-------- > mm/gup.c | 12 ++++-------- > mm/memory.c | 14 +++++++------- > mm/rmap.c | 2 +- > security/tomoyo/domain.c | 2 +- > virt/kvm/async_pf.c | 3 +-- > 10 files changed, 61 insertions(+), 40 deletions(-) > [...] > diff --git a/mm/memory.c b/mm/memory.c > index 146bb94764f8..63632a5eafc1 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -5590,7 +5590,6 @@ EXPORT_SYMBOL_GPL(generic_access_phys); > int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, > int len, unsigned int gup_flags) > { > - struct vm_area_struct *vma; > void *old_buf = buf; > int write = gup_flags & FOLL_WRITE; > > @@ -5599,13 +5598,15 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, > > /* ignore errors, just check how much was successfully transferred */ > while (len) { > - int bytes, ret, offset; > + int bytes, offset; > void *maddr; > - struct page *page = NULL; > + struct vm_area_struct *vma; > + struct page *page = get_user_page_vma_remote(mm, addr, > + gup_flags, &vma); > + > + if (IS_ERR_OR_NULL(page)) { > + int ret = 0; I see the warning below when building without CONFIG_HAVE_IOREMAP_PROT set. make --silent --keep-going --jobs=32 \ O=/home/anders/.cache/tuxmake/builds/1244/build ARCH=arm \ CROSS_COMPILE=arm-linux-gnueabihf- /home/anders/src/kernel/next/mm/memory.c: In function '__access_remote_vm': /home/anders/src/kernel/next/mm/memory.c:5608:29: warning: unused variable 'ret' [-Wunused-variable] 5608 | int ret = 0; | ^~~ > > - ret = get_user_pages_remote(mm, addr, 1, > - gup_flags, &page, &vma, NULL); > - if (ret <= 0) { > #ifndef CONFIG_HAVE_IOREMAP_PROT > break; > #else > @@ -5613,7 +5614,6 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, > * Check if this is a VM_IO | VM_PFNMAP VMA, which > * we can access using slightly different code. > */ > - vma = vma_lookup(mm, addr); > if (!vma) > break; > if (vma->vm_ops && vma->vm_ops->access) Cheers, Anders _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel