From: Jason Wang Subject: Re: thoughts stac/clac and get user for vhost Date: Thu, 27 Dec 2018 17:55:52 +0800 Message-ID: <042e0002-0dce-42e4-8694-4f3fa96c3975@redhat.com> References: <20181225113301-mutt-send-email-mst@kernel.org> <20181226100341-mutt-send-email-mst@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org To: "Michael S. Tsirkin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50460 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730555AbeL0Jz7 (ORCPT ); Thu, 27 Dec 2018 04:55:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E85F3C2CD0 for ; Thu, 27 Dec 2018 09:55:59 +0000 (UTC) In-Reply-To: <20181226100341-mutt-send-email-mst@kernel.org> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 2018/12/26 下午11:06, Michael S. Tsirkin wrote: > On Wed, Dec 26, 2018 at 12:03:50PM +0800, Jason Wang wrote: >> On 2018/12/26 上午12:41, Michael S. Tsirkin wrote: >>> Hi! >>> I was just wondering: packed ring batches things naturally. >>> E.g. >>> >>> user_access_begin >>> check descriptor valid >>> smp_rmb >>> copy descriptor >>> user_access_end >> >> But without speculation on the descriptor (which may only work for in-order >> or even a violation of spec). Only one two access of a single descriptor >> could be batched. For split ring, we can batch more since we know how many >> descriptors is pending. (avail_idx - last_avail_idx). >> >> Anything I miss? >> >> Thanks >> > just check more descriptors in a loop: > > user_access_begin > for (i = 0; i < 16; ++i) { > if (!descriptor valid) > break; > smp_rmb > copy descriptor > } > user_access_end > > you don't really need to know how many there are > ahead of the time as you still copy them 1 by one. So let's see the case of split ring user_access_begin n = avail_idx - last_avail_idx (1) n = MIN(n, 16) smp_rmb read n entries from avail_ring (2) for (i =0; i > >>> So packed layout should show the gain with this approach. >>> That could be motivation enough to finally enable vhost packed ring >>> support. >>> >>> Thoughts? >>>