Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3670435img; Mon, 25 Mar 2019 15:23:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFKln/DNJIemXU16Kal6WiKkVVswICZvjsKTcPtWOLb709RArryWfd3iVnssE31myFXOWC X-Received: by 2002:a65:63cd:: with SMTP id n13mr25980202pgv.193.1553552613486; Mon, 25 Mar 2019 15:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553552613; cv=none; d=google.com; s=arc-20160816; b=qdA+FhsyF2cbxpQQ13Bs/Ybaw+Q5TiHMyiR2P6ziAXCWJUbpqZtDO2bDJ30yQ/5EYY /1dqs2gYjLpid6kE0+vcgGL5HWXDmw7zneXEl5ISJqHRSruN6j3dU5c5X+92lnTY3Elb WQmZI0GLMjMRWmmiJXDMTiweloTLAumpopfTpwIczZpqFfGli4Yjy3XVds3SG1XoyHvD wn3u4vFzPrKPlQP+mXbTcxLFzieK3hFrK9Kt/oV1ZNakHhKBPKoD8Sh3fXJ8JJJXrK9z 2iVVBqoNjLgm//GMGa4jTX/t2I+ZgTmIiSUwgpI/7c/2TQ0UAZjEZrRluyxCBcqGPGJp bwYQ== 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=kBYvYqhG60ETdU1ejGn9ABkj+I7t2tDa9xJt7/kf8fI=; b=VjXbLp0vUPkiZh9g7eUSG0zuO2ImeaAmp1IjS1fSP445d63aeEyAO0d5hcYLsqvkOl SsVam1bKut4xJeLt8rEhPo9EjtMvCxLV2cPfrdKkTGUzTprEowKoBuNq3BSIA7Huzr2p deLxFyTY8B0tq2pdA+BjweZ8UCsKpsHSmwIXVqFvQZbjIkTAdOnKh56ZDypBYp4tVxSy RO2IyTDrGHD89uSpT6o6EzPnE7yBEWSeCkLOrLhzYvLyKSt+PmDPhyfGJlGbx6OIja6i kpmxrwzR4bLgaYXtvTS2IMQ9MHESLsR8/yV9q3dosD4bp3rDGC+6QyFPbCntQrxgtrnf mdbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34si3292528pgb.49.2019.03.25.15.23.18; Mon, 25 Mar 2019 15:23:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730568AbfCYWWh (ORCPT + 99 others); Mon, 25 Mar 2019 18:22:37 -0400 Received: from mga17.intel.com ([192.55.52.151]:34864 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbfCYWWh (ORCPT ); Mon, 25 Mar 2019 18:22:37 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Mar 2019 15:22:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,270,1549958400"; d="scan'208";a="143760397" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by FMSMGA003.fm.intel.com with ESMTP; 25 Mar 2019 15:22:36 -0700 Date: Mon, 25 Mar 2019 07:21:25 -0700 From: Ira Weiny To: Jason Gunthorpe Cc: Dan Williams , Andrew Morton , John Hubbard , Michal Hocko , "Kirill A. Shutemov" , Peter Zijlstra , Benjamin Herrenschmidt , Paul Mackerras , "David S. Miller" , Martin Schwidefsky , Heiko Carstens , Rich Felker , Yoshinori Sato , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Ralf Baechle , James Hogan , linux-mm , Linux Kernel Mailing List , linux-mips@vger.kernel.org, linuxppc-dev , linux-s390 , Linux-sh , sparclinux@vger.kernel.org, linux-rdma@vger.kernel.org, "netdev@vger.kernel.org" Subject: Re: [RESEND 4/7] mm/gup: Add FOLL_LONGTERM capability to GUP fast Message-ID: <20190325142125.GH16366@iweiny-DESK2.sc.intel.com> References: <20190317183438.2057-1-ira.weiny@intel.com> <20190317183438.2057-5-ira.weiny@intel.com> <20190325084225.GC16366@iweiny-DESK2.sc.intel.com> <20190325164713.GC9949@ziepe.ca> <20190325092314.GF16366@iweiny-DESK2.sc.intel.com> <20190325175150.GA21008@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325175150.GA21008@ziepe.ca> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 25, 2019 at 02:51:50PM -0300, Jason Gunthorpe wrote: > On Mon, Mar 25, 2019 at 02:23:15AM -0700, Ira Weiny wrote: > > > > Unfortunately holding the lock is required to support FOLL_LONGTERM (to check > > > > the VMAs) but we don't want to hold the lock to be optimal (specifically allow > > > > FAULT_FOLL_ALLOW_RETRY). So I'm maintaining the optimization for *_fast users > > > > who do not specify FOLL_LONGTERM. > > > > > > > > Another way to do this would have been to define __gup_longterm_unlocked with > > > > the above logic, but that seemed overkill at this point. > > > > > > get_user_pages_unlocked() is an exported symbol, shouldn't it work > > > with the FOLL_LONGTERM flag? > > > > > > I think it should even though we have no user.. > > > > > > Otherwise the GUP API just gets more confusing. > > > > I agree WRT to the API. But I think callers of get_user_pages_unlocked() are > > not going to get the behavior they want if they specify FOLL_LONGTERM. > > Oh? Isn't the only thing FOLL_LONGTERM does is block the call on DAX? From an API yes. > Why does the locking mode matter to this test? DAX checks for VMA's being Filesystem DAX. Therefore, it requires collection of VMA's as the GUP code executes. The unlocked version can drop the lock and therefore the VMAs may become invalid. Therefore, the 2 code paths are incompatible. Users of GUP unlocked are going to want the benefit of FAULT_FOLL_ALLOW_RETRY. So I don't anticipate anyone using FOLL_LONGTERM with get_user_pages_unlocked(). FWIW this thread is making me think my original patch which simply implemented get_user_pages_fast_longterm() would be more clear. There is some evidence that the GUP API was trending that way (see get_user_pages_remote). That seems wrong but I don't know how to ensure users don't specify the wrong flag. > > > What I could do is BUG_ON (or just WARN_ON) if unlocked is called with > > FOLL_LONGTERM similar to the code in get_user_pages_locked() which does not > > allow locked and vmas to be passed together: > > The GUP call should fail if you are doing something like this. But I'd > rather not see confusing specialc cases in code without a clear > comment explaining why it has to be there. Code comment would be necessary, sure. Was just throwing ideas out there. Ira