From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2xLI-00018z-W6 for qemu-devel@nongnu.org; Fri, 04 Jul 2014 02:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2xL8-0006T1-Af for qemu-devel@nongnu.org; Fri, 04 Jul 2014 02:51:32 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:59570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2xL8-0006St-3m for qemu-devel@nongnu.org; Fri, 04 Jul 2014 02:51:22 -0400 Received: by mail-wi0-f177.google.com with SMTP id r20so3395334wiv.10 for ; Thu, 03 Jul 2014 23:51:21 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53B64EE6.4000705@redhat.com> Date: Fri, 04 Jul 2014 08:51:18 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1404406760-22981-1-git-send-email-pbonzini@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.1?!?] AioContext: speed up aio_notify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Ming Lei , qemu-devel , Stefan Hajnoczi Il 03/07/2014 20:17, Stefan Hajnoczi ha scritto: > On Thu, Jul 3, 2014 at 6:59 PM, Paolo Bonzini wrote: > > Looks like a very interesting optimization for the block layer. If we > can get some performance results - especially how it improves the > virtio-blk dataplane regression - maybe we should merge it for 2.1. > >> @@ -247,9 +248,22 @@ ThreadPool *aio_get_thread_pool(AioContext *ctx) >> return ctx->thread_pool; >> } >> >> +void aio_set_dispatching(AioContext *ctx, bool dispatching) >> +{ >> + ctx->dispatching = dispatching; >> + /* Write ctx->dispatching before reading e.g. bh->scheduled. */ >> + if (!dispatching) { >> + smp_mb(); >> + } > > Is the if statement necessary? It seems like an optimization to avoid > the memory barrier in 50% of the calls. Yes. > But by avoiding the barrier it could cause other threads to "miss" the > dispatching period on machines with weak memory models. I guess > that's fine since we're not trying to optimize other threads but more > focussing on callers from the event loop's own thread. > > Anyway, the if statement makes this function trickier than it has to > be IMO. Want to drop it? I think this is the last "trickiness" problem of this patch, but of course I have no problem removing it if the patch goes into 2.1. Ming Lei's latest message suggests it is not necessary though. The patch should be tested at least on rbd or gluster, these are the main users of remote-thread notification via bottom halves. Paolo