From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 2AA038BEC for ; Sat, 11 Jan 2025 06:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736578051; cv=none; b=eMcEb3hNbFDHKsdqmZ+y3GNZ70JcfpMktoK65CqYDsNGs+EPVP+0ovX6RF8nJrjklZc8/M/nrwyIRV1PpmLbk551K4c6lNlgLd4tUqFaUBPV0NXX+fNmBH9ylQQWdVpXV0ptvMGWZopiAl/kRcWika06PCPIj8Vl1yQe5yvqX2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736578051; c=relaxed/simple; bh=rHZoLHQsbrAqebrGH7YsKdcPVW8c4BppHmd2jlpyLR4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GEzvFHuVCwqwWsBSFcADx42wFcCtUb6rD4eZcWW3D9i6FxUJ9voxGHRLT56LP8wFSmbjOhXwb6JnWsWT2VLjS/DQ169dGefBWHO1qfInwuN7NLWWl0mI6Hr5NmQ4lrNbk8KXp0Wlo3/qA1zkJ3/Nvuk+2mtxETeX7F1OrqNN46U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=TNnBynaA; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="TNnBynaA" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50B4W4HA018939; Sat, 11 Jan 2025 06:47:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=4kjNc3 tCuILS0UOM47eOBjqqnd7S22erMZdnlM8JJW0=; b=TNnBynaA3KjjwmXPj6ZaTV G4vFiuJBBk9ig7NeSFbm9548wlIl6XQm38Ue5v/X7E5E9ONx90iA4dKifRWVLX+k 3Y8t6wAp2PGSUCCpfwZt/diRA8dTDhXiLYeNWDI2JwzRSq33rLLXgJFaicB5VS4V pIu+CZ4yV8jO/6rlCuufS2KqSkIUJQoo902wKe2/dVHcqelMV2PpWAmo6CXJ6wLK d1Hg51kOxShIzE1sUWNuvq7BB9ynytD8pRaESPZsNvEEzmAr1rdALvMlW2DHjyZk giV4k69D7SO5CcSg8+7GizzmDnlKvWe5kmQcOv9FHJ+Y9IGYHm8Aeq85g5m4v1Xg == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 443f2hrqbc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 11 Jan 2025 06:47:22 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50B5NKUU003572; Sat, 11 Jan 2025 06:47:21 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 43yfatp665-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 11 Jan 2025 06:47:21 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50B6lLMb27984584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 11 Jan 2025 06:47:21 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 26D00580A4; Sat, 11 Jan 2025 06:47:21 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DA63580A0; Sat, 11 Jan 2025 06:47:19 +0000 (GMT) Received: from [9.43.3.138] (unknown [9.43.3.138]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Sat, 11 Jan 2025 06:47:19 +0000 (GMT) Message-ID: <58f51ab5-6048-4200-8a20-cf6a5c3f4dd9@linux.ibm.com> Date: Sat, 11 Jan 2025 12:17:17 +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 v2] mm/vmscan: Accumulate nr_demoted for accurate demotion statistics To: Li Zhijian , linux-mm@kvack.org Cc: Kaiyang Zhao , Andrew Morton , linux-kernel@vger.kernel.org References: <20250111015253.425693-1-lizhijian@fujitsu.com> Content-Language: en-US From: Donet Tom In-Reply-To: <20250111015253.425693-1-lizhijian@fujitsu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xBN5QtK5EDW-cQb4wkKxvUhPSOTbOHsH X-Proofpoint-ORIG-GUID: xBN5QtK5EDW-cQb4wkKxvUhPSOTbOHsH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxlogscore=991 phishscore=0 spamscore=0 priorityscore=1501 bulkscore=0 clxscore=1011 impostorscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501110054 On 1/11/25 07:22, Li Zhijian wrote: > In the shrink_folio_list() function, demote_folio_list() can be called > 2 times. Currently stat->nr_demoted will only store the last nr_demoted( > the later nr_demoted is always zero, the former nr_demoted will get lost), > as a result number of demoted pages is not accurate. > > Accumulate the nr_demoted count across multiple calls to > demote_folio_list(), ensuring accurate reporting of demotion statistics. > > Fixes: f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations") > Signed-off-by: Li Zhijian > --- > > Cc: Kaiyang Zhao > Cc: Andrew Morton > > Kaiyang, I removed you ACKED tag for V1, please review again > Andrew, Please drop the v1 from the mm-hotfixs-unstable if V2 is > accepted. > > V2: > Introudce a local nr_demoted to fix it's counted 2 times by nr_reclaimed wrongly. > --- > mm/vmscan.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 9a859b7d18d7..7f0624b98aa8 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -1053,7 +1053,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, > struct folio_batch free_folios; > LIST_HEAD(ret_folios); > LIST_HEAD(demote_folios); > - unsigned int nr_reclaimed = 0; > + unsigned int nr_reclaimed = 0, nr_demoted = 0; > unsigned int pgactivate = 0; > bool do_demote_pass; > struct swap_iocb *plug = NULL; > @@ -1522,8 +1522,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, > /* 'folio_list' is always empty here */ > > /* Migrate folios selected for demotion */ > - stat->nr_demoted = demote_folio_list(&demote_folios, pgdat); > - nr_reclaimed += stat->nr_demoted; > + nr_demoted = demote_folio_list(&demote_folios, pgdat); > + nr_reclaimed += nr_demoted; > + stat->nr_demoted += nr_demoted; > /* Folios that could not be demoted are still in @demote_folios */ > if (!list_empty(&demote_folios)) { > /* Folios which weren't demoted go back on @folio_list */ This patch looks good to me. I tested this patch with the stat fix [1] I could see the demotion counts are coming correctly. pgdemote_kswapd 60517 pgdemote_direct 6737 pgdemote_khugepaged 0 [1] https://lore.kernel.org/linux-mm/20250109060540.451261-1-donettom@linux.ibm.com/ Feel free to add Tested-by: Donet Tom Reviewed-by: Donet Tom