Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2227882ybm; Sun, 31 May 2020 12:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQpHUTEuV5DswH96+lZVVaOC6Xf3mMp3coLI+PuSplNBtieRaC+vCOoD1PlE7SGyXdAobj X-Received: by 2002:a17:906:944c:: with SMTP id z12mr16397194ejx.472.1590955046964; Sun, 31 May 2020 12:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590955046; cv=none; d=google.com; s=arc-20160816; b=XTsDHk9/CZaFdv4TxEafPhPx8ESaBUKxAM6JvGNvovuUVI+49VSHwXjun3cmDjTqaC Cn2rL8XiwmMfs+vAIVlvugqiUC65m6YOGyGpJTmZtO14anUkMtaSlTO+fGJnZB7MZPLS /d/YyzfDfPs5fQv/nZzGrs6kcAj768ghXiuLyx9zNIfFWo0hEBLMJkKDLufF0pCVrvz1 n4/KKH+K39ufMlYLUZQWcLgRp+VmmUXiolCzAYLV6kuf9PDmnFXPhgG1Y5rHjAYxqsSO +1bn1hsIbux5aebEpCm1OmlQE8+jLtYOQpivsDjIDPyeMeJJf1pmOP5ul6ZF5oXoL0QX NVAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=6z/YbkHrZ9dm2YGHFYSzu/H1Xlj5+faKi/stD2aHkKc=; b=Lb9ume1CJkV2OifM4LFu9f4tjWL3fa45wJks890KHYPompQq21mKjuUUff58fWWQCo DdYbSVKHO/DF7qHFNe2RlVu1VlCl/PrwRD9L/d47tdQ/Kdrs8f928JW5JBuz6wctIT1J biw4o0wVGqUnNQ7Z5RfpdFVKGFmBoqjZiNNryLkn3l0SY7hzMqIBZaYBJFTvm5YS5Ezb ziJJmhrGO78wq23Uwqnuew+hN4Azsoi8AAUbesC/KM3dDd+OndBdST5f1Qbv8ExnQtbt 1BbaLshnL1/feV7nxSRe57+Op+a2i4CcSfErJqvTcyQz123+muqcjqC55OaA8GBqopRs KLMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=niSJVFuX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si9759174edv.185.2020.05.31.12.57.03; Sun, 31 May 2020 12:57:26 -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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=niSJVFuX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgEaTwW (ORCPT + 99 others); Sun, 31 May 2020 15:52:22 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:13384 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbgEaTwW (ORCPT ); Sun, 31 May 2020 15:52:22 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 31 May 2020 12:50:56 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Sun, 31 May 2020 12:52:21 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sun, 31 May 2020 12:52:21 -0700 Received: from [10.2.56.10] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 31 May 2020 19:52:21 +0000 Subject: Re: [PATCH 1/2] mm/gup: introduce pin_user_pages_locked() To: Souptick Joarder CC: Andrew Morton , LKML , Linux-MM References: <20200527223243.884385-1-jhubbard@nvidia.com> <20200527223243.884385-2-jhubbard@nvidia.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Sun, 31 May 2020 12:52:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1590954656; bh=6z/YbkHrZ9dm2YGHFYSzu/H1Xlj5+faKi/stD2aHkKc=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=niSJVFuXnA8b/d8oNH3x2buUJqhUh6oEEmS2KE+lFnzt6CdbVqe7eeC9FZpgAWunx 6K5Wy7pSLZFZ/+LjqI7xVFVji2xi3+PQJNhVozOI23fuvG3iFCXN/+3x/nRnPh/SXd 3PXGOfBDR2GenwT/ZidAV3k73EpUSI5H4x8fxrryISuauAFU9H6r9exMkWy9w5ipMk ncAkI+lyhQBMmIh4Nzwx76gfSYMKXTTMNFaQVAnmNeGbt7JKrMFbscNYvP3IhX2qAb FlxzvoThc9xYA/Om9PI9VLJPnkkiarHdRXslLxAHuU9jBrHyTyxW3BLbeU0C622whY 8SNLn598TALkQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-31 00:04, Souptick Joarder wrote: ... >> +/* >> + * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked(). >> + * Behavior is the same, except that this one sets FOLL_PIN and rejects >> + * FOLL_GET. >> + */ >> +long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, >> + unsigned int gup_flags, struct page **pages, >> + int *locked) >> +{ >> + /* >> + * FIXME: Current FOLL_LONGTERM behavior is incompatible with >> + * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on >> + * vmas. As there are no users of this flag in this call we simply >> + * disallow this option for now. >> + */ >> + if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) >> + return -EINVAL; >> + >> + /* FOLL_GET and FOLL_PIN are mutually exclusive. */ >> + if (WARN_ON_ONCE(gup_flags & FOLL_GET)) >> + return -EINVAL; >> + >> + gup_flags |= FOLL_PIN; > > Right now get_user_pages_locked() doesn't have similar check for FOLL_PIN Yes, that should be added... > and also not setting FOLL_GET internally irrespective of gup_flags > passed by user. > Do we need to add the same in get_user_pages_locked() ? ...and no, that should not. Yes, it's prudent to assert that FOLL_PIN is *not* set, at all the get_user_pages*() API calls, thanks for spotting that. I'll add that to this patch and send out a v2. The same check should also be added to get_user_pages_unlocked(). I'll send out a correction (I think just a v3 of that patchset) to add that. The setting of FOLL_GET, on the other hand, is something best left as-is so far. Some call sites set FOLL_GET, some want it *not* set, and some expect that FOLL_GET is implied, and at the moment, the delicate balance is correct. :) thanks, -- John Hubbard NVIDIA