hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
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 };
....@@ -216,6 +218,8 @@
216218 pr_err("HFI: System BIOS may need to be upgraded\n");
217219 for (node = 0; node < node_affinity.num_possible_nodes; node++)
218220 hfi1_per_node_cntr[node] = 1;
221
+
222
+ pci_dev_put(dev);
219223
220224 return 0;
221225 }
....@@ -630,21 +634,10 @@
630634 */
631635 int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
632636 {
633
- int node = pcibus_to_node(dd->pcidev->bus);
634637 struct hfi1_affinity_node *entry;
635638 const struct cpumask *local_mask;
636639 int curr_cpu, possible, i, ret;
637640 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;
648641
649642 local_mask = cpumask_of_node(dd->node);
650643 if (cpumask_first(local_mask) >= nr_cpu_ids)
....@@ -658,7 +651,7 @@
658651 * create an entry in the global affinity structure and initialize it.
659652 */
660653 if (!entry) {
661
- entry = node_affinity_allocate(node);
654
+ entry = node_affinity_allocate(dd->node);
662655 if (!entry) {
663656 dd_dev_err(dd,
664657 "Unable to allocate global affinity node\n");
....@@ -749,6 +742,7 @@
749742 if (new_entry)
750743 node_affinity_add_tail(entry);
751744
745
+ dd->affinity_entry = entry;
752746 mutex_unlock(&node_affinity.lock);
753747
754748 return 0;
....@@ -764,10 +758,9 @@
764758 {
765759 struct hfi1_affinity_node *entry;
766760
767
- if (dd->node < 0)
768
- return;
769
-
770761 mutex_lock(&node_affinity.lock);
762
+ if (!dd->affinity_entry)
763
+ goto unlock;
771764 entry = node_affinity_lookup(dd->node);
772765 if (!entry)
773766 goto unlock;
....@@ -778,8 +771,8 @@
778771 */
779772 _dev_comp_vect_cpu_mask_clean_up(dd, entry);
780773 unlock:
774
+ dd->affinity_entry = NULL;
781775 mutex_unlock(&node_affinity.lock);
782
- dd->node = -1;
783776 }
784777
785778 /*
....@@ -819,10 +812,10 @@
819812 set = &entry->def_intr;
820813 cpumask_set_cpu(cpu, &set->mask);
821814 cpumask_set_cpu(cpu, &set->used);
822
- for (i = 0; i < dd->num_msix_entries; i++) {
815
+ for (i = 0; i < dd->msix_info.max_requested; i++) {
823816 struct hfi1_msix_entry *other_msix;
824817
825
- other_msix = &dd->msix_entries[i];
818
+ other_msix = &dd->msix_info.msix_entries[i];
826819 if (other_msix->type != IRQ_SDMA || other_msix == msix)
827820 continue;
828821
....@@ -914,6 +907,11 @@
914907 set = &entry->rcv_intr;
915908 scnprintf(extra, 64, "ctxt %u", rcd->ctxt);
916909 break;
910
+ case IRQ_NETDEVCTXT:
911
+ rcd = (struct hfi1_ctxtdata *)msix->arg;
912
+ set = &entry->def_intr;
913
+ scnprintf(extra, 64, "ctxt %u", rcd->ctxt);
914
+ break;
917915 default:
918916 dd_dev_err(dd, "Invalid IRQ type %d\n", msix->type);
919917 return -EINVAL;
....@@ -986,6 +984,10 @@
986984 if (rcd->ctxt != HFI1_CTRL_CTXT)
987985 set = &entry->rcv_intr;
988986 break;
987
+ case IRQ_NETDEVCTXT:
988
+ rcd = (struct hfi1_ctxtdata *)msix->arg;
989
+ set = &entry->def_intr;
990
+ break;
989991 default:
990992 mutex_unlock(&node_affinity.lock);
991993 return;
....@@ -1039,7 +1041,7 @@
10391041 struct hfi1_affinity_node *entry;
10401042 cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask;
10411043 const struct cpumask *node_mask,
1042
- *proc_mask = &current->cpus_allowed;
1044
+ *proc_mask = current->cpus_ptr;
10431045 struct hfi1_affinity_node_list *affinity = &node_affinity;
10441046 struct cpu_mask_set *set = &affinity->proc;
10451047
....@@ -1047,7 +1049,7 @@
10471049 * check whether process/context affinity has already
10481050 * been set
10491051 */
1050
- if (cpumask_weight(proc_mask) == 1) {
1052
+ if (current->nr_cpus_allowed == 1) {
10511053 hfi1_cdbg(PROC, "PID %u %s affinity set to CPU %*pbl",
10521054 current->pid, current->comm,
10531055 cpumask_pr_args(proc_mask));
....@@ -1058,7 +1060,7 @@
10581060 cpu = cpumask_first(proc_mask);
10591061 cpumask_set_cpu(cpu, &set->used);
10601062 goto done;
1061
- } else if (cpumask_weight(proc_mask) < cpumask_weight(&set->mask)) {
1063
+ } else if (current->nr_cpus_allowed < cpumask_weight(&set->mask)) {
10621064 hfi1_cdbg(PROC, "PID %u %s affinity set to CPU set(s) %*pbl",
10631065 current->pid, current->comm,
10641066 cpumask_pr_args(proc_mask));