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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33D07C2D0C4 for ; Tue, 10 Dec 2019 10:28:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 014322053B for ; Tue, 10 Dec 2019 10:28:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 014322053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8EBC26B2BCF; Tue, 10 Dec 2019 05:28:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 873D76B2BD0; Tue, 10 Dec 2019 05:28:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73C206B2BD1; Tue, 10 Dec 2019 05:28:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 5AEB86B2BCF for ; Tue, 10 Dec 2019 05:28:23 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id E9466180AD81D for ; Tue, 10 Dec 2019 10:28:22 +0000 (UTC) X-FDA: 76248857244.14.lunch99_6639843cde104 X-HE-Tag: lunch99_6639843cde104 X-Filterd-Recvd-Size: 4150 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 10:28:22 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 769B2B280; Tue, 10 Dec 2019 10:28:20 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id E89EB1E0B23; Tue, 10 Dec 2019 11:28:18 +0100 (CET) Date: Tue, 10 Dec 2019 11:28:18 +0100 From: Jan Kara To: John Hubbard Cc: Andrew Morton , Al Viro , Alex Williamson , Benjamin Herrenschmidt , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Christoph Hellwig , Dan Williams , Daniel Vetter , Dave Chinner , David Airlie , "David S . Miller" , Ira Weiny , Jan Kara , Jason Gunthorpe , Jens Axboe , Jonathan Corbet , =?iso-8859-1?B?Suly9G1l?= Glisse , Magnus Karlsson , Mauro Carvalho Chehab , Michael Ellerman , Michal Hocko , Mike Kravetz , Paul Mackerras , Shuah Khan , Vlastimil Babka , bpf@vger.kernel.org, dri-devel@lists.freedesktop.org, kvm@vger.kernel.org, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, linux-mm@kvack.org, LKML , Christoph Hellwig , Leon Romanovsky Subject: Re: [PATCH v8 08/26] mm/gup: allow FOLL_FORCE for get_user_pages_fast() Message-ID: <20191210102818.GF1551@quack2.suse.cz> References: <20191209225344.99740-1-jhubbard@nvidia.com> <20191209225344.99740-9-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191209225344.99740-9-jhubbard@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Mon 09-12-19 14:53:26, John Hubbard wrote: > Commit 817be129e6f2 ("mm: validate get_user_pages_fast flags") allowed > only FOLL_WRITE and FOLL_LONGTERM to be passed to get_user_pages_fast(). > This, combined with the fact that get_user_pages_fast() falls back to > "slow gup", which *does* accept FOLL_FORCE, leads to an odd situation: > if you need FOLL_FORCE, you cannot call get_user_pages_fast(). > > There does not appear to be any reason for filtering out FOLL_FORCE. > There is nothing in the _fast() implementation that requires that we > avoid writing to the pages. So it appears to have been an oversight. > > Fix by allowing FOLL_FORCE to be set for get_user_pages_fast(). > > Fixes: 817be129e6f2 ("mm: validate get_user_pages_fast flags") > Cc: Christoph Hellwig > Reviewed-by: Leon Romanovsky > Signed-off-by: John Hubbard Looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > mm/gup.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/gup.c b/mm/gup.c > index c0c56888e7cc..958ab0757389 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2414,7 +2414,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, > unsigned long addr, len, end; > int nr = 0, ret = 0; > > - if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM))) > + if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM | > + FOLL_FORCE))) > return -EINVAL; > > start = untagged_addr(start) & PAGE_MASK; > -- > 2.24.0 > -- Jan Kara SUSE Labs, CR