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

From: Muhammad Usama Anjum
Date: Wed Aug 16 2023 - 07:30:39 EST


On 8/16/23 4:17 PM, Michał Mirosław wrote:
> On Wed, Aug 16, 2023 at 03:38:10PM +0500, Muhammad Usama Anjum wrote:
>> The PAGEMAP_SCAN IOCTL on the pagemap file can be used to get or optionally
>> clear the info about page table entries.
> [...]
>> --- a/fs/proc/task_mmu.c
>> +++ b/fs/proc/task_mmu.c
> [...]
>> +static long do_pagemap_scan(struct mm_struct *mm, unsigned long uarg)
>> +{
> [...]
>> + for (walk_start = p.arg.start; walk_start < p.arg.end;
>> + walk_start = p.arg.walk_end) {
> [...]
>> + /* The walk_end isn't set when ret is zero */
>> + if (!p.arg.walk_end)
>> + p.arg.walk_end = p.arg.end;
>
> This is now redundant with the `if` after the loop. [1]
>
>> + if (ret != -ENOSPC)
>> + break;
>> +
>> + if (p.arg.vec_len == 0 || p.found_pages == p.arg.max_pages)
>> + break;
>> + }
>> +
>> + /* ENOSPC signifies early stop (buffer full) from the walk. */
>> + if (!ret || ret == -ENOSPC)
>> + ret = n_ranges_out;
>> +
>> + if (!p.arg.walk_end)
>> + p.arg.walk_end = p.arg.end;
>
> [1] The one above.
Thank you for noting it down. Let me remove it.

>
> Best Regards
> Michał Mirosław

--
BR,
Muhammad Usama Anjum