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

From: Muhammad Usama Anjum
Date: Wed Jun 28 2023 - 04:34:07 EST


On 6/28/23 12:54 AM, Michał Mirosław wrote:
> On Tue, 27 Jun 2023 at 21:20, Muhammad Usama Anjum
> <usama.anjum@xxxxxxxxxxxxx> wrote:
>> Thanks Michał for replying.
>>
>> On 6/27/23 11:52 PM, Michał Mirosław wrote:
>>> On Tue, 27 Jun 2023 at 11:00, Muhammad Usama Anjum
>>> <usama.anjum@xxxxxxxxxxxxx> wrote:
>>>>
>>>> Hi Andrei and Michal,
>>>>
>>>> Lets resolve last two points. Please reply below.
>>>>
>>>> On 6/27/23 6:46 AM, Andrei Vagin wrote:
>>> [...]
>>>>> And we need to report an address where it stopped scanning.
>>>>> We can do that by adding zero length vector.
>>>> I don't want to do multiplexing the ending address in vec. Can we add
>>>> end_addr variable in struct pm_scan_arg to always return the ending address?
>>>>
>>>> struct pm_scan_arg {
>>>> ...
>>>> _u64 end_addr;
>>>> };
>>>
>>> The idea to emit a zero-length entry for the end looks nice. This has
>>> the disadvantage that we'd need to either reserve one entry for the
>>> ending marker or stop the walk after the last entry is no longer
>>> matching.
>> This is ambiguous.
>
> Can you explain? Both solutions would allow to return the restart
> point back to the caller (the second one would need to stop the walk
> as soon as the matching page range finishes -- that creates
> discontinuity).
>
>>> Another solution would be to rewrite 'start' and 'len'. The caller
>>> would be forced to use non-const `pm_scan_arg`, but I expect the `vec`
>>> pointer would normally be written anyway (unless using only a
>>> statically-allocated buffer).
>>> Also, if the 'len' is replaced with 'end' that would make the ioctl
>>> easily restartable (just call again if start != end).
>> Nice idea. But returning ending address in len seems a bit strange.
>
> I mean that it would update `start` = start value for next call' and
> `len` = `len` - (new `start` - original `start`).
>
> By replacing `len` I meant to remove the field and add `end` instead
> to make the requested range use begin .. end (iterator range) style
> instead of start + len (buffer and length). In this version you only
> need to update `start` (or `begin` if you prefer).
The `start` and `end` with updating the `start` with ending address seems
most appropriate. I'll make updates.

>
> Best Regards
> Michał Mirosław

--
BR,
Muhammad Usama Anjum