Re: [PATCH] virtio-balloon: fix managed page counts when migrating pages between zones

David Hildenbrand
2019-12-05T10:13:24Z

On 05.12.19 11:08, Igor Mammedov wrote:
> On Wed, 4 Dec 2019 21:48:07 +0100
> David Hildenbrand <david@redhat.com> wrote:
>
>> In case we have to migrate a ballon page to a newpage of another zone, the
>> managed page count of both zones is wrong. Paired with memory offlining
>> (which will adjust the managed page count), we can trigger kernel crashes
>> and all kinds of different symptoms.
>>
>> One way to reproduce:
>> 1. Start a QEMU guest with 4GB, no NUMA
>> 2. Hotplug a 1GB DIMM and only the memory to ZONE_NORMAL
> ^^^^
> should it be "online" ?

Very right!
[...]

>> mutex_unlock(&vb->balloon_lock);
>>
>> + /* fixup the managed page count (esp. of the zone) */
>> + if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) {
> what happens when balloon has the feature?

With that feature we don't touch the managed page counts at all (see the
other 2 adjust_managed_page_count() callers in this file).

>
>> + adjust_managed_page_count(page, 1);
>> + adjust_managed_page_count(newpage, -1);
>> + }
>> +
>> put_page(page); /* balloon reference */
>>
>> return MIGRATEPAGE_SUCCESS;
>

BTW, I posted a v2 just some minutes ago
(https://lkml.kernel.org/r/20191205092420.6934-1-david@redhat.com)

Thanks!