Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp508647pxb; Wed, 27 Jan 2021 13:22:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4A5ZdmKT5w8u4azDnqzRrmWUgeFuBLOQRO/JvkweXhhrPGh/BnCokgFZ7h2hjyojMd0XP X-Received: by 2002:a17:907:20d5:: with SMTP id qq21mr8378741ejb.340.1611782529772; Wed, 27 Jan 2021 13:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611782529; cv=none; d=google.com; s=arc-20160816; b=OwZYDBOAqrGWwDf7PvdRyxCAz3aX34kbrPN6JY6L9v26njImGXMJycWVg/q+14rN+q kVTORFIRjOYE0bPyYPdv13WjiRTgIdqGadFtP9FxK8yP8wsR1e/Pv5nyjUB4JrXYwVv8 RNBjoAJp5a01/5Da3Qf6KWnugfVRLwaS8GgrxNvnD/6ZrpeQ8126HkikW1tUjS1MZ36S zWN6+vH7f9Uz/z4xe3L+fatkaSBfNifJktZNOwP5++cz+r5sDaDUo/vDOQbsSt2p2ok2 KcySWaAWebLKg9DOppFad8yzUKGycblBez7SozJ/7K3pXuwIEfT4AJkNVTgtxt2H8xIL HXLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=hjgiiKOhJziWBNh3d8LL/6onLTcBNILiV/+cJyouRR0=; b=JQUgf+J/9HNI0tbfBSGuAkjwkOzrD/eJXue0jydj4eYV/dLe4IzR4WSMACCg3Jo5X4 +fChPLyLJY3hVFxhbmgL34RzqS7ASzhYwz527LJeT5rgO4fGEvqafcUypvLGYF9keJgu rWgwAeqV7liGhJJ7gHOXbNcdP/Y1WCc5foQBh66lTwjjQAWtEAfYakhstuvhVBQLceI6 /iIAMQ6YN8KzGPf86V1YTOLBb8679GF7ROZPeDK33hxAGhfWipOX42BZjdDb510mg/gY sL7ZExW9n6k0gv00bg9lqKzc/mxmxQ0EWC8Oz6IP7kWZjqW+A1gZi1MEQfTR1JCTxpxg kdIA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg13si1532064ejc.669.2021.01.27.13.21.44; Wed, 27 Jan 2021 13:22:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235030AbhA0GDh (ORCPT + 99 others); Wed, 27 Jan 2021 01:03:37 -0500 Received: from mx2.suse.de ([195.135.220.15]:43904 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237332AbhA0Dvq (ORCPT ); Tue, 26 Jan 2021 22:51:46 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E9AECAB92; Wed, 27 Jan 2021 03:51:00 +0000 (UTC) Subject: Re: [PATCH V3] bcache: dont reset bio opf in bch_data_insert_start To: 20210127031111.3493-1-dongsheng.yang@easystack.cn Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, mchristi@redhat.com References: <20210127031550.3605-1-dongsheng.yang@easystack.cn> From: Coly Li Message-ID: Date: Wed, 27 Jan 2021 11:50:58 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210127031550.3605-1-dongsheng.yang@easystack.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/27/21 11:15 AM, Dongsheng Yang wrote: > 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 The V3 patch is added to my for-next queue. Thanks for the fix up. Coly Li > --- > 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); > >