From nobody Sun Dec 14 05:55:27 2025 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (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 9FF9C21E091 for ; Fri, 12 Dec 2025 03:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765509217; cv=none; b=hUJcQVR9pHhBmWUXiISMJDMyGZkksBPbD1vC06cHMYPMN6qXoJLryVDq6fSaSn5SZeod1/8WDJPuxC/iZ/ApqAcRp5zCyGUSjm2Bbbxx3BUdSIQNz4+xuB8eWODGDS7NGsrykzOIZ6GO4ZE/LRnWk/btdqQmnsSQK8KKBmjclw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765509217; c=relaxed/simple; bh=iHxeLMBp70d6Cty1L/bw0aBvhXEnL9bgQavdHa/Y/l4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bdFFt6t6+9rzQc8d4WMPXi3QUYzgDfsk7dVhzCkwWoSKZRWHsiBFhXLC3LVZRGahtVkpZQSVvI/yPA8LHf1ec4MmgxTJzklf/Xo8tfefGIVts+BQCguuY3uRaa9kV0blAd1Bp6J11EBlvc2W37bN/SHBqWdSSEsWea6/Bn9YH+s= 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=EzyenkBz; arc=none smtp.client-ip=115.124.30.111 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="EzyenkBz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1765509210; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=byRirJCR8uUeqSLSE6TQmk0JDyPI4CmoE6vRDYCIDjQ=; b=EzyenkBzgPCMyGRCLJtda2JnXYALLxTpAkSLPCJXAvXJeAhrF3O/aXaSJ1QCnj5qEnW0rR/xA6Xqonuwe2dP7lm43Kj4kTz+k/X5ZBXyJ95Az9T20dCQutwsKa2c0GWQ6S2ZSpif47toCyj3H108heClnJyx3478N3DFbf8s22U= Received: from localhost.localdomain(mailfrom:tongweilin@linux.alibaba.com fp:SMTPD_---0Wucbb11_1765509197 cluster:ay36) by smtp.aliyun-inc.com; Fri, 12 Dec 2025 11:13:29 +0800 From: Weilin Tong To: Hugh Dickins Cc: Baolin Wang , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Weilin Tong Subject: [RFC PATCH] mm/shmem: add mTHP swpout fallback statistics in shmem_writeout() Date: Fri, 12 Dec 2025 11:12:51 +0800 Message-ID: <20251212031250.206571-2-tongweilin@linux.alibaba.com> 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: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, when shmem mTHPs are split and swapped out via shmem_writeout(), there are no unified statistics to trace these mTHP swpout fallback events. This makes it difficult to analyze the prevalence of mTHP splitting and fallback during swap operations, which is important for memory diagnostics. Here we add statistics counting for mTHP fallback to small pages when splitting and swapping out in shmem_writeout(). Signed-off-by: Weilin Tong Reviewed-by: Baolin Wang --- mm/shmem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 3f194c9842a8..aa624c447358 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1593,11 +1593,23 @@ int shmem_writeout(struct folio *folio, struct swap= _iocb **plug, } =20 if (split) { + int order; + try_split: + order =3D folio_order(folio); /* Ensure the subpages are still dirty */ folio_test_set_dirty(folio); if (split_folio_to_list(folio, folio_list)) goto redirty; + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (order >=3D HPAGE_PMD_ORDER) { + count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1); + count_vm_event(THP_SWPOUT_FALLBACK); + } +#endif + count_mthp_stat(order, MTHP_STAT_SWPOUT_FALLBACK); + folio_clear_dirty(folio); } =20 --=20 2.43.5