How do “pinned” pages in Linux present (or actuall

2019-07-21 03:27发布

问题:

I am using get_user_pages in a Linux kernel driver to pin memory for the purposes of [hardware] DMA. It all seems to work fine - but I am having a hard time proving that the "pinning" is doing the proper thing.

When I inspect the flags on the physical pages after doing get_user_pages - the pages don't appear "locked" (as one might think they should be). In fact, I see no difference between the flags of otherwise "active" pages vs. those I have "pinned" via get_user_pages.

The only difference I see is that get_user_pages has taken a refcount on the page. So I guess my question is - is holding this reference alone sufficient to guarantee that this page will never be swapped-out, moved, or that my user-space's vaddr will still/always reference the same underlying page?

All the driver source I can find seems to use this mechanism, and documentation seems to indicate that this is the correct way - but I am having a hard time "proving" that this will give me the correct, reliable, intended behavior.