Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1674136ybj; Wed, 6 May 2020 03:10:51 -0700 (PDT) X-Google-Smtp-Source: APiQypJGvh2Drds6qIsfxJiVeRAuFm/W5tYh3aZs3PN5gqrNCEbLpmjQSccV5r+ZX3Hmeq5gmOXy X-Received: by 2002:aa7:c1ca:: with SMTP id d10mr6312914edp.152.1588759850901; Wed, 06 May 2020 03:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588759850; cv=none; d=google.com; s=arc-20160816; b=hKDeIhbAj5w6OPoX6PgpdJrxA+0+Y9t5M3sBmvkcsGNLXzPG55/xmrbMpL+UBycLlB 6vEeh15jrKBwuRsiM2QrciS33qWByZ/Cyu2FIj5xE3aFtiszAEz8r183SfMZ1zNnbcwJ hLjLjQt8L2iSYeLCyiM3F+Wcj3isFxmrHdXzKK1gU/dsqV54uycJR2kwoVRGP/yi8OHC cDKLl5Rsbp4eW5bzOGLIwp7ctF5O3S9RoRcqbDjJmtHeVuzxPjFCxPGXk1Gb8cNSm6Bx qJoF2EW/Dq5ZZkbPBdk2Z8hKLGGFRgLrkUr3R4i5/F1a/7QoOX2WBYAzXu/v5Jedl8H5 5bLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gI6wSS8MAguGMN89xvHhixIchAhfdlb12aVJXQ21S5Y=; b=wEVoxSsRGd8S85VUcsUHWVxxR9+3p54FubI15i+zukTgGY8dfcFnWTkim2Xgn5zzdT eFLg4SxA3OkoEUGRfvnxpXSSzGF7KNSG37hKIhwLHKd8KCOwyWH7LM5UnbUaWym6gLX8 48SHLQDZ+B4mT2OWN+xcItmsUlmm8F1lAqssggb4osKFhiBhkevO1mzxsbQULPitFZz/ KW2EZNbVuIvc1qarTPyeQXAU90GypyWUau1RkGqrJ1/X0NM4qMNhduC+ucA5OnvVY5Y+ 28ZNdmNncC55j/yUGAFxW9OXg1l0aFm6cm9KKl2IRewaI7zF1z+FIUhInWBD5rU/e4l7 y7BQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si696782eds.63.2020.05.06.03.10.27; Wed, 06 May 2020 03:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729194AbgEFKGx (ORCPT + 99 others); Wed, 6 May 2020 06:06:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:53192 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbgEFKGx (ORCPT ); Wed, 6 May 2020 06:06:53 -0400 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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