All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: 马磊 <aware.why@gmail.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [Problem] about src/xen/include/public/io/ring.h
Date: Wed, 10 Apr 2013 09:15:28 -0400	[thread overview]
Message-ID: <20130410131528.GC4865@phenom.dumpdata.com> (raw)
In-Reply-To: <CA+ePHTAmU3xzzY7P-k3a61TBnB2ZRR-ebobuNiwiVkL6E02HEg@mail.gmail.com>

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@oracle.com> 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@lists.xen.org
> > > 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@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2013-04-10 13:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-08  8:10 [Problem] about src/xen/include/public/io/ring.h 马磊
2013-04-08 13:32 ` Konrad Rzeszutek Wilk
2013-04-09  3:05   ` 马磊
2013-04-10 13:15     ` Konrad Rzeszutek Wilk [this message]
2013-04-11  7:46       ` 马磊
2013-04-11 13:20         ` Konrad Rzeszutek Wilk
2013-04-12  2:21           ` 马磊
2013-04-12  7:49             ` Ian Campbell
2013-04-12 10:35               ` 马磊
2013-04-12 11:14                 ` Ian Campbell
2013-04-12 11:24                   ` 马磊
2013-04-12 13:45                     ` Konrad Rzeszutek Wilk
2013-04-15  2:52                       ` 马磊
2013-04-10  6:20   ` 马磊
2013-04-10 13:15     ` Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130410131528.GC4865@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=aware.why@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.