> Emm, after checked the code again, it seems you are right. But this can not explain why i got inaccurate demotion statistics from /proc/vmstat compared to the value i counted in the code myself days ago. Well... I know what was going on, the second pass will override stat->nr_demoted to be *zero* that makes the first try stat->nr_demoted got lost. Get Outlook for Android ________________________________ 发件人: Li, Zhijian/李 智坚 发送时间: 2025年1月10日星期五 22:20 收件人: Kaiyang Zhao 抄送: linux-mm@kvack.org; Andrew Morton; linux-kernel@vger.kernel.org 主题: Re: [PATCH 1/2] mm/vmscan: Accumulate nr_demoted for accurate demotion statistics > It looks like demotion will only be attempted once. On the second pass, do_demote_pass will be false, demote_folios will be empty and demote_folio_list() will do nothing. But I guess there is no harm in making nr_demoted an accumulation for less confusion in the future... Emm, after checked the code again, it seems you are right. But this can not explain why i got inaccurate demotion statistics from /proc/vmstat compared to the value i counted in the code myself days ago. thanks for your feedback, i will take a look next week. Get Outlook for Android ________________________________ 发件人: Kaiyang Zhao 发送时间: 2025年1月10日星期五 20:50 收件人: Li, Zhijian/李 智坚 抄送: linux-mm@kvack.org; Andrew Morton; linux-kernel@vger.kernel.org 主题: Re: [PATCH 1/2] mm/vmscan: Accumulate nr_demoted for accurate demotion statistics On Fri, Jan 10, 2025 at 08:21:32PM +0800, Li Zhijian wrote: > In the shrink_folio_list() function, demote_folio_list() can be called > multiple times, which can lead to inaccurate demotion statistics if the > number of demoted pages is not accumulated correctly. It looks like demotion will only be attempted once. On the second pass, do_demote_pass will be false, demote_folios will be empty and demote_folio_list() will do nothing. But I guess there is no harm in making nr_demoted an accumulation for less confusion in the future...