Re: [PATCH v2 2/2] mm,page_owner: Fix accounting of pages when migrating
From: Vlastimil Babka
Date: Thu Mar 21 2024 - 06:50:48 EST
On 3/20/24 06:00, Oscar Salvador wrote:
> On Tue, Mar 19, 2024 at 06:48:31PM +0000, Matthew Wilcox wrote:
>> Is this the right way to fix this problem? I would have thought we'd
>> be better off accounting this as migration freeing the old page and
>> allocating the new page. If I understand correctly, this is the code
>> which says "This page was last allocated by X and freed by Y", and I
>> would think that being last freed (or allocated) by the migration code
>> would be a very nice hint about where a problem might stem from.
>
> I hear you, and I had the same thought when I stumbled upon this.
> I did not know that the handle was being changed, otherwise it would
> have saved me quite a lot of debugging time.
>
> Checking the history of this, I can see this decision was made in
> 2016 in:
>
> commit d435edca928805074dae005ab9a42d9fa60fc702
> Author: Vlastimil Babka <vbabka@xxxxxxx>
> Date: Tue Mar 15 14:56:15 2016 -0700
>
> mm, page_owner: copy page owner info during migration
>
Yeah I think we could keep that logic.
But we could also simply subtract the refcount of the old handle (the
"allocated for migration") in __folio_copy_owner() no? Then we wouldn't need
the extra migrate_handle.
Also we might have more issues here. Most page owner code takes care to set
everything for all pages within a folio, but __folio_copy_owner() and
__set_page_owner_migrate_reason() don't.