Re: [PATCH] virtio_balloon: high order allocation

From: Liu Shixin
Date: Fri Dec 23 2022 - 22:27:04 EST


Hi, Soichiro:

I'm interested with your patch. I'm looking at it and found some possible issues.


On 2022/12/23 17:35, Soichiro Ueda wrote:
> + for (i = 0; i < num_pfns; i++) {
> + set_page_pfns(vb, vb->pfns + vb->num_pfns + i,
> + nth_page(page, i));
> + }
Since the interval of vb->num_pfns is VIRTIO_BALLOON_PAGES_PER_PAGE,
it seems that the pfns[] should be vb->pfns + vb->num_pfns + i * VIRTIO_BALLOON_PAGES_PER_PAGE.
> + vb->num_pages +=
> + num_pfns * VIRTIO_BALLOON_PAGES_PER_PAGE;
> + if (!virtio_has_feature(
> + vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
> + adjust_managed_page_count(page, -num_pfns);
num_pfns is of the unsigned int type so need be to converted to long manually.

root@syzkaller:~# free -m
total used free shared buff/cache available
Mem: 1975 78 1822 2 74 1869
Swap: 0 0 0
root@syzkaller:~# QEMU 7.2.0 monitor - type 'help' for more information
(qemu) info balloon
balloon: actual=2048
(qemu) balloon 2046
(qemu)

root@syzkaller:~# free -m
total used free shared buff/cache available
Mem: 33556405 33554510 1819 2 74 1867
Swap: 0 0 0
> +
> + num_pfns = (1 << order);
> + for (i = 0; i < num_pfns; i++)
> + set_page_pfns(vb, vb->pfns + vb->num_pfns + i, nth_page(page, i));
The same problem mentioned above.


thanks,

Liu Shixin

.