From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53BD3290C4 for ; Thu, 12 Mar 2026 03:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773285516; cv=none; b=B5pegZ40LcbtC+fQ1YXSkCmcTpyCAmdv+QdIk8j6JUhCgCA04bCelbBWYc5szY1lbnA46BSfUCIcvAC4GaS0CMPC9zimrYn0E5XvoIh3HugUpZWqV2Q3J56blO4edRNqYaQJM92fTy6kjWanHz2bZMpU3XtUjS4Wx1PR6L3OvwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773285516; c=relaxed/simple; bh=awy3LV5pCrqhjD/rDq1mVshzDPtxgPG3P5d0YoTqzrw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Bc3dgtGfp1KfJbAPmevgO+EAhZ4klVCIlqNY/JxaQ1JHOzMg2o3drHPqmR4QdJdXohmqavzJ4xlfRYoa/n1WSO2dntQpIhAzb5a3kqqCOpNsByxd95cWRhmfMjitsNGBYZBpCapmYNPGPeSDr6+w5Y29thDKHEms0m2ldtzOLKw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dRlHFpyr; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dRlHFpyr" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-48535a0ef86so4080135e9.1 for ; Wed, 11 Mar 2026 20:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773285513; x=1773890313; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Dm2zCVu+a2rsibDge+oUz5GDb5YRFWaHQ3feSYuG1h4=; b=dRlHFpyrY5VE0/DB32hTChxgLMtRIxzTrDEmhQxYW0qLCrEeRKIET0njM4Hrat9DiI 9H4Tfn+Mf8AcQvFaLoqZGamb35ztybva2v9uCfjEo1apJBROTCp355R2t1Sx1xpHcJKo x8iwmIA1tAvzd74Cxqqk39zjGj6ffuGzjVvFSrKtdZvLqvVeN79kwiLh3zW0hlWIxo6S fPxjNUz8elDq00PQGeIPAoL8F9tZTcXN461bABJ2X8wXlDmJazI/JwSDmiKHWme1uhml ZGnv0ovf9BMV3ZJtJm7DjGskVkQloIJRynnmMyAtIwchr2qIrW+ZQ3FmnyX0pFtePf5O W0Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773285513; x=1773890313; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Dm2zCVu+a2rsibDge+oUz5GDb5YRFWaHQ3feSYuG1h4=; b=poU+MIhnFXCWO3mYBTu577pHE9W7A3AuYAg+MJ10xHBLRAMjnwd5OJkwCSCS9pbID1 qFC1y6uJLDHcWNTVG/ETtisQ6514Rz+uOmC4dBZOAV4FxEURtvAomAqq3BFAfeYP83dl SDpcILMlaJ/5lPo5UpJjayZoz8vnFn9+YYlg+YzxlVVaW1X90iO3TWKixdJQl3aQFY+5 tS6ajaupWUS8f1imIEMc9JMCBaZphWnNk1nGwzdaarYAuPd+Ej1YhTTIXVx6LMQB6vXJ p9GSrnMJYMvoxBNjXg3tnIniai/LGyA1JxqMwOPgFI+ExGweBKVujWYx9/qeKaF/kEAj x7JA== X-Forwarded-Encrypted: i=1; AJvYcCUBTh9JRyxZ500mOOeq96jk2y51jZzKMbKVazm3v0BDJkp6jV6gRWCxS2HEH23+XZcQvy3+wmbiUjt+xbE=@vger.kernel.org X-Gm-Message-State: AOJu0Yz89vCCWRTDhoPOtCTWiN1lkCuNNCC9xGV/Y2JBwg+RINU4UEEC P8lBJNJwicIcXf/a9OEt7+IpCTw3vEjT7sHNHEvEXAiKr86YbUgdBL8h X-Gm-Gg: ATEYQzyjliWyp/QIyQB8oJnK3HX60UH6x/PAnI24BQMDnzFIPCDWGrBsw5NhxKqLmRm ZrqMiHGkpLN4I6EQJy4ISpsFPHFVjZT4j21lpSE/Ga5YwFiMXMure12gdlMaWr9pVRWqolzf8xc 6anq7Q5aJtVAiwT0Cjg2vzSUFl0RHhft2WWxjUzXjaf55Up4mJnP7/mORVi52Ib/HvhPro67a+U p/+JQphoXsXjB/ndGY9B5DuTqnTaN+Tjp37IXEQ+hhfoNsUJ+AW5IQMKViwr7zyfqLcgfm9b1Um 0Z7lxC7Pa5yxAhNhtWlg9cKqQJ8tEfruqNmqyoiJeGeymTsMG4N42SQM/H9gCXoOL3NpfQaWk54 3vqKfbSxXk8STU4T3OxgKB9fnR6MBd8tQgW+9U98+BjUX7CgIaSfW+v5wik16DHgVFDy+nKaMt3 wXD9O/H2UI49RccunQgSlrwA== X-Received: by 2002:a05:600c:8b26:b0:485:3d43:7c9a with SMTP id 5b1f17b1804b1-4854b10c856mr71235035e9.25.1773285512686; Wed, 11 Mar 2026 20:18:32 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4854b0f0b5dsm32170905e9.26.2026.03.11.20.18.32 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Mar 2026 20:18:32 -0700 (PDT) Date: Thu, 12 Mar 2026 03:18:31 +0000 From: Wei Yang To: Usama Arif Cc: Andrew Morton , npache@redhat.com, david@kernel.org, ziy@nvidia.com, willy@infradead.org, linux-mm@kvack.org, 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 Subject: Re: [PATCH v2] mm: migrate: requeue destination folio on deferred split queue Message-ID: <20260312031831.xb6rvrelhw54cmio@master> Reply-To: Wei Yang References: <20260310105419.3256755-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260310105419.3256755-1-usama.arif@linux.dev> User-Agent: NeoMutt/20170113 (1.7.2) On Tue, Mar 10, 2026 at 03:54:19AM -0700, 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) && >+ !data_race(list_empty(&src->_deferred_list))) { We usually check order > 1, before accessing _deferred_list, because it is in subpage 2. I am not sure why we don't do it here. Do I miss something? >+ src_deferred_split = true; >+ src_partially_mapped = folio_test_partially_mapped(src); >+ } >+ > rc = move_to_new_folio(dst, src, mode); > if (rc) > goto out; >@@ -1393,6 +1401,15 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, > if (old_page_state & PAGE_WAS_MAPPED) > remove_migration_ptes(src, dst, 0); > >+ /* >+ * Requeue the destination folio on the deferred split queue if >+ * the source was on the queue. The source is unqueued in >+ * __folio_migrate_mapping(), so we recorded the state from >+ * before move_to_new_folio(). >+ */ >+ if (src_deferred_split) >+ deferred_split_folio(dst, src_partially_mapped); >+ > out_unlock_both: > folio_unlock(dst); > folio_set_owner_migrate_reason(dst, reason); >-- >2.47.3 > -- Wei Yang Help you, Help me