Roger Pau Monne
2013-Jul-08 13:03 UTC
[PATCH RFC 2/4] xen-blkfront: improve aproximation of required grants per request
Improve the calculation of required grants to process a request by using nr_phys_segments instead of always assuming a request is going to use all posible segments. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- drivers/block/xen-blkfront.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2e1ee34..187a437 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -400,10 +400,13 @@ static int blkif_queue_request(struct request *req) if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) return 1; - max_grefs = info->max_indirect_segments ? - info->max_indirect_segments + - INDIRECT_GREFS(info->max_indirect_segments) : - BLKIF_MAX_SEGMENTS_PER_REQUEST; + max_grefs = req->nr_phys_segments; + if (max_grefs > BLKIF_MAX_SEGMENTS_PER_REQUEST) + /* + * If we are using indirect segments we need to account + * for the indirect grefs used in the request. + */ + max_grefs += INDIRECT_GREFS(req->nr_phys_segments); /* Check if we have enough grants to allocate a requests */ if (info->persistent_gnts_c < max_grefs) { -- 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
David Vrabel
2013-Jul-11 13:20 UTC
Re: [PATCH RFC 2/4] xen-blkfront: improve aproximation of required grants per request
On 08/07/13 14:03, Roger Pau Monne wrote:> Improve the calculation of required grants to process a request by > using nr_phys_segments instead of always assuming a request is going > to use all posible segments.This isn''t obviously correct to me. Why is this correct value for the number of pages that need to be granted? David> --- a/drivers/block/xen-blkfront.c > +++ b/drivers/block/xen-blkfront.c > @@ -400,10 +400,13 @@ static int blkif_queue_request(struct request *req) > if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) > return 1; > > - max_grefs = info->max_indirect_segments ? > - info->max_indirect_segments + > - INDIRECT_GREFS(info->max_indirect_segments) : > - BLKIF_MAX_SEGMENTS_PER_REQUEST; > + max_grefs = req->nr_phys_segments; > + if (max_grefs > BLKIF_MAX_SEGMENTS_PER_REQUEST) > + /* > + * If we are using indirect segments we need to account > + * for the indirect grefs used in the request. > + */ > + max_grefs += INDIRECT_GREFS(req->nr_phys_segments); > > /* Check if we have enough grants to allocate a requests */ > if (info->persistent_gnts_c < max_grefs) {
Roger Pau Monné
2013-Jul-11 14:47 UTC
Re: [PATCH RFC 2/4] xen-blkfront: improve aproximation of required grants per request
On 11/07/13 15:20, David Vrabel wrote:> On 08/07/13 14:03, Roger Pau Monne wrote: >> Improve the calculation of required grants to process a request by >> using nr_phys_segments instead of always assuming a request is going >> to use all posible segments. > > This isn''t obviously correct to me. Why is this correct value for the > number of pages that need to be granted?This contains the number of scatter-gather DMA addr+len pairs, which is basically what we put at every granted page. for_each_sg iterates over the DMA addr+len pairs and uses a grant page for each of them.