Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp505963pxb; Wed, 27 Jan 2021 13:16:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoCbn81rebm6nGW8saQbs3XyFscreYMHpxR6cjX9UoQwsRtPQ8z/hRBbpq1NBzxcLZ136T X-Received: by 2002:a17:906:c954:: with SMTP id fw20mr8148208ejb.342.1611782215825; Wed, 27 Jan 2021 13:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611782215; cv=none; d=google.com; s=arc-20160816; b=bC78XxPJkF4yXvz3LKo9rOEezW/beFEnH63IOwbiHjrMZ/4td9T30JCi/MDlfQur4l +z45uVmysTnQCqjTJf7nmU+JUETFTxcjIThvjHgLlU9mXXsHCTpYDd51GxMOHERzPMt0 M16rl3C8REcDQHBxL94pvNZ236jmuBN1BkOowt6ZHoem5sN9d7xTz1qbb0TypR0FaZ7k 9A6G1tMVT+PbopriHlYsuvxrtjp8eEI6Lq20KmuYzCv4hlY5kMxGzGFMjrLE/VOtN5D1 v4imGBkotapFyM57Q2zmnSbwBl0pBB9gRVp9aqHLdDW+yzzUKkekSgjPGOCOORKDM5kC VQig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :message-id:date:subject:cc:to:from; bh=VnrNWhbVglLc9Ra8JjyHbUTuFgU5JqFit/UWfboGIaE=; b=gzWsV3a3Zb8DCeCFaXv74HUoO1hAuwZaogJCk+P/y2Wi+HAiNId53dsYnBb8leoF47 V9u8wr8q5KC5tSuVcJBzKscnmixGtt+s/BSuVn4206+QSgJOoTw+8J5ZPQeirAKiGl6q o/wlqAAi/HRlr1dydQL1tf1Kp4iMLgbd6EoMVj8An5HDKgdXpEnhXISv4N75XzLK6s15 psD+Z7PQbF2Mwznn7CiIROfBYdOFWfv25RZ9iyECecTUyrzF27ZD6XFCmsq+OpKYu+g5 3Uk9ePUacmRwu3D2uW/phSKK0dklh7en1yl+OWU2PhFfqPT7lS/MPXa2VxnZm0Gvcxu/ oPvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=easystack.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si1555517edv.64.2021.01.27.13.16.29; Wed, 27 Jan 2021 13:16:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=easystack.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232421AbhA0F6m (ORCPT + 99 others); Wed, 27 Jan 2021 00:58:42 -0500 Received: from m97179.mail.qiye.163.com ([220.181.97.179]:51822 "EHLO m97179.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235334AbhA0DQr (ORCPT ); Tue, 26 Jan 2021 22:16:47 -0500 Received: from localhost.localdomain (unknown [218.94.118.90]) by m97179.mail.qiye.163.com (Hmail) with ESMTPA id 69032E026F4; Wed, 27 Jan 2021 11:15:52 +0800 (CST) From: Dongsheng Yang To: colyli@suse.de, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, mchristi@redhat.com Cc: Dongsheng Yang Subject: [PATCH V3] bcache: dont reset bio opf in bch_data_insert_start Date: Wed, 27 Jan 2021 11:15:50 +0800 Message-Id: <20210127031550.3605-1-dongsheng.yang@easystack.cn> X-Mailer: git-send-email 2.25.1 Reply-To: 20210127031111.3493-1-dongsheng.yang@easystack.cn MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSUI3V1ktWUFJV1kPCR oVCBIfWUFZHhkaTR1ISk4eSE5KVkpNSkpMSkxITklMQ0pVGRETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hNSlVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Pio6Mxw6ED0xOggiMEoxE0sK PD0aCUpVSlVKTUpKTEpMSE5JQk5JVTMWGhIXVR8UFRwIEx4VHFUCGhUcOx4aCAIIDxoYEFUYFUVZ V1kSC1lBWUlKQ1VCT1VKSkNVQktZV1kIAVlBSE1NQzcG X-HM-Tid: 0a7741d71c7620bdkuqy69032e026f4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit ad0d9e76(bcache: use bio op accessors) makes the bi_opf modified by bio_set_op_attrs(). But there is a logical problem in this commit: trace_bcache_cache_insert(k); bch_keylist_push(&op->insert_keys); - n->bi_rw |= REQ_WRITE; + bio_set_op_attrs(n, REQ_OP_WRITE, 0); bch_submit_bbio(n, op->c, k, 0); } while (n != bio); The old code add REQ_WRITE into bio n and keep other flags; the new code set REQ_OP_WRITE to bi_opf, but reset all other flags. This problem is discoverd in our performance testing: (1) start a fio with 1M x 128depth for read in /dev/nvme0n1p1 (2) start a fio with 1M x 128depth for write in /dev/escache0 (cache device is /dev/nvme0n1p2) We found the BW of reading is 2000+M/s, but the BW of writing is 0-100M/s. After some debugging, we found the problem is io submit in writting is very slow. bch_data_insert_start() insert a bio to /dev/nvme0n1p1, but as cached_dev submit stack bio will be added into current->bio_list, and return.Then __submit_bio_noacct() will submit the new bio in bio_list into /dev/nvme0n1p1. This operation would be slow in blk_mq_submit_bio() -> rq_qos_throttle(q, bio); The rq_qos_throttle() will call wbt_should_throttle(), static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio) { switch (bio_op(bio)) { case REQ_OP_WRITE: /* * Don't throttle WRITE_ODIRECT */ if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) == (REQ_SYNC | REQ_IDLE)) return false; ... ... } As the bio_set_op_attrs() reset the (REQ_SYNC | REQ_IDLE), so this write bio will be considered as non-direct write. After this fix, bio to nvme will flaged as (REQ_SYNC | REQ_IDLE), then fio for writing will get about 1000M/s bandwidth. Fixes: ad0d9e76a412 ("bcache: use bio op accessors") CC: Mike Christie Signed-off-by: Dongsheng Yang --- V3-V2: remove an unused close-line in commit message. drivers/md/bcache/request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index c7cadaafa947..eb734f7ddaac 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -244,7 +244,7 @@ static void bch_data_insert_start(struct closure *cl) trace_bcache_cache_insert(k); bch_keylist_push(&op->insert_keys); - bio_set_op_attrs(n, REQ_OP_WRITE, 0); + n->bi_opf |= REQ_OP_WRITE; bch_submit_bbio(n, op->c, k, 0); } while (n != bio); -- 2.25.1