From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 770D3306D26 for ; Wed, 11 Mar 2026 13:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773235561; cv=none; b=NsxFD3RWpYvH+auCezYq8yepmTCGI4zOE5+mEHr/5ya6rOqORWiEv2vsnw3kdM+FHBahqNlK738nbtPU1ru8gPflxDZ9Ir4AOnDjjCPyiqXcLpllRL6vDb21tUrNb/58ZZ3kzCsZYhjXAbNsmJjDIJ1LIk4QMUAqAnNYvRyD6jE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773235561; c=relaxed/simple; bh=hvDCR5iN6Eh4P4ZHc/Q3zZ0p+Co3tGG7CFUt9rddRVQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CDtptBxy9Ix0ZEYa6+a+xLBxLvatXQxTAMeE+GuxsElGNuietbyKABtQlIsEd6jNNe3rViK7xhyPDTT5ilfZNzTaXQRd5Ry+V8Z/RxgcA5teNs3qsIaFiwZ6qHohCKiPcf7iGlSL2A5vMNKGelRE8bSPI6kNaGdTNU2UbIETHjk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DKWFD9TA; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DKWFD9TA" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773235558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zIOqQQg32OlTrnoQWipcCb+EJ6IeLqAL0TLWqd691x8=; b=DKWFD9TACw0weVBVbNnU0DetKwcOm8iEzA/nO7oGCujBR5njNmkxy83HnRfYNMP8pD0Kp/ lq4y9WnFV4xKBa0YO8mLbMZSVU/uzjpv7JnXjo6DEpfKoL2hc7SN/nGA0mQhWN+3zgwAz/ f4nkho1dR6f9IGveQfGoWJs1AF58auE= Date: Wed, 11 Mar 2026 16:25:49 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2] mm: migrate: requeue destination folio on deferred split queue Content-Language: en-GB To: "David Hildenbrand (Arm)" , Andrew Morton , npache@redhat.com, ziy@nvidia.com, willy@infradead.org, linux-mm@kvack.org Cc: matthew.brost@intel.com, joshua.hahnjy@gmail.com, hannes@cmpxchg.org, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20260310105419.3256755-1-usama.arif@linux.dev> <946b13be-55a4-4d3e-a931-0793bf22e28f@kernel.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Usama Arif In-Reply-To: <946b13be-55a4-4d3e-a931-0793bf22e28f@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 11/03/2026 12:23, David Hildenbrand (Arm) wrote: > On 3/10/26 11:54, Usama Arif wrote: >> During folio migration, __folio_migrate_mapping() removes the source >> folio from the deferred split queue, but the destination folio is never >> re-queued. This causes underutilized THPs to escape the shrinker after >> NUMA migration, since they silently drop off the deferred split list. >> >> Fix this by recording whether the source folio was on the deferred split >> queue and its partially mapped state before move_to_new_folio() unqueues >> it, and re-queuing the destination folio after a successful migration if >> it was. >> >> By the time migrate_folio_move() runs, partially mapped folios without a >> pin have already been split by migrate_pages_batch(). So only two cases >> remain on the deferred list at this point: >> 1. Partially mapped folios with a pin (split failed). >> 2. Fully mapped but potentially underused folios. >> The recorded partially_mapped state is forwarded to deferred_split_folio() >> so that the destination folio is correctly re-queued in both cases. >> >> Reported-by: Johannes Weiner >> Fixes: dafff3f4c850 ("mm: split underused THPs") >> Signed-off-by: Usama Arif >> --- >> v1 -> v2: >> - record whether source folio was on the deferred split queue before >> move_to_folio() (David) >> - record partially mapped state and update commit message (Zi) >> --- >> mm/migrate.c | 17 +++++++++++++++++ >> 1 file changed, 17 insertions(+) >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index ece77ccb2ec0..61013d258eb4 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1360,6 +1360,8 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, >> int rc; >> int old_page_state = 0; >> struct anon_vma *anon_vma = NULL; >> + bool src_deferred_split = false; >> + bool src_partially_mapped = false; >> struct list_head *prev; >> >> __migrate_folio_extract(dst, &old_page_state, &anon_vma); >> @@ -1373,6 +1375,12 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, >> goto out_unlock_both; >> } >> >> + if (folio_test_large(src) && folio_test_large_rmappable(src) && > > I don't think the folio_test_large_rmappable() check is required. Other > folios we migrate here would always have _deferred_list initialized but > unused. > > Acked-by: David Hildenbrand (Arm) > I have been auditing the THP shrinker code when it comes to NUMA migration and I think we need another fix for this. I have sent it here https://lore.kernel.org/all/20260311132342.3193160-1-usama.arif@linux.dev/