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 7/9] xen/blkback: separate ring information out of struct xen_blkif
Date: Wed, 07 Oct 2015 18:41:54 +0800 [thread overview]
Message-ID: <5614F6F2.2030407@oracle.com> (raw)
In-Reply-To: <56128F54.1090907@citrix.com>
On 10/05/2015 10:55 PM, Roger Pau Monné wrote:
> El 05/09/15 a les 14.39, Bob Liu ha escrit:
>> Split per ring information to an new structure:xen_blkif_ring, so that one vbd
>> device can associate with one or more rings/hardware queues.
>>
>> This patch is a preparation for supporting multi hardware queues/rings.
>>
>> Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
>> Signed-off-by: Bob Liu <bob.liu@oracle.com>
>> ---
>> drivers/block/xen-blkback/blkback.c | 365 ++++++++++++++++++-----------------
>> drivers/block/xen-blkback/common.h | 52 +++--
>> drivers/block/xen-blkback/xenbus.c | 130 +++++++------
>> 3 files changed, 295 insertions(+), 252 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
>> index 954c002..fd02240 100644
>> --- a/drivers/block/xen-blkback/blkback.c
>> +++ b/drivers/block/xen-blkback/blkback.c
>> @@ -113,71 +113,71 @@ module_param(log_stats, int, 0644);
>> /* Number of free pages to remove on each call to gnttab_free_pages */
>> #define NUM_BATCH_FREE_PAGES 10
>>
>> -static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
>> +static inline int get_free_page(struct xen_blkif_ring *ring, struct page **page)
>> {
>> unsigned long flags;
>>
>> - spin_lock_irqsave(&blkif->free_pages_lock, flags);
>> - if (list_empty(&blkif->free_pages)) {
>> - BUG_ON(blkif->free_pages_num != 0);
>> - spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
>> + spin_lock_irqsave(&ring->free_pages_lock, flags);
>> + if (list_empty(&ring->free_pages)) {
>
> I'm afraid the pool of free pages should be per-device, not per-ring.
>
>> + BUG_ON(ring->free_pages_num != 0);
>> + spin_unlock_irqrestore(&ring->free_pages_lock, flags);
>> return gnttab_alloc_pages(1, page);
>> }
>> - BUG_ON(blkif->free_pages_num == 0);
>> - page[0] = list_first_entry(&blkif->free_pages, struct page, lru);
>> + BUG_ON(ring->free_pages_num == 0);
>> + page[0] = list_first_entry(&ring->free_pages, struct page, lru);
>> list_del(&page[0]->lru);
>> - blkif->free_pages_num--;
>> - spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
>> + ring->free_pages_num--;
>> + spin_unlock_irqrestore(&ring->free_pages_lock, flags);
>>
>> return 0;
>> }
>>
>> -static inline void put_free_pages(struct xen_blkif *blkif, struct page **page,
>> +static inline void put_free_pages(struct xen_blkif_ring *ring, struct page **page,
>> int num)
>> {
>> unsigned long flags;
>> int i;
>>
>> - spin_lock_irqsave(&blkif->free_pages_lock, flags);
>> + spin_lock_irqsave(&ring->free_pages_lock, flags);
>> for (i = 0; i < num; i++)
>> - list_add(&page[i]->lru, &blkif->free_pages);
>> - blkif->free_pages_num += num;
>> - spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
>> + list_add(&page[i]->lru, &ring->free_pages);
>> + ring->free_pages_num += num;
>> + spin_unlock_irqrestore(&ring->free_pages_lock, flags);
>> }
>>
>> -static inline void shrink_free_pagepool(struct xen_blkif *blkif, int num)
>> +static inline void shrink_free_pagepool(struct xen_blkif_ring *ring, int num)
>> {
>> /* Remove requested pages in batches of NUM_BATCH_FREE_PAGES */
>> struct page *page[NUM_BATCH_FREE_PAGES];
>> unsigned int num_pages = 0;
>> unsigned long flags;
>>
>> - spin_lock_irqsave(&blkif->free_pages_lock, flags);
>> - while (blkif->free_pages_num > num) {
>> - BUG_ON(list_empty(&blkif->free_pages));
>> - page[num_pages] = list_first_entry(&blkif->free_pages,
>> + spin_lock_irqsave(&ring->free_pages_lock, flags);
>> + while (ring->free_pages_num > num) {
>> + BUG_ON(list_empty(&ring->free_pages));
>> + page[num_pages] = list_first_entry(&ring->free_pages,
>> struct page, lru);
>> list_del(&page[num_pages]->lru);
>> - blkif->free_pages_num--;
>> + ring->free_pages_num--;
>> if (++num_pages == NUM_BATCH_FREE_PAGES) {
>> - spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
>> + spin_unlock_irqrestore(&ring->free_pages_lock, flags);
>> gnttab_free_pages(num_pages, page);
>> - spin_lock_irqsave(&blkif->free_pages_lock, flags);
>> + spin_lock_irqsave(&ring->free_pages_lock, flags);
>> num_pages = 0;
>> }
>> }
>> - spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
>> + spin_unlock_irqrestore(&ring->free_pages_lock, flags);
>> if (num_pages != 0)
>> gnttab_free_pages(num_pages, page);
>> }
>>
>> #define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page)))
>>
>> -static int do_block_io_op(struct xen_blkif *blkif);
>> -static int dispatch_rw_block_io(struct xen_blkif *blkif,
>> +static int do_block_io_op(struct xen_blkif_ring *ring);
>> +static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
>> struct blkif_request *req,
>> struct pending_req *pending_req);
>> -static void make_response(struct xen_blkif *blkif, u64 id,
>> +static void make_response(struct xen_blkif_ring *ring, u64 id,
>> unsigned short op, int st);
>>
>> #define foreach_grant_safe(pos, n, rbtree, node) \
>> @@ -198,19 +198,19 @@ static void make_response(struct xen_blkif *blkif, u64 id,
>> * bit operations to modify the flags of a persistent grant and to count
>> * the number of used grants.
>> */
>> -static int add_persistent_gnt(struct xen_blkif *blkif,
>> +static int add_persistent_gnt(struct xen_blkif_ring *ring,
>> struct persistent_gnt *persistent_gnt)
>> {
>> struct rb_node **new = NULL, *parent = NULL;
>> struct persistent_gnt *this;
>>
>> - if (blkif->persistent_gnt_c >= xen_blkif_max_pgrants) {
>> - if (!blkif->vbd.overflow_max_grants)
>> - blkif->vbd.overflow_max_grants = 1;
>> + if (ring->persistent_gnt_c >= xen_blkif_max_pgrants) {
>> + if (!ring->blkif->vbd.overflow_max_grants)
>> + ring->blkif->vbd.overflow_max_grants = 1;
>
> The same for the pool of persistent grants, it should be per-device and
> not per-ring.
>
> And I think this issue is far worse than the others, because a frontend
> might use a persistent grant on different queues, forcing the backend
> map the grant several times for each queue, this is not acceptable IMO.
>
Thanks, will be updated.
--
Regards,
-Bob
next prev parent reply other threads:[~2015-10-07 10:42 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 [this message]
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
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=5614F6F2.2030407@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).