linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bob Liu <bob.liu@oracle.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: xen-devel@lists.xen.org, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org, konrad.wilk@oracle.com,
	felipe.franciosi@citrix.com, axboe@fb.com, hch@infradead.org,
	avanzini.arianna@gmail.com, rafal.mielniczuk@citrix.com,
	boris.ostrovsky@oracle.com, jonathan.davies@citrix.com
Subject: Re: [PATCH v3 9/9] xen/blkback: get number of hardware queues/rings from blkfront
Date: Wed, 07 Oct 2015 18:54:49 +0800	[thread overview]
Message-ID: <5614F9F9.90607@oracle.com> (raw)
In-Reply-To: <561293F9.1050006@citrix.com>


On 10/05/2015 11:15 PM, Roger Pau Monné wrote:
> El 05/09/15 a les 14.39, Bob Liu ha escrit:
>> Backend advertises "multi-queue-max-queues" to front, and then read back the
>> final negotiated queues/rings from "multi-queue-num-queues" which is wrote by
>> blkfront.
>>
>> Signed-off-by: Bob Liu <bob.liu@oracle.com>
>> ---
>>  drivers/block/xen-blkback/blkback.c |    8 ++++++++
>>  drivers/block/xen-blkback/xenbus.c  |   36 ++++++++++++++++++++++++++++++-----
>>  2 files changed, 39 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
>> index fd02240..b904fe05f0 100644
>> --- a/drivers/block/xen-blkback/blkback.c
>> +++ b/drivers/block/xen-blkback/blkback.c
>> @@ -83,6 +83,11 @@ module_param_named(max_persistent_grants, xen_blkif_max_pgrants, int, 0644);
>>  MODULE_PARM_DESC(max_persistent_grants,
>>                   "Maximum number of grants to map persistently");
>>  
>> +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 order of pages to be used for the shared ring between front and
>>   * backend, 4KB page granularity is used.
>> @@ -1458,6 +1463,9 @@ static int __init xen_blkif_init(void)
>>  		xen_blkif_max_ring_order = XENBUS_MAX_RING_PAGE_ORDER;
>>  	}
>>  
>> +	/* Allow as many queues as there are CPUs, by default */
>> +	xenblk_max_queues = num_online_cpus();
> 
> Hm, I'm not sure of the best way to set a default value for this.
> Consider for example a scenario were Dom0 is limited to 2vCPUs, but DomU
> has 8 vCPUs. Are we going to limit the number of queues to two? Is that
> the most appropriate value from a performance PoV?
> 
> I have to admit I don't have a clear idea of a default value for this
> field, and maybe the number of CPUs on the backend is indeed what works
> better, but there needs to be a comment explaining the reasoning behind
> this setting.
> 

It looks like xen-netback also chose num online cpus as the default value.
Anyway, that's not a big problem and can be fixed easily in future.

Thanks again for reviewing this big patch set!

Regards,
-Bob

