Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp603319img; Fri, 22 Mar 2019 05:00:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwM0eFp4CuD1rA2iqu2rw1s26PqY+R+TTGus5E17o3yXTJmASOg/seBf2eLrc7B5N2bF8N2 X-Received: by 2002:a17:902:4681:: with SMTP id p1mr8870149pld.42.1553256031065; Fri, 22 Mar 2019 05:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256031; cv=none; d=google.com; s=arc-20160816; b=I7J9FnJcSiY2NknHJjA/YLQwSIE3fHtxjXslJXDjLgQI6ZZeO1p8bHYNFkVUVTcVWq PgWX99sByNHaHfK2lcoRGY5Sv59NjFOK3mm2tdKaDb/tRWNFcA2CpJGPsBySICuf1q0s T+ZLb69riJXCeEYRH1tAt+ZLdYNGzXP+pQAIdpJimIrevxsS/NW/rlrM2panm6GRZYse in1W5iFvdmT7zPMKOg5xaiU75Y/6+IOtBXkDGAsMe5nl3cZ57qaJO+Ws6AvbBdIUZ4zG /+gUj6ur3Qm9Fuwfb/r8tcEIp9inWOJxI+JdDVa94EhF2YU0E67CpULvzEILeZeXw53j BjCw== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=nBL4+RHOYzG4OWB9aNyOjbCEf0XNxXIGQYLtHZrRaEU=; b=iHkQEo2kZNMcEaVDALvf32c/iMVzp2vhluJdzSEA3mqeHv0/eFmVt+8JeGKNcHRY+m h2D+4RrLf3EQHaOb3gjrkQcb28BjyCc1wsiYF1TIQmDUP+G+wewlrnrvLV6UhayfXNiW ezjB7YE6xD+lWCrnmnytjxt+ZKpymqiPyXG1QMkkh/7AtBb1zkJ3XfF5Pk4SDL/GQcuu PcBOuIKm7qvTqq//9qRAHYj67oO0dLFJenhaLpMYOpg9ZROb618CrsVI2tG6Ngku0dy8 BBY2OSyRufp08bxBmZ18VWg6cCN1mxaP2GaihwuT+sHY0SG3HEx/LQCkrylh1oTjxZfO Ledg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=TwYPEBnF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f40si7304289plb.339.2019.03.22.05.00.15; Fri, 22 Mar 2019 05:00:31 -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=@oracle.com header.s=corp-2018-07-02 header.b=TwYPEBnF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387841AbfCVL6a (ORCPT + 99 others); Fri, 22 Mar 2019 07:58:30 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:33548 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387823AbfCVL61 (ORCPT ); Fri, 22 Mar 2019 07:58:27 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2MBnJno030483; Fri, 22 Mar 2019 11:58:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=nBL4+RHOYzG4OWB9aNyOjbCEf0XNxXIGQYLtHZrRaEU=; b=TwYPEBnFFZYF2kSvZvWHnl3P8vv6DFCp5rnrETRkyMomrVy8YjYXxDOfoi0NYYvx8bAd sxkBobpDVQ+hKhFqASDYEB8fBg9P062T6GdJSOItGFwn8PiUctH57cuJGRUcsUVQl3Tq EiJ0ahrcfBkNbOeedff8dixTdTOFtZhbDDPkoyUlPflCNu821G8ft2TE3rtvfxAvhuI6 pPRHzs+7B9kqkEqSSZGkQ8HW68flbXGEzPcF1HsDWXG4MZyvC5CsDVmatEnqyTWqs2rc CRthmYuz42d3uMr1lbn7vtYFOAL/Y5o0LZa3D5/zTROKp9fZgvFLp3jD4SrXzc3X+alZ TQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2r8pnf5tnf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 11:58:15 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2MBwEds030966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 11:58:14 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2MBwEtr022364; Fri, 22 Mar 2019 11:58:14 GMT Received: from [10.191.13.95] (/10.191.13.95) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Mar 2019 04:58:14 -0700 Subject: Re: [PATCH] block/mq: blk map queues by core id To: luferry References: <20190322100949.5555-1-luferry@163.com> Cc: Jens Axboe , Ming Lei , Christoph Hellwig , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org From: Dongli Zhang Message-ID: <9fa3eda2-536c-86a1-a7a3-c157fd0cdfdc@oracle.com> Date: Fri, 22 Mar 2019 19:58:08 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20190322100949.5555-1-luferry@163.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9202 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903220089 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/22/2019 06:09 PM, luferry wrote: > under virtual machine environment, cpu topology may differ from normal > physical server. Would mind share the name of virtual machine monitor, the command line if available, and which device to reproduce. For instance, I am not able to reproduce with qemu nvme or virtio-blk as I assume they use pci or virtio specific mapper to establish the mapping. E.g., with qemu and nvme: -smp 8,sockets=1,cores=4,threads=2 Indeed I use three queues instead of twp as one is reserved for admin. # ls /sys/block/nvme0n1/mq/* /sys/block/nvme0n1/mq/0: cpu0 cpu1 cpu2 cpu3 cpu_list nr_reserved_tags nr_tags /sys/block/nvme0n1/mq/1: cpu4 cpu5 cpu6 cpu7 cpu_list nr_reserved_tags nr_tags Thank you very much! Dongli Zhang > for example (machine with 4 cores, 2 threads per core): > > normal physical server: > core-id thread-0-id thread-1-id > 0 0 4 > 1 1 5 > 2 2 6 > 3 3 7 > > virtual machine: > core-id thread-0-id thread-1-id > 0 0 1 > 1 2 3 > 2 4 5 > 3 6 7 > > When attach disk with two queues, all the even numbered cpus will be > mapped to queue 0. Under virtual machine, all the cpus is followed by > its sibling cpu.Before this patch, all the odd numbered cpus will also > be mapped to queue 0, can cause serious imbalance.this will lead to > performance impact on system IO > > So suggest to allocate cpu map by core id, this can be more currency > > Signed-off-by: luferry > --- > block/blk-mq-cpumap.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c > index 03a534820271..4125e8e77679 100644 > --- a/block/blk-mq-cpumap.c > +++ b/block/blk-mq-cpumap.c > @@ -35,7 +35,7 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap) > { > unsigned int *map = qmap->mq_map; > unsigned int nr_queues = qmap->nr_queues; > - unsigned int cpu, first_sibling; > + unsigned int cpu, first_sibling, core = 0; > > for_each_possible_cpu(cpu) { > /* > @@ -48,9 +48,10 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap) > map[cpu] = cpu_to_queue_index(qmap, nr_queues, cpu); > } else { > first_sibling = get_first_sibling(cpu); > - if (first_sibling == cpu) > - map[cpu] = cpu_to_queue_index(qmap, nr_queues, cpu); > - else > + if (first_sibling == cpu) { > + map[cpu] = cpu_to_queue_index(qmap, nr_queues, core); > + core++; > + } else > map[cpu] = map[first_sibling]; > } > } >