From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (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 874BA18C31 for ; Thu, 11 Dec 2025 08:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765441036; cv=none; b=iYBuVlwiCkpej0ipRFKEwYiICoDvw71vUFoysiYLDED1e8jrBYpBiTOp3lBQJIrlHhfezaxvsG1zuuReNbCkeeC6QfeurGMhJWzBZqcdF8xUeNEU1bx/THgr1A4l95vEusAxQVH8kMJQecZ2khYgGqAyemSZULsQcBXpm22QCpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765441036; c=relaxed/simple; bh=1cM/YDECMsL5D2k8aoKmP1HjUQiBKaUZNuzFspZldPo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=najbiGX2FIyujcZmftaqtVK6lpBV7dbTReVO14D9djjGObloDNiuARAP4uAOeVbCR/hdQJg5M0275GfH/gOA10x66k9tHPSHVeYBRiCmR5XZLp4p0ICM9VgFmgPxx3dtG/FbH+m1Jp2GDhmPqrM3mKWVJGLifAiUxIWtiX12gIU= 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=BkXQniJS; arc=none smtp.client-ip=115.124.30.118 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="BkXQniJS" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1765441031; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=F7ZBUFth2QS91MsUVzia8UnQfPYwaqtJvLrEI1PCTTw=; b=BkXQniJSXLcChS265vqghd45l7wNsRgJK6LYS81iEDCPRKxk8cjU1tptEGK1NJ2wzn8e8A8vTySyBPx8AiWqOoGpNTqOPE1p88U0ZWqAhK0yLRsE6gQSXKUxGvYAvPAgmU6aBNPxgDJMRIJMFWcm3i1Xn3FxF8HWYzfjf0h0afQ= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WuZl4F4_1765441028 cluster:ay36) by smtp.aliyun-inc.com; Thu, 11 Dec 2025 16:17:09 +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 0/3] support batch checking of references and unmapping for large folios Date: Thu, 11 Dec 2025 16:16:53 +0800 Message-ID: X-Mailer: git-send-email 2.43.7 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, folio_referenced_one() always checks the young flag for each PTE sequentially, which is inefficient for large folios. This inefficiency is especially noticeable when reclaiming clean file-backed large folios, where folio_referenced() is observed as a significant performance hotspot. Moreover, on Arm architecture, which supports contiguous PTEs, there is already an optimization to clear the young flags for PTEs within a contiguous range. However, this is not sufficient. We can extend this to perform batched operations for the entire large folio (which might exceed the contiguous range: CONT_PTE_SIZE). Similar to folio_referenced_one(), we can also apply batched unmapping for large file folios to optimize the performance of file folio reclamation. By supporting batched checking of the young flags, flushing TLB entries, and unmapping, I can observed a significant performance improvements in my performance tests for file folios reclamation. Please check the performance data in the commit message of each patch. Run stress-ng and mm selftests, no issues were found. Changes from v1: - Add a new patch to support batched unmapping for file large folios. - Update the cover letter. Baolin Wang (3): arm64: mm: support batch clearing of the young flag for large folios mm: rmap: support batched checks of the references for large folios mm: rmap: support batched unmapping for file large folios arch/arm64/include/asm/pgtable.h | 23 ++++++++++++----- arch/arm64/mm/contpte.c | 44 ++++++++++++++++++++++---------- include/linux/mmu_notifier.h | 9 ++++--- include/linux/pgtable.h | 19 ++++++++++++++ mm/rmap.c | 29 +++++++++++++++++---- 5 files changed, 96 insertions(+), 28 deletions(-) -- 2.47.3