cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
Cc: Hao Lee <haolee.swjtu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Linux MM <linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
	Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
	vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	Shakeel Butt <shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] mm: reduce spinlock contention in release_pages()
Date: Mon, 29 Nov 2021 13:23:19 +0000	[thread overview]
Message-ID: <YaTUR9WcGoOG4oLo@casper.infradead.org> (raw)
In-Reply-To: <YaSRtKwTCOj7JnR6-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>

On Mon, Nov 29, 2021 at 09:39:16AM +0100, Michal Hocko wrote:
> On Fri 26-11-21 16:26:23, Hao Lee wrote:
> [...]
> > I will try Matthew's idea to use semaphore or mutex to limit the number of BE
> > jobs that are in the exiting path. This sounds like a feasible approach for
> > our scenario...
> 
> I am not really sure this is something that would be acceptable. Your
> problem is resource partitioning. Papering that over by a lock is not
> the right way to go. Besides that you will likely hit a hard question on
> how many tasks to allow to run concurrently. Whatever the value some
> workload will very likely going to suffer. We cannot assume admin to
> chose the right value because there is no clear answer for that. Not to
> mention other potential problems - e.g. even more priority inversions
> etc.

I don't see how we get priority inversions.  These tasks are exiting; at
the point they take the semaphore, they should not be holding any locks.
They're holding a resource (memory) that needs to be released, but a
task wanting to acquire memory must already be prepared to sleep.

I see this as being a thundering herd problem.  We have dozens, maybe
hundreds of tasks all trying to free their memory at once.  If we force
the herd to go through a narrow gap, they arrive at the spinlock in an
orderly manner.

  parent reply	other threads:[~2021-11-29 13:23 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
     [not found] ` <20211124151915.GA6163-09FY7RZCRvthl2p70BpVqQ@public.gmane.org>
2021-11-24 15:57   ` Matthew Wilcox
     [not found]     ` <YZ5hBtWPBpHDWzE4-FZi0V3Vbi30CUdFEqe4BF2D2FQJk+8+b@public.gmane.org>
2021-11-25  3:13       ` Hao Lee
2021-11-24 16:31   ` Michal Hocko
     [not found]     ` <YZ5o/VmU59evp65J-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-11-25  3:24       ` Hao Lee
     [not found]         ` <CA+PpKPmy-u_BxYMCQOFyz78t2+3uM6nR9mQeX+MPyH6H2tOOHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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
     [not found]                   ` <20211125123133.GA7758-09FY7RZCRvthl2p70BpVqQ@public.gmane.org>
2021-11-25 14:18                     ` Michal Hocko
     [not found]                       ` <YZ+bI1fNpKar0bSU-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-11-26  6:50                         ` Hao Lee
     [not found]                           ` <CA+PpKP=hsuBmvv09OcD2Nct8B8Cqa03UfKFHAHzKxwE0SXGP4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-26 10:46                             ` Michal Hocko
     [not found]                               ` <YaC7BcTSijFj+bxR-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-11-26 16:26                                 ` Hao Lee
2021-11-29  8:39                                   ` Michal Hocko
     [not found]                                     ` <YaSRtKwTCOj7JnR6-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-11-29 13:23                                       ` Matthew Wilcox [this message]
     [not found]                                         ` <YaTUR9WcGoOG4oLo-FZi0V3Vbi30CUdFEqe4BF2D2FQJk+8+b@public.gmane.org>
2021-11-29 13:39                                           ` Michal Hocko
     [not found]               ` <20211125080238.GA7356-09FY7RZCRvthl2p70BpVqQ@public.gmane.org>
2021-11-25 18:04                 ` Matthew Wilcox
     [not found]                   ` <YZ/QFWzt/XbsLCqR-FZi0V3Vbi30CUdFEqe4BF2D2FQJk+8+b@public.gmane.org>
2021-11-26  6:54                     ` Hao Lee

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=YaTUR9WcGoOG4oLo@casper.infradead.org \
    --to=willy-wegcikhe2lqwvfeawa7xhq@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=haolee.swjtu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mhocko-IBi9RG/b67k@public.gmane.org \
    --cc=shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).