Re: [PATCH] virtio_balloon: fix deadlock on OOM

From: Wei Wang
Date: Thu Oct 19 2017 - 03:57:59 EST


On 10/19/2017 01:19 AM, Michael S. Tsirkin wrote:
On Fri, Oct 13, 2017 at 11:06:23PM +0900, Tetsuo Handa wrote:
Michael S. Tsirkin wrote:
This is a replacement for
[PATCH] virtio: avoid possible OOM lockup at virtballoon_oom_notify()
but unlike that patch it actually deflates on oom even in presence of
lock contention.
But Wei Wang is proposing VIRTIO_BALLOON_F_SG which will try to allocate
memory, isn't he?
Hopefully that can be fixed by allocating outside the lock.


I think that would still have an issue even without the lock, because we can't do
any memory allocation in the OOM code path.

Probably, we could write a separate function, leak_balloon_oom() for the oom notifier,
which puts the oom deflating pages to the vq one by one, and kick when the vq is full.

In this case, we would need to stop the normal leak_balloon while oom deflating starts.
However, a better optimization I think would be to do some kind of consolidation, since
leak_balloon is already deflating, leak_ballon_oom can just count the number of pages
that have been deflated by leak_balloon and return when it reaches oom_pages.


Best,
Wei