Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp599927img; Fri, 22 Mar 2019 04:55:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrev51iWbnomY2JTmt3PsHjeoFFst/V/NgOWU+K6ZdxG/q4gIvH5SfET9tH7lqt7vxoyWi X-Received: by 2002:a63:fd10:: with SMTP id d16mr8418718pgh.306.1553255752918; Fri, 22 Mar 2019 04:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553255752; cv=none; d=google.com; s=arc-20160816; b=IFKImyR4gQnDSZik1mI+WY0LzyXdYm0+LzRDJ9GaQTslEFpn1t4nozsBw799sDYDgT L5LFz6b+gVETgbN+2IdxXTiqcNKrflmOVFqWyDL+Ag0UZjOWikELosR9alB1puygS2lg UPc67492WBE1uwAk/cSqWqZYm0fhigtP5HKV/lFL9ddsPyVE/Gk4vNqLW/y2li06PLB0 YSbZ8uWbify8u+Oleelvwj1og/KRrQqKkJEUSLBcUTVEvtPzOigVm/4bIJ+ddE9pbuty XvZwp+JjxfesBkdURKDGPKiDJKAHNwcSq5cQkgVKpdjtO8SSdpFC7qSIh2BfB1WnGAmT bKSg== 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=5kIC1lIBPr6kULrAGUH8q+RWbSEpFtG1sSRhYzaZhYs=; b=bfmXt22nplQZQeNbdBvj/YJIdNfFTmuSjJmZTpdX0RSKrwQzKU37wTq/2JtIfi7I8N VCL2b7SXJivNkWlDx99Ui38lHaC5uoUJwizKfNlSQVENer0tJtu77EIuIRvdCEOkX0bG PDmsj7J3STNEV58jtIlqMEAtiXVrC3Q7DCP3zQd/naMpqCWHoYaJNT9zB4FvdLRRBH2A n/1kQ6pqMJScaMLasSH3OluRz2fbZV/tHKeTtWLVzRYfQbC5tJbkezTIru6almD1msRe hFlQKsbBorXswSjsinkYRMxbmLeaITx3CrLbVdWc7b8CQeOs4qyZykypHxz4157Vbzoq WiXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=dJ4w6UQI; 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 r4si6570921plo.416.2019.03.22.04.55.34; Fri, 22 Mar 2019 04:55:52 -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=dJ4w6UQI; 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 S1733045AbfCVLx0 (ORCPT + 99 others); Fri, 22 Mar 2019 07:53:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58370 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732685AbfCVLxZ (ORCPT ); Fri, 22 Mar 2019 07:53:25 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2MBmqed000797; Fri, 22 Mar 2019 11:53:12 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=5kIC1lIBPr6kULrAGUH8q+RWbSEpFtG1sSRhYzaZhYs=; b=dJ4w6UQIrnRYAYrcR76eJ0QEemtElXs93Djzx1N0YDxwLPmLqWrC7GXH2FL4Pg51rXco 0RCZ9tloVNZHSuA8XHkSdyNGenwbLAgZb5FiRiLtaC6sfzGzsiT4evYz5/xQ3gCG74wn X1ghOhPTa6Oy1ydm8C/+7lRAVFpPQRVcqtClI15yAZjMxpciaIzkyDNi+Aa2oDApjOiO moD2qNK9BcIrwCwttPbuw2jk3bNZl37EL33XyMg08l1Z+Uc0CU0uyRsmBxwxXc9u3vfv 6MTdlS/5lEB6pgZLyN2RyCEyJcyLsHK+DDMccbkSvqZr591f4iH6gbJiVRiA9cEoYXfY 0w== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2r8ssrwf66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 11:53:12 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2MBr64q002866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 11:53:07 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2MBr6qY017040; Fri, 22 Mar 2019 11:53:06 GMT Received: from [192.168.2.8] (/106.39.150.192) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Mar 2019 04:53:06 -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: <6d6ca45d-fa9e-6a1c-e6e6-b07ba195a8f2@oracle.com> Date: Fri, 22 Mar 2019 19:53:01 +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=utf-8 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=1011 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 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 > physical server. > 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]; > } > } >