From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (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 E89D5212548 for ; Fri, 12 Dec 2025 05:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765518520; cv=none; b=fb1Xg4grR0Et8MhULDPP6b4DLNKppT00fc6UJh72iHq0MPZUtUeQbzUVqP+7nPxKgWh9I6pfKSYlFmDT7McEOCSt20Hhjg1/DCQwE5BfWPMgcLhHJpaybu0SZ8RPzt94WHR0vbdPK4PItDSwnDYe98oJFagIRqxZWFsi2YZWX4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765518520; c=relaxed/simple; bh=V4XauFN3UG/8J6IHQToxDLRiKNhi09CcytyXYLHBjbQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Z22Hn/ynhow7jCXWAC49/kZFGs6xMaJIafwAEfHHDnlFCwQc9Vi3FLclIuXzR6KBYjB8tGD/EDbbcJaUnVksFgg1YuqONkG+61OhAeMhu5gxGi3p4vmD7PxY+4eP3/tsdCYM/DePEmynw7Caj/AC6PyK7YtvKQw+v6NSQ8n7/Nw= 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=W7bVQuu1; arc=none smtp.client-ip=115.124.30.98 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="W7bVQuu1" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1765518514; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=0zzX2IhdyHL+K9V+o1socKE9g1Ws1/CmO0XCpwAXjFQ=; b=W7bVQuu1YhAGqRyw7SMcvmMCv40e3ociO+Czj8+dNoHVab7xNQmZEaZ7ZehXOSsW8uYKsuf6i6ABNE0Es7GS1qw1LWje4hAvVaxCf6vRMR5iYHF9B5Z5GaO2HCWImsGLBD/Gss77KDMlGqi2X2DO2taZ58NPIoa2DPYiY9wd/jg= Received: from 30.74.144.130(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Wud5Ubw_1765518513 cluster:ay36) by smtp.aliyun-inc.com; Fri, 12 Dec 2025 13:48:33 +0800 Message-ID: <7f681d9d-0b24-4230-bd5a-bf056c6c396e@linux.alibaba.com> Date: Fri, 12 Dec 2025 13:48:32 +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: [RFC PATCH] mm/shmem: add mTHP swpout fallback statistics in shmem_writeout() To: Weilin Tong , Hugh Dickins Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20251212031250.206571-2-tongweilin@linux.alibaba.com> From: Baolin Wang In-Reply-To: <20251212031250.206571-2-tongweilin@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025/12/12 11:12, Weilin Tong wrote: > 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 > --- Looks reasonable to me. Thanks. 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, > } > > if (split) { > + int order; > + > try_split: > + order = 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 >= 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); > } >