From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-return-3448-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Date: Tue, 3 Nov 2020 16:42:07 -0500 From: "Michael S. Tsirkin" Message-ID: <20201103164113-mutt-send-email-mst@kernel.org> References: <20201029075047.119209-1-mst@redhat.com> <20201030113732.GG307361@stefanha-x1.localdomain> <20201030105945-mutt-send-email-mst@kernel.org> <20201103171834.GC259481@stefanha-x1.localdomain> MIME-Version: 1.0 In-Reply-To: <20201103171834.GC259481@stefanha-x1.localdomain> Subject: Re: [virtio] Re: [virtio-dev] [PATCH] VIRTIO_F_RING_PACKED_USED: packing used descriptors Content-Type: text/plain; charset=us-ascii Content-Disposition: inline To: Stefan Hajnoczi Cc: virtio-comment@lists.oasis-open.org, virtio-dev@lists.oasis-open.org, virtio@lists.oasis-open.org List-ID: On Tue, Nov 03, 2020 at 05:18:34PM +0000, Stefan Hajnoczi wrote: > On Fri, Oct 30, 2020 at 11:01:10AM -0400, Michael S. Tsirkin wrote: > > On Fri, Oct 30, 2020 at 11:37:32AM +0000, Stefan Hajnoczi wrote: > > > On Thu, Oct 29, 2020 at 03:50:57AM -0400, Michael S. Tsirkin wrote: > > > > +When after processing the used descriptor, the batch counter > > > > +exceeds the ring size, the batch counter is decremented by the > > > > +ring size; both device and driver then skip to the > > > > +beginning (offset 0) of the ring until processing (reading for > > > > +the driver and writing for the device) the next used descriptor. > > > > > > This may be clearer: > > > > > > both device and driver then use ring index 0 for the next used > > > descriptor > > > > > > Or: > > > > > > The device writes the next used descriptor at ring index 0. The driver > > > reads the next used descriptor from ring index 0. > > > > > > I'm not sure I understand this scheme. Is this pseudo-code correct? > > > > > > batch_counter += num_used_descs > > > if batch_counter > ring_size: > > > batch_counter -= ring_size > > > used_idx = 0 > > > > yes > > > > > > > Can you share an explanation of how this scheme ensures that the > > > driver's next avail descriptor index never overtakes the device's next > > > used descriptor index? > > > > Simply because to overtake it, it needs to wrap around to 0. > > That happens when batch counter wraps over to 0, if we make > > device wrap at that point all is well. > > What confuses me is that batch_counter is not reset to 0. It is set to > batch_counter -= ring_size. > > I guess I need to get my crayons and draw pictures :-). > > Stefan The idea is that when all available buffers have been used then batch counter of the device matches the next avail index of the driver. --------------------------------------------------------------------- To unsubscribe from this mail list, you must leave the OASIS TC that generates this mail. Follow this link to all your TCs in OASIS at: https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php