[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <10cd22d3-cb58-4ec9-a22d-5b8555044623@redhat.com>
Date: Fri, 21 Jun 2024 09:31:17 +0200
From: David Hildenbrand <david@...hat.com>
To: Baolin Wang <baolin.wang@...ux.alibaba.com>, linux-kernel@...r.kernel.org
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v1 2/2] mm/migrate: move NUMA hinting fault folio
isolation + checks under PTL
On 21.06.24 06:07, Baolin Wang wrote:
>
>
> On 2024/6/21 05:29, David Hildenbrand wrote:
>> Currently we always take a folio reference even if migration will not
>> even be tried or isolation failed, requiring us to grab+drop an additional
>> reference.
>>
>> Further, we end up calling folio_likely_mapped_shared() while the folio
>> might have already been unmapped, because after we dropped the PTL, that
>> can easily happen. We want to stop touching mapcounts and friends from
>> such context, and only call folio_likely_mapped_shared() while the folio
>> is still mapped: mapcount information is pretty much stale and unreliable
>> otherwise.
>>
>> So let's move checks into numamigrate_isolate_folio(), rename that
>> function to migrate_misplaced_folio_prepare(), and call that function
>> from callsites where we call migrate_misplaced_folio(), but still with
>> the PTL held.
>>
>> We can now stop taking temporary folio references, and really only take
>> a reference if folio isolation succeeded. Doing the
>> folio_likely_mapped_shared() + golio isolation under PT lock is now similar
>> to how we handle MADV_PAGEOUT.
>
> s/golio/folio
>
> Make sense to me. Feel free to add:
> Reviewed-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
Thanks!
[...]
>> node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio),
>> nr_pages);
>> -
>> - /*
>> - * Isolating the folio has taken another reference, so the
>> - * caller's reference can be safely dropped without the folio
>> - * disappearing underneath us during migration.
>> - */
>> - folio_put(folio);
>> - return 1;
>> + return 0;
>> }
>
> (just a nit: returning boolean seems more readable)
"return true" on success really is nasty in a code base where most
functions return "0" on success. Like most functions in mm/migrate.c --
like migrate_pages() -- do.
Thanks!
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists