lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2b0656a2-3402-f376-7440-481124485bde@nvidia.com>
Date:   Wed, 5 Feb 2020 15:58:53 -0800
From:   John Hubbard <jhubbard@...dia.com>
To:     "Kirill A. Shutemov" <kirill@...temov.name>
CC:     Andrew Morton <akpm@...ux-foundation.org>,
        Al Viro <viro@...iv.linux.org.uk>,
        Christoph Hellwig <hch@...radead.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Dave Chinner <david@...morbit.com>,
        Ira Weiny <ira.weiny@...el.com>, Jan Kara <jack@...e.cz>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Jonathan Corbet <corbet@....net>,
        Jérôme Glisse <jglisse@...hat.com>,
        Michal Hocko <mhocko@...e.com>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Shuah Khan <shuah@...nel.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Matthew Wilcox <willy@...radead.org>,
        <linux-doc@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
        <linux-kselftest@...r.kernel.org>, <linux-rdma@...r.kernel.org>,
        <linux-mm@...ck.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 10/12] mm/gup: /proc/vmstat: pin_user_pages (FOLL_PIN)
 reporting

On 2/5/20 3:43 AM, Kirill A. Shutemov wrote:
> On Tue, Feb 04, 2020 at 03:41:15PM -0800, John Hubbard wrote:
>> Now that pages are "DMA-pinned" via pin_user_page*(), and unpinned via
>> unpin_user_pages*(), we need some visibility into whether all of this is
>> working correctly.
>>
>> Add two new fields to /proc/vmstat:
>>
>>     nr_foll_pin_acquired
>>     nr_foll_pin_released
>>
>> These are documented in Documentation/core-api/pin_user_pages.rst.
>> They represent the number of pages (since boot time) that have been
>> pinned ("nr_foll_pin_acquired") and unpinned ("nr_foll_pin_released"),
>> via pin_user_pages*() and unpin_user_pages*().
>>
>> In the absence of long-running DMA or RDMA operations that hold pages
>> pinned, the above two fields will normally be equal to each other.
>>
>> Also: update Documentation/core-api/pin_user_pages.rst, to remove an
>> earlier (now confirmed untrue) claim about a performance problem with
>> /proc/vmstat.
>>
>> Also: updated Documentation/core-api/pin_user_pages.rst to rename the
>> new /proc/vmstat entries, to the names listed here.
>>
>> Signed-off-by: John Hubbard <jhubbard@...dia.com>
> 
> Please, clarify semantics for huge page. An user may want to know if we
> count huge page as one pin-acquired or by number of pages.


OK, I've added this for the next version:


diff --git a/Documentation/core-api/pin_user_pages.rst b/Documentation/core-api/pin_user_pages.rst
index 5776ad1ed5e4..2e939ff10b86 100644
--- a/Documentation/core-api/pin_user_pages.rst
+++ b/Documentation/core-api/pin_user_pages.rst
@@ -211,6 +211,33 @@ since the system was booted, via two new /proc/vmstat entries: ::
     /proc/vmstat/nr_foll_pin_acquired
     /proc/vmstat/nr_foll_pin_released
 
+Under normal conditions, these two values will be equal unless there are any
+long-term [R]DMA pins in place, or during pin/unpin transitions.
+
+* nr_foll_pin_acquired: This is the number of logical pins that have been
+  acquired since the system was powered on. For huge pages, the head page is
+  pinned once for each page (head page and each tail page) within the huge page.
+  This follows the same sort of behavior that get_user_pages() uses for huge
+  pages: the head page is refcounted once for each tail or head page in the huge
+  page, when get_user_pages() is applied to a huge page.
+
+* nr_foll_pin_released: The number of logical pins that have been released since
+  the system was powered on. Note that pages are released (unpinned) on a
+  PAGE_SIZE granularity, even if the original pin was applied to a huge page.
+  Becaused of the pin count behavior described above in "nr_foll_pin_acquired",
+  the accounting balances out, so that after doing this::
+
+    pin_user_pages(huge_page);
+    for (each page in huge_page)
+        unpin_user_page(page);
+
+...the following is expected::
+
+    nr_foll_pin_released == nr_foll_pin_acquired
+
+(...unless it was already out of balance due to a long-term RDMA pin being in
+place.)
+
 Other diagnostics
 =================
 


thanks,
-- 
John Hubbard
NVIDIA

> 
> Otherwise looks good (given Jan concern is addressed).
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