From patchwork Thu Oct 25 21:16:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10656617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1D3914BB for ; Thu, 25 Oct 2018 21:16:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E62E82C463 for ; Thu, 25 Oct 2018 21:16:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1C6E2C64C; Thu, 25 Oct 2018 21:16:51 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 70DAE2C463 for ; Thu, 25 Oct 2018 21:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726149AbeJZFvJ (ORCPT ); Fri, 26 Oct 2018 01:51:09 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:40221 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbeJZFvJ (ORCPT ); Fri, 26 Oct 2018 01:51:09 -0400 Received: by mail-io1-f65.google.com with SMTP id a23-v6so6415144iod.7 for ; Thu, 25 Oct 2018 14:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9LrmkFD+aQRBlC5/q6dcnEeOWB1KK8o1CyOk8gYLMr4=; b=beIx9rWo/P0GtMI4nVlV7zUq1/Z02WJWbnX1AyigJ6+3NODSjAvHqTxwgLVb+rQlxg GpTJgpigZBq6n1NJr03QlOPOU/b2pUIu61S5rJx07PcXfsNoS5bjhzyXj7RcHd5ENBFn nXND9Z3oE4z1xoN5uk0lFfvzC89Qnti4d58iEq0FbsfT4rU1FQVMDOVT+PpYimGozzep 6Ivd53hrpyP0NLTswsQa9pCX74ncD5/7Dzu7kvoqEBfezqJRVVDme3B+DXIgdvFO7O9m LzpPC60QU1KufNKfmBXg3QowVo6N8f3o5L7bs7qxCVjNe7E8R87bpWM1lZjBPd81Yz2c dIFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9LrmkFD+aQRBlC5/q6dcnEeOWB1KK8o1CyOk8gYLMr4=; b=F7OzJCTvH+w+qpSmxj1Je+FvCoOXVTHjtS3FSNo242V4pBFvYkZm1voqx+pnSLVJOt KEl+IQKY7EJwk3PvTa5MfBOvMj7n4ledop6X+K0TMIFXKWnDagbyX3H/i7kdTsZ0Asg7 d92J5/d5xW/aQJhIO9kx2WqlTWb/2LAn8EgPS+vkzC2HZhXO2IWcmkyTPWb3+SNCi86D hxQiyA+i8H/VC+AUN6OIgKBRnxeCiUGeRdL2xdL2WH+OZKXwy52vpWMSzaKPiiqdkVbU DuPCuPH5Et8CnvkeZZHaxRj7m2cuNiBuva8Ikyui0tpawmgiiLu88T7Szv/ddQ2QHovy TAJQ== X-Gm-Message-State: AGRZ1gL8txTLqVPAi5H8VActCZaNl4Wvn/n0Rm4m+jeyqJbVYEDn7oAn QkZS7ARNp5DFxU5t8hSDCepNrv8TjkAEAA== X-Google-Smtp-Source: AJdET5fGMahKTlB7Hei8bxkje1fOErKDW1WCJuE2bfz89C6q3kqCjBfBaPgjwJRJvUFaxPN/58pAcA== X-Received: by 2002:a6b:710b:: with SMTP id q11-v6mr510345iog.138.1540502209126; Thu, 25 Oct 2018 14:16:49 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id l23-v6sm2831890ioj.40.2018.10.25.14.16.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 14:16:47 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Jens Axboe Subject: [PATCH 10/14] blk-mq: initial support for multiple queue maps Date: Thu, 25 Oct 2018 15:16:22 -0600 Message-Id: <20181025211626.12692-11-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025211626.12692-1-axboe@kernel.dk> References: <20181025211626.12692-1-axboe@kernel.dk> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a queue offset to the tag map. This enables users to map iteratively, for each queue map type they support. Bump maximum number of supported maps to 2, we're now fully able to support more than 1 map. Signed-off-by: Jens Axboe Reviewed-by: Hannes Reinecke --- block/blk-mq-cpumap.c | 9 +++++---- block/blk-mq-pci.c | 2 +- block/blk-mq-virtio.c | 2 +- include/linux/blk-mq.h | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 6e6686c55984..03a534820271 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -14,9 +14,10 @@ #include "blk.h" #include "blk-mq.h" -static int cpu_to_queue_index(unsigned int nr_queues, const int cpu) +static int cpu_to_queue_index(struct blk_mq_queue_map *qmap, + unsigned int nr_queues, const int cpu) { - return cpu % nr_queues; + return qmap->queue_offset + (cpu % nr_queues); } static int get_first_sibling(unsigned int cpu) @@ -44,11 +45,11 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap) * performace optimizations. */ if (cpu < nr_queues) { - map[cpu] = cpu_to_queue_index(nr_queues, cpu); + 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(nr_queues, cpu); + map[cpu] = cpu_to_queue_index(qmap, nr_queues, cpu); else map[cpu] = map[first_sibling]; } diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index 40333d60a850..1dce18553984 100644 --- a/block/blk-mq-pci.c +++ b/block/blk-mq-pci.c @@ -43,7 +43,7 @@ int blk_mq_pci_map_queues(struct blk_mq_queue_map *qmap, struct pci_dev *pdev, goto fallback; for_each_cpu(cpu, mask) - qmap->mq_map[cpu] = queue; + qmap->mq_map[cpu] = qmap->queue_offset + queue; } return 0; diff --git a/block/blk-mq-virtio.c b/block/blk-mq-virtio.c index 661fbfef480f..370827163835 100644 --- a/block/blk-mq-virtio.c +++ b/block/blk-mq-virtio.c @@ -44,7 +44,7 @@ int blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap, goto fallback; for_each_cpu(cpu, mask) - qmap->mq_map[cpu] = queue; + qmap->mq_map[cpu] = qmap->queue_offset + queue; } return 0; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 7e792ffb09bb..250b9ed86cd4 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -78,10 +78,11 @@ struct blk_mq_hw_ctx { struct blk_mq_queue_map { unsigned int *mq_map; unsigned int nr_queues; + unsigned int queue_offset; }; enum { - HCTX_MAX_TYPES = 1, + HCTX_MAX_TYPES = 2, }; struct blk_mq_tag_set {