From: Tyler Sanderson <tysand@google.com>
To: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
David Hildenbrand <david@redhat.com>,
"Wang, Wei W" <wei.w.wang@intel.com>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
David Rientjes <rientjes@google.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Michal Hocko <mhocko@kernel.org>
Subject: Re: Balloon pressuring page cache
Date: Mon, 3 Feb 2020 15:16:04 -0800 [thread overview]
Message-ID: <CAJuQAmogkvpZfxH-pyHHYpzRpQpigiha4bfA8pofRiVqKh89Pw@mail.gmail.com> (raw)
In-Reply-To: <2584af9b8d358faf27ee838fdab2be594e255433.camel@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4548 bytes --]
On Mon, Feb 3, 2020 at 1:22 PM Alexander Duyck <
alexander.h.duyck@linux.intel.com> wrote:
> On Mon, 2020-02-03 at 12:32 -0800, Tyler Sanderson wrote:
> > There were apparently good reasons for moving away from OOM notifier
> > callback:
> > https://lkml.org/lkml/2018/7/12/314
> > https://lkml.org/lkml/2018/8/2/322
> >
> > In particular the OOM notifier is worse than the shrinker because:
> > It is last-resort, which means the system has already gone through
> > heroics to prevent OOM. Those heroic reclaim efforts are expensive and
> > impact application performance.
> > It lacks understanding of NUMA or other OOM constraints.
> > It has a higher potential for bugs due to the subtlety of the callback
> > context.
> > Given the above, I think the shrinker API certainly makes the most sense
> > _if_ the balloon size is static. In that case memory should be reclaimed
> > from the balloon early and proportionally to balloon size, which the
> > shrinker API achieves.
>
> The problem is the shrinker doesn't have any concept of tiering or
> priority. I suspect he reason for using the OOM notification is because in
> practice it should be the last thing we are pulling memory out of with
> things like page cache and slab caches being first. Once we have pages
> that are leaked out of the balloon by the shrinker it will trigger the
> balloon wanting to reinflate.
Deciding whether to trade IO performance (page cache) for memory-usage
efficiency (balloon) seems use-case dependent.
Deciding when to re-inflate is a similar policy choice.
If the balloon's shrinker priority is hard-coded to "last-resort" then
there would be no way to implement a policy where page cache growth could
shrink the balloon.
The current balloon implementation allows the host to implement this policy
and tune the tradeoff between balloon and page cache.
> Ideally if the shrinker is running we
> shouldn't be able to reinflate the balloon, and if we are reinflating the
> balloon we shouldn't need to run the shrinker. The fact that we can do
> both at the same time is problematic.
>
I agree that this is inefficient.
>
> > However, if the balloon is inflating and intentionally causing memory
> > pressure then this results in the inefficiency pointed out earlier.
> >
> > If the balloon is inflating but not causing memory pressure then there
> > is no problem with either API.
>
> The entire point of the balloon is to cause memory pressure. Otherwise
> essentially all we are really doing is hinting since the guest doesn't
> need the memory and isn't going to use it any time soon.
>
Causing memory pressure is just a mechanism to achieve increased reclaim.
If there was a better mechanism (like the fine-grained-cache-shrinking one
discussed below) then I think the balloon device would be perfectly
justified in using that instead (and maybe "balloon" becomes a misnomer. Oh
well).
>
> > This suggests another route: rather than cause memory pressure to shrink
> > the page cache, the balloon could issue the equivalent of "echo 3 >
> > /proc/sys/vm/drop_caches".
> > Of course ideally, we want to be more fine grained than "drop
> > everything". We really want an API that says "drop everything that
> > hasn't been accessed in the last 5 minutes".
> >
> > This would eliminate the need for the balloon to cause memory pressure
> > at all which avoids the inefficiency in question. Furthermore, this
> > pairs nicely with the FREE_PAGE_HINT feature.
>
> Something similar was brought up in the discussion we had about this in my
> patch set. The problem is, by trying to use a value like "5 minutes" it
> implies that we are going to need to track some extra state somewhere to
> determine that value.
>
> An alternative is to essentially just slowly shrink memory for the guest.
> We had some discussion about this in another thread, and the following
> code example was brought up as a way to go about doing that:
>
> https://github.com/Conan-Kudo/omv-kernel-rc/blob/master/0154-sysctl-vm-Fine-grained-cache-shrinking.patch
>
> The idea is you essentially just slowly bleed the memory from the guest by
> specifying some amount of MB of cache to be freed on some regular
> interval.
>
Makes sense. Whatever API is settled on, I'd just propose that we allow the
host to invoke it via the balloon device since the host has a host-global
view of memory and can make decisions that an individual guest cannot.
Alex, what is the status of your fine-grained-cache-shrinking patch? It
seems like a really good idea.
> Thanks.
>
> - Alex
>
>
[-- Attachment #2: Type: text/html, Size: 6266 bytes --]
next prev parent reply other threads:[~2020-02-03 23:16 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAJuQAmpDUyve2S+oxp9tLUhuRcnddXnNztC5PmYOOCpY6c68xg@mail.gmail.com>
[not found] ` <91270a68-ff48-88b0-219c-69801f0c252f@redhat.com>
[not found] ` <CAJuQAmoaK0Swytu2Os_SQRfG5_LqiCPaDa9yatatm9MtfncNTQ@mail.gmail.com>
2020-01-30 15:02 ` David Hildenbrand
2020-01-30 15:20 ` Michael S. Tsirkin
2020-01-30 15:23 ` David Hildenbrand
2020-01-30 15:31 ` Wang, Wei W
2020-01-30 19:59 ` Tyler Sanderson
2020-02-03 13:11 ` Michael S. Tsirkin
2020-02-03 16:18 ` Alexander Duyck
2020-02-03 16:34 ` David Hildenbrand
2020-02-03 17:03 ` Michael S. Tsirkin
2020-02-03 20:32 ` Tyler Sanderson
2020-02-03 21:22 ` Alexander Duyck
2020-02-03 23:16 ` Tyler Sanderson [this message]
2020-02-04 0:10 ` Alexander Duyck
2020-02-04 5:45 ` Michael S. Tsirkin
2020-02-04 8:29 ` David Hildenbrand
2020-02-04 18:52 ` Tyler Sanderson
2020-02-04 18:56 ` Michael S. Tsirkin
2020-02-04 19:17 ` David Hildenbrand
2020-02-04 23:58 ` Tyler Sanderson
2020-02-05 0:15 ` Tyler Sanderson
2020-02-05 6:57 ` Michael S. Tsirkin
2020-02-05 19:01 ` Tyler Sanderson
2020-02-05 19:22 ` Alexander Duyck
2020-02-05 21:44 ` Tyler Sanderson
2020-02-06 11:00 ` David Hildenbrand
2020-02-03 22:50 ` Nadav Amit
2020-02-04 8:35 ` David Hildenbrand
2020-02-04 8:40 ` Michael S. Tsirkin
2020-02-04 8:48 ` David Hildenbrand
2020-02-04 14:30 ` David Hildenbrand
2020-02-04 16:50 ` Michael S. Tsirkin
2020-02-04 16:56 ` David Hildenbrand
2020-02-04 20:33 ` Michael S. Tsirkin
2020-02-05 8:31 ` David Hildenbrand
2020-02-05 6:52 ` Wang, Wei W
2020-02-05 7:05 ` Michael S. Tsirkin
2020-02-05 8:50 ` Wang, Wei W
2020-02-05 6:49 ` Wang, Wei W
2020-02-05 8:19 ` David Hildenbrand
2020-02-05 8:54 ` Wang, Wei W
2020-02-05 8:56 ` David Hildenbrand
2020-02-05 9:00 ` Wang, Wei W
2020-02-05 9:05 ` David Hildenbrand
2020-02-05 9:19 ` Wang, Wei W
2020-02-05 9:22 ` David Hildenbrand
2020-02-05 9:35 ` Wang, Wei W
2020-02-05 9:37 ` David Hildenbrand
2020-02-05 9:49 ` Wang, Wei W
2020-02-05 9:58 ` David Hildenbrand
2020-02-05 10:25 ` Michael S. Tsirkin
2020-02-05 10:42 ` David Hildenbrand
2020-02-05 9:35 ` Michael S. Tsirkin
2020-02-05 18:43 ` Tyler Sanderson
2020-02-06 9:30 ` Wang, Wei W
2020-02-05 7:35 ` Nadav Amit
2020-02-05 8:19 ` David Hildenbrand
2020-02-05 10:27 ` Michael S. Tsirkin
2020-02-05 10:43 ` David Hildenbrand
2020-01-30 22:46 ` Tyler Sanderson
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=CAJuQAmogkvpZfxH-pyHHYpzRpQpigiha4bfA8pofRiVqKh89Pw@mail.gmail.com \
--to=tysand@google.com \
--cc=alexander.h.duyck@linux.intel.com \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mst@redhat.com \
--cc=rientjes@google.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.w.wang@intel.com \
/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