On Thu, 30 Jul 2020 16:57:05 -0400 Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> wrote: > On Wed, Jul 29, 2020 at 12:21:11PM -0700, Hugh Dickins wrote: > > On Sun, 26 Jul 2020, Pengfei Li wrote: > > > > > Since mm->locked_vm is already an atomic counter, > > > account_locked_vm() does not need to hold mmap_lock. > > > > I am worried that this patch, already added to mmotm, along with its > > 1/2 making locked_vm an atomic64, might be rushed into v5.9 with > > just that two-line commit description, and no discussion at all. > > > > locked_vm belongs fundamentally to mm/mlock.c, and the lock to guard > > it is mmap_lock; and mlock() has some complicated stuff to do under > > that lock while it decides how to adjust locked_vm. > > > > It is very easy to convert an unsigned long to an atomic64_t, but > > "atomic read, check limit and do stuff, atomic add" does not give > > the same guarantee as holding the right lock around it all. > > Yes, this is why I withdrew my attempt to do something similar last > year, I didn't want to make the accounting racy. Stack and heap > growing and mremap would be affected in addition to mlock. > > It'd help to hear more about the motivation for this. > Thanks for your comments. My motivation is to allow mm related counters to be safely read and written without holding mmap_lock. But sorry i didn't do well. -- Pengfei