On Fri, Jan 19, 2018 at 11:44:21AM +0800, Wei Wang wrote:
On 01/18/2018 12:44 AM, Michael S. Tsirkin wrote:Like this:
On Wed, Jan 17, 2018 at 01:10:11PM +0800, Wei Wang wrote:I think that case won't happen, because
+ vb->start_cmd_id = cmd_id;It seems that if a command was already queued (with a different id),
+ queue_work(vb->balloon_wq, &vb->report_free_page_work);
this will result in new command id being sent to host twice, which will
likely confuse the host.
- 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.
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