All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Bob Liu <bob.liu@oracle.com>
Cc: xen-devel@lists.xen.org, linux-kernel@vger.kernel.org,
	roger.pau@citrix.com, felipe.franciosi@citrix.com, axboe@fb.com,
	avanzini.arianna@gmail.com, rafal.mielniczuk@citrix.com,
	jonathan.davies@citrix.com, david.vrabel@citrix.com
Subject: Re: [PATCH v5 08/10] xen/blkback: get the number of hardware queues/rings from blkfront
Date: Wed, 25 Nov 2015 12:58:36 -0500	[thread overview]
Message-ID: <20151125175836.GC19188@x230.dumpdata.com> (raw)
In-Reply-To: <1447470739-18136-9-git-send-email-bob.liu@oracle.com>

On Sat, Nov 14, 2015 at 11:12:17AM +0800, Bob Liu wrote:
> Backend advertises "multi-queue-max-queues" to front, also get the negotiated
> number from "multi-queue-num-queues" written by blkfront.
> 
> Signed-off-by: Bob Liu <bob.liu@oracle.com>
> ---
>  drivers/block/xen-blkback/blkback.c |   12 ++++++++++++
>  drivers/block/xen-blkback/common.h  |    1 +
>  drivers/block/xen-blkback/xenbus.c  |   34 ++++++++++++++++++++++++++++------
>  3 files changed, 41 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
> index fb5bfd4..acedc46 100644
> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -84,6 +84,15 @@ MODULE_PARM_DESC(max_persistent_grants,
>                   "Maximum number of grants to map persistently");
>  
>  /*
> + * Maximum number of rings/queues blkback supports, allow as many queues as there
> + * are CPUs if user has not specified a value.
> + */
> +unsigned int xenblk_max_queues;
> +module_param_named(max_queues, xenblk_max_queues, uint, 0644);
> +MODULE_PARM_DESC(max_queues,
> +		 "Maximum number of hardware queues per virtual disk");

Added:
 unsigned int xenblk_max_queues;
 module_param_named(max_queues, xenblk_max_queues, uint, 0644);
 MODULE_PARM_DESC(max_queues,
-                "Maximum number of hardware queues per virtual disk");
+                "Maximum number of hardware queues per virtual disk." \
+                "By default it is the number of online CPUs.");
 
 /*

> +
> +/*
>   * Maximum order of pages to be used for the shared ring between front and
>   * backend, 4KB page granularity is used.
>   */
> @@ -1483,6 +1492,9 @@ static int __init xen_blkif_init(void)
>  		xen_blkif_max_ring_order = XENBUS_MAX_RING_GRANT_ORDER;
>  	}
>  
> +	if (xenblk_max_queues == 0)
> +		xenblk_max_queues = num_online_cpus();
> +
>  	rc = xen_blkif_interface_init();
>  	if (rc)
>  		goto failed_init;
> diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
> index f2386e3..0833dc6 100644
> --- a/drivers/block/xen-blkback/common.h
> +++ b/drivers/block/xen-blkback/common.h
> @@ -46,6 +46,7 @@
>  #include <xen/interface/io/protocols.h>
>  
>  extern unsigned int xen_blkif_max_ring_order;
> +extern unsigned int xenblk_max_queues;
>  /*
>   * This is the maximum number of segments that would be allowed in indirect
>   * requests. This value will also be passed to the frontend.
> diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
> index 6c6e048..d83b790 100644
> --- a/drivers/block/xen-blkback/xenbus.c
> +++ b/drivers/block/xen-blkback/xenbus.c
> @@ -181,12 +181,6 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
>  	blkif->st_print = jiffies;
>  	INIT_WORK(&blkif->persistent_purge_work, xen_blkbk_unmap_purged_grants);
>  
> -	blkif->nr_rings = 1;
> -	if (xen_blkif_alloc_rings(blkif)) {
> -		kmem_cache_free(xen_blkif_cachep, blkif);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -
>  	return blkif;
>  }
>  
> @@ -595,6 +589,12 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
>  		goto fail;
>  	}
>  
> +	/* Multi-queue: write how many queues are supported by the backend. */
> +	err = xenbus_printf(XBT_NIL, dev->nodename,
> +			    "multi-queue-max-queues", "%u", xenblk_max_queues);
> +	if (err)
> +		pr_warn("Error writing multi-queue-num-queues\n");

