From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD580C433EF for ; Thu, 10 Feb 2022 21:17:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4D9D6B0074; Thu, 10 Feb 2022 16:17:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD5EC6B0075; Thu, 10 Feb 2022 16:17:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A50466B0078; Thu, 10 Feb 2022 16:17:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 8FED36B0074 for ; Thu, 10 Feb 2022 16:17:10 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4FE06894A2 for ; Thu, 10 Feb 2022 21:17:10 +0000 (UTC) X-FDA: 79128130620.29.856E160 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf29.hostedemail.com (Postfix) with ESMTP id CB618120005 for ; Thu, 10 Feb 2022 21:17:09 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id h14-20020a17090a130e00b001b88991a305so9882544pja.3 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=T6YrRofucP/efcyHMHAienJR7+RMuv2vlHSjSt86OX3BlXlX1086LOBv7kOQGjyfjp zfhMFJJJiobbdq6zd/taZrUHwG3XT83p6iGVXcZnP3lbYDFAmynk0gBi/NmVH4tQj+vi 7tcLtoWidh8DIy6gYv4xPhigCKYWhN/fn2Zn8QmEp62Vidv6yKcsAJZ689cBXj0+dihn uR9ALJQb61P1E1ABnEHiyOW19XeLsP8RLc3GvkF9iqJOsaxiDwDZ0/LgDmWn7Kv7yzZr CJ3UK/AkDWwOUD5++4FGdxXkVR7aJlzW2uGV/tne79QhcJzD6XxKxAt7lZfNmI+0DJvY 4K2A== X-Gm-Message-State: AOAM530YGTD0vxzQXSit33BCCu0gKPxnpXfvATJ7CS8cEzwSCL05qLZb PCbkdqBUylGxzKyikc+rs1g= X-Google-Smtp-Source: ABdhPJzbDUswAcBLWyy+uZdpy13ki7D3sk4jsS4Arwzqmj3OZfvVw0yCLk+VkNvkHyoiEELbzXsLnQ== 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) 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: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=q0RzZLGm; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf29.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: hzmx1b3jjr1zen6n31w7ixquu78bgi6k X-Rspamd-Queue-Id: CB618120005 X-HE-Tag: 1644527829-274999 X-Bogosity: Ham, tests=bogofilter, spamicity=0.187004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.