From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752378AbcJCWs2 (ORCPT ); Mon, 3 Oct 2016 18:48:28 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34595 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750890AbcJCWsV (ORCPT ); Mon, 3 Oct 2016 18:48:21 -0400 Subject: Re: [PATCH] ringtest: Look at next descriptor before setting up event index To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <1474285139-11612-1-git-send-email-pbonzini@redhat.com> Cc: mst@redhat.com From: Paolo Bonzini Message-ID: <4cf8d7ac-c34e-2cd3-c552-37daa41467c8@redhat.com> Date: Tue, 4 Oct 2016 00:48:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1474285139-11612-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/09/2016 13:38, Paolo Bonzini wrote: > This avoids an expensive memory barrier if the next descriptor > is already there. The benefit is around 10%. > > Signed-off-by: Paolo Bonzini > --- > tools/virtio/ringtest/ring.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c > index c25c8d248b6b..e617e20538bf 100644 > --- a/tools/virtio/ringtest/ring.c > +++ b/tools/virtio/ringtest/ring.c > @@ -182,6 +182,9 @@ bool enable_call() > { > unsigned head = (ring_size - 1) & guest.last_used_idx; > > + if (!(ring[head].flags & DESC_HW)) > + return false; > + > event->call_index = guest.last_used_idx; > /* Flush call index write */ > /* Barrier D (for pairing) */ > @@ -215,6 +218,9 @@ bool enable_kick() > { > unsigned head = (ring_size - 1) & host.used_idx; > > + if (ring[head].flags & DESC_HW) > + return false; > + > event->kick_index = host.used_idx; > /* Barrier C (for pairing) */ > smp_mb(); > Ping? Paolo