From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752598AbaKDTrJ (ORCPT ); Tue, 4 Nov 2014 14:47:09 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:55233 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbaKDTrG (ORCPT ); Tue, 4 Nov 2014 14:47:06 -0500 Message-ID: <54592D33.4080405@de.ibm.com> Date: Tue, 04 Nov 2014 20:46:59 +0100 From: Christian Borntraeger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.0 MIME-Version: 1.0 To: Tejun Heo , Jens Axboe CC: Kent Overstreet , Christoph Hellwig , "linux-kernel@vger.kernel.org >> Linux Kernel Mailing List" , linux-s390 Subject: Re: [PATCH block/for-linus] blk-mq: make mq_queue_reinit_notify() freeze queues in parallel References: <544FF00B.8050403@de.ibm.com> <20141028200055.GA8205@htj.dyndns.org> <544FFAA7.1060705@de.ibm.com> <20141028202255.GB8205@htj.dyndns.org> <544FFC9C.60908@de.ibm.com> <20141028203040.GD8205@htj.dyndns.org> <20141104185227.GH14459@htj.dyndns.org> In-Reply-To: <20141104185227.GH14459@htj.dyndns.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14110419-0029-0000-0000-000001873F09 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 04.11.2014 19:52, schrieb Tejun Heo: > q->mq_usage_counter is a percpu_ref which is killed and drained when > the queue is frozen. On a CPU hotplug event, blk_mq_queue_reinit() > which involves freezing the queue is invoked on all existing queues. > Because percpu_ref killing and draining involve a RCU grace period, > doing the above on one queue after another may take a long time if > there are many queues on the system. > > This patch splits out initiation of freezing and waiting for its > completion, and updates blk_mq_queue_reinit_notify() so that the > queues are frozen in parallel instead of one after another. Note that > freezing and unfreezing are moved from blk_mq_queue_reinit() to > blk_mq_queue_reinit_notify(). > > Signed-off-by: Tejun Heo > Reported-by: Christian Borntraeger Tested-by: Christian Borntraeger Thanks. > --- > Christian, can you please verify that this resolves the latency issue > that you're seeing? Jens, can you please route this patch once > Christian confirms it? > > Thanks! > > block/blk-mq.c | 41 +++++++++++++++++++++++++++++++++-------- > 1 file changed, 33 insertions(+), 8 deletions(-) > > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -107,11 +107,7 @@ static void blk_mq_usage_counter_release > wake_up_all(&q->mq_freeze_wq); > } > > -/* > - * Guarantee no request is in use, so we can change any data structure of > - * the queue afterward. > - */ > -void blk_mq_freeze_queue(struct request_queue *q) > +static void blk_mq_freeze_queue_start(struct request_queue *q) > { > bool freeze; > > @@ -123,9 +119,23 @@ void blk_mq_freeze_queue(struct request_ > percpu_ref_kill(&q->mq_usage_counter); > blk_mq_run_queues(q, false); > } > +} > + > +static void blk_mq_freeze_queue_wait(struct request_queue *q) > +{ > wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter)); > } > > +/* > + * Guarantee no request is in use, so we can change any data structure of > + * the queue afterward. > + */ > +void blk_mq_freeze_queue(struct request_queue *q) > +{ > + blk_mq_freeze_queue_start(q); > + blk_mq_freeze_queue_wait(q); > +} > + > static void blk_mq_unfreeze_queue(struct request_queue *q) > { > bool wake; > @@ -1921,7 +1931,7 @@ void blk_mq_free_queue(struct request_qu > /* Basically redo blk_mq_init_queue with queue frozen */ > static void blk_mq_queue_reinit(struct request_queue *q) > { > - blk_mq_freeze_queue(q); > + WARN_ON_ONCE(!q->mq_freeze_depth); > > blk_mq_sysfs_unregister(q); > > @@ -1936,8 +1946,6 @@ static void blk_mq_queue_reinit(struct r > blk_mq_map_swqueue(q); > > blk_mq_sysfs_register(q); > - > - blk_mq_unfreeze_queue(q); > } > > static int blk_mq_queue_reinit_notify(struct notifier_block *nb, > @@ -1956,8 +1964,25 @@ static int blk_mq_queue_reinit_notify(st > return NOTIFY_OK; > > mutex_lock(&all_q_mutex); > + > + /* > + * We need to freeze and reinit all existing queues. Freezing > + * involves synchronous wait for an RCU grace period and doing it > + * one by one may take a long time. Start freezing all queues in > + * one swoop and then wait for the completions so that freezing can > + * take place in parallel. > + */ > + list_for_each_entry(q, &all_q_list, all_q_node) > + blk_mq_freeze_queue_start(q); > + list_for_each_entry(q, &all_q_list, all_q_node) > + blk_mq_freeze_queue_wait(q); > + > list_for_each_entry(q, &all_q_list, all_q_node) > blk_mq_queue_reinit(q); > + > + list_for_each_entry(q, &all_q_list, all_q_node) > + blk_mq_unfreeze_queue(q); > + > mutex_unlock(&all_q_mutex); > return NOTIFY_OK; > } >