Re: On guest free page hinting and OOM
From: Michael S. Tsirkin
Date: Fri Mar 29 2019 - 11:08:55 EST
On Fri, Mar 29, 2019 at 03:24:24PM +0100, David Hildenbrand wrote:
>
> We had a very simple idea in mind: As long as a hinting request is
> pending, don't actually trigger any OOM activity, but wait for it to be
> processed. Can be done using simple atomic variable.
>
> This is a scenario that will only pop up when already pretty low on
> memory. And the main difference to ballooning is that we *know* we will
> get more memory soon.
No we don't. If we keep polling we are quite possibly keeping the CPU
busy so delaying the hint request processing. Again the issue it's a
tradeoff. One performance for the other. Very hard to know which path do
you hit in advance, and in the real world no one has the time to profile
and tune things. By comparison trading memory for performance is well
understood.
> "appended to guest memory", "global list of memory", malicious guests
> always using that memory like what about NUMA?
This can be up to the guest. A good approach would be to take
a chunk out of each node and add to the hints buffer.
> What about different page
> granularity?
Seems like an orthogonal issue to me.
> What about malicious guests?
That's an interesting question. Host can actually enforce that # of
hinted free pages at least matches the hint buffer size.
> What about more hitning
> requests than the buffer is capable to handle?
The idea is that we don't send more hints than in the buffer.
In this way host can actually control the overhead which
is probably a good thing - host knows how much benefit
can be derived from hinting. Guest doesn't.
> Honestly, requiring page hinting to make use of actual ballooning or
> additional memory makes me shiver. I hope I don't get nightmares ;) In
> the long term we might want to get rid of the inflation/deflation side
> of virtio-balloon, not require it.
>
> Please don't over-engineer an issue we haven't even see yet.
All hinting patches are very lightly tested as it is. OOM especially is
very hard to test properly. So *I* will sleep better at night if we
don't have corner cases. Balloon is already involved in MM for
isolation and somehow we live with that. So wait until you see actual
code before worrying about nightmares.
> Especially
> not using a mechanism that sounds more involved than actual hinting.
That would depend on the implementation.
It's just moving a page between two lists.
>
> As always, I might be very wrong, but this sounds way too complicated to
> me, both on the guest and the hypervisor side.
On the hypervisor side it can be literally nothing if we don't
want to enforce buffer size.
> --
>
> Thanks,
>
> David / dhildenb