From patchwork Fri Jul 20 01:25:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 10535849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EBE586054B for ; Fri, 20 Jul 2018 01:25:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC78B298FA for ; Fri, 20 Jul 2018 01:25:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFDD2298FD; Fri, 20 Jul 2018 01:25:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 201D5298FB for ; Fri, 20 Jul 2018 01:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728018AbeGTCLa (ORCPT ); Thu, 19 Jul 2018 22:11:30 -0400 Received: from mail-eopbgr50048.outbound.protection.outlook.com ([40.107.5.48]:43225 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730556AbeGTCL3 (ORCPT ); Thu, 19 Jul 2018 22:11:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KQDr3+6x7DyCmrNyKWXgXDuUPVmVO7aJiR/Urx39bJc=; b=XSjITY+5jsOhx8RkarpPo6FqprIebd5u4j6fs9o4PMJ+xSrPg8SfjywKqeSzwjNLh1SLUN7WXA+phvghbNM7w820KCCeqojWOHMuTwDIgqzWuUMs5eNmdAA/kJvBVDLJmBuA03y8ytR+8NqtSYEiiQTf+V5tdqOJDWL1Bp97kIk= Received: from HE1PR05CA0348.eurprd05.prod.outlook.com (2603:10a6:7:92::43) by DB4PR05MB0800.eurprd05.prod.outlook.com (2a01:111:e400:985c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.20; Fri, 20 Jul 2018 01:25:37 +0000 Received: from DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::209) by HE1PR05CA0348.outlook.office365.com (2603:10a6:7:92::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.973.16 via Frontend Transport; Fri, 20 Jul 2018 01:25:36 +0000 Authentication-Results: spf=pass (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=mellanox.com; Received-SPF: Pass (protection.outlook.com: domain of mellanox.com designates 193.47.165.134 as permitted sender) receiver=protection.outlook.com; client-ip=193.47.165.134; helo=mtlcas13.mtl.com; Received: from mtlcas13.mtl.com (193.47.165.134) by DB5EUR03FT015.mail.protection.outlook.com (10.152.20.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.952.17 via Frontend Transport; Fri, 20 Jul 2018 01:25:35 +0000 Received: from MTLCAS13.mtl.com (10.0.8.78) by mtlcas13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Fri, 20 Jul 2018 04:25:34 +0300 Received: from MTLCAS01.mtl.com (10.0.8.71) by MTLCAS13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.1178.4 via Frontend Transport; Fri, 20 Jul 2018 04:25:34 +0300 Received: from [172.16.0.76] (172.16.0.76) by MTLCAS01.mtl.com (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.3.301.0; Fri, 20 Jul 2018 04:25:32 +0300 Subject: Re: [PATCH mlx5-next] RDMA/mlx5: Don't use cached IRQ affinity mask To: Steve Wise , 'Sagi Grimberg' , 'Leon Romanovsky' CC: 'Doug Ledford' , 'Jason Gunthorpe' , 'RDMA mailing list' , "'Saeed Mahameed'" , 'linux-netdev' References: <20180716083012.15410-1-leon@kernel.org> <0cf29652-9034-6283-ef36-95de4588980f@grimberg.me> <20180716103046.GJ3152@mtr-leonro.mtl.com> <1cb63259-9fb6-59b0-3a34-0659973228ea@mellanox.com> <40d49fe1-c548-31ec-7daa-b19056215d69@mellanox.com> <243215dc-2b06-9c99-a0cb-8a45e0257077@opengridcomputing.com> <3f827784-3089-2375-9feb-b3c1701d7471@mellanox.com> <01cd01d41dce$992f4f30$cb8ded90$@opengridcomputing.com> <0834cae6-33d6-3526-7d85-f5cae18c5487@grimberg.me> <9a4d8d50-19b0-fcaa-d4a3-6cfa2318a973@mellanox.com> <02dc01d41ecd$9cc8a0b0$d659e210$@opengridcomputing.com> From: Max Gurtovoy Message-ID: Date: Fri, 20 Jul 2018 04:25:32 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: he X-Originating-IP: [172.16.0.76] X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:193.47.165.134; IPV:NLI; CTRY:IL; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(39860400002)(136003)(346002)(396003)(2980300002)(438002)(189003)(51234002)(199004)(568964002)(76176011)(81166006)(33964004)(3846002)(305945005)(478600001)(316002)(36756003)(58126008)(93886005)(5024004)(6116002)(2476003)(7736002)(31696002)(5000100001)(65826007)(86362001)(106002)(81156014)(8936002)(8676002)(356003)(37036004)(110136005)(54906003)(16576012)(5660300001)(4610100001)(486006)(6246003)(126002)(77096007)(106466001)(2906002)(476003)(26005)(11346002)(84326002)(2870700001)(4326008)(446003)(65956001)(561944003)(229853002)(64126003)(336012)(16526019)(2616005)(186003)(31686004)(65806001)(3940600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR05MB0800; H:mtlcas13.mtl.com; FPR:; SPF:Pass; LANG:en; PTR:mail13.mellanox.com; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DB5EUR03FT015; 1:gBnnaA2Qry/sstx2+J0ylOsS81sOmpmRXHd+1VIf2JDbjOR+oFHJiw0KJYMTHfMLEbMutlCWem8dmVj3CCNOFZotZkSdsPTUh3ZHkMklPNlCwired5k2lHCu2Ea5ZTUI X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6a5a4f39-691f-4b35-f099-08d5eddfb1f5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(49563074)(7193020); SRVR:DB4PR05MB0800; X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0800; 3:CHCfxsdLFes6ge/v+QUw05Nsn58S1bdEk+nFKTmxhpsrUCgN9QGRrsurx0PljxYpovd0P/c1UCafI05UpdMvsXYTMlglBR+1GiXLUxtWMkadlU6e1aWspfLDgIImtYZ4YEMjgi+uBzHEgNKJ4E5/+lI767mw30hy9rCO7NW8OgFWIpCN9OaLzMwWDx85xi7rvD8g9ya0TN1IlU76wXhupirBVmKIiuLSLh/1pfDPKkHZEv7Bd0tZ1/aIK3d4+jLTUaioFEKyZh53FvSc0woZc8yx3v1FFYxwJMqE9ZNSzdzYYz0EgJPj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fFBS4I+dmPoM2ijHHILyHuoBaGPYUZMTuuSzCFd/u962qJ80Lb2DY00tIUd+jcquCLnLUbudvlfiT9fgRk0xjghpCCy3WvU/bcECdLV9wCMNDWqWe4fGqIP1juO7LFYIr3eyuhMrwsnQgNX1n X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(21532816269658); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(102415395)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93004095)(3002001)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB4PR05MB0800; BCL:0; PCL:0; RULEID:; SRVR:DB4PR05MB0800; X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0800; 4:o0oKOXVcSE3dwAkIuJuugAPdjK4TAA3nFs+pKLidbMtwOymzYyzW0FeDojoJ/NnD/6ibBz/x6fsYumYwbqBD/uksgpnTgRel84AyFnUctZrS0VcNVp76GfEv7cCIksi+3Jx9ACQ8wPOz3lvwwXH8JZyrsz39C2mBwIZSojRD4m7nVOdaNxEuafft5UXVxqXDxaCdDWWq1pPmKJ9uYMdhi/+qU/6njHud+lwbb9yhCsTLFd0RFTf4p2gVAt+uBAXMDU5eAyyHtWSxwC4tPbtL5ohRpmYCENh506LB/c4WolQK3RYuQg1ES1UJgstM/5MC X-Forefront-PRVS: 073966E86B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB4PR05MB0800; 23:cvc4TIgppvK0RR9USH8mykB8p1JjzfjpWbya7uK3i?= =?us-ascii?Q?bFhXViIC/9IcLhDm9IMx2YVF6CIlphMJVeUcf97MkNoitJ9Ysn4ax0g5/+Ps?= =?us-ascii?Q?hFUIVB4JIuazH2/tvJ8yurtQvMW/kYQXhCP8c1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h57x/VSYUR6/WzcrLqNQfMsP8gUr7cieJ39OwW8UNpuJs2hFidbLo+iOUpYlNXzO6+ejWvGlpX6InClW41FZhfOqpO/zktKXENqkCmyGfubBbW4gSxVi4d8ZIAY6PTX5CILekQBUr7slclAaHPUfseJF0Nn/BjdPaO8vo8qo6txQ2r3HFMGoQxls3luFs2DunipPwNuBwQGJd4BhUPv9dQ9BDgk4RepSIXhjJnWpE9qxayHjL/b7I4jGSDOgXuYHx3Klh/1XgbZpmw7d5IRRW9CKQ450FiLS45VjqMWyWT4HqLy9rJTa4My0fLxF+ZbIwRyE97i9/UvcxgGwyF6k3eeA==; 5:uP8a7AUxEhePv96+gwV2XEWe3xTgnRoh1/H68UHUPJQjoK2FlUDXFkC1DL79Nhfi1NNX3beaePHRznmxsVUpQqtsG834QQ2SRGv0weXBr7u9xFMDhNsOPkeTay9Zm6SvNHe05Ex5hTaUqCKbvXb7xQFjFWeGuvJ75oDl3k/XFQU=; 24:CetXYackqtj1JgrZzZ1gYK2qBPM7fbCT6VEN4GPvx6uQ7Lt7UN8wGZSx8AKoutgTtJgveyF9oUOHsgbAzj+OxD5GGwC+E0yp+bVtiiNWHAA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0800; 7:WWwqwirq3oX78k1YPb5vsrlrD5MCw2UEIUxwCYee80O4GlSlQBNc+zvL5eByreki7nL5oh+Z+DVwlLu9bx2L6IBF8EQSNMmrxyTLcMqNPJcTgZj6+U1FUvI8dKghFdJ6dnPBZydIizljCby2BABedNiukZcE4xNqQ3Nf7YTuIK4v3kNVm7DsCCKVb3q3llwCBbB0ATXY+m8HiAGAeUkoF9Q5yVQnJudpecEHPnesVILM4l6IxXk5DMdUiQBwkJRZ X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2018 01:25:35.9624 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a5a4f39-691f-4b35-f099-08d5eddfb1f5 X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b; Ip=[193.47.165.134]; Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR05MB0800 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP >>> [ 2032.194376] nvme nvme0: failed to connect queue: 9 ret=-18 >> >> queue 9 is not mapped (overlap). >> please try the bellow: >> > > This seems to work.  Here are three mapping cases:  each vector on its > own cpu, each vector on 1 cpu within the local numa node, and each > vector having all cpus in its numa node.  The 2nd mapping looks kinda > funny, but I think it achieved what you wanted?  And all the cases > resulted in successful connections. > Thanks for testing this. I slightly improved the setting of the left CPUs and actually used Sagi's initial proposal. Sagi, please review the attached patch and let me know if I should add your signature on it. I'll run some perf test early next week on it (meanwhile I run login/logout with different num_queues successfully and irq settings). Steve, It will be great if you can apply the attached in your system and send your findings. Regards, Max, From 6f7b98f1c43252f459772390c178fc3ad043fc82 Mon Sep 17 00:00:00 2001 From: Max Gurtovoy Date: Thu, 19 Jul 2018 12:42:00 +0000 Subject: [PATCH 1/1] blk-mq: fix RDMA queue/cpu mappings assignments for mq In order to fulfil the block layer cpu <-> queue mapping, all the allocated queues and all the possible CPUs should be mapped. First, try to map the queues according to the affinity hint from the underlying RDMA device. Second, map all the unmapped queues in a naive way to unmapped CPU. In case we still have unmapped CPUs, use the default blk-mq mappings to map the rest. This way we guarantee that no matter what is the underlying affinity, all the possible CPUs and all the allocated block queues will be mapped. Signed-off-by: Max Gurtovoy Signed-off-by: Max Gurtovoy Signed-off-by: Israel Rukshin Signed-off-by: Sagi Grimberg Tested-by: Steve Wise --- block/blk-mq-cpumap.c | 41 ++++++++++++++++++++++++----------------- block/blk-mq-rdma.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- include/linux/blk-mq.h | 1 + 3 files changed, 67 insertions(+), 19 deletions(-) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 3eb169f..02b888f 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -30,29 +30,36 @@ static int get_first_sibling(unsigned int cpu) return cpu; } -int blk_mq_map_queues(struct blk_mq_tag_set *set) +void blk_mq_map_queue_to_cpu(struct blk_mq_tag_set *set, unsigned int cpu) { unsigned int *map = set->mq_map; unsigned int nr_queues = set->nr_hw_queues; - unsigned int cpu, first_sibling; + unsigned int first_sibling; - for_each_possible_cpu(cpu) { - /* - * First do sequential mapping between CPUs and queues. - * In case we still have CPUs to map, and we have some number of - * threads per cores then map sibling threads to the same queue for - * performace optimizations. - */ - if (cpu < nr_queues) { + /* + * First do sequential mapping between CPUs and queues. + * In case we still have CPUs to map, and we have some number of + * threads per cores then map sibling threads to the same queue for + * performace optimizations. + */ + if (cpu < nr_queues) { + map[cpu] = cpu_to_queue_index(nr_queues, cpu); + } else { + first_sibling = get_first_sibling(cpu); + if (first_sibling == cpu) map[cpu] = cpu_to_queue_index(nr_queues, cpu); - } else { - first_sibling = get_first_sibling(cpu); - if (first_sibling == cpu) - map[cpu] = cpu_to_queue_index(nr_queues, cpu); - else - map[cpu] = map[first_sibling]; - } + else + map[cpu] = map[first_sibling]; } +} +EXPORT_SYMBOL_GPL(blk_mq_map_queue_to_cpu); + +int blk_mq_map_queues(struct blk_mq_tag_set *set) +{ + unsigned int cpu; + + for_each_possible_cpu(cpu) + blk_mq_map_queue_to_cpu(set, cpu); return 0; } diff --git a/block/blk-mq-rdma.c b/block/blk-mq-rdma.c index 996167f..10e4f8a 100644 --- a/block/blk-mq-rdma.c +++ b/block/blk-mq-rdma.c @@ -34,14 +34,54 @@ int blk_mq_rdma_map_queues(struct blk_mq_tag_set *set, { const struct cpumask *mask; unsigned int queue, cpu; + bool mapped; + /* reset all CPUs mapping */ + for_each_possible_cpu(cpu) + set->mq_map[cpu] = UINT_MAX; + + /* Try to map the queues according to affinity */ for (queue = 0; queue < set->nr_hw_queues; queue++) { mask = ib_get_vector_affinity(dev, first_vec + queue); if (!mask) goto fallback; - for_each_cpu(cpu, mask) - set->mq_map[cpu] = queue; + for_each_cpu(cpu, mask) { + if (set->mq_map[cpu] == UINT_MAX) { + set->mq_map[cpu] = queue; + /* Initialy each queue mapped to 1 cpu */ + break; + } + } + } + + /* Map the unmapped queues in a naive way */ + for (queue = 0; queue < set->nr_hw_queues; queue++) { + mapped = false; + for_each_possible_cpu(cpu) { + if (set->mq_map[cpu] == queue) { + mapped = true; + break; + } + } + if (!mapped) { + for_each_possible_cpu(cpu) { + if (set->mq_map[cpu] == UINT_MAX) { + set->mq_map[cpu] = queue; + mapped = true; + break; + } + } + } + /* This case should never happen */ + if (WARN_ON_ONCE(!mapped)) + goto fallback; + } + + /* set all the rest of the CPUs */ + for_each_possible_cpu(cpu) { + if (set->mq_map[cpu] == UINT_MAX) + blk_mq_map_queue_to_cpu(set, cpu); } return 0; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index e3147eb..d6cd114 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -282,6 +282,7 @@ void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout); +void blk_mq_map_queue_to_cpu(struct blk_mq_tag_set *set, unsigned int cpu); int blk_mq_map_queues(struct blk_mq_tag_set *set); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);