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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 E0EAEC38A24 for ; Wed, 6 May 2020 10:06:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B180C20714 for ; Wed, 6 May 2020 10:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B180C20714 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 46A618E0005; Wed, 6 May 2020 06:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41A358E0003; Wed, 6 May 2020 06:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 356948E0005; Wed, 6 May 2020 06:06:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id 1B3DD8E0003 for ; Wed, 6 May 2020 06:06:54 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C78582C8B for ; Wed, 6 May 2020 10:06:53 +0000 (UTC) X-FDA: 76785865506.13.elbow80_5943ecd471b51 X-HE-Tag: elbow80_5943ecd471b51 X-Filterd-Recvd-Size: 3659 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 May 2020 10:06:53 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E1564AF85; Wed, 6 May 2020 10:06:53 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 6FC051E12B1; Wed, 6 May 2020 12:06:49 +0200 (CEST) Date: Wed, 6 May 2020 12:06:49 +0200 From: Jan Kara To: Souptick Joarder Cc: John Hubbard , Tony Luck , fenghua.yu@intel.com, Rob Springer , Todd Poynor , benchan@chromium.org, Greg KH , Jens Wiklander , Andrew Morton , santosh.shilimkar@oracle.com, "David S. Miller" , kuba@kernel.org, Jan Kara , Ira Weiny , =?iso-8859-1?B?Suly9G1l?= Glisse , inux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, "open list:ANDROID DRIVERS" , tee-dev@lists.linaro.org, Linux-MM , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Subject: Re: [RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast() Message-ID: <20200506100649.GI17863@quack2.suse.cz> References: <1588706059-4208-1-git-send-email-jrdr.linux@gmail.com> <0bfe4a8a-0d91-ef9b-066f-2ea7c68571b3@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed 06-05-20 02:06:56, Souptick Joarder wrote: > On Wed, May 6, 2020 at 1:08 AM John Hubbard wrote: > > > > On 2020-05-05 12:14, Souptick Joarder wrote: > > > Currently {get|pin}_user_pages_fast() have 3 return value 0, -errno > > > and no of pinned pages. The only case where these two functions will > > > return 0, is for nr_pages <= 0, which doesn't find a valid use case. > > > But if at all any, then a -ERRNO will be returned instead of 0, which > > > means {get|pin}_user_pages_fast() will have 2 return values -errno & > > > no of pinned pages. > > > > > > Update all the callers which deals with return value 0 accordingly. > > > > Hmmm, seems a little shaky. In order to do this safely, I'd recommend > > first changing gup_fast/pup_fast so so that they return -EINVAL if > > the caller specified nr_pages==0, and of course auditing all callers, > > to ensure that this won't cause problems. > > While auditing it was figured out, there are 5 callers which cares for > return value > 0 of gup_fast/pup_fast. What problem it might cause if we change > gup_fast/pup_fast > to return -EINVAL and update all the callers in a single commit ? Well, first I'd ask a different question: Why do you want to change the current behavior? It's not like the current behavior is confusing. Callers that pass >0 pages can happily rely on the simple behavior of < 0 return on error or > 0 return if we mapped some pages. Callers that can possibly ask to map 0 pages can get 0 pages back - kind of expected - and I don't see any benefit in trying to rewrite these callers to handle -EINVAL instead... Honza -- Jan Kara SUSE Labs, CR