Message ID | 5ab860d8ee987955e917748f9d6da525d3b52690.1718326003.git.baolin.wang@linux.alibaba.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2] mm: shmem: fix getting incorrect lruvec when replacing a shmem folio | expand |
On Fri, Jun 14, 2024 at 08:49:13AM +0800, Baolin Wang wrote: > * Charge @new as a replacement folio for @old. @old will > - * be uncharged upon free. This is only used by the page cache > - * (in replace_page_cache_folio()). > + * be uncharged upon free. This is used by the page cache > + * and shmem (in replace_page_cache_folio() and > + * shmem_replace_folio()). Please just delete this sentence. Functions do not keep track of who their callers are.
On 2024/6/14 11:22, Matthew Wilcox wrote: > On Fri, Jun 14, 2024 at 08:49:13AM +0800, Baolin Wang wrote: >> * Charge @new as a replacement folio for @old. @old will >> - * be uncharged upon free. This is only used by the page cache >> - * (in replace_page_cache_folio()). >> + * be uncharged upon free. This is used by the page cache >> + * and shmem (in replace_page_cache_folio() and >> + * shmem_replace_folio()). > > Please just delete this sentence. Functions do not keep track of who > their callers are. Sure. This sentence seems less helpful. Will do in v3.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a811dfff10cd..4d9fda1d84a0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7780,8 +7780,9 @@ void __mem_cgroup_uncharge_folios(struct folio_batch *folios) * @new: Replacement folio. * * Charge @new as a replacement folio for @old. @old will - * be uncharged upon free. This is only used by the page cache - * (in replace_page_cache_folio()). + * be uncharged upon free. This is used by the page cache + * and shmem (in replace_page_cache_folio() and + * shmem_replace_folio()). * * Both folios must be locked, @new->mapping must be set up. */ diff --git a/mm/shmem.c b/mm/shmem.c index 99bd3c34f0fb..4acaf02bfe44 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1908,7 +1908,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, xa_lock_irq(&swap_mapping->i_pages); error = shmem_replace_entry(swap_mapping, swap_index, old, new); if (!error) { - mem_cgroup_migrate(old, new); + mem_cgroup_replace_folio(old, new); __lruvec_stat_mod_folio(new, NR_FILE_PAGES, 1); __lruvec_stat_mod_folio(new, NR_SHMEM, 1); __lruvec_stat_mod_folio(old, NR_FILE_PAGES, -1);