Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2209968pxb; Fri, 8 Oct 2021 03:16:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwUE1NgTIZ0vnoO/RNV7jvsALevdtgvczOaGF/LQYzfpaS4E76havdtlRCyOM092CxncAL X-Received: by 2002:a17:906:2c53:: with SMTP id f19mr3327930ejh.326.1633688214323; Fri, 08 Oct 2021 03:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633688214; cv=none; d=google.com; s=arc-20160816; b=VahvE/oudhorPD9i9SIRPihkrDaP41dXiO+rc0dTeGSFtkh7m4tOeTfF4cXT5p89Gr BpgmeX3ngK09uYDHVz+CVk4d3zvlZprwQ5BioY5FeYNDITPrxxoH19v7xx5La68FfBzZ dyiMcG0H1vPlXvmwvNkgvSoiD8l6i8Ud4pFOVI+H6d1Ffayx0+ySZFWEDDq05Zjkubos n1uMW7WZt9zBtX7pXXXkhTEbIv3ayPsVnUKP0WBWy2yjubefDj+Ha0xE+oP30SdaS+qm m2ycmge00R5292peSfICZfxX3qDeChVfHuWONDw5iODBcJe9r3WnKDbCDFjUsUtpdFma 7YWw== 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=N8UkLvkBp2BUtF69QZIYhsW7OuuacSIZp8eiNBlJGR8=; b=Nh6SPQw7aY4Q2LHiSxcEqBedVF8L7jU21iPHDqQcPas4BTJ+5y5YumICdtBIeKcbfL 3ae8WFOodCJ4Eqr1ZByuUEhDdsPaMiAOIEgiLf0eR0Hi/r5r/yhn0DPbjcJC9aZ6+qvo LEPN03Isme/+4JckcndKserQ67YVJLSKupBzRo1XmsA0kTqtmEM03rQmNCy9k3FMsBOD 8ll/Y0q+UpSRbFsQeeRTQOBa5F1qT/d56V9KqD3XdYEVda6QT1QWZOLPiDZiaQ8rtnQt K5ZYEx6cSa7Quuveb/Hp3GSazVULhm5cJcvXtFgotyuJB0dCiVb0+maRbw+uuOti8LsT 2R4g== 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=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hz2si3695205ejc.296.2021.10.08.03.16.28; Fri, 08 Oct 2021 03:16:54 -0700 (PDT) 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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239228AbhJHKRD (ORCPT + 99 others); Fri, 8 Oct 2021 06:17:03 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3945 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbhJHKRC (ORCPT ); Fri, 8 Oct 2021 06:17:02 -0400 Received: from fraeml735-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HQkW92w2xz67yBh; Fri, 8 Oct 2021 18:11:49 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml735-chm.china.huawei.com (10.206.15.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Fri, 8 Oct 2021 12:15:05 +0200 Received: from [10.47.80.141] (10.47.80.141) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Fri, 8 Oct 2021 11:15:04 +0100 Subject: Re: [PATCH v5 00/14] blk-mq: Reduce static requests memory footprint for shared sbitmap To: Kashyap Desai , Jens Axboe CC: , , , , References: <1633429419-228500-1-git-send-email-john.garry@huawei.com> <81d9e019-b730-221e-a8c0-f72a8422a2ec@huawei.com> From: John Garry Message-ID: <8867352d-2107-1f8a-0f1c-ef73450bf256@huawei.com> Date: Fri, 8 Oct 2021 11:17:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.80.141] X-ClientProxiedBy: lhreml744-chm.china.huawei.com (10.201.108.194) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/10/2021 21:31, Kashyap Desai wrote: > Perf top data indicates lock contention in "blk_mq_find_and_get_req" call. > > 1.31% 1.31% kworker/57:1H-k [kernel.vmlinux] > native_queued_spin_lock_slowpath > ret_from_fork > kthread > worker_thread > process_one_work > blk_mq_timeout_work > blk_mq_queue_tag_busy_iter > bt_iter > blk_mq_find_and_get_req > _raw_spin_lock_irqsave > native_queued_spin_lock_slowpath > > > Kernel v5.14 Data - > > %Node1 : 8.4 us, 31.2 sy, 0.0 ni, 43.7 id, 0.0 wa, 0.0 hi, 16.8 si, 0.0 > st > 4.46% [kernel] [k] complete_cmd_fusion > 3.69% [kernel] [k] megasas_build_and_issue_cmd_fusion > 2.97% [kernel] [k] blk_mq_find_and_get_req > 2.81% [kernel] [k] megasas_build_ldio_fusion > 2.62% [kernel] [k] syscall_return_via_sysret > 2.17% [kernel] [k] __entry_text_start > 2.01% [kernel] [k] io_submit_one > 1.87% [kernel] [k] scsi_queue_rq > 1.77% [kernel] [k] native_queued_spin_lock_slowpath > 1.76% [kernel] [k] scsi_complete > 1.66% [kernel] [k] llist_reverse_order > 1.63% [kernel] [k] _raw_spin_lock_irqsave > 1.61% [kernel] [k] llist_add_batch > 1.39% [kernel] [k] aio_complete_rw > 1.37% [kernel] [k] read_tsc > 1.07% [kernel] [k] blk_complete_reqs > 1.07% [kernel] [k] native_irq_return_iret > 1.04% [kernel] [k] __x86_indirect_thunk_rax > 1.03% fio [.] __fio_gettime > 1.00% [kernel] [k] flush_smp_call_function_queue > > > Test #2: Three VDs (each VD consist of 8 SAS SSDs). > (numactl -N 1 fio > 3vd.fio --rw=randread --bs=4k --iodepth=32 --numjobs=8 > --ioscheduler=none/mq-deadline) > > There is a performance regression but it is not due to this patch set. > Kernel v5.11 gives 2.1M IOPs on mq-deadline but 5.15 (without this patchset) > gives 1.8M IOPs. > In this test I did not noticed CPU issue as mentioned in Test-1. > > In general, I noticed host_busy is incorrect once I apply this patchset. It > should not be more than can_queue, but sysfs host_busy value is very high > when IOs are running. This issue is only after applying this patchset. > > Is this patch set only change the behavior of enabled > driver ? Will there be any impact on mpi3mr driver ? I can test that as > well. I can see where the high value of host_busy is coming from in this series - we incorrectly re-iter the tags by #hw queues times in blk_mq_tagset_busy_iter() - d'oh. Please try the below patch. I have looked at other places where we may have similar problems in looping the hw queue count for tagset->tags[], and they look ok. But I will double-check. I think that blk_mq_queue_tag_busy_iter() should be fine - Ming? --->8---- From e6ecaa6d624ebb903fa773ca2a2035300b4c55c5 Mon Sep 17 00:00:00 2001 From: John Garry Date: Fri, 8 Oct 2021 10:55:11 +0100 Subject: [PATCH] blk-mq: Fix blk_mq_tagset_busy_iter() for shared tags Since it is now possible for a tagset to share a single set of tags, the iter function should not re-iter the tags for the count of hw queues in that case. Rather it should just iter once. Signed-off-by: John Garry diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 72a2724a4eee..ef888aab81b3 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -378,9 +378,15 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn, void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, busy_tag_iter_fn *fn, void *priv) { + int nr_hw_queues; int i; - for (i = 0; i < tagset->nr_hw_queues; i++) { + if (blk_mq_is_shared_tags(tagset->flags)) + nr_hw_queues = 1; + else + nr_hw_queues = tagset->nr_hw_queues; + + for (i = 0; i < nr_hw_queues; i++) { if (tagset->tags && tagset->tags[i]) __blk_mq_all_tag_iter(tagset->tags[i], fn, priv, BT_TAG_ITER_STARTED); ----8<---- Thanks, john