From: Pengfei Li <fly@kernel.page>
To: Hugh Dickins <hughd@google.com>
Cc: akpm@linux-foundation.org, bmt@zurich.ibm.com,
dledford@redhat.com, willy@infradead.org, vbabka@suse.cz,
kirill.shutemov@linux.intel.com, jgg@ziepe.ca,
alex.williamson@redhat.com, cohuck@redhat.com,
daniel.m.jordan@oracle.com, dbueso@suse.de, jglisse@redhat.com,
jhubbard@nvidia.com, ldufour@linux.ibm.com,
Liam.Howlett@oracle.com, peterz@infradead.org, cl@linux.com,
jack@suse.cz, rientjes@google.com, walken@google.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, fly@kernel.page
Subject: Re: [PATCH 2/2] mm, util: account_locked_vm() does not hold mmap_lock
Date: Sun, 2 Aug 2020 19:07:24 +0800 [thread overview]
Message-ID: <20200802190724.493304b6.fly@kernel.page> (raw)
In-Reply-To: <alpine.LSU.2.11.2007291121280.4649@eggly.anvils>
On Wed, 29 Jul 2020 12:21:11 -0700 (PDT)
Hugh Dickins <hughd@google.com> wrote:
Sorry for the late reply.
> 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.
>
> (At the very least, __account_locked_vm() in 1/2 should be changed to
> replace its atomic64_add by an atomic64_cmpxchg, to enforce the limit
> that it just checked. But that will be no more than lipstick on a
> pig, when the right lock that everyone else agrees upon is not being
> held.)
>
Thank you for your detailed comment.
You are right, I should use atomic64_cmpxchg to guarantee the limit of
RLIMIT_MEMLOCK.
> Now, it can be argued that our locked_vm and pinned_vm maintenance
> is so random and deficient, and too difficult to keep right across
> a sprawl of drivers, that we should just be grateful for those that
> do volunteer to subject themselves to RLIMIT_MEMLOCK limitation,
> and never mind if it's a little racy.
>
> And it may well be that all those who have made considerable efforts
> in the past to improve the situation, have more interesting things to
> devote their time to, and would prefer not to get dragged back here.
>
> But let's at least give this a little more visibility, and hope
> to hear opinions one way or the other from those who care.
Thank you. My patch should be more thoughtful.
I will send an email to Stephen soon asking to remove these two patches
from -mm tree.
--
Pengfei
prev parent reply other threads:[~2020-08-02 11:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-26 8:02 [PATCH 1/2] mm: make mm->locked_vm an atomic64 counter Pengfei Li
2020-07-26 8:02 ` [PATCH 2/2] mm, util: account_locked_vm() does not hold mmap_lock Pengfei Li
2020-07-29 19:21 ` Hugh Dickins
2020-07-30 20:57 ` Daniel Jordan
2020-08-02 11:23 ` Pengfei Li
2020-08-02 11:07 ` Pengfei Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200802190724.493304b6.fly@kernel.page \
--to=fly@kernel.page \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=alex.williamson@redhat.com \
--cc=bmt@zurich.ibm.com \
--cc=cl@linux.com \
--cc=cohuck@redhat.com \
--cc=daniel.m.jordan@oracle.com \
--cc=dbueso@suse.de \
--cc=dledford@redhat.com \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=jgg@ziepe.ca \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=ldufour@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
--cc=walken@google.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.