From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-dev-return-3037-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [66.179.20.138]) by lists.oasis-open.org (Postfix) with ESMTP id 046925818F80 for ; Tue, 23 Jan 2018 19:16:22 -0800 (PST) Message-ID: <5A67FB10.2050201@intel.com> Date: Wed, 24 Jan 2018 11:18:40 +0800 From: Wei Wang MIME-Version: 1.0 References: <1516165812-3995-1-git-send-email-wei.w.wang@intel.com> <1516165812-3995-3-git-send-email-wei.w.wang@intel.com> <20180117180337-mutt-send-email-mst@kernel.org> <5A616995.4050702@intel.com> <20180119143517-mutt-send-email-mst@kernel.org> <5A65CA39.2070906@intel.com> In-Reply-To: <5A65CA39.2070906@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [virtio-dev] Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ To: "Michael S. Tsirkin" Cc: yang.zhang.wz@gmail.com, virtio-dev@lists.oasis-open.org, riel@redhat.com, quan.xu0@gmail.com, kvm@vger.kernel.org, nilal@redhat.com, liliang.opensource@gmail.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, pbonzini@redhat.com, akpm@linux-foundation.org, virtualization@lists.linux-foundation.org List-ID: On 01/22/2018 07:25 PM, Wei Wang wrote: > 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. Thanks for the comments, and I adopted most of them in the new posted v23 patches. The above discussion is the one that I haven't included. If you could still see issues in the above analysis, please let me know. Thanks. Best, Wei --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang Subject: Re: [virtio-dev] Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Date: Wed, 24 Jan 2018 11:18:40 +0800 Message-ID: <5A67FB10.2050201@intel.com> References: <1516165812-3995-1-git-send-email-wei.w.wang@intel.com> <1516165812-3995-3-git-send-email-wei.w.wang@intel.com> <20180117180337-mutt-send-email-mst@kernel.org> <5A616995.4050702@intel.com> <20180119143517-mutt-send-email-mst@kernel.org> <5A65CA39.2070906@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5A65CA39.2070906@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: "Michael S. Tsirkin" Cc: yang.zhang.wz@gmail.com, virtio-dev@lists.oasis-open.org, riel@redhat.com, quan.xu0@gmail.com, kvm@vger.kernel.org, liliang.opensource@gmail.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, pbonzini@redhat.com, akpm@linux-foundation.org, nilal@redhat.com, virtualization@lists.linux-foundation.org List-Id: virtualization@lists.linuxfoundation.org On 01/22/2018 07:25 PM, Wei Wang wrote: > 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. Thanks for the comments, and I adopted most of them in the new posted v23 patches. The above discussion is the one that I haven't included. If you could still see issues in the above analysis, please let me know. Thanks. Best, Wei From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id 07412800D8 for ; Tue, 23 Jan 2018 22:16:14 -0500 (EST) Received: by mail-pg0-f71.google.com with SMTP id e12so1480830pgu.11 for ; Tue, 23 Jan 2018 19:16:13 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id m67si2235291pfa.283.2018.01.23.19.16.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 19:16:12 -0800 (PST) Message-ID: <5A67FB10.2050201@intel.com> Date: Wed, 24 Jan 2018 11:18:40 +0800 From: Wei Wang MIME-Version: 1.0 Subject: Re: [virtio-dev] Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ References: <1516165812-3995-1-git-send-email-wei.w.wang@intel.com> <1516165812-3995-3-git-send-email-wei.w.wang@intel.com> <20180117180337-mutt-send-email-mst@kernel.org> <5A616995.4050702@intel.com> <20180119143517-mutt-send-email-mst@kernel.org> <5A65CA39.2070906@intel.com> In-Reply-To: <5A65CA39.2070906@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: "Michael S. Tsirkin" Cc: yang.zhang.wz@gmail.com, virtio-dev@lists.oasis-open.org, riel@redhat.com, quan.xu0@gmail.com, kvm@vger.kernel.org, nilal@redhat.com, liliang.opensource@gmail.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, pbonzini@redhat.com, akpm@linux-foundation.org, virtualization@lists.linux-foundation.org On 01/22/2018 07:25 PM, Wei Wang wrote: > 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. Thanks for the comments, and I adopted most of them in the new posted v23 patches. The above discussion is the one that I haven't included. If you could still see issues in the above analysis, please let me know. Thanks. 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752370AbeAXDQN (ORCPT ); Tue, 23 Jan 2018 22:16:13 -0500 Received: from mga03.intel.com ([134.134.136.65]:27826 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752009AbeAXDQM (ORCPT ); Tue, 23 Jan 2018 22:16:12 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,405,1511856000"; d="scan'208";a="25857072" Message-ID: <5A67FB10.2050201@intel.com> Date: Wed, 24 Jan 2018 11:18:40 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: yang.zhang.wz@gmail.com, virtio-dev@lists.oasis-open.org, riel@redhat.com, quan.xu0@gmail.com, kvm@vger.kernel.org, nilal@redhat.com, liliang.opensource@gmail.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, pbonzini@redhat.com, akpm@linux-foundation.org, virtualization@lists.linux-foundation.org Subject: Re: [virtio-dev] Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ References: <1516165812-3995-1-git-send-email-wei.w.wang@intel.com> <1516165812-3995-3-git-send-email-wei.w.wang@intel.com> <20180117180337-mutt-send-email-mst@kernel.org> <5A616995.4050702@intel.com> <20180119143517-mutt-send-email-mst@kernel.org> <5A65CA39.2070906@intel.com> In-Reply-To: <5A65CA39.2070906@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/22/2018 07:25 PM, Wei Wang wrote: > 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. Thanks for the comments, and I adopted most of them in the new posted v23 patches. The above discussion is the one that I haven't included. If you could still see issues in the above analysis, please let me know. Thanks. Best, Wei