From: Wei Wang <wei.w.wang@intel.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org, kvm@vger.kernel.org,
linux-mm@kvack.org, mhocko@kernel.org, akpm@linux-foundation.org,
pbonzini@redhat.com, liliang.opensource@gmail.com,
yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com,
riel@redhat.com
Subject: Re: [virtio-dev] Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ
Date: Mon, 22 Jan 2018 19:25:45 +0800 [thread overview]
Message-ID: <5A65CA39.2070906@intel.com> (raw)
In-Reply-To: <20180119143517-mutt-send-email-mst@kernel.org>
On 01/19/2018 08:39 PM, Michael S. Tsirkin wrote:
> On Fri, Jan 19, 2018 at 11:44:21AM +0800, Wei Wang wrote:
>> On 01/18/2018 12:44 AM, Michael S. Tsirkin wrote:
>>> On Wed, Jan 17, 2018 at 01:10:11PM +0800, Wei Wang wrote:
>>>
>>>> + vb->start_cmd_id = cmd_id;
>>>> + queue_work(vb->balloon_wq, &vb->report_free_page_work);
>>> It seems that if a command was already queued (with a different id),
>>> this will result in new command id being sent to host twice, which will
>>> likely confuse the host.
>> I think that case won't happen, because
>> - the host sends a cmd id to the guest via the config, while the guest acks
>> back the received cmd id via the virtqueue;
>> - the guest ack back a cmd id only when a new cmd id is received from the
>> host, that is the above check:
>>
>> if (cmd_id != vb->start_cmd_id) { --> the driver only queues the
>> reporting work only when a new cmd id is received
>> /*
>> * Host requests to start the reporting by sending a
>> * new cmd id.
>> */
>> WRITE_ONCE(vb->report_free_page, true);
>> vb->start_cmd_id = cmd_id;
>> queue_work(vb->balloon_wq,
>> &vb->report_free_page_work);
>> }
>>
>> So the same cmd id wouldn't queue the reporting work twice.
>>
> Like this:
>
> vb->start_cmd_id = cmd_id;
> queue_work(vb->balloon_wq, &vb->report_free_page_work);
>
> command id changes
>
> vb->start_cmd_id = cmd_id;
>
> work executes
>
> queue_work(vb->balloon_wq, &vb->report_free_page_work);
>
> work executes again
>
If we think about the whole working flow, I think this case couldn't happen:
1) device send cmd_id=1 to driver;
2) driver receives cmd_id=1 in the config and acks cmd_id=1 to the
device via the vq;
3) device revives cmd_id=1;
4) device wants to stop the reporting by sending cmd_id=STOP;
5) driver receives cmd_id=STOP from the config, and acks cmd_id=STOP to
the device via the vq;
6) device sends cmd_id=2 to driver;
...
cmd_id=2 won't come after cmd_id=1, there will be a STOP cmd in between
them (STOP won't queue the work).
How about defining the correct device behavior in the spec:
The device Should NOT send a second cmd id to the driver until a STOP
cmd ack for the previous cmd id has been received from the guest.
Best,
Wei
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-01-22 11:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 5:10 [PATCH v22 0/3] Virtio-balloon: support free page reporting Wei Wang
2018-01-17 5:10 ` [PATCH v22 1/3] mm: support reporting free page blocks Wei Wang
2018-01-17 5:10 ` [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Wei Wang
2018-01-17 8:21 ` Pankaj Gupta
2018-01-17 9:00 ` Wei Wang
2018-01-17 9:27 ` Pankaj Gupta
2018-01-17 10:47 ` Wei Wang
2018-01-17 16:44 ` Michael S. Tsirkin
2018-01-18 13:30 ` Tetsuo Handa
2018-01-18 19:09 ` Michael S. Tsirkin
2018-01-18 21:11 ` Tetsuo Handa
2018-01-18 22:32 ` Michael S. Tsirkin
2018-01-20 14:23 ` Tetsuo Handa
2018-01-19 3:44 ` Wei Wang
2018-01-19 12:39 ` Michael S. Tsirkin
2018-01-22 11:25 ` Wei Wang [this message]
2018-01-24 3:18 ` [virtio-dev] " Wei Wang
2018-01-24 4:31 ` Michael S. Tsirkin
2018-01-24 4:29 ` Michael S. Tsirkin
2018-01-24 11:28 ` Wei Wang
2018-01-19 6:24 ` Wei Wang
2018-01-17 5:10 ` [PATCH v22 3/3] virtio-balloon: don't report free pages when page poisoning is enabled Wei Wang
2018-01-18 22:37 ` Michael S. Tsirkin
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=5A65CA39.2070906@intel.com \
--to=wei.w.wang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=kvm@vger.kernel.org \
--cc=liliang.opensource@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mst@redhat.com \
--cc=nilal@redhat.com \
--cc=pbonzini@redhat.com \
--cc=quan.xu0@gmail.com \
--cc=riel@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
--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).