Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp654000ybg; Thu, 19 Mar 2020 06:28:33 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuyKS7R3kBsmLVGenhUy+C6BWB91BsWPHb2Iw53ntzNpik3kanW+ufCUjh/fHL/9uvebOhk X-Received: by 2002:a9d:60b:: with SMTP id 11mr2289837otn.126.1584624513484; Thu, 19 Mar 2020 06:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624513; cv=none; d=google.com; s=arc-20160816; b=Tv3MCf5m1ZVb5NeQaR+LygsUj8eDkIPLTP/QLzmTdW/eauRnmV2Pm7NajDVTVaxoPc KtROvHh9lmpU40qq9fwf09/LcEmSzQ/queov30TB1jb5gkh930GrdRs01Z8nGyXwFieT FCMQ+irYl2053RLWjw96N1Q03FLVUGof7GF+gzFMFY36LcuhASCIkWtO99W0b3L8GEjE PuqZQcJxdxXybP1TwVI8k6DxysjDtBj+M4ScWv2yOJijt94Rel80YB8cRdZSHW+oWuwN JZLLHI/f6y0w1OkNtNHZMhAigoRxpGka8sO5BWXKaUWj3YRNX/oil9vylMpDgfNwtUvC Oo6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KLrWd1XqlGdDZN5/dqVmErPkIRcJ3UdyLh+QcyqrPH4=; b=WpZD5eru7quc705i8kp+2rLIc1ZdSKYPjCtIiMVxEMni+MSwTOWTHjzeMyPH9YxD2n tfsunAo6aUg3MHL3+LGFLbHS02vzhw/eiI9QRhsCmiPbiMVclOze1kq9BxiT73OUcK58 HbLnDeiGORjrtRBDhG+hK0OlaetxpYm5Ik2HhOXkdJmXfODD8/q06tpHeZjANKP8jZFe ZeoDs3p+NcCrIpTV5vpSZXM7Zore4qTXghG9nRKHK/r4LDuVt3zU6/VyWV8tX7IMyZc8 8b3UKVxtBDTBnpszOptDyqkvuVVkD9At/ELai+kmnmN7ySZvdZxorNq1w5FZxkISWedh bqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ixnl/9SD"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q131si993322oig.203.2020.03.19.06.28.20; Thu, 19 Mar 2020 06:28:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ixnl/9SD"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730978AbgCSN2B (ORCPT + 99 others); Thu, 19 Mar 2020 09:28:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:56444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730963AbgCSN15 (ORCPT ); Thu, 19 Mar 2020 09:27:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CD414208D6; Thu, 19 Mar 2020 13:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624476; bh=bUaOVor2yx1FOOgO8uJd78Y2jDFUGYryKlGVpqN3LX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ixnl/9SDfI+udjt2Ulumf7qRzQlvWI1EB1MVIAVi02kj6VHcE3AzjSOVBsVVRQPso YE4r8/Ig4idFWnlLohbDeQQSivV6+yMwF9CHUn/uF//Ow3JkvB3PKYO5dD8MZP7RGv g689/b8UKh3Z//TiVCQFHuZdsJZA2DmHgLrmWC7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Shinichiro Kawasaki , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 5.5 58/65] blk-mq: insert flush request to the front of dispatch queue Date: Thu, 19 Mar 2020 14:04:40 +0100 Message-Id: <20200319123944.552521031@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123926.466988514@linuxfoundation.org> References: <20200319123926.466988514@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit cc3200eac4c5eb11c3f34848a014d1f286316310 ] commit 01e99aeca397 ("blk-mq: insert passthrough request into hctx->dispatch directly") may change to add flush request to the tail of dispatch by applying the 'add_head' parameter of blk_mq_sched_insert_request. Turns out this way causes performance regression on NCQ controller because flush is non-NCQ command, which can't be queued when there is any in-flight NCQ command. When adding flush rq to the front of hctx->dispatch, it is easier to introduce extra time to flush rq's latency compared with adding to the tail of dispatch queue because of S_SCHED_RESTART, then chance of flush merge is increased, and less flush requests may be issued to controller. So always insert flush request to the front of dispatch queue just like before applying commit 01e99aeca397 ("blk-mq: insert passthrough request into hctx->dispatch directly"). Cc: Damien Le Moal Cc: Shinichiro Kawasaki Reported-by: Shinichiro Kawasaki Fixes: 01e99aeca397 ("blk-mq: insert passthrough request into hctx->dispatch directly") Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq-sched.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -398,6 +398,28 @@ void blk_mq_sched_insert_request(struct WARN_ON(e && (rq->tag != -1)); if (blk_mq_sched_bypass_insert(hctx, !!e, rq)) { + /* + * Firstly normal IO request is inserted to scheduler queue or + * sw queue, meantime we add flush request to dispatch queue( + * hctx->dispatch) directly and there is at most one in-flight + * flush request for each hw queue, so it doesn't matter to add + * flush request to tail or front of the dispatch queue. + * + * Secondly in case of NCQ, flush request belongs to non-NCQ + * command, and queueing it will fail when there is any + * in-flight normal IO request(NCQ command). When adding flush + * rq to the front of hctx->dispatch, it is easier to introduce + * extra time to flush rq's latency because of S_SCHED_RESTART + * compared with adding to the tail of dispatch queue, then + * chance of flush merge is increased, and less flush requests + * will be issued to controller. It is observed that ~10% time + * is saved in blktests block/004 on disk attached to AHCI/NCQ + * drive when adding flush rq to the front of hctx->dispatch. + * + * Simply queue flush rq to the front of hctx->dispatch so that + * intensive flush workloads can benefit in case of NCQ HW. + */ + at_head = (rq->rq_flags & RQF_FLUSH_SEQ) ? true : at_head; blk_mq_request_bypass_insert(rq, at_head, false); goto run; }