From patchwork Sun Dec 17 21:32:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13496008 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1683D48CE6; Sun, 17 Dec 2023 21:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a/agvUpw" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-5e4e05eedf6so8023907b3.1; Sun, 17 Dec 2023 13:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702848739; x=1703453539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=auyx6SZcEGnvEGrHnzOQrDxyNrYMhwUgQ6pbJgj8x3Y=; b=a/agvUpwupImSz1M5QAWqzrFv1ZTUftRc+9WNFLUrhy6mryAwumxQVEiuXztE3evU+ GeHlA902uOvQMMJMo2bT/blEYxBtQ52oGbgPY3bTWAcYRllAxsEX8D7rb+wKkZoX5gTn 7MGkT3Bk7Q8wuslIELajtArk8L02knN65zr9jGN8RodwffqK9TPwSB9z5sOx4+00B5u2 vWwO9ZNXRYX59yoXvvogwFbkbowqu4W7G/Zij+4ATUqfMRgADgVePop0jerdOmgAqBFF bWOnq3ZbYh+wnUjcG7654GX5HCxW9oNkJqiXygT/1v57tUN7lYX5L0ZnKiJXS2DpPIHK LRvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702848739; x=1703453539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=auyx6SZcEGnvEGrHnzOQrDxyNrYMhwUgQ6pbJgj8x3Y=; b=i6IubGn2kfDRIeW5hK6f50qKCyG3Wm/DqItUk3cyDotZQYoOllAUGPPC9lxYr8+rhD VSv3BCoVhWm5Zf0aJt+/JgyDudMByNb9Ki6tL/oKwVzvcPpseEXcVVrNO/vRIG/mW7+g 4NU9n3GS37kwwQ/UCivD8HE8d2miyKGXD69y5WVpVz+rrM/c1FGeSSlEWrzz7F0DveuK CoaxZaZ0Vrl9S8p+WXe3iRB4xztW+qb+HpBepmiXiVWqa1KXVh8Cas+9coXfdBlt9SGz /W4WBtiFQep8IVJisME6ObF0UjJIvWG5+jj/cB32Ot589/HyYuPW3OBGFm1gleYl8x6a s+AA== X-Gm-Message-State: AOJu0Ywu9HL1j59OW9gzVBxt7N5cliHF1ax8IsMGUgz0fVZ3/DRI6gyq nKOBakDCZqzO2hShkIRzAZU= X-Google-Smtp-Source: AGHT+IHrVJh65QscY3p0Jy/D0oultjqQoAlOiktIjt87rcL3Qvqjz6HxK+awwKKSPzoRtatI2hoa3w== X-Received: by 2002:a81:5f08:0:b0:5e2:6d88:5b41 with SMTP id t8-20020a815f08000000b005e26d885b41mr4928049ywb.16.1702848738771; Sun, 17 Dec 2023 13:32:18 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:9c41:1dd2:7d5d:e008]) by smtp.gmail.com with ESMTPSA id p5-20020a0dff05000000b005d38b70b3easm8337664ywf.19.2023.12.17.13.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 13:32:17 -0800 (PST) From: Yury Norov To: Souradeep Chakrabarti , kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, longli@microsoft.com, yury.norov@gmail.com, leon@kernel.org, cai.huoqing@linux.dev, ssengar@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: schakrabarti@microsoft.com, paulros@microsoft.com Subject: [PATCH 1/3] cpumask: add cpumask_weight_andnot() Date: Sun, 17 Dec 2023 13:32:12 -0800 Message-Id: <20231217213214.1905481-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231217213214.1905481-1-yury.norov@gmail.com> References: <20231217213214.1905481-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similarly to cpumask_weight_and(), cpumask_weight_andnot() is a handy helper that may help to avoid creating an intermediate mask just to calculate number of bits that set in a 1st given mask, and clear in 2nd one. Signed-off-by: Yury Norov Reviewed-by: Jacob Keller --- include/linux/bitmap.h | 12 ++++++++++++ include/linux/cpumask.h | 13 +++++++++++++ lib/bitmap.c | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 99451431e4d6..5814e9ee40ba 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -54,6 +54,7 @@ struct device; * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_weight(src, nbits) Hamming Weight: number set bits * bitmap_weight_and(src1, src2, nbits) Hamming Weight of and'ed bitmap + * bitmap_weight_andnot(src1, src2, nbits) Hamming Weight of andnot'ed bitmap * bitmap_set(dst, pos, nbits) Set specified bit area * bitmap_clear(dst, pos, nbits) Clear specified bit area * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area @@ -169,6 +170,8 @@ bool __bitmap_subset(const unsigned long *bitmap1, unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); unsigned int __bitmap_weight_and(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int nbits); +unsigned int __bitmap_weight_andnot(const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int nbits); void __bitmap_set(unsigned long *map, unsigned int start, int len); void __bitmap_clear(unsigned long *map, unsigned int start, int len); @@ -425,6 +428,15 @@ unsigned long bitmap_weight_and(const unsigned long *src1, return __bitmap_weight_and(src1, src2, nbits); } +static __always_inline +unsigned long bitmap_weight_andnot(const unsigned long *src1, + const unsigned long *src2, unsigned int nbits) +{ + if (small_const_nbits(nbits)) + return hweight_long(*src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits)); + return __bitmap_weight_andnot(src1, src2, nbits); +} + static __always_inline void bitmap_set(unsigned long *map, unsigned int start, unsigned int nbits) { diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index cfb545841a2c..228c23eb36d2 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -719,6 +719,19 @@ static inline unsigned int cpumask_weight_and(const struct cpumask *srcp1, return bitmap_weight_and(cpumask_bits(srcp1), cpumask_bits(srcp2), small_cpumask_bits); } +/** + * cpumask_weight_andnot - Count of bits in (*srcp1 & ~*srcp2) + * @srcp1: the cpumask to count bits (< nr_cpu_ids) in. + * @srcp2: the cpumask to count bits (< nr_cpu_ids) in. + * + * Return: count of bits set in both *srcp1 and *srcp2 + */ +static inline unsigned int cpumask_weight_andnot(const struct cpumask *srcp1, + const struct cpumask *srcp2) +{ + return bitmap_weight_andnot(cpumask_bits(srcp1), cpumask_bits(srcp2), small_cpumask_bits); +} + /** * cpumask_shift_right - *dstp = *srcp >> n * @dstp: the cpumask result diff --git a/lib/bitmap.c b/lib/bitmap.c index 09522af227f1..b97692854966 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -348,6 +348,13 @@ unsigned int __bitmap_weight_and(const unsigned long *bitmap1, } EXPORT_SYMBOL(__bitmap_weight_and); +unsigned int __bitmap_weight_andnot(const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int bits) +{ + return BITMAP_WEIGHT(bitmap1[idx] & ~bitmap2[idx], bits); +} +EXPORT_SYMBOL(__bitmap_weight_andnot); + void __bitmap_set(unsigned long *map, unsigned int start, int len) { unsigned long *p = map + BIT_WORD(start); From patchwork Sun Dec 17 21:32:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13496009 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A532495FE; Sun, 17 Dec 2023 21:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IgIDyJup" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-4274fd310c2so15778991cf.3; Sun, 17 Dec 2023 13:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702848740; x=1703453540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wpzqsz/EY8Rq2EqPBcLuvwzIwmdW6wTukR95VYfZ1CM=; b=IgIDyJupFClZoNgCuvM1/sUlMo6Cw+hjm7qrbaiZkto2eW3R6F+RUzay1Ql7ldABYp ExVMfZSPIk49fOFoi6NceX2hxbioqcq0bMmo2RpsouhEgTxYdXElaGFlDZoVj5rOq13d Qbgp2zP0wqQWGAXXJCeF8rb9+rrA4Jyua4DgVNRHtpQh5TsJRTOdFLi1VRnyjq5J5rOk QFR1vmvNBGwRHeYSJ8M8WhLOgxehJlBYo1B8XjkKthPDhwPgUd04+ECtff5QU6LTb9YB wZA0JSX/hbWw+Ova5chG1Ln3lVWg+dYihPQb5K5UDWLhRxQJ7STEHAhN2Mr1sh730cjj cQgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702848740; x=1703453540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wpzqsz/EY8Rq2EqPBcLuvwzIwmdW6wTukR95VYfZ1CM=; b=B5+itcPcoYxZqTuxOg5NJtxqMJLNzeG5WynDO6OnZljgwVmp+xc88N+TcejCOU4Zkr FT4vEY7TH2aawsEaAOKZh+0AdtfSj8z4i1FqdWC+fTeNvA0aJ+vjwSM32EI4AEX+Bnhv nDpoZpswlVXzO+QPwi9Apnct+4v5oe55qZIjk8Vfm1yYdX72bMdka7CyWpGUYEWMBD8p uGhYVwxzEe+VTkP7op4ipsdZjGkMhJC3EU1TgFVxK0GY9ElrHBjxX1+7aU4ofDhTbOQ5 Hr71gDm4f1VkO2Z/NBAyc81wWxbGrg3h/nLbqZ1XqdgRNj/J1C955VIMPva+f0Dejvh3 DcQA== X-Gm-Message-State: AOJu0YzqvHoDDsekiC7qm5QzmwyuR2gnZFvt1pKs2nwKz0edjHY+s/pn Sx2AXSJLqvQQkN3Y6twVAf8= X-Google-Smtp-Source: AGHT+IEZVQkdZq/1iUqyA9DBOS4LYVte6GxBq8TXOHZIg5QPSd3+cDqAgWalYEOrgwQSUGHOemvrcw== X-Received: by 2002:a05:620a:2456:b0:77f:2496:4988 with SMTP id h22-20020a05620a245600b0077f24964988mr20524359qkn.14.1702848740308; Sun, 17 Dec 2023 13:32:20 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:9c41:1dd2:7d5d:e008]) by smtp.gmail.com with ESMTPSA id p191-20020a0de6c8000000b005e3cbaa5ac3sm1564107ywe.105.2023.12.17.13.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 13:32:19 -0800 (PST) From: Yury Norov To: Souradeep Chakrabarti , kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, longli@microsoft.com, yury.norov@gmail.com, leon@kernel.org, cai.huoqing@linux.dev, ssengar@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: schakrabarti@microsoft.com, paulros@microsoft.com Subject: [PATCH 2/3] cpumask: define cleanup function for cpumasks Date: Sun, 17 Dec 2023 13:32:13 -0800 Message-Id: <20231217213214.1905481-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231217213214.1905481-1-yury.norov@gmail.com> References: <20231217213214.1905481-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now we can simplify code that allocates cpumasks for local needs. Signed-off-by: Yury Norov --- include/linux/cpumask.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 228c23eb36d2..1c29947db848 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -7,6 +7,7 @@ * set of CPUs in a system, one bit position per CPU number. In general, * only nr_cpu_ids (<= NR_CPUS) bits are valid. */ +#include #include #include #include @@ -990,6 +991,8 @@ static inline bool cpumask_available(cpumask_var_t mask) } #endif /* CONFIG_CPUMASK_OFFSTACK */ +DEFINE_FREE(free_cpumask_var, struct cpumask *, if (_T) free_cpumask_var(_T)); + /* It's common to want to use cpu_all_mask in struct member initializers, * so it has to refer to an address rather than a pointer. */ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); From patchwork Sun Dec 17 21:32:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13496010 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2E4449F98; Sun, 17 Dec 2023 21:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q2BgPGcK" Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-7b3b819f8a3so132375839f.1; Sun, 17 Dec 2023 13:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702848742; x=1703453542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S9EUtlC/PMv4Un3TQIvI6rNRv4BEn/NrIpICR/MmGos=; b=Q2BgPGcKFLcr1fSJmlUw66t671tYkTyrzSm9Vh2AwIyaqwNyPAgvO3nXj77HvgGG2n iH8Mij1vaDJQb10NbUr+UMUU/ksKH/owHnlIIUfI7hFBIxyVXA1dgamS8o3jN8UydJd4 pBonbJhd+ETQY/uV2N5P4A0YHBHdSSGm4veBsUIkjbQjVH69d08/nH1PcI/jVzbDaZ3m azP6OQwZDyry5J2YTw/ATC+O8lRORB8F3CLrSXqWfDQzDX7Z4BN+DfGFBU60vAoMLpaq RhKt3LAXWjV5iSe2wEi/NRUf3BY+GpjNlb6LDIBl5CFhfkNhriyccrneb8oYuzcTi83z BepA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702848742; x=1703453542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S9EUtlC/PMv4Un3TQIvI6rNRv4BEn/NrIpICR/MmGos=; b=oGvwWY0bwvNQr2PM5guOv8+BtlzkOXZLvqyaAtGOiy6XavfWXO8FhEhRNDbb5HxIVQ D3YMZYlJhBOinqWwemWAuUXlPS0X9ooqvxafn+S56FXdJivALiNIDp6gW6xURvxX+UV1 WfJ2o+KKERvAibxV/XImUgMPHUczQmPc3ENzBMj1itWI2jF4mi/t+ABfj4MhIMQX8J8L WlFsG7qj53Ri1cwq4ODb2ZNqmBa4586yu5mfOcOtPDOuFqHggrmGmGcdGQA+T2nffJQa 0Ks2lx3iRKorED+AwkPceukLppGn0puYZyB2i21Q09Kluo5BJOxWvtiP5u0sF2zKjknv nMig== X-Gm-Message-State: AOJu0YzFd/rnCkdor1RysE+echqtElEdJ0ZkeedJAc5cHx/6AXIaWaMa lWXnY2/MqbyxZ8vgdj5PdNQ= X-Google-Smtp-Source: AGHT+IEtk5oBf0yL162N5sduVtfni1aVSJeCPUAgGE2Xbp4M7tnAcPmIbMNqo1Wg89oUvIg7rz6GvA== X-Received: by 2002:a92:ca4a:0:b0:35c:e547:d759 with SMTP id q10-20020a92ca4a000000b0035ce547d759mr15814238ilo.12.1702848741771; Sun, 17 Dec 2023 13:32:21 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:9c41:1dd2:7d5d:e008]) by smtp.gmail.com with ESMTPSA id e4-20020a0df504000000b005d746ac7f6bsm8197364ywf.69.2023.12.17.13.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 13:32:21 -0800 (PST) From: Yury Norov To: Souradeep Chakrabarti , kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, longli@microsoft.com, yury.norov@gmail.com, leon@kernel.org, cai.huoqing@linux.dev, ssengar@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: schakrabarti@microsoft.com, paulros@microsoft.com Subject: [PATCH 3/3] net: mana: add a function to spread IRQs per CPUs Date: Sun, 17 Dec 2023 13:32:14 -0800 Message-Id: <20231217213214.1905481-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231217213214.1905481-1-yury.norov@gmail.com> References: <20231217213214.1905481-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Souradeep investigated that the driver performs faster if IRQs are spread on CPUs with the following heuristics: 1. No more than one IRQ per CPU, if possible; 2. NUMA locality is the second priority; 3. Sibling dislocality is the last priority. Let's consider this topology: Node 0 1 Core 0 1 2 3 CPU 0 1 2 3 4 5 6 7 The most performant IRQ distribution based on the above topology and heuristics may look like this: IRQ Nodes Cores CPUs 0 1 0 0-1 1 1 1 2-3 2 1 0 0-1 3 1 1 2-3 4 2 2 4-5 5 2 3 6-7 6 2 2 4-5 7 2 3 6-7 The irq_setup() routine introduced in this patch leverages the for_each_numa_hop_mask() iterator and assigns IRQs to sibling groups as described above. According to [1], for NUMA-aware but sibling-ignorant IRQ distribution based on cpumask_local_spread() performance test results look like this: ./ntttcp -r -m 16 NTTTCP for Linux 1.4.0 --------------------------------------------------------- 08:05:20 INFO: 17 threads created 08:05:28 INFO: Network activity progressing... 08:06:28 INFO: Test run completed. 08:06:28 INFO: Test cycle finished. 08:06:28 INFO: ##### Totals: ##### 08:06:28 INFO: test duration :60.00 seconds 08:06:28 INFO: total bytes :630292053310 08:06:28 INFO: throughput :84.04Gbps 08:06:28 INFO: retrans segs :4 08:06:28 INFO: cpu cores :192 08:06:28 INFO: cpu speed :3799.725MHz 08:06:28 INFO: user :0.05% 08:06:28 INFO: system :1.60% 08:06:28 INFO: idle :96.41% 08:06:28 INFO: iowait :0.00% 08:06:28 INFO: softirq :1.94% 08:06:28 INFO: cycles/byte :2.50 08:06:28 INFO: cpu busy (all) :534.41% For NUMA- and sibling-aware IRQ distribution, the same test works 15% faster: ./ntttcp -r -m 16 NTTTCP for Linux 1.4.0 --------------------------------------------------------- 08:08:51 INFO: 17 threads created 08:08:56 INFO: Network activity progressing... 08:09:56 INFO: Test run completed. 08:09:56 INFO: Test cycle finished. 08:09:56 INFO: ##### Totals: ##### 08:09:56 INFO: test duration :60.00 seconds 08:09:56 INFO: total bytes :741966608384 08:09:56 INFO: throughput :98.93Gbps 08:09:56 INFO: retrans segs :6 08:09:56 INFO: cpu cores :192 08:09:56 INFO: cpu speed :3799.791MHz 08:09:56 INFO: user :0.06% 08:09:56 INFO: system :1.81% 08:09:56 INFO: idle :96.18% 08:09:56 INFO: iowait :0.00% 08:09:56 INFO: softirq :1.95% 08:09:56 INFO: cycles/byte :2.25 08:09:56 INFO: cpu busy (all) :569.22% [1] https://lore.kernel.org/all/20231211063726.GA4977@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net/ Signed-off-by: Yury Norov Co-developed-by: Souradeep Chakrabarti --- .../net/ethernet/microsoft/mana/gdma_main.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 6367de0c2c2e..11e64e42e3b2 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -1243,6 +1243,34 @@ void mana_gd_free_res_map(struct gdma_resource *r) r->size = 0; } +static __maybe_unused int irq_setup(unsigned int *irqs, unsigned int len, int node) +{ + const struct cpumask *next, *prev = cpu_none_mask; + cpumask_var_t cpus __free(free_cpumask_var); + int cpu, weight; + + if (!alloc_cpumask_var(&cpus, GFP_KERNEL)) + return -ENOMEM; + + rcu_read_lock(); + for_each_numa_hop_mask(next, node) { + weight = cpumask_weight_andnot(next, prev); + while (weight-- > 0) { + cpumask_andnot(cpus, next, prev); + for_each_cpu(cpu, cpus) { + if (len-- == 0) + goto done; + irq_set_affinity_and_hint(*irqs++, topology_sibling_cpumask(cpu)); + cpumask_andnot(cpus, cpus, topology_sibling_cpumask(cpu)); + } + } + prev = next; + } +done: + rcu_read_unlock(); + return 0; +} + static int mana_gd_setup_irqs(struct pci_dev *pdev) { unsigned int max_queues_per_port = num_online_cpus();