Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1676367 > unrolled thread
| Started by | Dongli Zhang <dongli.zhang@oracle.com> |
|---|---|
| First post | 2017-06-28 06:50 +0200 |
| Last post | 2017-06-28 10:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] xen/blkfront: always allocate grants first from per-queue persistent grants Dongli Zhang <dongli.zhang@oracle.com> - 2017-06-28 06:50 +0200
Re: [PATCH 1/1] xen/blkfront: always allocate grants first from per-queue persistent grants Roger Pau Monné <roger.pau@citrix.com> - 2017-06-28 10:40 +0200
| From | Dongli Zhang <dongli.zhang@oracle.com> |
|---|---|
| Date | 2017-06-28 06:50 +0200 |
| Subject | [PATCH 1/1] xen/blkfront: always allocate grants first from per-queue persistent grants |
| Message-ID | <tXd5n-2b5-1@gated-at.bofh.it> |
This patch partially reverts 3df0e50 ("xen/blkfront: pseudo support for
multi hardware queues/rings"). The xen-blkfront queue/ring might hang due
to grants allocation failure in the situation when gnttab_free_head is
almost empty while many persistent grants are reserved for this queue/ring.
As persistent grants management was per-queue since 73716df ("xen/blkfront:
make persistent grants pool per-queue"), we should always allocate from
persistent grants first.
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
drivers/block/xen-blkfront.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 3945963..d2b759f 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -713,6 +713,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
* existing persistent grants, or if we have to get new grants,
* as there are not sufficiently many free.
*/
+ bool new_persistent_gnts = false;
struct scatterlist *sg;
int num_sg, max_grefs, num_grant;
@@ -724,12 +725,13 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
*/
max_grefs += INDIRECT_GREFS(max_grefs);
- /*
- * We have to reserve 'max_grefs' grants because persistent
- * grants are shared by all rings.
- */
- if (max_grefs > 0)
- if (gnttab_alloc_grant_references(max_grefs, &setup.gref_head) < 0) {
+ /* Check if we have enough persistent grants to allocate a requests */
+ if (rinfo->persistent_gnts_c < max_grefs) {
+ new_persistent_gnts = true;
+
+ if (gnttab_alloc_grant_references(
+ max_grefs - rinfo->persistent_gnts_c,
+ &setup.gref_head) < 0) {
gnttab_request_free_callback(
&rinfo->callback,
blkif_restart_queue_callback,
@@ -737,6 +739,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
max_grefs);
return 1;
}
+ }
/* Fill out a communications ring structure. */
id = blkif_ring_get_request(rinfo, req, &ring_req);
@@ -837,7 +840,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
if (unlikely(require_extra_req))
rinfo->shadow[extra_id].req = *extra_ring_req;
- if (max_grefs > 0)
+ if (new_persistent_gnts)
gnttab_free_grant_references(setup.gref_head);
return 0;
--
2.7.4
[toc] | [next] | [standalone]
| From | Roger Pau Monné <roger.pau@citrix.com> |
|---|---|
| Date | 2017-06-28 10:40 +0200 |
| Subject | Re: [PATCH 1/1] xen/blkfront: always allocate grants first from per-queue persistent grants |
| Message-ID | <tXgFY-4t8-19@gated-at.bofh.it> |
| In reply to | #1676367 |
On Wed, Jun 28, 2017 at 12:43:03PM +0800, Dongli Zhang wrote:
> This patch partially reverts 3df0e50 ("xen/blkfront: pseudo support for
> multi hardware queues/rings"). The xen-blkfront queue/ring might hang due
> to grants allocation failure in the situation when gnttab_free_head is
> almost empty while many persistent grants are reserved for this queue/ring.
>
> As persistent grants management was per-queue since 73716df ("xen/blkfront:
> make persistent grants pool per-queue"), we should always allocate from
> persistent grants first.
>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> drivers/block/xen-blkfront.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 3945963..d2b759f 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -713,6 +713,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
> * existing persistent grants, or if we have to get new grants,
> * as there are not sufficiently many free.
> */
> + bool new_persistent_gnts = false;
> struct scatterlist *sg;
> int num_sg, max_grefs, num_grant;
>
> @@ -724,12 +725,13 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
> */
> max_grefs += INDIRECT_GREFS(max_grefs);
>
> - /*
> - * We have to reserve 'max_grefs' grants because persistent
> - * grants are shared by all rings.
> - */
> - if (max_grefs > 0)
> - if (gnttab_alloc_grant_references(max_grefs, &setup.gref_head) < 0) {
> + /* Check if we have enough persistent grants to allocate a requests */
> + if (rinfo->persistent_gnts_c < max_grefs) {
> + new_persistent_gnts = true;
> +
> + if (gnttab_alloc_grant_references(
> + max_grefs - rinfo->persistent_gnts_c,
> + &setup.gref_head) < 0) {
> gnttab_request_free_callback(
> &rinfo->callback,
> blkif_restart_queue_callback,
AFAICT you should also change the call to gnttab_request_free_callback
to request for max_grefs - rinfo->persistent_gnts_c. In any case the
number of persistent grants is not going to decrease now, because the
buffer is per-queue, so the only thing that can happen is that
requests complete and the number of persistent grants increase.
Roger.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web