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 35A8CC77B7F for ; Tue, 16 May 2023 22:02:46 +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:Mime-Version:References:In-Reply-To: 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=Bdhuoj9sXc3hn4jmdYMtLvMvnIuPbSCxWl+unOFNhHo=; b=3qkhsfAXlkguBe 7wa6ETMN5WbQlZ1TcW71NZWtOBhKEMSeaaUuqKrt3aT82cYCFU6Z5QdYZON1MkPc3dcf2eorjhJJj uY9HD47QGTVN5MzivXdl46PaATiR+tCKBj4FWReC1SRLqMcHrbIk6NbLMFgfRlIR0sr+CgF46rs8b 5Xp1xb20G3+T8u38oG92vTtvC++GwCVrRD8CztwbHYGHIJ0SygyXpbhxs45Qxplw84bhDC8GZkF/i /R4agHJSA7iIRSJxXDRPfHnawxEfjl0VLXm1BexxZ8gBNOp1NVUBjbjpBnReQXnj8jo+Yi31T3lS7 +4B0YX32uL4/cEV1CxcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pz2kR-007FkW-31; Tue, 16 May 2023 22:02:23 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pz2kP-007Fjj-0b for linux-arm-kernel@lists.infradead.org; Tue, 16 May 2023 22:02:22 +0000 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 B581E6357B; Tue, 16 May 2023 22:02:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C90F7C433EF; Tue, 16 May 2023 22:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1684274540; bh=Xn5gFOegvDQoAs6fV+QPMtWJd/9gIN1gu+8PHj8jATQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=I8HmcSl3RSMNgObVi4nyzA8Dn0pIVn3Hyd4M9+6+jiCnOIEHPDAD1katsykkWAiMa gn5fQMZJ0CFmK2NC9H7JKcNfD2tVhwbbUSeGJQe61+ttSYu+uB1762WRf9rvoaH/7u R2FZf07p1aiooDIDhn5t28F6IgINIJ5khA8X4Fo4= Date: Tue, 16 May 2023 15:02:18 -0700 From: Andrew Morton To: Anders Roxell Cc: Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, 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: <20230516150218.477c5e9d0a2d9ef8b057069c@linux-foundation.org> In-Reply-To: <20230516094919.GA411@mutt> References: <20230516094919.GA411@mutt> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230516_150221_324174_A9ECC778 X-CRM114-Status: GOOD ( 29.69 ) 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 Tue, 16 May 2023 11:49:19 +0200 Anders Roxell wrote: > 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. > > > > - 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; > | ^~~ Thanks, I did the obvious. Also s/ret/res/, as `ret' is kinda reserved for "this is what this function will return". --- a/mm/memory.c~mm-gup-remove-vmas-parameter-from-get_user_pages_remote-fix +++ a/mm/memory.c @@ -5605,11 +5605,11 @@ int __access_remote_vm(struct mm_struct gup_flags, &vma); if (IS_ERR_OR_NULL(page)) { - int ret = 0; - #ifndef CONFIG_HAVE_IOREMAP_PROT break; #else + int res = 0; + /* * Check if this is a VM_IO | VM_PFNMAP VMA, which * we can access using slightly different code. @@ -5617,11 +5617,11 @@ int __access_remote_vm(struct mm_struct if (!vma) break; if (vma->vm_ops && vma->vm_ops->access) - ret = vma->vm_ops->access(vma, addr, buf, + res = vma->vm_ops->access(vma, addr, buf, len, write); - if (ret <= 0) + if (res <= 0) break; - bytes = ret; + bytes = res; #endif } else { bytes = len; _ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel