From nobody Wed Dec 17 02:25:58 2025 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (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 69B6B298CC4 for ; Thu, 11 Dec 2025 08:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765441040; cv=none; b=i+CJiWMBsR/lPI353kv8PNvfsjl2EjkFR7V/2ytHK1k2zPHuYN3EFw3oeiJJ0ZFQW4RpRGQ0hYfKzW7C+IvWvQai/bK069TC88DEutcb/qLk6NGwuVPq6IHj40Jm4mbAMWv3lTb+s3D9/T3dfvNXJJiYUqo4MnK9u/iN4KmsnH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765441040; c=relaxed/simple; bh=UFZxc/ZRMGIPUXnfqq32PnB9V1MiPcBtIySry0YhS8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jqMk+/yPEXSPLRYcgRzJKfx20b7eJWMEfOGUPLC/vDqEaSaYvOODNqylS2HipAwOAxyAavuZKHeQ4KptosKPNTQGS1YGBhou4hrooxL4qLLEvHRsouh4r1YOZabF1TkIAAK0dSp8epZt8y4+2xGN1vwQJoHquIcAtVpk0GXS8Us= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=gJo4993S; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="gJo4993S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1765441035; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=GTUtfG6uYByUGiREez0T2P/sllJfoIOg91OqMSv2QCo=; b=gJo4993SZkNx01mWQ6MeC3Fw+IYxByVyhZDRR9vJ6k1L9JJzXVA5emuoqZiUBlPCSn3gJfEj+C2dWyT+gJ8tpjboG+vt9A3XfbnMjOdShZYU891+Ib5M9FMIJkqwO4Gs7mupJBRGkPRy/xacdXNsuS4Ul8WvftrsBFKoUEN/w18= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WuZjI5S_1765441033 cluster:ay36) by smtp.aliyun-inc.com; Thu, 11 Dec 2025 16:17:14 +0800 From: Baolin Wang To: akpm@linux-foundation.org, david@kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: lorenzo.stoakes@oracle.com, ryan.roberts@arm.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, willy@infradead.org, baohua@kernel.org, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] mm: rmap: support batched unmapping for file large folios Date: Thu, 11 Dec 2025 16:16:56 +0800 Message-ID: X-Mailer: git-send-email 2.43.7 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Similar to folio_referenced_one(), we can apply batched unmapping for file large folios to optimize the performance of file folios reclamation. Performance testing: Allocate 10G clean file-backed folios by mmap() in a memory cgroup, and try= to reclaim 8G file-backed folios via the memory.reclaim interface. I can obser= ve 75% performance improvement on my Arm64 32-core server. W/o patch: real 0m1.018s user 0m0.000s sys 0m1.018s W/ patch: real 0m0.249s user 0m0.000s sys 0m0.249s Signed-off-by: Baolin Wang Acked-by: Barry Song --- mm/rmap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index ec232165c47d..4c9d5777c8da 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1855,9 +1855,10 @@ static inline unsigned int folio_unmap_pte_batch(str= uct folio *folio, end_addr =3D pmd_addr_end(addr, vma->vm_end); max_nr =3D (end_addr - addr) >> PAGE_SHIFT; =20 - /* We only support lazyfree batching for now ... */ - if (!folio_test_anon(folio) || folio_test_swapbacked(folio)) + /* We only support lazyfree or file folios batching for now ... */ + if (folio_test_anon(folio) && folio_test_swapbacked(folio)) return 1; + if (pte_unused(pte)) return 1; =20 @@ -2223,7 +2224,7 @@ static bool try_to_unmap_one(struct folio *folio, str= uct vm_area_struct *vma, * * See Documentation/mm/mmu_notifier.rst */ - dec_mm_counter(mm, mm_counter_file(folio)); + add_mm_counter(mm, mm_counter_file(folio), -nr_pages); } discard: if (unlikely(folio_test_hugetlb(folio))) { --=20 2.47.3