Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp175348iof; Mon, 6 Jun 2022 00:39:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbbcgwyZ7Nrj+1P1dXRJ+aL5hK5UBk6ZDAjjBHOJpjZ2s0NtjZpRo0VD5o/2fcaM55quxa X-Received: by 2002:a17:90a:1c1:b0:1e0:788a:ba35 with SMTP id 1-20020a17090a01c100b001e0788aba35mr59637292pjd.13.1654501157938; Mon, 06 Jun 2022 00:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654501157; cv=none; d=google.com; s=arc-20160816; b=rCeGXHd3IEdJKxUoll3Yx5Wf3mY2vHf+z7YYdjUitxfhOqD7IUUVpd4QbX5T0FZN5k F1BGezrZYV15EunM1mJo7MXSVGFHHpUo8+jBuqS221Jm1ChEtC+PI6aWHMBVpMP4OG9D oyOtOeyo9zU+5AYWn3WqQFlgR7QSa+Npm5VyMNpM7tQrSDX2/z4VcjLdLtaRTbW0gOGj yllyXmrLrutgYJmqL5buO1ocPI7UMcTiUgcrnjMFE8KW7m1G7DTMb/KbBPNXV0JJNcNa sCchHP3sjFjl28WgNaiFK1CgjS87EqY1oVIX94peIzDLZekNscjfvnjx2Sexlk2rgk0u IYpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8/spSkG48ZCb5AaW/OX1PXeTSCTspY6xIl9KOwnlQEE=; b=d85hiIOLLgSre84nZWv5gRN3TpmHN/RL+QFmbZwqrz/WnHyd2wlHo31ZOJkmp6h4WA IKEgKNYTeuLvDofhJjT9sPFgWzpeeoHwMlRHkDfwAfLoimOWWKBpNe+++L4ckom+Es3g S4DQnx9jCr20bc7uZ/VwRlddJu091rwo5dbOXKBIQEbNpMFcSV4Q+yqvoGKfZDM8iN79 7i1ltXqSj6KN0My9bjtE6GtVn9D2ic489hH51nilBqOdeYwG39qByh/sYc/aaEEhkXdG f+I1RwcNgg1wmNHdhFM1P1TLE73CfyWoH+nUECIU1GXPxJWnOBBv7IKXIyfsaMoSNEYs QiGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="HKbJr/9P"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id gq13-20020a17090b104d00b001e095c5ec83si18086333pjb.165.2022.06.06.00.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 00:39:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="HKbJr/9P"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 044252A420; Mon, 6 Jun 2022 00:14:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbiFFHOT (ORCPT + 99 others); Mon, 6 Jun 2022 03:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230380AbiFFHON (ORCPT ); Mon, 6 Jun 2022 03:14:13 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CA823140; Mon, 6 Jun 2022 00:14:11 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1654499648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8/spSkG48ZCb5AaW/OX1PXeTSCTspY6xIl9KOwnlQEE=; b=HKbJr/9P6lZoMfgp514GsqB9AzkN6RClucSsvn4YoglgScPcGxpWvpyMvmnZCqA4ADFhB/ K2CRbBlNyR5YJRNBXTF5sv8/iMZmrG/81kqx7WSNXty4rzUc8+K3dnBta1sTlO6Tc4hm0x 92o2Oack6RKuc+sxHHAxujuivfg6408= From: Yajun Deng To: saeedm@nvidia.com, leon@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] net/mlx5: Add affinity for each irq Date: Mon, 6 Jun 2022 15:13:51 +0800 Message-Id: <20220606071351.3550997-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mlx5 would allocate no less than one irq for per cpu, we can bond each irq to a cpu to improve interrupt performance. Signed-off-by: Yajun Deng --- .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c index 662f1d55e30e..d13fc403fe78 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c @@ -624,11 +624,27 @@ int mlx5_irq_table_get_num_comp(struct mlx5_irq_table *table) return table->pf_pool->xa_num_irqs.max - table->pf_pool->xa_num_irqs.min; } +static void mlx5_calc_sets(struct irq_affinity *affd, unsigned int nvecs) +{ + int i; + + affd->nr_sets = (nvecs - 1) / num_possible_cpus() + 1; + + for (i = 0; i < affd->nr_sets; i++) { + affd->set_size[i] = min(nvecs, num_possible_cpus()); + nvecs -= num_possible_cpus(); + } +} + int mlx5_irq_table_create(struct mlx5_core_dev *dev) { int num_eqs = MLX5_CAP_GEN(dev, max_num_eqs) ? MLX5_CAP_GEN(dev, max_num_eqs) : 1 << MLX5_CAP_GEN(dev, log_max_eq); + struct irq_affinity affd = { + .pre_vectors = 0, + .calc_sets = mlx5_calc_sets, + }; int total_vec; int pf_vec; int err; @@ -644,7 +660,8 @@ int mlx5_irq_table_create(struct mlx5_core_dev *dev) total_vec += MLX5_IRQ_CTRL_SF_MAX + MLX5_COMP_EQS_PER_SF * mlx5_sf_max_functions(dev); - total_vec = pci_alloc_irq_vectors(dev->pdev, 1, total_vec, PCI_IRQ_MSIX); + total_vec = pci_alloc_irq_vectors_affinity(dev->pdev, 1, total_vec, + PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, &affd); if (total_vec < 0) return total_vec; pf_vec = min(pf_vec, total_vec); -- 2.25.1