Re: [PATCH] tools/mm: prevent page_owner_sort from truncating input

From: 熊卧龙

Date: Wed Jul 29 2026 - 21:34:38 EST


> This all sounds complex. How does sort(1) do it? Write to a temporary
> file then a rename?
>
> For page_owner_sort I expect we could load all the input into memory
> before opening the output file?

I checked the GNU sort documentation. In normal mode, sort reads all
input before opening the output file. page_owner_sort already stores all
input records in memory, so moving fopen() after the input loop is simpler
and also allows in-place sorting.

I will rework the patch and send v2. Thanks for the suggestion.

Warren