On Wed, 12 Feb 2025 04:28PM +0000, Matthew Wilcox wrote: >On Wed, Feb 12, 2025 at 10:06:27AM +0800, Shengken Lin wrote: >> The function of PageMemcgKmem(page) is the same as that of >> folio_memcg_kmem(folio). >> >> Since __memcg_kmem_uncharge_page already uses folio_memcg_kmem to check >> if a folio has been uncharged, calling PageMemcgKmem(page) before >> __memcg_kmem_uncharge_page is redundant. > >But it saves a function call. NAK. Hi Matthew Wilcox, If it can save a function call, then adding PageMemcgKmem(page) in include/linux/memcontrol.h would make the code more consistent. If this is considered more reasonable, I can submit a new patch. --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1707,7 +1707,7 @@ static inline int memcg_kmem_charge_page(struct page *page, gfp_t gfp, static inline void memcg_kmem_uncharge_page(struct page *page, int order) { - if (memcg_kmem_online()) + if (memcg_kmem_online() && PageMemcgKmem(page)) __memcg_kmem_uncharge_page(page, order); } -- Best regards, Shengken Lin