Re: [PATCH v4 10/12] mm/gup: /proc/vmstat: pin_user_pages (FOLL_PIN) reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> 
> 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).
> 



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux