From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF7CD1DE4E0 for ; Tue, 16 Dec 2025 06:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765866859; cv=none; b=Idx1uSf4X+iF9GM6oeN7gjtZLX86mB97jclp3HsuE5QIpzCevH5BmwJzGpmBAURYj4GjdNhSuJbGEUntaDNnRc4rLCljx76WVpqSwbQKryZw1NFmA7nZbTaZHTjjK83Y1xCPB+EeUHa9KGBjzrTMie5bdhlUolg9YcIB6VgOndU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765866859; c=relaxed/simple; bh=ql+dwWtJuJ1BSwtpAmAbBbX6i5OUguW9yAxQf1xPTgI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=q4350i+zcrPtmFdDG5+e5oODkbfU4WqAouFdevJ4NUGE6SrmXjHAPyPopN6c8AKP3KkVSUa+oaQ+qi7ZJSA/Dm/geZgEiMOBjImV5UgZs/R0KFBxxh8AuTv1mfgaLqRKPGkWz8bs+BRFPqc2qfsa4eLx8Ii7bWZ6En/a6JXhW8I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B2544FEC; Mon, 15 Dec 2025 22:34:00 -0800 (PST) Received: from [10.163.80.100] (unknown [10.163.80.100]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0AC313F762; Mon, 15 Dec 2025 22:34:05 -0800 (PST) Message-ID: <3c86d612-aab7-4e80-bc6a-3ccf2bab9c34@arm.com> Date: Tue, 16 Dec 2025 12:04:02 +0530 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] mm/shmem: add mTHP swpout fallback statistics in shmem_writeout() To: Weilin Tong , Hugh Dickins Cc: Baolin Wang , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20251215024632.250149-1-tongweilin@linux.alibaba.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: <20251215024632.250149-1-tongweilin@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 15/12/25 8:16 AM, 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 > 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; > + Could this be moved up near the 'nr_pages' declaration instead ? > 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); > } > Otherwise LGTM.