From patchwork Mon Sep 25 10:46:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 9969655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D249E602D8 for ; Mon, 25 Sep 2017 10:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4EFB28B6A for ; Mon, 25 Sep 2017 10:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9CFB28B97; Mon, 25 Sep 2017 10:47:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F98828B6A for ; Mon, 25 Sep 2017 10:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934479AbdIYKrF (ORCPT ); Mon, 25 Sep 2017 06:47:05 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:35095 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933162AbdIYKrE (ORCPT ); Mon, 25 Sep 2017 06:47:04 -0400 Received: by mail-oi0-f67.google.com with SMTP id r20so3475348oie.2 for ; Mon, 25 Sep 2017 03:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=ka527T9SrxSXX0ex+TA4d+SISkzgwOfwAU+53LsrtA4=; b=G3IRNHfE4EYp2v2BQeuDImQtsDVOzZdBLQm+qDfD1btqudx4/TR1KJIlCM/G1zCOKP 1FE3PnfxMGFhGA4KaEln5YJB0P6WaTS+IuRtpyKy4hffVXY1gpJIImcCorVAocD2gIN+ 6HclaIw2nPiK0IsnG5KltSS11FDB/pUMTPPto/cNxowkxm2pHRvMA89h7XraUvHBBXPG anVBwxy+sPLC8tNq2u3obspyX/invpDI51gEuoT0bCb46RlaVV7GBAD0nfqtPLdBoPaN T21Iqmg2/11gDglE9JVazLketw6zGaG85RV+/80kW4yDyPTQ4SSTytl5NYGh+M5myCrL Yryg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=ka527T9SrxSXX0ex+TA4d+SISkzgwOfwAU+53LsrtA4=; b=Cg1r5iIQ/Dso+5Gqpt4AsA1Qe/WkWUkPuk0ZVjpYATYl4FDKbDPLrY4B6nu4HFl7eP x5oYtvjfcaNAv44fuT9Sd0oXAbzNC08rsHVJaYw/GYjCCJRiS6wC0XmiD4lxA0y3j8Nz Wkq8V1R9bYX4wXv/Vn4yYkzHarcgst18HnN1XFeLX/o8c/A7G+jtH/k3zT6kTXUht2IT HAc9glmIRpNAFeWlFunOszcHOJxzgpl00CE55C1CWepiKBZOPu5iGnwSYY74GLHTAULl wLjpO/YJbnSk1omVCutA/XWHXc3oV6557gl/g08RQRtmo2m1MYH9XpVrOIdOCQzeCdfF vx7A== X-Gm-Message-State: AHPjjUidi/hSZ30xA/aIboyY16vWKw89dW4ngfhGHecJwK2i+l6SEV8w ceiffAxUFWT0UV8WSRCx7Cc= X-Google-Smtp-Source: AOwi7QBREWSnpoBGZ7OjwJCfDXEdgxPsSF7imU6ofp2tDvYr9Sdqjv9qwkFf2kghLPGOOB9129MGXg== X-Received: by 10.202.222.138 with SMTP id v132mr8887072oig.170.1506336424063; Mon, 25 Sep 2017 03:47:04 -0700 (PDT) Received: from JosephdeMacBook-Pro.local ([205.204.117.17]) by smtp.gmail.com with ESMTPSA id d74sm6263328oib.30.2017.09.25.03.46.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 03:47:03 -0700 (PDT) From: Joseph Qi Subject: [PATCH] blk-throttle: fix possible io stall when doing upgrade To: linux-block Cc: Jens Axboe , Shaohua Li , boyu.mt@taobao.com, wenqing.lz@taobao.com, qijiang.qj@alibaba-inc.com Message-ID: <5b918e35-7072-ba9a-92cc-726d02777b4f@gmail.com> Date: Mon, 25 Sep 2017 18:46:42 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-US Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joseph Qi Currently it will try to dispatch bio in throtl_upgrade_state. This may lead to io stall in the following case. Say the hierarchy is like: /-test1 |-subtest1 and subtest1 has 32 queued bios now. throtl_pending_timer_fn throtl_upgrade_state ------------------------------------------------------------------------ upgrade to max throtl_select_dispatch throtl_schedule_next_dispatch throtl_select_dispatch throtl_schedule_next_dispatch Since throtl_select_dispatch will move queued bios from subtest1 to test1 in throtl_upgrade_state, it will then just do nothing in throtl_pending_timer_fn. As a result, queued bios won't be dispatched any more if no proper timer scheduled. Fix this issue by just scheduling dispatch now and let the dispatch be done only in timer. Signed-off-by: Joseph Qi --- block/blk-throttle.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 0fea76a..29d282f 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1909,13 +1909,11 @@ static void throtl_upgrade_state(struct throtl_data *td) struct throtl_grp *tg = blkg_to_tg(blkg); struct throtl_service_queue *sq = &tg->service_queue; - tg->disptime = jiffies - 1; - throtl_select_dispatch(sq); - throtl_schedule_next_dispatch(sq, false); + tg->disptime = jiffies; + throtl_schedule_next_dispatch(sq, true); } rcu_read_unlock(); - throtl_select_dispatch(&td->service_queue); - throtl_schedule_next_dispatch(&td->service_queue, false); + throtl_schedule_next_dispatch(&td->service_queue, true); queue_work(kthrotld_workqueue, &td->dispatch_work); }