Roger Pau Monne
2013-Feb-28 10:28 UTC
[PATCH RFC 01/12] xen-blkback: don''t store dev_bus_addr
dev_bus_addr returned in the grant ref map operation is the mfn of the passed page, there's no need to store it in the persistent grant entry, since we can always get it provided that we have the page. This reduces the memory overhead of persistent grants in blkback. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: xen-devel@lists.xen.org --- drivers/block/xen-blkback/blkback.c | 7 +++---- drivers/block/xen-blkback/common.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index de1f319..d40beb3 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -621,9 +621,7 @@ static int xen_blkbk_map(struct blkif_request *req, * If this is a new persistent grant * save the handler */ - persistent_gnts[i]->handle = map[j].handle; - persistent_gnts[i]->dev_bus_addr - map[j++].dev_bus_addr; + persistent_gnts[i]->handle = map[j++].handle; } pending_handle(pending_req, i) persistent_gnts[i]->handle; @@ -631,7 +629,8 @@ static int xen_blkbk_map(struct blkif_request *req, if (ret) continue; - seg[i].buf = persistent_gnts[i]->dev_bus_addr | + seg[i].buf = pfn_to_mfn(page_to_pfn( + persistent_gnts[i]->page)) << PAGE_SHIFT | (req->u.rw.seg[i].first_sect << 9); } else { pending_handle(pending_req, i) = map[j].handle; diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h index 6072390..f338f8a 100644 --- a/drivers/block/xen-blkback/common.h +++ b/drivers/block/xen-blkback/common.h @@ -172,7 +172,6 @@ struct persistent_gnt { struct page *page; grant_ref_t gnt; grant_handle_t handle; - uint64_t dev_bus_addr; struct rb_node node; }; -- 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Jan Beulich
2013-Feb-28 10:58 UTC
Re: [PATCH RFC 01/12] xen-blkback: don''t store dev_bus_addr
>>> On 28.02.13 at 11:28, Roger Pau Monne <roger.pau@citrix.com> wrote: > dev_bus_addr returned in the grant ref map operation is the mfn of the > passed page, there''s no need to store it in the persistent grant > entry, since we can always get it provided that we have the page.Interesting that you come up with this, as I have a similar patch pending (not posted yet), aiming at reducing the stack usage in dispatch_rw_block_io(): seg[].buf is really unnecessary with the dev_bus_addr storing removed, as the only reader of that field can equally well use req->u.rw.seg[i].first_sect. And then the biolist[] array really can be folded into a union with the remaining seg[] one, as their usage scopes are easily separable.> --- a/drivers/block/xen-blkback/blkback.c > +++ b/drivers/block/xen-blkback/blkback.c > @@ -621,9 +621,7 @@ static int xen_blkbk_map(struct blkif_request *req, > * If this is a new persistent grant > * save the handler > */ > - persistent_gnts[i]->handle = map[j].handle; > - persistent_gnts[i]->dev_bus_addr > - map[j++].dev_bus_addr; > + persistent_gnts[i]->handle = map[j++].handle; > } > pending_handle(pending_req, i) > persistent_gnts[i]->handle; > @@ -631,7 +629,8 @@ static int xen_blkbk_map(struct blkif_request *req, > if (ret) > continue; > > - seg[i].buf = persistent_gnts[i]->dev_bus_addr | > + seg[i].buf = pfn_to_mfn(page_to_pfn( > + persistent_gnts[i]->page)) << PAGE_SHIFT |So why do you do this? The only reader masks the field with ~PAGE_MASK anyway. Jan
Roger Pau Monné
2013-Mar-04 17:19 UTC
Re: [PATCH RFC 01/12] xen-blkback: don''t store dev_bus_addr
On 28/02/13 11:58, Jan Beulich wrote:>>>> On 28.02.13 at 11:28, Roger Pau Monne <roger.pau@citrix.com> wrote: >> dev_bus_addr returned in the grant ref map operation is the mfn of the >> passed page, there''s no need to store it in the persistent grant >> entry, since we can always get it provided that we have the page. > > Interesting that you come up with this, as I have a similar patch > pending (not posted yet), aiming at reducing the stack usage in > dispatch_rw_block_io(): seg[].buf is really unnecessary with the > dev_bus_addr storing removed, as the only reader of that field > can equally well use req->u.rw.seg[i].first_sect.Well, it can if we are not using indirect descriptors, because once we start using indirect descriptors segments are inside a gref frame, so it''s quite comfortable to store first_sect inside a separate array, this way we can map indirect segments, copy whatever data we need from them and unmap them, without having them around for the whole lifetime of the request.> > And then the biolist[] array really can be folded into a union > with the remaining seg[] one, as their usage scopes are easily > separable.Could we leave that for a further patch? I would like to avoid messing any more with blkback, as I''m already touching a lot of bits with this patch series.> >> --- a/drivers/block/xen-blkback/blkback.c >> +++ b/drivers/block/xen-blkback/blkback.c >> @@ -621,9 +621,7 @@ static int xen_blkbk_map(struct blkif_request *req, >> * If this is a new persistent grant >> * save the handler >> */ >> - persistent_gnts[i]->handle = map[j].handle; >> - persistent_gnts[i]->dev_bus_addr >> - map[j++].dev_bus_addr; >> + persistent_gnts[i]->handle = map[j++].handle; >> } >> pending_handle(pending_req, i) >> persistent_gnts[i]->handle; >> @@ -631,7 +629,8 @@ static int xen_blkbk_map(struct blkif_request *req, >> if (ret) >> continue; >> >> - seg[i].buf = persistent_gnts[i]->dev_bus_addr | >> + seg[i].buf = pfn_to_mfn(page_to_pfn( >> + persistent_gnts[i]->page)) << PAGE_SHIFT | > > So why do you do this? The only reader masks the field with > ~PAGE_MASK anyway.Yes, I only need to store first_sect.
Jan Beulich
2013-Mar-05 08:06 UTC
Re: [PATCH RFC 01/12] xen-blkback: don''t store dev_bus_addr
>>> On 04.03.13 at 18:19, Roger Pau Monné<roger.pau@citrix.com> wrote: > On 28/02/13 11:58, Jan Beulich wrote: >>>>> On 28.02.13 at 11:28, Roger Pau Monne <roger.pau@citrix.com> wrote: >> And then the biolist[] array really can be folded into a union >> with the remaining seg[] one, as their usage scopes are easily >> separable. > > Could we leave that for a further patch? I would like to avoid messing > any more with blkback, as I'm already touching a lot of bits with this > patch series.Fine by me, but ...>>> @@ -631,7 +629,8 @@ static int xen_blkbk_map(struct blkif_request *req, >>> if (ret) >>> continue; >>> >>> - seg[i].buf = persistent_gnts[i]->dev_bus_addr | >>> + seg[i].buf = pfn_to_mfn(page_to_pfn( >>> + persistent_gnts[i]->page)) << PAGE_SHIFT | >> >> So why do you do this? The only reader masks the field with >> ~PAGE_MASK anyway. > > Yes, I only need to store first_sect.... as you're touching this code anyway, and as it'll make the code as well as the patch smaller, could you at least drop this pointless storing of the page address (which otherwise I'd ask you to properly parenthesize anyway)? And iirc once that's dropped, the storing of first_sect ends up being identical between the if and else bodies, so it could be pulled out (further reducing code size, albeit at the price of a marginally bigger patch). Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Roger Pau Monné
2013-Mar-05 17:02 UTC
Re: [PATCH RFC 01/12] xen-blkback: don''t store dev_bus_addr
On 05/03/13 09:06, Jan Beulich wrote:>>>> On 04.03.13 at 18:19, Roger Pau Monné<roger.pau@citrix.com> wrote: >> On 28/02/13 11:58, Jan Beulich wrote: >>>>>> On 28.02.13 at 11:28, Roger Pau Monne <roger.pau@citrix.com> wrote: >>> And then the biolist[] array really can be folded into a union >>> with the remaining seg[] one, as their usage scopes are easily >>> separable. >> >> Could we leave that for a further patch? I would like to avoid messing >> any more with blkback, as I'm already touching a lot of bits with this >> patch series. > > Fine by me, but ... > >>>> @@ -631,7 +629,8 @@ static int xen_blkbk_map(struct blkif_request *req, >>>> if (ret) >>>> continue; >>>> >>>> - seg[i].buf = persistent_gnts[i]->dev_bus_addr | >>>> + seg[i].buf = pfn_to_mfn(page_to_pfn( >>>> + persistent_gnts[i]->page)) << PAGE_SHIFT | >>> >>> So why do you do this? The only reader masks the field with >>> ~PAGE_MASK anyway. >> >> Yes, I only need to store first_sect. > > ... as you're touching this code anyway, and as it'll make the > code as well as the patch smaller, could you at least drop this > pointless storing of the page address (which otherwise I'd ask > you to properly parenthesize anyway)? > > And iirc once that's dropped, the storing of first_sect ends up > being identical between the if and else bodies, so it could be > pulled out (further reducing code size, albeit at the price of a > marginally bigger patch).Yes, I've already done that, thanks for the suggestion. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel