From: David Hildenbrand <david@redhat.com>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 1/2] virtio-balloon: Prevent guest from starting a report when we didn't request one
Date: Tue, 23 Jun 2020 08:54:31 +0200 [thread overview]
Message-ID: <4ea55633-51df-1ca7-72bc-4c9c7d429575@redhat.com> (raw)
In-Reply-To: <CAKgT0UcP6gGK_X80pepwpsC=JFmL9+n61ow-HEJMKbFVZ4Jh8g@mail.gmail.com>
>>> +++ b/hw/virtio/virtio-balloon.c
>>> @@ -527,7 +527,8 @@ static bool get_free_page_hints(VirtIOBalloon *dev)
>>> ret = false;
>>> goto out;
>>> }
>>> - if (id == dev->free_page_report_cmd_id) {
>>> + if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED &&
>>> + id == dev->free_page_report_cmd_id) {
>>> dev->free_page_report_status = FREE_PAGE_REPORT_S_START;
>>> } else {
>>> /*
>>
>> But doesn't that mean that, after the first hint, all further ones will
>> be discarded and we'll enter the STOP state in the else case? Or am I
>> missing something?
>>
>> Shouldn't this be something like
>>
>> if (id == dev->free_page_report_cmd_id) {
>> if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED) {
>> dev->free_page_report_status = FREE_PAGE_REPORT_S_START;
>> }
>> /* Stay in FREE_PAGE_REPORT_S_START as long as the cmd_id match .*/
>> } else { ...
>
> There should only be one element containing an outbuf at the start of
> the report. Once that is processed we should not see the driver
> sending additional outbufs unless it is sending the STOP command ID.
Ok, I assume what Linux guests do is considered the correct protocol.
[...]
>
>>> @@ -592,14 +593,16 @@ static void virtio_balloon_free_page_start(VirtIOBalloon *s)
>>> return;
>>> }
>>>
>>> - if (s->free_page_report_cmd_id == UINT_MAX) {
>>> + qemu_mutex_lock(&s->free_page_lock);
>>> +
>>> + if (s->free_page_report_cmd_id++ == UINT_MAX) {
>>> s->free_page_report_cmd_id =
>>> VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN;
>>> - } else {
>>> - s->free_page_report_cmd_id++;
>>> }
>>
>> Somewhat unrelated cleanup.
>
> Agreed. I can drop it if preferred. I just took care of it because I
> was adding the lock above and below to prevent us from getting into
> any wierd states where the command ID might be updated but the report
> status was not.
No hard feelings, it just makes reviewing harder, because one has to
investigate how the changes relate to the locking changes - to find out
they don't. :)
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2020-06-23 6:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 21:53 [PATCH 0/2] virtio-balloon: Free page hinting clean-ups Alexander Duyck
2020-06-19 21:53 ` [PATCH 1/2] virtio-balloon: Prevent guest from starting a report when we didn't request one Alexander Duyck
2020-06-22 8:10 ` David Hildenbrand
2020-06-22 22:37 ` Alexander Duyck
2020-06-23 6:54 ` David Hildenbrand [this message]
2020-06-19 21:53 ` [PATCH 2/2] virtio-balloon: Replace free page hinting references to 'report' with 'hint' Alexander Duyck
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=4ea55633-51df-1ca7-72bc-4c9c7d429575@redhat.com \
--to=david@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtio-dev@lists.oasis-open.org \
/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).