[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [PATCH v7 4/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT
On 05/29/2018 11:24 PM, Michael S. Tsirkin wrote:
On Tue, Apr 24, 2018 at 02:13:47PM +0800, Wei Wang wrote:+/* + * Balloon will report pages which were free at the time of this call. As the + * reporting happens asynchronously, dirty bit logging must be enabled before + * this call is made. + */ +void balloon_free_page_start(void) +{ + balloon_free_page_start_fn(balloon_opaque); +}Please create notifier support, not a single global.
OK. The start is called at the end of bitmap_sync, and the stop is called at the beginning of bitmap_sync. In this case, we will need to add two migration states, MIGRATION_STATUS_BEFORE_BITMAP_SYNC and MIGRATION_STATUS_AFTER_BITMAP_SYNC, right?
+static void virtio_balloon_poll_free_page_hints(void *opaque) +{ + VirtQueueElement *elem; + VirtIOBalloon *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VirtQueue *vq = dev->free_page_vq; + uint32_t id; + size_t size; + + while (1) { + qemu_mutex_lock(&dev->free_page_lock); + while (dev->block_iothread) { + qemu_cond_wait(&dev->free_page_cond, &dev->free_page_lock); + } + + /* + * If the migration thread actively stops the reporting, exit + * immediately. + */ + if (dev->free_page_report_status == FREE_PAGE_REPORT_S_STOP) { Please refactor this : move loop body into a function so you can do lock/unlock in a single place.
Sounds good.
+ +static bool virtio_balloon_free_page_support(void *opaque) +{ + VirtIOBalloon *s = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(s); + + return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT); or if poison is negotiated.
Will make itreturn virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT) && !virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)
Best, Wei
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]