On Tue, May 07, 2024 at 05:06:57PM +0800, Kefeng Wang wrote: > > +static void filemap_lruvec_stat_update(struct mem_cgroup *memcg, > > + pg_data_t *pgdat, int nr) > > +{ > > + struct lruvec *lruvec; > > + > > + if (!memcg) { > > + __mod_node_page_state(pgdat, NR_FILE_MAPPED, nr); > > + return; > > + } > > + > > + lruvec = mem_cgroup_lruvec(memcg, pgdat); > > + __mod_lruvec_state(lruvec, NR_FILE_MAPPED, nr); > > +} > > + > > vm_fault_t filemap_map_pages(struct vm_fault *vmf, > > pgoff_t start_pgoff, pgoff_t end_pgoff) > > { > > @@ -3628,6 +3642,9 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, > > vm_fault_t ret = 0; > > unsigned long rss = 0; > > unsigned int nr_pages = 0, mmap_miss = 0, mmap_miss_saved, folio_type; > > + struct mem_cgroup *memcg, *memcg_cur; > > + pg_data_t *pgdat, *pgdat_cur; > > + int nr_mapped = 0; > > > > rcu_read_lock(); > > folio = next_uptodate_folio(&xas, mapping, end_pgoff); > > @@ -3648,9 +3665,20 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, > > } > > > > folio_type = mm_counter_file(folio); > > + memcg = folio_memcg(folio); > > + pgdat = folio_pgdat(folio); You should be able to do: lruvec = folio_lruvec(folio); and then pass that directly to filemap_lruvec_stat_update().