From: Nitesh Narayan Lal <nitesh@redhat.com>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: kvm list <kvm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
virtio-dev@lists.oasis-open.org,
Paolo Bonzini <pbonzini@redhat.com>,
lcapitulino@redhat.com, pagupta@redhat.com, wei.w.wang@intel.com,
Yang Zhang <yang.zhang.wz@gmail.com>,
Rik van Riel <riel@surriel.com>,
David Hildenbrand <david@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
dodgen@google.com, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
dhildenb@redhat.com, Andrea Arcangeli <aarcange@redhat.com>,
john.starks@microsoft.com, Dave Hansen <dave.hansen@intel.com>,
Michal Hocko <mhocko@suse.com>,
cohuck@redhat.com
Subject: Re: [QEMU Patch 2/2] virtio-balloon: support for handling page reporting
Date: Mon, 12 Aug 2019 11:26:38 -0400 [thread overview]
Message-ID: <101649ae-58d4-76ee-91f3-42ac1c145c46@redhat.com> (raw)
In-Reply-To: <CAKgT0Uc8kGwX8VwU2b51qVuh2z5eZQ6XhSnYMryTVa_pKHCvew@mail.gmail.com>
On 8/12/19 11:18 AM, Alexander Duyck wrote:
> On Mon, Aug 12, 2019 at 6:14 AM Nitesh Narayan Lal <nitesh@redhat.com> wrote:
>> Page reporting is a feature which enables the virtual machine to report
>> chunk of free pages to the hypervisor.
>> This patch enables QEMU to process these reports from the VM and discard the
>> unused memory range.
>>
>> Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
>> ---
>> hw/virtio/virtio-balloon.c | 41 ++++++++++++++++++++++++++++++
>> include/hw/virtio/virtio-balloon.h | 2 +-
>> 2 files changed, 42 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
>> index 25de154307..1132e47ee0 100644
>> --- a/hw/virtio/virtio-balloon.c
>> +++ b/hw/virtio/virtio-balloon.c
>> @@ -320,6 +320,39 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
>> balloon_stats_change_timer(s, 0);
>> }
>>
>> +static void virtio_balloon_handle_reporting(VirtIODevice *vdev, VirtQueue *vq)
>> +{
>> + VirtQueueElement *elem;
>> +
>> + while ((elem = virtqueue_pop(vq, sizeof(VirtQueueElement)))) {
>> + unsigned int i;
>> +
>> + for (i = 0; i < elem->in_num; i++) {
>> + void *gaddr = elem->in_sg[i].iov_base;
>> + size_t size = elem->in_sg[i].iov_len;
>> + ram_addr_t ram_offset;
>> + size_t rb_page_size;
>> + RAMBlock *rb;
>> +
>> + if (qemu_balloon_is_inhibited())
>> + continue;
>> +
>> + rb = qemu_ram_block_from_host(gaddr, false, &ram_offset);
>> + rb_page_size = qemu_ram_pagesize(rb);
>> +
>> + /* For now we will simply ignore unaligned memory regions */
>> + if ((ram_offset | size) & (rb_page_size - 1))
>> + continue;
>> +
>> + ram_block_discard_range(rb, ram_offset, size);
>> + }
>> +
>> + virtqueue_push(vq, elem, 0);
>> + virtio_notify(vdev, vq);
>> + g_free(elem);
>> + }
>> +}
>> +
> No offense, but I am a bit annoyed.
None taken at all.
> If you are going to copy my code
> you should at least keep up with the fixes.
Yeah I did refer to your code and just because the quality of your code is
better than what I posted earlier and there is quite a lot for me to learn from it.
> stuff to handle the poison value. If you are going to just duplicate
> my setup you might as well have just pulled the QEMU patches from the
> last submission I did. Then this would have at least has the fix for
> the page poisoning.
>
The only reason I didn't include the poison change as I still need to understand
them.
I have this mentioned in my cover-email.
> Also it wouldn't hurt to mention that you are
> basing it off of the patch set I submitted since it hasn't been
> accepted yet.
My bad!! This I will surely do from next time.
>
>> static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)
>> {
>> VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
>> @@ -792,6 +825,12 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
>> s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
>> s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
>>
>> + if (virtio_has_feature(s->host_features,
>> + VIRTIO_BALLOON_F_REPORTING)) {
>> + s->reporting_vq = virtio_add_queue(vdev, 16,
>> + virtio_balloon_handle_reporting);
>> + }
>> +
>> if (virtio_has_feature(s->host_features,
>> VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
>> s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE,
>> @@ -912,6 +951,8 @@ static Property virtio_balloon_properties[] = {
>> * is disabled, resulting in QEMU 3.1 migration incompatibility. This
>> * property retains this quirk for QEMU 4.1 machine types.
>> */
>> + DEFINE_PROP_BIT("free-page-reporting", VirtIOBalloon, host_features,
>> + VIRTIO_BALLOON_F_REPORTING, true),
>> DEFINE_PROP_BOOL("qemu-4-0-config-size", VirtIOBalloon,
>> qemu_4_0_config_size, false),
>> DEFINE_PROP_LINK("iothread", VirtIOBalloon, iothread, TYPE_IOTHREAD,
>> diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h
>> index d1c968d237..15a05e6435 100644
>> --- a/include/hw/virtio/virtio-balloon.h
>> +++ b/include/hw/virtio/virtio-balloon.h
>> @@ -42,7 +42,7 @@ enum virtio_balloon_free_page_report_status {
>>
>> typedef struct VirtIOBalloon {
>> VirtIODevice parent_obj;
>> - VirtQueue *ivq, *dvq, *svq, *free_page_vq;
>> + VirtQueue *ivq, *dvq, *svq, *free_page_vq, *reporting_vq;
>> uint32_t free_page_report_status;
>> uint32_t num_pages;
>> uint32_t actual;
>> --
>> 2.21.0
>> q
--
Thanks
Nitesh
next prev parent reply other threads:[~2019-08-12 15:27 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 13:12 [RFC][PATCH v12 0/2] mm: Support for page reporting Nitesh Narayan Lal
2019-08-12 13:12 ` [RFC][Patch v12 1/2] mm: page_reporting: core infrastructure Nitesh Narayan Lal
2019-08-12 18:47 ` Alexander Duyck
2019-08-12 20:04 ` Nitesh Narayan Lal
2019-08-20 14:11 ` Nitesh Narayan Lal
2019-08-12 20:05 ` David Hildenbrand
2019-08-13 10:30 ` Nitesh Narayan Lal
2019-08-13 10:34 ` David Hildenbrand
2019-08-13 10:42 ` Nitesh Narayan Lal
2019-08-13 10:44 ` David Hildenbrand
2019-08-13 23:14 ` Alexander Duyck
2019-08-14 7:07 ` David Hildenbrand
2019-08-14 12:49 ` [virtio-dev] " Nitesh Narayan Lal
2019-08-14 15:49 ` Nitesh Narayan Lal
2019-08-14 16:11 ` Alexander Duyck
2019-08-15 13:15 ` Nitesh Narayan Lal
2019-08-15 19:22 ` Nitesh Narayan Lal
2019-08-15 23:00 ` Alexander Duyck
2019-08-16 18:35 ` Nitesh Narayan Lal
2019-08-30 15:15 ` Nitesh Narayan Lal
2019-08-30 15:31 ` Alexander Duyck
2019-08-30 16:05 ` Nitesh Narayan Lal
2019-09-04 8:40 ` [virtio-dev] " David Hildenbrand
2019-10-10 20:36 ` Alexander Duyck
2019-10-11 11:02 ` Nitesh Narayan Lal
2019-08-12 13:12 ` [RFC][Patch v12 2/2] virtio-balloon: interface to support free page reporting Nitesh Narayan Lal
2019-08-14 10:29 ` Cornelia Huck
2019-08-14 11:47 ` Nitesh Narayan Lal
2019-08-14 13:42 ` Cornelia Huck
2019-08-14 14:01 ` Nitesh Narayan Lal
2019-08-12 13:13 ` [QEMU Patch 1/2] virtio-balloon: adding bit for page reporting support Nitesh Narayan Lal
2019-08-12 13:13 ` [QEMU Patch 2/2] virtio-balloon: support for handling page reporting Nitesh Narayan Lal
2019-08-12 15:18 ` Alexander Duyck
2019-08-12 15:26 ` Nitesh Narayan Lal [this message]
2019-09-11 12:30 ` [RFC][PATCH v12 0/2] mm: Support for " David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=101649ae-58d4-76ee-91f3-42ac1c145c46@redhat.com \
--to=nitesh@redhat.com \
--cc=aarcange@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=cohuck@redhat.com \
--cc=dave.hansen@intel.com \
--cc=david@redhat.com \
--cc=dhildenb@redhat.com \
--cc=dodgen@google.com \
--cc=john.starks@microsoft.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mst@redhat.com \
--cc=pagupta@redhat.com \
--cc=pbonzini@redhat.com \
--cc=riel@surriel.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=wei.w.wang@intel.com \
--cc=yang.zhang.wz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).