From: Souradeep Chakrabarti <schakrabarti@microsoft.com>
To: Haiyang Zhang <haiyangz@microsoft.com>,
Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>,
KY Srinivasan <kys@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
Dexuan Cui <decui@microsoft.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
Long Li <longli@microsoft.com>,
"sharmaajay@microsoft.com" <sharmaajay@microsoft.com>,
"leon@kernel.org" <leon@kernel.org>,
"cai.huoqing@linux.dev" <cai.huoqing@linux.dev>,
"ssengar@linux.microsoft.com" <ssengar@linux.microsoft.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: Paul Rosswurm <paulros@microsoft.com>
Subject: RE: [PATCH net-next] net: mana: Assigning IRQ affinity on HT cores
Date: Thu, 16 Nov 2023 11:21:08 +0000 [thread overview]
Message-ID: <PUZP153MB0788BF5F18973922F03C2CA4CCB0A@PUZP153MB0788.APCP153.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <PH7PR21MB311687F4F37C55D6B332D7F0CAB1A@PH7PR21MB3116.namprd21.prod.outlook.com>
>-----Original Message-----
>From: Haiyang Zhang <haiyangz@microsoft.com>
>Sent: Thursday, November 16, 2023 4:25 AM
>To: Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>; KY Srinivasan
><kys@microsoft.com>; wei.liu@kernel.org; Dexuan Cui <decui@microsoft.com>;
>davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
>pabeni@redhat.com; Long Li <longli@microsoft.com>;
>sharmaajay@microsoft.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: Souradeep Chakrabarti <schakrabarti@microsoft.com>; Paul Rosswurm
><paulros@microsoft.com>
>Subject: RE: [PATCH net-next] net: mana: Assigning IRQ affinity on HT cores
>
>
>
>> -----Original Message-----
>> From: Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>
>> Sent: Wednesday, November 15, 2023 8:49 AM
>> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
>> <haiyangz@microsoft.com>; wei.liu@kernel.org; Dexuan Cui
>> <decui@microsoft.com>; davem@davemloft.net; edumazet@google.com;
>> kuba@kernel.org; pabeni@redhat.com; Long Li <longli@microsoft.com>;
>> sharmaajay@microsoft.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: Souradeep Chakrabarti <schakrabarti@microsoft.com>; Paul Rosswurm
>> <paulros@microsoft.com>; Souradeep Chakrabarti
>> <schakrabarti@linux.microsoft.com>
>> Subject: [PATCH net-next] net: mana: Assigning IRQ affinity on HT
>> cores
>>
>> Existing MANA design assigns IRQ affinity to every sibling CPUs, which
>> causes IRQ coalescing and may reduce the network performance with RSS.
>>
>> Improve the performance by adhering the configuration for RSS, which
>> prioritise IRQ affinity on HT cores.
>>
>> Signed-off-by: Souradeep Chakrabarti
>> <schakrabarti@linux.microsoft.com>
>> ---
>> .../net/ethernet/microsoft/mana/gdma_main.c | 126 ++++++++++++++++-
>> -
>> 1 file changed, 117 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c
>> b/drivers/net/ethernet/microsoft/mana/gdma_main.c
>> index 6367de0c2c2e..839be819d46e 100644
>> --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
>> +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
>> @@ -1243,13 +1243,115 @@ void mana_gd_free_res_map(struct
>> gdma_resource *r)
>> r->size = 0;
>> }
>>
>> +static void cpu_mask_set(cpumask_var_t *filter_mask, cpumask_var_t
>> **filter_mask_list)
>> +{
>> + unsigned int core_count = 0, cpu;
>> + cpumask_var_t *filter_mask_list_tmp;
>> +
>> + BUG_ON(!filter_mask || !filter_mask_list);
>> + filter_mask_list_tmp = *filter_mask_list;
>> + cpumask_copy(*filter_mask, cpu_online_mask);
>> + /* for each core create a cpumask lookup table,
>> + * which stores all the corresponding siblings
>> + */
>> + for_each_cpu(cpu, *filter_mask) {
>> +
>> BUG_ON(!alloc_cpumask_var(&filter_mask_list_tmp[core_count],
>> GFP_KERNEL));
>> + cpumask_or(filter_mask_list_tmp[core_count],
>> filter_mask_list_tmp[core_count],
>> + topology_sibling_cpumask(cpu));
>> + cpumask_andnot(*filter_mask, *filter_mask,
>> topology_sibling_cpumask(cpu));
>> + core_count++;
>> + }
>> +}
>> +
>> +static int irq_setup(int *irqs, int nvec) {
>> + cpumask_var_t filter_mask;
>> + cpumask_var_t *filter_mask_list;
>> + unsigned int cpu_first, cpu, irq_start, cores = 0;
>> + int i, core_count = 0, numa_node, cpu_count = 0, err = 0;
>> +
>> + BUG_ON(!alloc_cpumask_var(&filter_mask, GFP_KERNEL));
>> + cpus_read_lock();
>> + cpumask_copy(filter_mask, cpu_online_mask);
>> + /* count the number of cores
>> + */
>> + for_each_cpu(cpu, filter_mask) {
>> + cpumask_andnot(filter_mask, filter_mask,
>> topology_sibling_cpumask(cpu));
>> + cores++;
>> + }
>> + filter_mask_list = kcalloc(cores, sizeof(cpumask_var_t), GFP_KERNEL);
>> + if (!filter_mask_list) {
>> + err = -ENOMEM;
>> + goto free_irq;
>> + }
>> + /* if number of cpus are equal to max_queues per port, then
>> + * one extra interrupt for the hardware channel communication.
>> + */
>> + if (nvec - 1 == num_online_cpus()) {
>> + irq_start = 1;
>> + cpu_first = cpumask_first(cpu_online_mask);
>> + irq_set_affinity_and_hint(irqs[0], cpumask_of(cpu_first));
>> + } else {
>> + irq_start = 0;
>> + }
>> + /* reset the core_count and num_node to 0.
>> + */
>> + core_count = 0;
>> + numa_node = 0;
>
>Please start with gc->numa_node here. I know it's 0 for now. But the host will
>provide real numa node# close to the device in the future.
Thank you. Will take care of it in next version.
>
>Also, as we discussed, consider using the NUMA distance to select the next numa
>node (in a separate patch).
>
>> + cpu_mask_set(&filter_mask, &filter_mask_list);
>> + /* for each interrupt find the cpu of a particular
>> + * sibling set and if it belongs to the specific numa
>> + * then assign irq to it and clear the cpu bit from
>> + * the corresponding sibling list from filter_mask_list.
>> + * Increase the cpu_count for that node.
>> + * Once all cpus for a numa node is assigned, then
>> + * move to different numa node and continue the same.
>> + */
>> + for (i = irq_start; i < nvec; ) {
>> + cpu_first = cpumask_first(filter_mask_list[core_count]);
>> + if (cpu_first < nr_cpu_ids && cpu_to_node(cpu_first) ==
>> numa_node) {
>> + irq_set_affinity_and_hint(irqs[i],
>> cpumask_of(cpu_first));
>> + cpumask_clear_cpu(cpu_first,
>> filter_mask_list[core_count]);
>> + cpu_count = cpu_count + 1;
>> + i = i + 1;
>> + /* checking if all the cpus are used from the
>> + * particular node.
>> + */
>> + if (cpu_count == nr_cpus_node(numa_node)) {
>> + numa_node = numa_node + 1;
>> + if (numa_node == num_online_nodes()) {
>> + cpu_mask_set(&filter_mask,
>> &filter_mask_list);
>> + numa_node = 0;
>Ditto.
>
>Other things look good to me.
>
>Thanks,
>- Haiyang
next prev parent reply other threads:[~2023-11-16 11:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 13:48 Souradeep Chakrabarti
2023-11-15 22:54 ` Haiyang Zhang
2023-11-16 11:21 ` Souradeep Chakrabarti [this message]
2023-11-16 5:25 ` Michael Kelley
2023-11-16 6:17 ` Michael Kelley
2023-11-21 13:59 ` Souradeep Chakrabarti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PUZP153MB0788BF5F18973922F03C2CA4CCB0A@PUZP153MB0788.APCP153.PROD.OUTLOOK.COM \
--to=schakrabarti@microsoft.com \
--cc=cai.huoqing@linux.dev \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=haiyangz@microsoft.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulros@microsoft.com \
--cc=schakrabarti@linux.microsoft.com \
--cc=sharmaajay@microsoft.com \
--cc=ssengar@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®