From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: RING_HAS_UNCONSUMED_REQUESTS oddness Date: Tue, 11 Mar 2014 15:44:26 +0000 Message-ID: <1394552666.30915.64.camel@kazak.uk.xensource.com> References: <5318987C.3030303@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WNOr1-00060e-Oa for xen-devel@lists.xenproject.org; Tue, 11 Mar 2014 15:44:32 +0000 In-Reply-To: <5318987C.3030303@citrix.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: Zoltan Kiss Cc: "xen-devel@lists.xenproject.org" , Wei Liu , Tim Deegan List-Id: xen-devel@lists.xenproject.org On Thu, 2014-03-06 at 15:47 +0000, Zoltan Kiss wrote: > Hi, > > I was wondering for a while why this macro looks like this: > > #define RING_HAS_UNCONSUMED_REQUESTS(_r) \ > ({ \ > unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ > unsigned int rsp = RING_SIZE(_r) - \ > ((_r)->req_cons - (_r)->rsp_prod_pvt); \ > req < rsp ? req : rsp; \ > }) > > I would expect to check prod - cons, like RING_HAS_UNCONSUMED_RESPONSES does: > > #define RING_HAS_UNCONSUMED_RESPONSES(_r) \ > ((_r)->sring->rsp_prod - (_r)->rsp_cons) > > By my understanding, there is no way rsp could be smaller than req, so > there is no point having this. Am I missing something? Just looking at this again. All that stuff I said about wraparound was misleading/irrelevant since req and rsp are not the pointers, but actually the number of things. Sorry. Is it the case that this macro considers a request to be unconsumed if the *response* to a request is outstanding as well as if the request itself is still on the ring? I wonder if this apparently weird construction is due to pathological cases when one or the other end is not picking up requests/responses? i.e. trying to avoid deadlocking the ring or generating an interrupt storm when the ring it is full of one or the other or something along those lines? Ian.