[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8444ca4b-f59e-43fd-b458-186ead4cffa9@suse.cz>
Date: Tue, 26 Mar 2024 16:25:29 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Johannes Weiner <hannes@...xchg.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Mel Gorman <mgorman@...hsingularity.net>, Zi Yan <ziy@...dia.com>,
"Huang, Ying" <ying.huang@...el.com>, David Hildenbrand <david@...hat.com>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 07/10] mm: page_alloc: close migratetype race between
freeing and stealing
On 3/20/24 7:02 PM, Johannes Weiner wrote:
> There are three freeing paths that read the page's migratetype
> optimistically before grabbing the zone lock. When this races with
> block stealing, those pages go on the wrong freelist.
>
> The paths in question are:
> - when freeing >costly orders that aren't THP
> - when freeing pages to the buddy upon pcp lock contention
> - when freeing pages that are isolated
> - when freeing pages initially during boot
> - when freeing the remainder in alloc_pages_exact()
> - when "accepting" unaccepted VM host memory before first use
> - when freeing pages during unpoisoning
>
> None of these are so hot that they would need this optimization at the
> cost of hampering defrag efforts. Especially when contrasted with the
> fact that the most common buddy freeing path - free_pcppages_bulk - is
> checking the migratetype under the zone->lock just fine.
>
> In addition, isolated pages need to look up the migratetype under the
> lock anyway, which adds branches to the locked section, and results in
> a double lookup when the pages are in fact isolated.
>
> Move the lookups into the lock.
>
> Reported-by: Vlastimil Babka <vbabka@...e.cz>
> Signed-off-by: Johannes Weiner <hannes@...xchg.org>
Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
Powered by blists - more mailing lists