All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v1 2/7] xen-blkback: use balloon pages for all mappings
Date: Wed, 17 Apr 2013 10:00:35 -0400	[thread overview]
Message-ID: <20130417140035.GC21378@phenom.dumpdata.com> (raw)
In-Reply-To: <516BB4C6.8090101@citrix.com>

> /*
>  * No need to set unmap_seg bit, since
>  * we can not unmap this grant because
>  * the handle is invalid.
>  */
> 
> > 
> > But then that begs the question - why do we even need the bitmap_set code path anymore?
> 
> To know which grants are mapped persistenly, so we don't unmap them in
> xen_blkbk_unmap.

Aha! I missed that part.
> 
> >>               }
> >> -             if (persistent_gnts[i]) {
> >> -                     if (persistent_gnts[i]->handle ==
> >> -                         BLKBACK_INVALID_HANDLE) {
> >> +             if (persistent_gnts[i])
> >> +                     goto next;
> >> +             if (use_persistent_gnts &&
> >> +                 blkif->persistent_gnt_c <
> >> +                 max_mapped_grant_pages(blkif->blk_protocol)) {
> >> +                     /*
> >> +                      * We are using persistent grants, the grant is
> >> +                      * not mapped but we have room for it
> >> +                      */
> >> +                     persistent_gnt = kmalloc(sizeof(struct persistent_gnt),
> >> +                                              GFP_KERNEL);
> >> +                     if (!persistent_gnt) {
> >>                               /*
> >> -                              * If this is a new persistent grant
> >> -                              * save the handler
> >> +                              * If we don't have enough memory to
> >> +                              * allocate the persistent_gnt struct
> >> +                              * map this grant non-persistenly
> >>                                */
> >> -                             persistent_gnts[i]->handle = map[j++].handle;
> >> +                             j++;
> >> +                             goto next;
> > 
> > So you are doing this by assuming that get_persistent_gnt in the earlier loop
> > failed, which means you have in effect done this:
> >         map[segs_to_map++]
> > 
> > Doing the next label will set:
> >                 seg[i].offset = (req->u.rw.seg[i].first_sect << 9);
> > 
> > OK, that sounds right. Is this then:
> > 
> >         bitmap_set(pending_req->unmap_seg, i, 1);
> > 
> > even needed? The "pending_handle(pending_req, i) = map[j].handle;" had already been
> > done in the  /* This is a newly mapped grant */ if case, so we are set there.
> 
> We need to mark this grant as non-persistent, so we unmap it on
> xen_blkbk_unmap.

And then this makes sense.
> 
> > 
> > Perhaps you could update the comment from saying 'map this grant' (which
> > implies doing it NOW as opposed to have done it already), and say:
> > 
> > /*
> > .. continue using the grant non-persistently. Note that
> > we mapped it in the earlier loop and the earlier if conditional
> > sets pending_handle(pending_req, i) = map[j].handle.
> > */
> > 
> > 
> > 
> >>                       }
> >> -                     pending_handle(pending_req, i) =
> >> -                             persistent_gnts[i]->handle;
> >> -
> >> -                     if (ret)
> >> -                             continue;
> >> -             } else {
> >> -                     pending_handle(pending_req, i) = map[j++].handle;
> >> -                     bitmap_set(pending_req->unmap_seg, i, 1);
> >> -
> >> -                     if (ret)
> >> -                             continue;
> >> +                     persistent_gnt->gnt = map[j].ref;
> >> +                     persistent_gnt->handle = map[j].handle;
> >> +                     persistent_gnt->page = pages[i];
> > 
> > Oh boy, that is a confusing. i and j. Keep loosing track which one is which.
> > It lookis right.
> > 
> >> +                     if (add_persistent_gnt(&blkif->persistent_gnts,
> >> +                                            persistent_gnt)) {
> >> +                             kfree(persistent_gnt);
> > 
> > I would also say 'persisten_gnt = NULL' for extra measure of safety
> 
> Done.
> 
> > 
> > 
> >> +                             j++;
> > 
> > Perhaps the 'j' variable can be called 'map_idx' ? By this point I am pretty
> > sure I know what the 'i' and 'j' variables are used for, but if somebody new
> > is trying to grok this code they might spend some 5 minutes trying to figure
> > this out.
> 
> Yes, I agree that i and j are not the best names, I propose to call j
> new_map_idx, and i seg_idx.

Sounds good.

  parent reply	other threads:[~2013-04-17 14:00 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-27 11:10 [PATCH v1 0/7] xen-block: indirect descriptors Roger Pau Monne
2013-03-27 11:10 ` [PATCH v1 1/7] xen-blkback: print stats about persistent grants Roger Pau Monne
2013-03-27 11:10   ` Roger Pau Monne
2013-04-09 14:47   ` Konrad Rzeszutek Wilk
2013-04-09 14:47   ` Konrad Rzeszutek Wilk
2013-03-27 11:10 ` [PATCH v1 2/7] xen-blkback: use balloon pages for all mappings Roger Pau Monne
2013-04-09 14:47   ` Konrad Rzeszutek Wilk
2013-04-15  8:05     ` Roger Pau Monné
2013-04-15  8:05     ` Roger Pau Monné
2013-04-15  8:12       ` [Xen-devel] " Roger Pau Monné
2013-04-15  8:12       ` Roger Pau Monné
2013-04-17 14:00       ` Konrad Rzeszutek Wilk [this message]
2013-04-17 14:00       ` Konrad Rzeszutek Wilk
2013-04-15  9:14     ` Roger Pau Monné
2013-04-17 14:05       ` Konrad Rzeszutek Wilk
2013-04-17 14:05       ` Konrad Rzeszutek Wilk
2013-04-15  9:14     ` Roger Pau Monné
2013-04-09 14:47   ` Konrad Rzeszutek Wilk
2013-04-09 15:46   ` Konrad Rzeszutek Wilk
2013-04-15  8:21     ` Roger Pau Monné
2013-04-15  8:21     ` Roger Pau Monné
2013-04-09 15:46   ` Konrad Rzeszutek Wilk
2013-03-27 11:10 ` Roger Pau Monne
2013-03-27 11:10 ` [PATCH v1 3/7] xen-blkback: implement LRU mechanism for persistent grants Roger Pau Monne
2013-04-09 15:42   ` Konrad Rzeszutek Wilk
2013-04-15 11:19     ` Roger Pau Monné
2013-04-17 14:15       ` Konrad Rzeszutek Wilk
2013-04-17 14:15       ` Konrad Rzeszutek Wilk
2013-04-15 11:19     ` Roger Pau Monné
2013-04-09 15:42   ` Konrad Rzeszutek Wilk
2013-03-27 11:10 ` Roger Pau Monne
2013-03-27 11:10 ` [PATCH v1 4/7] xen-blkback: move pending handles list from blkbk to pending_req Roger Pau Monne
2013-03-27 11:10 ` Roger Pau Monne
2013-03-27 11:10 ` [PATCH v1 5/7] xen-blkback: make the queue of free requests per backend Roger Pau Monne
2013-03-27 11:10 ` Roger Pau Monne
2013-04-09 16:13   ` Konrad Rzeszutek Wilk
2013-04-09 16:13   ` Konrad Rzeszutek Wilk
2013-04-15 13:50     ` Roger Pau Monné
2013-04-17 14:16       ` Konrad Rzeszutek Wilk
2013-04-17 14:16       ` Konrad Rzeszutek Wilk
2013-04-15 13:50     ` Roger Pau Monné
2013-03-27 11:10 ` [PATCH v1 6/7] xen-blkback: expand map/unmap functions Roger Pau Monne
2013-03-27 11:10   ` Roger Pau Monne
2013-03-27 11:10 ` [PATCH v1 7/7] xen-block: implement indirect descriptors Roger Pau Monne
2013-04-09 18:49   ` Konrad Rzeszutek Wilk
2013-04-15 17:01     ` Roger Pau Monné
2013-04-17 14:25       ` Konrad Rzeszutek Wilk
2013-04-17 17:04         ` Roger Pau Monné
2013-04-17 17:27           ` Konrad Rzeszutek Wilk
2013-04-17 17:27           ` Konrad Rzeszutek Wilk
2013-04-18 12:43             ` Jens Axboe
2013-04-18 12:43             ` Jens Axboe
2013-04-18 14:16               ` Roger Pau Monné
2013-04-18 14:26                 ` Jens Axboe
2013-04-18 15:14                   ` Roger Pau Monné
2013-04-18 15:58                     ` Jens Axboe
2013-04-18 15:58                     ` Jens Axboe
2013-04-18 15:14                   ` Roger Pau Monné
2013-04-18 14:26                 ` Jens Axboe
2013-04-18 14:16               ` Roger Pau Monné
2013-04-17 17:04         ` Roger Pau Monné
2013-04-17 14:25       ` Konrad Rzeszutek Wilk
2013-04-15 17:01     ` Roger Pau Monné
2013-04-09 18:49   ` Konrad Rzeszutek Wilk
2013-03-27 11:10 ` Roger Pau Monne

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=20130417140035.GC21378@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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.