Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

memcg-v1: no need for memcg locking for MGLRU

While updating the generation of the folios, MGLRU requires that the
folio's memcg association remains stable. With the charge migration
deprecated, there is no need for MGLRU to acquire locks to keep the folio
and memcg association stable.

[yuzhao@google.com: remove !rcu_read_lock_held() assertion]
Link: https://lkml.kernel.org/r/ZykEtcHrQRq-KrBC@google.com
Link: https://syzkaller.appspot.com/bug?extid=24f45b8beab9788e467e
Link: https://lore.kernel.org/lkml/67294349.050a0220.701a.0010.GAE@google.com/
[akpm@linux-foundation.org: remove now-unused local]
[shakeel.butt@linux.dev: folio_rcu() fixup, per Yu Zhao]
Link: https://lkml.kernel.org/r/iwmabnye3nl4merealrawt3bdvfii2pwavwrddrqpraoveet7h@ezrsdhjwwej7
Link: https://lkml.kernel.org/r/20241025012304.2473312-6-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shakeel Butt and committed by
Andrew Morton
cf4a6553 568bcf41

+1 -15
+1 -15
mm/vmscan.c
··· 3137 3137 unsigned long new_flags, old_flags = READ_ONCE(folio->flags); 3138 3138 3139 3139 VM_WARN_ON_ONCE(gen >= MAX_NR_GENS); 3140 - VM_WARN_ON_ONCE(!rcu_read_lock_held()); 3141 3140 3142 3141 do { 3143 3142 /* lru_gen_del_folio() has isolated this page? */ ··· 3352 3353 if (folio_nid(folio) != pgdat->node_id) 3353 3354 return NULL; 3354 3355 3355 - if (folio_memcg_rcu(folio) != memcg) 3356 + if (folio_memcg(folio) != memcg) 3356 3357 return NULL; 3357 3358 3358 3359 /* file VMAs can contain anon pages from COW */ ··· 3648 3649 .p4d_entry = walk_pud_range, 3649 3650 .walk_lock = PGWALK_RDLOCK, 3650 3651 }; 3651 - 3652 3652 int err; 3653 3653 struct lruvec *lruvec = walk->lruvec; 3654 - struct mem_cgroup *memcg = lruvec_memcg(lruvec); 3655 3654 3656 3655 walk->next_addr = FIRST_USER_ADDRESS; 3657 3656 ··· 3662 3665 if (walk->seq != max_seq) 3663 3666 break; 3664 3667 3665 - /* folio_update_gen() requires stable folio_memcg() */ 3666 - if (!mem_cgroup_trylock_pages(memcg)) 3667 - break; 3668 - 3669 3668 /* the caller might be holding the lock for write */ 3670 3669 if (mmap_read_trylock(mm)) { 3671 3670 err = walk_page_range(mm, walk->next_addr, ULONG_MAX, &mm_walk_ops, walk); 3672 3671 3673 3672 mmap_read_unlock(mm); 3674 3673 } 3675 - 3676 - mem_cgroup_unlock_pages(); 3677 3674 3678 3675 if (walk->batched) { 3679 3676 spin_lock_irq(&lruvec->lru_lock); ··· 4090 4099 } 4091 4100 } 4092 4101 4093 - /* folio_update_gen() requires stable folio_memcg() */ 4094 - if (!mem_cgroup_trylock_pages(memcg)) 4095 - return true; 4096 - 4097 4102 arch_enter_lazy_mmu_mode(); 4098 4103 4099 4104 pte -= (addr - start) / PAGE_SIZE; ··· 4134 4147 } 4135 4148 4136 4149 arch_leave_lazy_mmu_mode(); 4137 - mem_cgroup_unlock_pages(); 4138 4150 4139 4151 /* feedback from rmap walkers to page table walkers */ 4140 4152 if (mm_state && suitable_to_scan(i, young))