From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 0D94C1E2834 for ; Tue, 25 Nov 2025 00:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764032229; cv=none; b=UHqN53YoI1XMycYwS339IPgD7zYv1vaYUZ37RUJ0912vlZScdKQpHAXE2zJlqunlpTFoOOXb+h/z2dj0X3tBL2XC7scCte9OBnl6eSPiomXenUj+U8zuujEzIEHmyMtRO2WZN7mbuEo/4zvNo6yK0eTvZkxiLfc/6X4/HBsTH5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764032229; c=relaxed/simple; bh=16P41emR9cpdUVGwi4g1jLf+hW19uk936Hm6/yUf01M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=p+pJbVCnKHuk+uDZ3a521r/quTT1Pg62GT9T0HEIS3/uiJn1SQP/d5byeQZobMSSKJuFlrrL+KYTxWpMv/73x6NTT4/XD2T0wma/VvQeKxsHumt22PrS92ximdqO65pB/7rFJjW4JAzxPFugVlA2b4haJC++rlbBe8S1n1u8l04= 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=cyQ4amxC; arc=none smtp.client-ip=115.124.30.130 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="cyQ4amxC" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1764032219; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=eQOzOdTt+5ga5DERa19IdsHmZ9YtEuF1FLhAp11XwR8=; b=cyQ4amxCgKuWo1VSMPU31DlSDqi/su95o+WYEJ9tWlIBCZnDFvDR8CD4OPdEUydS0Pp6WxnJc163ULAdPBh4rXYCu7Ni7qCm8cCk5pVaYrVuU8F/XS4VTy4ed3/Y0gXajBp5IHOasyIBWdlVBqj9DIiLyzzp5WVnTjFpTd5jh3c= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WtL7S5r_1764032217 cluster:ay36) by smtp.aliyun-inc.com; Tue, 25 Nov 2025 08:56:58 +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 0/2] support batched checks of the references for large folios Date: Tue, 25 Nov 2025 08:56:49 +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). By supporting batched checking of the young flags and flushing TLB entries, I observed a 33% performance improvement in my file-backed folios reclaim tests. BTW, I still noticed a hotspot in try_to_unmap() in my test. Hope Barry can resend the optimization patch for try_to_unmap() [1]. [1] https://lore.kernel.org/all/20250513084620.58231-1-21cnbao@gmail.com/ Baolin Wang (2): arm64: mm: support batch clearing of the young flag for large folios mm: rmap: support batched checks of the references for 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 | 22 ++++++++++++++-- 5 files changed, 92 insertions(+), 25 deletions(-) -- 2.47.3