Roger Pau Monne
2013-Jul-08 13:03 UTC
[PATCH RFC 3/4] xen-blkfront: prevent hoarding all grants
Prevent blkfront from hoarding all grants by adding a minimum number of grants that must be free at all times. We still need a way to free unused grants in blkfront, but this patch will mitigate the problem in the meantime. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- drivers/block/xen-blkfront.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 187a437..3d445c0 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -101,6 +101,12 @@ MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests (default #define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE) /* + * Make sure there are at least MIN_FREE_GRANTS at all times, preventing + * blkfront from hoarding all grants + */ +#define MIN_FREE_GRANTS 512 + +/* * We have one of these per vbd, whether ide, scsi or 'other'. They * hang in private_data off the gendisk structure. We may end up * putting all kinds of interesting stuff here :-) @@ -412,13 +418,13 @@ static int blkif_queue_request(struct request *req) if (info->persistent_gnts_c < max_grefs) { new_persistent_gnts = 1; if (gnttab_alloc_grant_references( - max_grefs - info->persistent_gnts_c, + max_grefs - info->persistent_gnts_c + MIN_FREE_GRANTS, &gref_head) < 0) { gnttab_request_free_callback( &info->callback, blkif_restart_queue_callback, info, - max_grefs); + max_grefs + MIN_FREE_GRANTS); return 1; } } else -- 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:32 UTC
Re: [PATCH RFC 3/4] xen-blkfront: prevent hoarding all grants
On 08/07/13 14:03, Roger Pau Monne wrote:> Prevent blkfront from hoarding all grants by adding a minimum number > of grants that must be free at all times. We still need a way to free > unused grants in blkfront, but this patch will mitigate the problem > in the meantime.I think this could end up with the a frontend being able to get no grants because some other frontend always grabs the free grants first. Particularly as the free grant callbacks are done in the wrong order. David> --- a/drivers/block/xen-blkfront.c > +++ b/drivers/block/xen-blkfront.c > @@ -101,6 +101,12 @@ MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests (default > #define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE) > > /* > + * Make sure there are at least MIN_FREE_GRANTS at all times, preventing > + * blkfront from hoarding all grants > + */ > +#define MIN_FREE_GRANTS 512 > + > +/* > * We have one of these per vbd, whether ide, scsi or ''other''. They > * hang in private_data off the gendisk structure. We may end up > * putting all kinds of interesting stuff here :-) > @@ -412,13 +418,13 @@ static int blkif_queue_request(struct request *req) > if (info->persistent_gnts_c < max_grefs) { > new_persistent_gnts = 1; > if (gnttab_alloc_grant_references( > - max_grefs - info->persistent_gnts_c, > + max_grefs - info->persistent_gnts_c + MIN_FREE_GRANTS, > &gref_head) < 0) { > gnttab_request_free_callback( > &info->callback, > blkif_restart_queue_callback, > info, > - max_grefs); > + max_grefs + MIN_FREE_GRANTS); > return 1; > } > } else
Roger Pau Monné
2013-Jul-11 14:57 UTC
Re: [PATCH RFC 3/4] xen-blkfront: prevent hoarding all grants
On 11/07/13 15:32, David Vrabel wrote:> On 08/07/13 14:03, Roger Pau Monne wrote: >> Prevent blkfront from hoarding all grants by adding a minimum number >> of grants that must be free at all times. We still need a way to free >> unused grants in blkfront, but this patch will mitigate the problem >> in the meantime. > > I think this could end up with the a frontend being able to get no > grants because some other frontend always grabs the free grants first. > > Particularly as the free grant callbacks are done in the wrong order.I''m not so sure this patch is worth pushing any more, given that we will be freeing grants instead of keeping them all in blkfront. It seems like it might still be useful if we are under a lot of IO pressure on different blkfronts and for example wanted to hot-attach a new network interface (which requires 512 grants).