hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/infiniband/hw/hfi1/affinity.c
....@@ -1,5 +1,5 @@
11 /*
2
- * Copyright(c) 2015 - 2018 Intel Corporation.
2
+ * Copyright(c) 2015 - 2020 Intel Corporation.
33 *
44 * This file is provided under a dual BSD/GPLv2 license. When using or
55 * redistributing this file, you may do so under either license.
....@@ -48,6 +48,7 @@
4848 #include <linux/cpumask.h>
4949 #include <linux/module.h>
5050 #include <linux/interrupt.h>
51
+#include <linux/numa.h>
5152
5253 #include "hfi.h"
5354 #include "affinity.h"
....@@ -63,6 +64,7 @@
6364 static const char * const irq_type_names[] = {
6465 "SDMA",
6566 "RCVCTXT",
67
+ "NETDEVCTXT",
6668 "GENERAL",
6769 "OTHER",
6870 };
....@@ -630,21 +632,10 @@
630632 */
631633 int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
632634 {
633
- int node = pcibus_to_node(dd->pcidev->bus);
634635 struct hfi1_affinity_node *entry;
635636 const struct cpumask *local_mask;
636637 int curr_cpu, possible, i, ret;
637638 bool new_entry = false;
638
-
639
- /*
640
- * If the BIOS does not have the NUMA node information set, select
641
- * NUMA 0 so we get consistent performance.
642
- */
643
- if (node < 0) {
644
- dd_dev_err(dd, "Invalid PCI NUMA node. Performance may be affected\n");
645
- node = 0;
646
- }
647
- dd->node = node;
648639
649640 local_mask = cpumask_of_node(dd->node);
650641 if (cpumask_first(local_mask) >= nr_cpu_ids)
....@@ -658,7 +649,7 @@
658649 * create an entry in the global affinity structure and initialize it.
659650 */
660651 if (!entry) {
661
- entry = node_affinity_allocate(node);
652
+ entry = node_affinity_allocate(dd->node);
662653 if (!entry) {
663654 dd_dev_err(dd,
664655 "Unable to allocate global affinity node\n");
....@@ -749,6 +740,7 @@
749740 if (new_entry)
750741 node_affinity_add_tail(entry);
751742
743
+ dd->affinity_entry = entry;
752744 mutex_unlock(&node_affinity.lock);
753745
754746 return 0;
....@@ -764,10 +756,9 @@
764756 {
765757 struct hfi1_affinity_node *entry;
766758
767
- if (dd->node < 0)
768
- return;
769
-
770759 mutex_lock(&node_affinity.lock);
760
+ if (!dd->affinity_entry)
761
+ goto unlock;
771762 entry = node_affinity_lookup(dd->node);
772763 if (!entry)
773764 goto unlock;
....@@ -778,8 +769,8 @@
778769 */
779770 _dev_comp_vect_cpu_mask_clean_up(dd, entry);
780771 unlock:
772
+ dd->affinity_entry = NULL;
781773 mutex_unlock(&node_affinity.lock);
782
- dd->node = -1;
783774 }
784775
785776 /*
....@@ -819,10 +810,10 @@
819810 set = &entry->def_intr;
820811 cpumask_set_cpu(cpu, &set->mask);
821812 cpumask_set_cpu(cpu, &set->used);
822
- for (i = 0; i < dd->num_msix_entries; i++) {
813
+ for (i = 0; i < dd->msix_info.max_requested; i++) {
823814 struct hfi1_msix_entry *other_msix;
824815
825
- other_msix = &dd->msix_entries[i];
816
+ other_msix = &dd->msix_info.msix_entries[i];
826817 if (other_msix->type != IRQ_SDMA || other_msix == msix)
827818 continue;
828819
....@@ -914,6 +905,11 @@
914905 set = &entry->rcv_intr;
915906 scnprintf(extra, 64, "ctxt %u", rcd->ctxt);
916907 break;
908
+ case IRQ_NETDEVCTXT:
909
+ rcd = (struct hfi1_ctxtdata *)msix->arg;
910
+ set = &entry->def_intr;
911
+ scnprintf(extra, 64, "ctxt %u", rcd->ctxt);
912
+ break;
917913 default:
918914 dd_dev_err(dd, "Invalid IRQ type %d\n", msix->type);
919915 return -EINVAL;
....@@ -986,6 +982,10 @@
986982 if (rcd->ctxt != HFI1_CTRL_CTXT)
987983 set = &entry->rcv_intr;
988984 break;
985
+ case IRQ_NETDEVCTXT:
986
+ rcd = (struct hfi1_ctxtdata *)msix->arg;
987
+ set = &entry->def_intr;
988
+ break;
989989 default:
990990 mutex_unlock(&node_affinity.lock);
991991 return;
....@@ -1039,7 +1039,7 @@
10391039 struct hfi1_affinity_node *entry;
10401040 cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask;
10411041 const struct cpumask *node_mask,
1042
- *proc_mask = &current->cpus_allowed;
1042
+ *proc_mask = current->cpus_ptr;
10431043 struct hfi1_affinity_node_list *affinity = &node_affinity;
10441044 struct cpu_mask_set *set = &affinity->proc;
10451045
....@@ -1047,7 +1047,7 @@
10471047 * check whether process/context affinity has already
10481048 * been set
10491049 */
1050
- if (cpumask_weight(proc_mask) == 1) {
1050
+ if (current->nr_cpus_allowed == 1) {
10511051 hfi1_cdbg(PROC, "PID %u %s affinity set to CPU %*pbl",
10521052 current->pid, current->comm,
10531053 cpumask_pr_args(proc_mask));
....@@ -1058,7 +1058,7 @@
10581058 cpu = cpumask_first(proc_mask);
10591059 cpumask_set_cpu(cpu, &set->used);
10601060 goto done;
1061
- } else if (cpumask_weight(proc_mask) < cpumask_weight(&set->mask)) {
1061
+ } else if (current->nr_cpus_allowed < cpumask_weight(&set->mask)) {
10621062 hfi1_cdbg(PROC, "PID %u %s affinity set to CPU set(s) %*pbl",
10631063 current->pid, current->comm,
10641064 cpumask_pr_args(proc_mask));