Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3674922pxb; Fri, 11 Feb 2022 05:26:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9TK0heH6E8ueGKuNMspVrYTVBaM0NjwIKD6+MW4nin/ilgbffy7rSeoh0jrAkgMjJ44GM X-Received: by 2002:a17:902:f78c:: with SMTP id q12mr1454549pln.165.1644585973772; Fri, 11 Feb 2022 05:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644585973; cv=none; d=google.com; s=arc-20160816; b=uD+wpVQeJDcESPCT/iVcXg3SOUI0KkCbvkN7Jb5LFFxGrbdlACQipInWaS6TDRy+OE eJ+rQ33sbR0eMrzBMcRdSQBbFq1GQethM+hmgWBmp2C0gUv9herJ8uhVKVup1FiFluyu gwSlFb9NBkuLZt7/E0G2a+7tga6rxPVbW4xxvHDxT2NClOUZkMIlqUOsFkybAAp1l/Z8 4OBNnTw8a3jbhSL9DMHwWruqQc6GREbDqIhwx6Xci5m6cVkn5m6gvFzVdRGH+wTih0Xu hz0Z/ilLcKrzwkM6bRAuooMHPt0bIl0/WrKyX8veU85nMyr4A0qRFw0pRCqG1HS+2yDo WE4g== 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=17Wd9VZDSOB+nZkIHBHopkVTOYm7CGsey4V1v+U3EFs=; b=UEJai80jwEAu8+rztfbNLOnXN4tdIVwm9fQ1GiV1x4MkKjCjAZxG97Xq39NMDgJlpa m9vi3RuSHA2kT40cpLDnExWP+8Mxcbs5Mv2tOQyzGeBIJw4xcxSbiD3ajGw4FlR5Vu5o cm7DPj+oP8rP+oC5XyQGZvbfB+OfUrkSsny8pdwAi9kR4Se6hiO0UBNQYk+exoDLyExg N7r19PpoN8rKSEPCI58M2+W9KtsPD7vVbXqQCn4sfiVmXVrVR9JW9s1A3CyJxFvD6F5H t1hWsBl/fO740ROcN2Q11knvKVY5Bp1nehTWzlrsxjzA3kOyL90F7KuySSH0UgODftTQ iCmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q0RzZLGm; 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 h190si19925628pgc.874.2022.02.11.05.26.00; Fri, 11 Feb 2022 05:26:13 -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=q0RzZLGm; 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 S1344570AbiBJVRL (ORCPT + 99 others); Thu, 10 Feb 2022 16:17:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243233AbiBJVRJ (ORCPT ); Thu, 10 Feb 2022 16:17:09 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B6CB26C5 for ; Thu, 10 Feb 2022 13:17:09 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id q11-20020a17090a304b00b001b94d25eaecso2339574pjl.4 for ; Thu, 10 Feb 2022 13:17:09 -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=17Wd9VZDSOB+nZkIHBHopkVTOYm7CGsey4V1v+U3EFs=; b=q0RzZLGmDnL6quoiqHZ65sqv5PykSXNqdb9+2sQd+vnKa6X5AWyC5haucLs8T/SQHg w9Yw986B5QeJPKSVIpzOwx0WorL40gAdFfaQ1cc0qZ9mNVxxqmpJLAfOitmJDMHHlY5E XW4kxhfZ7pIlpD+h372lZEsHH7XNbSbqXnOcwuMIyIHGzoZMLcw5gq9eaYKfQPOd2UeX c91Z4YhNlHXF1pgTKvBnM4JYoYRwTwhOsWV3H2ScUkBXMZq1gkS5aTSB/U4SLAcdKY5q m+3/7QWCLVweBcLFYLXjRIcZSKRtHlj9O1KRAXSIbLEyFwhXKQ7jEnpPmqnDG2wa2tHy 2NNA== 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=17Wd9VZDSOB+nZkIHBHopkVTOYm7CGsey4V1v+U3EFs=; b=JSDCguhxODtvfDypKJPyx7xvI7F5S+ZV59xrQ4Sg4LanNKEA828OzNrzLThBp6EGl+ uk49GWf4i+W/CLq6nNm7E8A0AxbekL4oJw4lMLpu/vAw4ZXJt1uR+ZcagCq4QyimNsuz zbBso3QRmmAsjYfjncPMN4ysAqo5Z2JCY9rWDgTZfHiETyjcsW9fEt2hNLJcXrdhD3qM 6ztKlw0lk5QW9oTtyEAGwIrmweHzbTawMIAmrvE6Qe83Y96y16xFonCGiCPxDcTmboJ+ GE0K7j66odwOaoABMF8BSMxFMF1HcV1Y3JQys08GEeYgKPZ5DdOtLPOMMbqJz5X/NbB7 Tp9A== X-Gm-Message-State: AOAM531d9qtbgjFq7L/9p15c+fH1VjLGaR6Ghf9JWF361/3MXT3S1XfF QrhxymHCzOkbzdXYwqMrDdDwDQDvpQo= X-Received: by 2002:a17:903:1c4:: with SMTP id e4mr9388727plh.147.1644527828548; Thu, 10 Feb 2022 13:17:08 -0800 (PST) Received: from google.com ([2620:15c:211:201:4c8c:3496:9911:5b66]) by smtp.gmail.com with ESMTPSA id pj8sm3300485pjb.26.2022.02.10.13.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 13:17:08 -0800 (PST) Sender: Minchan Kim Date: Thu, 10 Feb 2022 13:17:06 -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: 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 12:20:47PM -0800, John Hubbard wrote: > On 2/10/22 11:29, Minchan Kim wrote: > > 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? > > > > Oh right, that is a conflict. The documentation should *not* say that a > NULL **pages arg is supported. Because the whole point of the FOLL_PIN > APIs is to actually pin struct pages. The NULL cases are only useful for > get_user_pages*(). > > So removing that last sentence is appropriate, plus also looking around > for similar documentation claims, including in pin_user_pages.rst. I > don't see anything from a very quick scan, though. > > Sending out a fix will also trigger the observation that both the > kerneldoc headers mm/gup.c, and the writings in pin_user_pages.rst, > could use some updating. However, it is also true that this can be > reasonably treated as a documentation bug fix, and therefore allowed to > be limited to just this change. > > Were you going to send out a formal patch? If not, I can include it in > an upcoming gup series, with your Reported-by tag. Up to you. Yes, please. Thank you, John.