[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [Problem] about src/xen/include/public/io/ring.h



On Tue, Apr 09, 2013 at 11:05:52AM +0800, éç wrote:
> On Mon, Apr 8, 2013 at 9:32 PM, Konrad Rzeszutek Wilk <
> konrad.wilk@xxxxxxxxxx> wrote:
> 
> > On Mon, Apr 08, 2013 at 04:10:49PM +0800, éç wrote:
> > > Hi,
> > >     there is a macro in io/ring.h as follows:
> > >
> > > 211#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({
> > > \                                         |
> > > 212    unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;
> > >  \
> > > 213    unsigned int rsp = RING_SIZE(_r) -
> > >  \
> > > 214        ((_r)->req_cons - (_r)->rsp_prod_pvt);
> > >  \
> > > 215    req < rsp ? req : rsp;
> > >  \
> > > 216})
> > >
> > > Anyone could explain this?
> >
> > Which part are you unclear about?
> >
> > I might be easier if you deconstruct the macro and write out
> > inthe code. That should give you an idea of what it does.
> > <hint: Figure out first what RING_SIZE comes out to>
> >
> > > _______________________________________________
> > > Xen-devel mailing list
> > > Xen-devel@xxxxxxxxxxxxx
> > > http://lists.xen.org/xen-devel
> >
> >
> Why does the macro for response is :
> 207#define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
> 208    ((_r)->sring->rsp_prod - (_r)->rsp_cons)
> 
> why not the macro for request written like this:
> #define RING_HAS_UNCONSUMED_REQUESTS(_r)                               \
>     ((_r)->sring->req_prod - (_r)->req_cons)
> 
> 
> The RING_SIZE means the maximum number for the shared ring to accommodate
> the req/resp message struct, is that?

Correct. The req message is about 112 bytes, and at the start of the ring
you have 64-bytes for rsp, req, etc. So the end result is 32 ring entries.

The response structures are much smaller, but since you are sharing the ring
(so you put both requests and responses on it), it is still limited to 32
entries.

I am not really sure what you mean by 'why not the macro'.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.