From: Hao Lee <haolee.swjtu@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>, Linux MM <linux-mm@kvack.org>,
Johannes Weiner <hannes@cmpxchg.org>,
vdavydov.dev@gmail.com, Shakeel Butt <shakeelb@google.com>,
cgroups@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: reduce spinlock contention in release_pages()
Date: Fri, 26 Nov 2021 14:54:23 +0800 [thread overview]
Message-ID: <CA+PpKPmHfHca07W8aO+3bGjsqpUYOid=qBzm6dNuTyMmmkEpzQ@mail.gmail.com> (raw)
In-Reply-To: <YZ/QFWzt/XbsLCqR@casper.infradead.org>
On Fri, Nov 26, 2021 at 2:04 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Thu, Nov 25, 2021 at 08:02:38AM +0000, Hao Lee wrote:
> > On Thu, Nov 25, 2021 at 03:30:44AM +0000, Matthew Wilcox wrote:
> > > On Thu, Nov 25, 2021 at 11:24:02AM +0800, Hao Lee wrote:
> > > > On Thu, Nov 25, 2021 at 12:31 AM Michal Hocko <mhocko@suse.com> wrote:
> > > > > We do batch currently so no single task should be
> > > > > able to monopolize the cpu for too long. Why this is not sufficient?
> > > >
> > > > uncharge and unref indeed take advantage of the batch process, but
> > > > del_from_lru needs more time to complete. Several tasks will contend
> > > > spinlock in the loop if nr is very large.
> > >
> > > Is SWAP_CLUSTER_MAX too large? Or does your architecture's spinlock
> > > implementation need to be fixed?
> > >
> >
> > My testing server is x86_64 with 5.16-rc2. The spinlock should be normal.
> >
> > I think lock_batch is not the point. lock_batch only break spinning time
> > into small parts, but it doesn't reduce spinning time. The thing may get
> > worse if lock_batch is very small.
>
> OK. So if I understand right, you've got a lot of processes all
> calling exit_mmap() at the same time, which eventually becomes calls to
> unmap_vmas(), unmap_single_vma(), unmap_page_range(), zap_pte_range(),
> tlb_flush_mmu(), tlb_batch_pages_flush(), free_pages_and_swap_cache(),
> release_pages(), and then you see high contention on the LRU lock.
Exactly.
>
> Your use-case doesn't seem to mind sleeping (after all, these processes
> are exiting).
Yes!
> So we could put a semaphore in exit_mmap() to limit the
> number of simultaneous callers to unmap_vmas(). Do you want to try
> that out and see if it solves your problem? You might want to make it
> a counting semaphore (eg permit two tasks to exit at once) rather than
> a mutex. But maybe a mutex is just fine.
This is really a good idea. My train of thought was trapped in reducing the
lock contention. I will try to implement this idea and see if the service
stability will be improved much. Thanks for your help!
prev parent reply other threads:[~2021-11-26 6:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 15:19 [PATCH] mm: reduce spinlock contention in release_pages() Hao Lee
2021-11-24 15:57 ` Matthew Wilcox
2021-11-25 3:13 ` Hao Lee
2021-11-24 16:31 ` Michal Hocko
2021-11-25 3:24 ` Hao Lee
2021-11-25 3:30 ` Matthew Wilcox
2021-11-25 8:02 ` Hao Lee
2021-11-25 10:01 ` Michal Hocko
2021-11-25 12:31 ` Hao Lee
2021-11-25 14:18 ` Michal Hocko
2021-11-26 6:50 ` Hao Lee
2021-11-26 10:46 ` Michal Hocko
2021-11-26 16:26 ` Hao Lee
2021-11-29 8:39 ` Michal Hocko
2021-11-29 13:23 ` Matthew Wilcox
2021-11-29 13:39 ` Michal Hocko
2021-11-25 18:04 ` Matthew Wilcox
2021-11-26 6:54 ` Hao Lee [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='CA+PpKPmHfHca07W8aO+3bGjsqpUYOid=qBzm6dNuTyMmmkEpzQ@mail.gmail.com' \
--to=haolee.swjtu@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=shakeelb@google.com \
--cc=vdavydov.dev@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).