s/num/max/

> +
>  	/* setup back pointer */
>  	be->blkif->be = be;
>  
> @@ -980,6 +980,7 @@ static int connect_ring(struct backend_info *be)
>  	char *xspath;
>  	size_t xspathsize;
>  	const size_t xenstore_path_ext_size = 11; /* sufficient for "/queue-NNN" */
> +	unsigned int requested_num_queues = 0;
>  
>  	pr_debug("%s %s\n", __func__, dev->otherend);
>  
> @@ -1007,6 +1008,27 @@ static int connect_ring(struct backend_info *be)
>  	be->blkif->vbd.feature_gnt_persistent = pers_grants;
>  	be->blkif->vbd.overflow_max_grants = 0;
>  
> +	/*
> +	 * Read the number of hardware queues from frontend.
> +	 */
> +	err = xenbus_scanf(XBT_NIL, dev->otherend, "multi-queue-num-queues",
> +			   "%u", &requested_num_queues);
> +	if (err < 0) {
> +		requested_num_queues = 1;
> +	} else {
> +		if (requested_num_queues > xenblk_max_queues
> +		    || requested_num_queues == 0) {
> +			/* buggy or malicious guest */
> +			xenbus_dev_fatal(dev, err,
> +					"guest requested %u queues, exceeding the maximum of %u.",
> +					requested_num_queues, xenblk_max_queues);
> +			return -1;

And made this return -ENOSYS.


> +		}
> +	}
> +	be->blkif->nr_rings = requested_num_queues;
> +	if (xen_blkif_alloc_rings(be->blkif))
> +		return -ENOMEM;
> +
>  	pr_info("%s: using %d queues, protocol %d (%s) %s\n", dev->nodename,
>  		 be->blkif->nr_rings, be->blkif->blk_protocol, protocol,
>  		 pers_grants ? "persistent grants" : "");
> -- 
> 1.7.10.4
> 

  parent reply	other threads:[~2015-11-25 17:58 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-14  3:12 [PATCH v5 00/10] xen-block: multi hardware-queues/rings support Bob Liu
2015-11-14  3:12 ` [PATCH v5 01/10] xen/blkif: document blkif multi-queue/ring extension Bob Liu
2015-11-14  3:12 ` Bob Liu
2015-11-16 19:27   ` Konrad Rzeszutek Wilk
2015-11-14  3:12 ` [PATCH v5 02/10] xen/blkfront: separate per ring information out of device info Bob Liu
2015-11-14  3:12   ` Bob Liu
2015-11-16 19:44   ` Konrad Rzeszutek Wilk
2015-11-14  3:12 ` [PATCH v5 03/10] xen/blkfront: pseudo support for multi hardware queues/rings Bob Liu
2015-11-14  3:12   ` Bob Liu
2015-11-16 20:38   ` Konrad Rzeszutek Wilk
2015-11-16 21:54     ` Konrad Rzeszutek Wilk
2015-11-14  3:12 ` [PATCH v5 04/10] xen/blkfront: split per device io_lock Bob Liu
2015-11-16 20:59   ` Konrad Rzeszutek Wilk
2015-11-14  3:12 ` Bob Liu
2015-11-14  3:12 ` [PATCH v5 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend Bob Liu
2015-11-14  3:12 ` Bob Liu
2015-11-16 21:27   ` Konrad Rzeszutek Wilk
2015-11-16 23:13     ` Bob Liu
2015-11-17 14:20       ` Konrad Rzeszutek Wilk
2015-11-16 23:13     ` Bob Liu
2015-11-14  3:12 ` [PATCH v5 06/10] xen/blkback: separate ring information out of struct xen_blkif Bob Liu
2015-11-14  3:12   ` Bob Liu
2015-11-14  3:12 ` [PATCH v5 07/10] xen/blkback: pseudo support for multi hardware queues/rings Bob Liu
2015-11-25 17:40   ` Konrad Rzeszutek Wilk
2015-11-25 17:40   ` Konrad Rzeszutek Wilk
2015-11-14  3:12 ` Bob Liu
2015-11-14  3:12 ` [PATCH v5 08/10] xen/blkback: get the number of hardware queues/rings from blkfront Bob Liu
2015-11-14  3:12 ` Bob Liu
2015-11-25 17:58   ` Konrad Rzeszutek Wilk
2015-11-25 17:58   ` Konrad Rzeszutek Wilk [this message]
2015-11-14  3:12 ` [PATCH v5 09/10] xen/blkfront: make persistent grants pool per-queue Bob Liu
2015-11-14  3:12 ` Bob Liu
2015-11-14  3:12 ` [PATCH v5 10/10] xen/blkback: make pool of persistent grants and free pages per-queue Bob Liu
2015-11-14  3:12 ` Bob Liu
2015-11-16 21:08 ` [PATCH v5 00/10] xen-block: multi hardware-queues/rings support Konrad Rzeszutek Wilk
2015-11-16 21:35 ` [PATCH] cleanups to xen-lkbfront on top of " Konrad Rzeszutek Wilk
2015-11-16 21:35   ` [PATCH 1/2] xen/blkfront: Cleanup of comments, fix unaligned variables, and syntax errors Konrad Rzeszutek Wilk
2015-11-16 21:35   ` [PATCH 2/2] xen/blkfront: Remove duplicate setting of ->xbdev Konrad Rzeszutek Wilk
2015-11-25 19:25 ` [PATCH v5 00/10] xen-block: multi hardware-queues/rings support Konrad Rzeszutek Wilk
2015-11-25 20:56   ` Konrad Rzeszutek Wilk
2015-11-25 20:56   ` Konrad Rzeszutek Wilk
2015-11-25 22:12     ` Konrad Rzeszutek Wilk
2015-11-26  2:28       ` Bob Liu
2015-11-26  2:28       ` Bob Liu
2015-11-26  2:57         ` Konrad Rzeszutek Wilk
2015-11-26  7:09           ` Bob Liu
2015-11-26 16:20             ` Konrad Rzeszutek Wilk
2015-11-26 16:20             ` Konrad Rzeszutek Wilk
2015-11-30 22:03             ` Konrad Rzeszutek Wilk
2015-11-26  7:09           ` Bob Liu
2015-11-26  2:57         ` Konrad Rzeszutek Wilk
2015-11-25 22:12     ` Konrad Rzeszutek Wilk
2015-11-25 19:25 ` Konrad Rzeszutek Wilk
2015-11-25 19:35 ` [PATCH RFC] Various fixes to xen block drivers on top of Bob's multi-queue patches Konrad Rzeszutek Wilk
2015-11-25 19:35   ` [PATCH RFC 1/2] xen/blocks: Return -EXX instead of -1 Konrad Rzeszutek Wilk
2015-11-25 19:35   ` Konrad Rzeszutek Wilk
2015-11-25 19:35   ` [PATCH RFC 2/2] xen/blkback: Free resources if connect_ring failed Konrad Rzeszutek Wilk
2015-11-25 19:35   ` Konrad Rzeszutek Wilk
2015-11-25 19:35 ` [PATCH RFC] Various fixes to xen block drivers on top of Bob's multi-queue patches Konrad Rzeszutek Wilk

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=20151125175836.GC19188@x230.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=avanzini.arianna@gmail.com \
    --cc=axboe@fb.com \
    --cc=bob.liu@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=felipe.franciosi@citrix.com \
    --cc=jonathan.davies@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafal.mielniczuk@citrix.com \
    --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.