From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCH 1/2] events/fifo: don't spin indefinitely when setting LINK Date: Mon, 11 Nov 2013 16:56:53 +0000 Message-ID: <52810C55.6070107@citrix.com> References: <1384185808-13822-1-git-send-email-david.vrabel@citrix.com> <1384185808-13822-2-git-send-email-david.vrabel@citrix.com> <52811626020000780010206E@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VfunK-000160-Kq for xen-devel@lists.xenproject.org; Mon, 11 Nov 2013 16:56:58 +0000 In-Reply-To: <52811626020000780010206E@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: David Vrabel , xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org On 11/11/13 16:38, Jan Beulich wrote: >>>> On 11.11.13 at 17:03, David Vrabel wrote: > >> + w = read_atomic(word); >> + >> + for ( try = 0; try < 4; try++ ) >> + { >> + ret = try_set_link(word, &w, link); >> + if ( ret >= 0 ) >> + { >> + clear_bit(EVTCHN_FIFO_BUSY, word); > > Considering that this is another atomic operation, wouldn't it > make sense to have the cmpxchg() at once clear the flag, > and hence you'd need to clear it here only when ret == 0 > (which I understand isn't the common case)? The common case (I believe, but haven't measured it) is the first try_set_link() call without BUSY set. In the loop, I suspect the mostly likely write by the guest is clearing LINKED, i.e., ret == 0. Still, it seems easy enough to have: for ( try = 0; try < 4; try++ ) { ret = try_set_link(word, &w, link); if ( ret >= 0 ) { if ( ret == 0 ) clear_bit(EVTCHN_FIFO_BUSY, word); return ret; } } David