Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp524464img; Fri, 22 Mar 2019 03:11:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwr/dQrSus76n2UDWI5myrb3ty3QlqzvxzNik65F1cml7jloAwozrjMLDPutkOZkzsxcoYt X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr8694736plq.293.1553249460417; Fri, 22 Mar 2019 03:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553249460; cv=none; d=google.com; s=arc-20160816; b=p8VK9KanM4ys2Fa/GqD4Diivy/PLCNf4UM1REEPZdgEt1V+LqkVBo7DcVjwP3VqTz5 5/Re7lJVJv+/BS7i+f4HwNEYfy6bbQucyK802ffpjAQK224q/zLvKUfrv5LozQ1q0a0h wXydQ4ZL1Ih4+MLyCD/LilX6DRXE1Gx9JRbwRjy2K8pfTsl10jvBekw6V06TdjADPD/T yejzrGlpf8x3eMmFdF6paPPiJl0TQ4QsTanC1Hpm1x9Ks+7eEC+2i5Xog3FbqotWZ6LL XEHoV3TkHO8gEs80ZtOHHwkjXt1/57eTCj2R2g0oDr851KUfPopQN2voiNTYZU5b4Eqw xCEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=CESTLGwAfcQfHJ2H49WSr6BzPB3M2SoBVB9y8nCwm+Y=; b=n7sFc0XSXXPTSVJ4+7EG9EOYqFgOy2ckJ3JwsjVAtCX3P9xW7OTwaBkxZHJsKOEhp3 gHbyBgHfEzVSTktHQIHTYE6iBJlfgSRuZc3t1hlrzmRLBN0UVMt2uMuq0dOfluymkTBx hJlgI91wMKMdypsMgYN9FiLvfNmkP9UYE6M3E0J9eAwXvoOFoeTZpmoJ1c7rFyndqZY1 nkjZL03Xt1kpXRf33zoKakJ8JuU52HVpLKiqYe2cr0PAhRLN70S5hi/AcyxA0m+p3S+B 5mJ8BqCmUgiXFa8e8dz5nQXpLNp72N8OXZs2b8Krw+0Cnu5VpbfJtyrpYHF3sBn/qMr2 cnIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alibaba-inc.com header.s=default header.b=bpqjAucu; 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=fail (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i196si5178829pgd.113.2019.03.22.03.10.44; Fri, 22 Mar 2019 03:11:00 -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=@alibaba-inc.com header.s=default header.b=bpqjAucu; 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=fail (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbfCVKKJ (ORCPT + 99 others); Fri, 22 Mar 2019 06:10:09 -0400 Received: from out0-147.mail.aliyun.com ([140.205.0.147]:53569 "EHLO out0-147.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbfCVKKJ (ORCPT ); Fri, 22 Mar 2019 06:10:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1553249405; h=From:To:Subject:Date:Message-Id; bh=CESTLGwAfcQfHJ2H49WSr6BzPB3M2SoBVB9y8nCwm+Y=; b=bpqjAucuZ3VIB7kQvQ+pteYLMwbGi/hVZamdTdM/wxS5mMmIpJZLLF6M+KmWUCcr6q2/5NjPS4Aizc3eqq8CZ5mUia29xO8d+O0+ViLWmcmVoO9MB8uIHSdhdvwEH6wJX7O5hv1GLKWgJNAPVdWrfgarpLQOPB0tHfsUai2vAt8= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03299;MF=xuyun.xy@alibaba-inc.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---.EBGcyQx_1553249398; Received: from localhost(mailfrom:xuyun.xy@alibaba-inc.com fp:SMTPD_---.EBGcyQx_1553249398) by smtp.aliyun-inc.com(127.0.0.1); Fri, 22 Mar 2019 18:10:04 +0800 From: luferry To: Jens Axboe Cc: Ming Lei , Christoph Hellwig , xuyun , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] block/mq: blk map queues by core id Date: Fri, 22 Mar 2019 18:09:49 +0800 Message-Id: <20190322100949.5555-1-luferry@163.com> X-Mailer: git-send-email 2.14.1.40.g8e62ba1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org under virtual machine environment, cpu topology may differ from normal 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]; } } -- 2.14.1.40.g8e62ba1