From mboxrd@z Thu Jan 1 00:00:00 1970 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 72666258CDF for ; Mon, 9 Feb 2026 09:43:15 +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=1770630196; cv=none; b=gsLS0hEocJ5YrYJfMmwQAptIFkPaOGFheDzc9wGQmW687A+aZwgNg66NbbC73D+Fca63qivjzhp9AOXCFPTN2RymH/dkJaGzz/rQmvXdUGwSBG4snK2ulENZBhi+e0rgpD2dHGnCmqyNEe7UfM1SGcqZdGQ0/M4k0KwKA1rMVaw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770630196; c=relaxed/simple; bh=LGpndIka6EfREhmLruHHdCl8gYO6ndQ7xeWTbE4X9wM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VUhl7orlcAAKC3jWFeSu9Xj0LBE4+RyMABrvd938n0zULT+dYiQqXq/dsuwLevREXiTaEva7+IpVuHLIV7jsAGAF8eHiyLSIjjAq8marhA81Sey37xpf1kMJLEUX75nARuPdnQz9pXlzgkK0kT8DP7ncm6auF8oHUYMWkBtjanc= 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=DaTO/iLp; 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="DaTO/iLp" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1770630187; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=UBI+jRRyuRr+QajwiPV5bCA0PKZRJLu20S4RKTSvJt4=; b=DaTO/iLpeSs/akyf9IZ7VeSAu0Gv7B1sh/xlOeIXi/3tKl3pmIz2DvmdgLdiJ6Mn7GGCHMbMqE34rd4BuCewZ3y00OWa3EgGX6B2WxO3oW8BLOJvHvYTKOxPmT9Rle3i5QftaPgJ36qCHYheHAQC1gqald2RiWkrlB5UiMFlWfg= Received: from 30.74.144.127(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WyqXdyS_1770630184 cluster:ay36) by smtp.aliyun-inc.com; Mon, 09 Feb 2026 17:43:05 +0800 Message-ID: Date: Mon, 9 Feb 2026 17:43:04 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/5] mm: rmap: support batched unmapping for file large folios To: "David Hildenbrand (Arm)" , akpm@linux-foundation.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, dev.jain@arm.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <142919ac14d3cf70cba370808d85debe089df7b4.1766631066.git.baolin.wang@linux.alibaba.com> <46d0b6bf-db7e-418f-a497-983db4d4d786@kernel.org> From: Baolin Wang In-Reply-To: <46d0b6bf-db7e-418f-a497-983db4d4d786@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2/9/26 5:38 PM, David Hildenbrand (Arm) wrote: > On 12/26/25 07:07, Baolin Wang wrote: >> Similar to folio_referenced_one(), we can apply batched unmapping for >> file >> large folios to optimize the performance of file folios reclamation. >> >> Barry previously implemented batched unmapping for lazyfree anonymous >> large >> folios[1] and did not further optimize anonymous large folios or file- >> backed >> large folios at that stage. As for file-backed large folios, the batched >> unmapping support is relatively straightforward, as we only need to clear >> the consecutive (present) PTE entries for file-backed large folios. >> >> 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 >> observe >> 75% performance improvement on my Arm64 32-core server (and 50%+ >> improvement >> on my X86 machine) with this patch. >> >> W/o patch: >> real    0m1.018s >> user    0m0.000s >> sys     0m1.018s >> >> W/ patch: >> real    0m0.249s >> user    0m0.000s >> sys    0m0.249s >> >> [1] https://lore.kernel.org/ >> all/20250214093015.51024-4-21cnbao@gmail.com/T/#u >> Reviewed-by: Ryan Roberts >> Acked-by: Barry Song >> Signed-off-by: Baolin Wang >> --- >>   mm/rmap.c | 7 ++++--- >>   1 file changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/mm/rmap.c b/mm/rmap.c >> index 985ab0b085ba..e1d16003c514 100644 >> --- a/mm/rmap.c >> +++ b/mm/rmap.c >> @@ -1863,9 +1863,10 @@ static inline unsigned int >> folio_unmap_pte_batch(struct folio *folio, >>       end_addr = pmd_addr_end(addr, vma->vm_end); >>       max_nr = (end_addr - addr) >> PAGE_SHIFT; >> -    /* 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; > > Right, the anon folio handling would require a bit more work in the > > >     } else if (folio_test_anon(folio)) { > > branch. > > Do you intend to tackle that one as well? >> I'll reply to the fixup. I'm not sure whether Barry has time to continue this work. If he does not, I can take over. Barry?