From patchwork Mon Feb 5 19:11:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 10201551 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 DB176601A1 for ; Mon, 5 Feb 2018 19:12:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA6EE2882C for ; Mon, 5 Feb 2018 19:12:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8E9A287CF; Mon, 5 Feb 2018 19:12:14 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 2D51E2884C for ; Mon, 5 Feb 2018 19:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752738AbeBETMA (ORCPT ); Mon, 5 Feb 2018 14:12:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45272 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbeBETL7 (ORCPT ); Mon, 5 Feb 2018 14:11:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6659B4901B; Mon, 5 Feb 2018 19:11:59 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 347EF60C4E; Mon, 5 Feb 2018 19:11:56 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w15JBtDH017057; Mon, 5 Feb 2018 14:11:55 -0500 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w15JBtrE017053; Mon, 5 Feb 2018 14:11:55 -0500 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 5 Feb 2018 14:11:55 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Jens Axboe cc: linux-block@vger.kernel.org, dm-devel@redhat.com Subject: [PATCH] wbt: fix incorrect throttling due to flush latency Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 05 Feb 2018 19:11:59 +0000 (UTC) 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 I have a workload where one process sends many asynchronous write bios (without waiting for them) and another process sends synchronous flush bios. During this workload, writeback throttling throttles down to one outstanding bio, and this incorrect throttling causes performance degradation (all write bios sleep in __wbt_wait and they couldn't be sent in parallel). The reason for this throttling is that wbt_data_dir counts flush requests in the read bucket. The flush requests (that take quite a long time) trigger this condition repeatedly: if (stat[READ].min > rwb->min_lat_nsec) and that condition causes scale down to one outstanding request, despite the fact that there are no read bios at all. A similar problem could also show up with REQ_OP_ZONE_REPORT and REQ_OP_ZONE_RESET - they are also counted in the read bucket. This patch fixes the function wbt_data_dir, so that only REQ_OP_READ requests are counted in the read bucket. The patch improves SATA write+flush throughput from 130MB/s to 350MB/s. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org # v4.12+ --- block/blk-wbt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) Index: linux-stable/block/blk-wbt.c =================================================================== --- linux-stable.orig/block/blk-wbt.c 2018-02-05 12:30:09.606063908 -0500 +++ linux-stable/block/blk-wbt.c 2018-02-05 13:50:02.784213501 -0500 @@ -697,7 +697,11 @@ u64 wbt_default_latency_nsec(struct requ static int wbt_data_dir(const struct request *rq) { - return rq_data_dir(rq); + /* + * Flushes must be counted in the write bucket, so that high flush + * latencies don't cause scale down. + */ + return req_op(rq) == REQ_OP_READ ? READ : WRITE; } int wbt_init(struct request_queue *q)