>>  	rc = xen_blkif_interface_init();
>>  	if (rc)
>>  		goto failed_init;
>> diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
>> index 04b8d0d..aa97ea5 100644
>> --- a/drivers/block/xen-blkback/xenbus.c
>> +++ b/drivers/block/xen-blkback/xenbus.c
>> @@ -28,6 +28,8 @@
>>  #define RINGREF_NAME_LEN (20)
>>  #define RINGREF_NAME_LEN (20)
>>  
>> +extern unsigned int xenblk_max_queues;
> 
> This should live in blkback/common.h
> 
>> +
>>  struct backend_info {
>>  	struct xenbus_device	*dev;
>>  	struct xen_blkif	*blkif;
>> @@ -191,11 +193,6 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
>>  	atomic_set(&blkif->drain, 0);
>>  	INIT_WORK(&blkif->free_work, xen_blkif_deferred_free);
>>  
>> -	blkif->nr_rings = 1;
>> -	if (xen_blkif_alloc_rings(blkif)) {
>> -		kmem_cache_free(xen_blkif_cachep, blkif);
>> -		return ERR_PTR(-ENOMEM);
>> -	}
>>  	return blkif;
>>  }
>>  
>> @@ -618,6 +615,14 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
>>  		goto fail;
>>  	}
>>  
>> +	/* Multi-queue: wrte how many queues backend supported. */
>                         ^ 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_debug("Error writing multi-queue-num-queues\n");
>                 ^ pr_warn at least.
>> +		goto fail;
>> +	}
>> +
>>  	/* setup back pointer */
>>  	be->blkif->be = be;
>>  
>> @@ -1008,6 +1013,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);
>>  
>> @@ -1035,6 +1041,26 @@ 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 queus from frontend.
>                                        ^ queues
>> +	 */
>> +	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;
>> +		}
>> +	}
>> +	be->blkif->nr_rings = requested_num_queues;
>> +	if (xen_blkif_alloc_rings(be->blkif))
>> +		return -ENOMEM;
>> +
>>  	pr_info("nr_rings:%d protocol %d (%s) %s\n", be->blkif->nr_rings,
>>  		 be->blkif->blk_protocol, protocol,
>>  		 pers_grants ? "persistent grants" : "");
>>

  reply	other threads:[~2015-10-07 10:55 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-05 12:39 [PATCH v3 0/9] xen-block: support multi hardware-queues/rings Bob Liu
2015-09-05 12:39 ` [PATCH v3 1/9] xen-blkfront: convert to blk-mq APIs Bob Liu
2015-09-23 20:31   ` Konrad Rzeszutek Wilk
2015-09-23 21:12     ` Konrad Rzeszutek Wilk
2015-09-05 12:39 ` [PATCH v3 2/9] xen-block: add document for mutli hardware queues/rings Bob Liu
2015-09-23 20:32   ` Konrad Rzeszutek Wilk
2015-10-02 16:04   ` Roger Pau Monné
2015-10-02 16:12     ` [Xen-devel] " Wei Liu
2015-10-02 16:22       ` Roger Pau Monné
2015-10-02 23:55         ` Bob Liu
2015-09-05 12:39 ` [PATCH v3 3/9] xen/blkfront: separate per ring information out of device info Bob Liu
2015-10-02 17:02   ` Roger Pau Monné
2015-10-03  0:34     ` Bob Liu
2015-10-05 15:17       ` Roger Pau Monné
2015-10-10  8:30     ` Bob Liu
2015-10-19  9:42       ` Roger Pau Monné
2015-09-05 12:39 ` [PATCH v3 4/9] xen/blkfront: pseudo support for multi hardware queues/rings Bob Liu
2015-10-05 10:52   ` Roger Pau Monné
2015-10-07 10:28     ` Bob Liu
2015-09-05 12:39 ` [PATCH v3 5/9] xen/blkfront: convert per device io_lock to per ring ring_lock Bob Liu
2015-10-05 14:13   ` Roger Pau Monné
2015-10-07 10:34     ` Bob Liu
2015-09-05 12:39 ` [PATCH v3 6/9] xen/blkfront: negotiate the number of hw queues/rings with backend Bob Liu
2015-10-05 14:40   ` Roger Pau Monné
2015-10-07 10:39     ` Bob Liu
2015-10-07 11:46       ` Roger Pau Monné
2015-10-07 12:19         ` Bob Liu
2015-09-05 12:39 ` [PATCH v3 7/9] xen/blkback: separate ring information out of struct xen_blkif Bob Liu
2015-10-05 14:55   ` Roger Pau Monné
2015-10-07 10:41     ` Bob Liu
2015-10-10  4:08     ` Bob Liu
2015-10-19  9:36       ` Roger Pau Monné
2015-10-19 10:03         ` Bob Liu
2015-10-05 14:55   ` Roger Pau Monné
2015-09-05 12:39 ` [PATCH v3 8/9] xen/blkback: pseudo support for multi hardware queues/rings Bob Liu
2015-10-05 15:08   ` Roger Pau Monné
2015-10-07 10:50     ` Bob Liu
2015-10-07 11:49       ` Roger Pau Monné
2015-09-05 12:39 ` [PATCH v3 9/9] xen/blkback: get number of hardware queues/rings from blkfront Bob Liu
2015-10-05 15:15   ` Roger Pau Monné
2015-10-07 10:54     ` Bob Liu [this message]
2015-10-02  9:57 ` [PATCH v3 0/9] xen-block: support multi hardware-queues/rings Rafal Mielniczuk

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=5614F9F9.90607@oracle.com \
    --to=bob.liu@oracle.com \
    --cc=avanzini.arianna@gmail.com \
    --cc=axboe@fb.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=felipe.franciosi@citrix.com \
    --cc=hch@infradead.org \
    --cc=jonathan.davies@citrix.com \
    --cc=konrad.wilk@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).