Linux block layer
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	Bart van Assche <bvanassche@acm.org>,
	John Garry <john.garry@huawei.com>,
	linux-scsi@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH 4/8] blk-mq: Facilitate a shared sbitmap per tagset
Date: Tue, 26 Nov 2019 12:27:50 +0100	[thread overview]
Message-ID: <8a10e2f0-bbdc-8b47-a118-0fd7837ef44e@suse.de> (raw)
In-Reply-To: <20191126110527.GE32135@ming.t460p>

On 11/26/19 12:05 PM, Ming Lei wrote:
> On Tue, Nov 26, 2019 at 10:14:12AM +0100, Hannes Reinecke wrote:
[ .. ]
>> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
>> index ca22afd47b3d..f3589f42b96d 100644
>> --- a/block/blk-mq-sched.c
>> +++ b/block/blk-mq-sched.c
>> @@ -452,7 +452,7 @@ static void blk_mq_sched_free_tags(struct blk_mq_tag_set *set,
>>  {
>>  	if (hctx->sched_tags) {
>>  		blk_mq_free_rqs(set, hctx->sched_tags, hctx_idx);
>> -		blk_mq_free_rq_map(hctx->sched_tags);
>> +		blk_mq_free_rq_map(hctx->sched_tags, false);
>>  		hctx->sched_tags = NULL;
>>  	}
>>  }
>> @@ -462,10 +462,14 @@ static int blk_mq_sched_alloc_tags(struct request_queue *q,
>>  				   unsigned int hctx_idx)
>>  {
>>  	struct blk_mq_tag_set *set = q->tag_set;
>> +	int flags = set->flags;
>>  	int ret;
>>  
>> +	/* Scheduler tags are never shared */
>> +	set->flags &= ~BLK_MQ_F_TAG_HCTX_SHARED;
>>  	hctx->sched_tags = blk_mq_alloc_rq_map(set, hctx_idx, q->nr_requests,
>>  					       set->reserved_tags);
>> +	set->flags = flags;
> 
> This way is very fragile, race is made against other uses of
> blk_mq_is_sbitmap_shared().
> 
We are allocating tags, I don't think we're even able to modify it at
this point.

> From performance viewpoint, all hctx belonging to this request queue should
> share one scheduler tagset in case of BLK_MQ_F_TAG_HCTX_SHARED, cause
> driver tag queue depth isn't changed.
> 
Hmm. Now you get me confused.
In an earlier mail you said:

> This kind of sharing is wrong, sched tags should be request
> queue wide instead of tagset wide, and each request queue has
> its own & independent scheduler queue.

as in v2 we _had_ shared scheduler tags, too.
Did I misread your comment above?

>>  	if (!hctx->sched_tags)
>>  		return -ENOMEM;
>>  
[ .. ]
>> @@ -2456,7 +2459,8 @@ static void blk_mq_free_map_and_requests(struct blk_mq_tag_set *set,
>>  {
>>  	if (set->tags && set->tags[hctx_idx]) {
>>  		blk_mq_free_rqs(set, set->tags[hctx_idx], hctx_idx);
>> -		blk_mq_free_rq_map(set->tags[hctx_idx]);
>> +		blk_mq_free_rq_map(set->tags[hctx_idx],
>> +				   blk_mq_is_sbitmap_shared(set));
>>  		set->tags[hctx_idx] = NULL;
>>  	}
> 
> Who will free the shared tags finally in case of blk_mq_is_sbitmap_shared()?
> 
Hmm. Indeed, that bit is missing; will be adding it.

>>  }
[ .. ]
>> @@ -3168,8 +3186,17 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
>>  			q->elevator->type->ops.depth_updated(hctx);
>>  	}
>>  
>> -	if (!ret)
>> +	if (!ret) {
>> +		if (blk_mq_is_sbitmap_shared(set)) {
>> +			sbitmap_queue_resize(&set->shared_bitmap_tags, nr);
>> +			sbitmap_queue_resize(&set->shared_breserved_tags, nr);
>> +		}
> 
> The above change is wrong in case of hctx->sched_tags.
> 
Yes, we need to add a marker here if these are 'normal' or 'scheduler'
tags. This will also help when allocating as then we won't need this
flag twiddling you've complained about.

>>  		q->nr_requests = nr;
>> +	}
>> +	/*
>> +	 * if ret != 0, q->nr_requests would not be updated, yet the depth
>> +	 * for some hctx may have changed - is that right?
>> +	 */
>>  
>>  	blk_mq_unquiesce_queue(q);
>>  	blk_mq_unfreeze_queue(q);
[ .. ]
>> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
>> index 147185394a25..670e9a949d32 100644
>> --- a/include/linux/blk-mq.h
>> +++ b/include/linux/blk-mq.h
>> @@ -109,6 +109,12 @@ struct blk_mq_tag_set {
>>  	unsigned int		flags;		/* BLK_MQ_F_* */
>>  	void			*driver_data;
>>  
>> +	struct sbitmap_queue shared_bitmap_tags;
>> +	struct sbitmap_queue shared_breserved_tags;
>> +
>> +	struct sbitmap_queue sched_shared_bitmap_tags;
>> +	struct sbitmap_queue sched_shared_breserved_tags;
>> +
> 
> The above two fields aren't used in this patch.
> 
Left-overs from merging. Will be removed.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      Teamlead Storage & Networking
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

  reply	other threads:[~2019-11-26 11:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26  9:14 [PATCH RFC v3 0/8] blk-mq/scsi: Provide hostwide shared tags for SCSI HBAs Hannes Reinecke
2019-11-26  9:14 ` [PATCH 1/8] blk-mq: Remove some unused function arguments Hannes Reinecke
2019-11-26  9:14 ` [PATCH 2/8] blk-mq: rename BLK_MQ_F_TAG_SHARED as BLK_MQ_F_TAG_QUEUE_SHARED Hannes Reinecke
2019-11-26  9:14 ` [PATCH 3/8] blk-mq: Use a pointer for sbitmap Hannes Reinecke
2019-11-26 15:14   ` Jens Axboe
2019-11-26 16:54     ` John Garry
2019-11-26 17:11       ` Jens Axboe
2019-11-26 17:23         ` John Garry
2019-11-26 17:25           ` Jens Axboe
2019-11-26 18:08             ` John Garry
2019-11-27  1:46               ` Jens Axboe
2019-11-27 13:05                 ` John Garry
2019-11-27 13:12                   ` Hannes Reinecke
2019-11-27 14:20                     ` Jens Axboe
2019-11-27 14:21                   ` Jens Axboe
2019-11-27 14:44                     ` John Garry
2019-11-27 16:52                       ` Hannes Reinecke
2019-11-27 18:02                         ` John Garry
2019-11-26  9:14 ` [PATCH 4/8] blk-mq: Facilitate a shared sbitmap per tagset Hannes Reinecke
2019-11-26 11:05   ` Ming Lei
2019-11-26 11:27     ` Hannes Reinecke [this message]
2019-11-26 11:50       ` John Garry
2019-11-26 15:54       ` Ming Lei
2019-11-27 17:02         ` Hannes Reinecke
2019-11-29  0:25           ` Ming Lei
2019-11-29  9:21             ` John Garry
2019-11-26  9:14 ` [PATCH 5/8] scsi: Add template flag 'host_tagset' Hannes Reinecke
2019-11-26  9:14 ` [PATCH 6/8] scsi: hisi_sas: Switch v3 hw to MQ Hannes Reinecke
2019-11-26  9:14 ` [PATCH 7/8] smartpqi: enable host tagset Hannes Reinecke
2019-11-26  9:14 ` [PATCH 8/8] hpsa: switch to using blk-mq Hannes Reinecke
2019-11-26 10:09 ` [PATCH RFC v3 0/8] blk-mq/scsi: Provide hostwide shared tags for SCSI HBAs John Garry
  -- strict thread matches above, loose matches on Subject: below --
2019-11-26 13:10 [PATCH RFC v4 " Hannes Reinecke
2019-11-26 13:10 ` [PATCH 4/8] blk-mq: Facilitate a shared sbitmap per tagset Hannes Reinecke
2019-11-26 13:59   ` John Garry
2019-11-26 14:10     ` Hannes Reinecke
2019-11-27 17:03   ` Bart Van Assche

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=8a10e2f0-bbdc-8b47-a118-0fd7837ef44e@suse.de \
    --to=hare@suse.de \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=john.garry@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    /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