Re: [PATCH v26 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs

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

 



On 7/27/23 4:40 PM, Michał Mirosław wrote:
> On Thu, 27 Jul 2023 at 11:37, Muhammad Usama Anjum
> <usama.anjum@xxxxxxxxxxxxx> wrote:
>> This IOCTL, PAGEMAP_SCAN on pagemap file can be used to get and/or clear
>> the info about page table entries. The following operations are supported
>> in this ioctl:
>> - Get the information if the pages have Async Write-Protection enabled
>>   (``PAGE_IS_WPALLOWED``), have been written to (``PAGE_IS_WRITTEN``), file
>>   mapped (``PAGE_IS_FILE``), present (``PAGE_IS_PRESENT``), swapped
>>   (``PAGE_IS_SWAPPED``) or page has pfn zero (``PAGE_IS_PFNZERO``).
>> - Find pages which have been written to and/or write protect
>>   (atomic ``PM_SCAN_WP_MATCHING + PM_SCAN_CHECK_WPASYNC``) the pages
>>   atomically. The (``PM_SCAN_WP_MATCHING``) is used to WP the matched
>>   pages. The (``PM_SCAN_CHECK_WPASYNC``) aborts the operation if
>>   non-Async-Write-Protected pages are found. Get is automatically performed
>>   if output buffer is specified.
>>
>> This IOCTL can be extended to get information about more PTE bits. The
>> entire address range passed by user [start, end) is scanned until either
>> the user provided buffer is full or max_pages have been found.
>>
>> Reviewed-by: Andrei Vagin <avagin@xxxxxxxxx>
>> Reviewed-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
>> Signed-off-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
> 
> Thanks for all the work!
> 
> Small request below.
> 
>> --- a/fs/proc/task_mmu.c
>> +++ b/fs/proc/task_mmu.c
> [...]
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> +static unsigned long pagemap_thp_category(pmd_t pmd)
>> +{
>> +       unsigned long categories = 0;
>> +
>> +       if (pmd_present(pmd)) {
>> +               categories |= PAGE_IS_PRESENT;
>> +               if (!pmd_uffd_wp(pmd))
>> +                       categories |= PAGE_IS_WRITTEN;
>> +               if (is_zero_pfn(pmd_pfn(pmd)))
>> +                       categories |= PAGE_IS_PFNZERO;
>> +       } else if (is_swap_pmd(pmd)) {
>> +               categories |= PAGE_IS_SWAPPED;
>> +               if (!pmd_swp_uffd_wp(pmd))
>> +                       categories |= PAGE_IS_WRITTEN;
>> +       }
>> +
>> +       return categories;
>> +}
> [...]
>> +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
>> +
>> +#ifdef CONFIG_HUGETLB_PAGE
>> +static unsigned long pagemap_hugetlb_category(pte_t pte)
>> +{
>> +       unsigned long categories = 0;
>> +
>> +       if (pte_present(pte)) {
>> +               categories |= PAGE_IS_PRESENT;
>> +               if (!huge_pte_uffd_wp(pte))
>> +                       categories |= PAGE_IS_WRITTEN;
>> +               if (!PageAnon(pte_page(pte)))
>> +                       categories |= PAGE_IS_FILE;
>> +               if (is_zero_pfn(pte_pfn(pte)))
>> +                       categories |= PAGE_IS_PFNZERO;
>> +       } else if (is_swap_pte(pte)) {
>> +               categories |= PAGE_IS_SWAPPED;
>> +               if (!pte_swp_uffd_wp_any(pte))
>> +                       categories |= PAGE_IS_WRITTEN;
>> +       }
>> +
>> +       return categories;
>> +}
> 
> Could you add PAGE_IS_HUGE for THP and HugeTLB pages? This would help
> maintaining checkpointed process'es page sizes by CRIU when THP is
> used.
Can be done.

> 
> Best Regards
> Michał Mirosław

-- 
BR,
Muhammad Usama Anjum



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

  Powered by Linux