Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3442887pxb; Thu, 10 Feb 2022 22:54:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4L1WP0TbuaOYNcRuajWMiVysNBw8lRd27Z2b3B2gY2ogrmTxq0xLyzXHW8U5e78F8vTrn X-Received: by 2002:a50:fc86:: with SMTP id f6mr406565edq.176.1644562448399; Thu, 10 Feb 2022 22:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644562448; cv=none; d=google.com; s=arc-20160816; b=LEQTEmjR5OlXo/No8EGK8mqdIwZY8qG7d1Shh3b21fy/x1yNY8gzhfCk+EGFqfE2Us S7+bn6v1jLaLQwkurvkqA3d/qo0M03/1H8f82/oe1wGr+kqCP84lNniEThxULFtnMuo8 8KRszOKOrWCLjtUOFREr4u2Cso0HZLYPgrZnNHgDWpd6EqF7UlDs1Gi74EyqyQq7l02s 69qPMmQZZAb8KZflua1BsFJIDtQM52Ist0p1MXwElPp0ltfH9jXdYeQ2lu19yHD/cCVt HVH1EbjyCimrhDT7wlSKGYnaV/XfGF8/yemkLLryLdo7Zmt6V8w7klsaGbeC3df0vjvm B3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=JEtaSIPUmwPMEbht/8GtpdgCpAImz37J+lOV4wPhprY=; b=qKpjLs86uD3hcV0jRGtEeBd5ChswOInGpHabqOk+opuj6j1ODjyDOxrHeU1nba3r3a AuAGE7Jz9wnuaP3Rhr+BfY6KQF+WqoUTafNo1DKyEg2zUghuYLDUBzxo3RlsNFtD15WC 3KUbCmWajIZjV7Yvo1n3zRHBasbq3ujjCu6Xq+84rHCgqsl1PYRYqq28lFOYo+Tt2K7b 54+du50wkn7hwzoQ0M55RFyecGZ2zB0HlNNd0CHOx/dzeUYYH3FWqksvoSq00+/CXAyl gg71LVJ6EbYG92vjtp+w47P8WhHchF/6hCFfRrT3PHKF7ZRq27Tv0kDvyo+if2uyCFQS bt5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aUPjrbgO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di2si9392100ejc.796.2022.02.10.22.53.43; Thu, 10 Feb 2022 22:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aUPjrbgO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344025AbiBJT37 (ORCPT + 99 others); Thu, 10 Feb 2022 14:29:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241448AbiBJT36 (ORCPT ); Thu, 10 Feb 2022 14:29:58 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2ABD62 for ; Thu, 10 Feb 2022 11:29:59 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so6564973pjh.3 for ; Thu, 10 Feb 2022 11:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JEtaSIPUmwPMEbht/8GtpdgCpAImz37J+lOV4wPhprY=; b=aUPjrbgO33gzzmshctnoKvqOJvUxoWLMN42XPnz4Vokls/etwnpBR1+icvCJ7InEKU yA+FswwCL3wJSPkXrnkU9/XqlprHFyMpdCVZsa3Za/szdtUQHgmgxTGZnS85bd4+DjT3 nMVP1gXBZss6DtZYothTZlr4WSTHL6uTxqdjhU73IlnN7LFYkW4efH1OryuNDt2Xe9i3 Ngh5ATcsKtuiyfmCAi1oHmoUx1NGabGWWHDJd+9n+2R4JI77QCh192SfMDwH9yFiFs4Q JAcpdNNN+jQaDOHnFs6fNsSN0mDWDL3yyaEOBKLWrJAKXtOQi5GY3dm/A0mCMk3yRXho l0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=JEtaSIPUmwPMEbht/8GtpdgCpAImz37J+lOV4wPhprY=; b=1VzOAfgKLdlv2rdhECNjf6irQy2bNk3t5EqspGqh+18Cw/AGSrwmYAVYftbyjWwCNb p4ns/kjjIyzyxyfwo0TrFXAusj2qFeCQzc2sPQeP4PzrRL1MBEsgrpCgP7eixkAgRkhw eOYeoFzvLa1ijbGPNNbKl0cc/Jb+wBaGwZkraaCXXZIxj5H4PHq1N+EkdAL7a83VAwlO 1Y/TNbYh5ASiQqqy9Be7murHItruO/8no2JW49NOdspnHRUgKH2psSOBWQJeKs/4E7Ss Ph4HvWXa/Yt5LLGMRvAalmnfPeHxOsGXjyIDOXOrJ+icFUqQitfazM89p+Xtp0pLTCvd 3SZg== X-Gm-Message-State: AOAM532jIWACo4ehlE6H7W0+BaJHh65vqTHyIGD4SwM8Xv3z7ksOYXWx BqpkZyudB3Accm0Pg3dPGPE= X-Received: by 2002:a17:902:c702:: with SMTP id p2mr9003202plp.37.1644521398357; Thu, 10 Feb 2022 11:29:58 -0800 (PST) Received: from google.com ([2620:15c:211:201:4c8c:3496:9911:5b66]) by smtp.gmail.com with ESMTPSA id r7sm11913794pgv.15.2022.02.10.11.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:29:58 -0800 (PST) Sender: Minchan Kim Date: Thu, 10 Feb 2022 11:29:56 -0800 From: Minchan Kim To: John Hubbard Cc: linux-mm , LKML Subject: Re: pin_user_pages supports NULL pages arguments? Message-ID: References: <7b19b521-01cf-fafb-e616-21deced2cd5b@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7b19b521-01cf-fafb-e616-21deced2cd5b@nvidia.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 10, 2022 at 11:20:31AM -0800, John Hubbard wrote: > On 2/10/22 11:17, Minchan Kim wrote: > > * pin_user_pages() - pin user pages in memory for use by other devices > > < snip > > > * @pages: array that receives pointers to the pages pinned. > > * Should be at least nr_pages long. Or NULL, if caller > > * only intends to ensure the pages are faulted in. > > > > pin_user_pages(,, pages = NULL, ); > > gup_flags |= FOLL_PIN > > __get_user_pages_locked > > __get_user_pages > > .. > > VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN))); > > Only FOLL_GET or FOLL_PIN are supposed to fill in the **pages array. So > if a caller passes a null **pages arg, then that caller must not also > set FOLL_GET or FOLL_PIN. That's what the VM_BUG_ON() is expressing. Yub, but pin_user_pages adds FOLL_PIN unconditinally and the comments says it supports NUU pages argument. Isn't it conflict? > > Perhaps that should be part of the documentation. It sort of is already, > for get_user_pages*(). I expected it was just copied from get_user_pages.