.. | .. |
---|
1 | 1 | /* |
---|
2 | | - * Copyright(c) 2015 - 2018 Intel Corporation. |
---|
| 2 | + * Copyright(c) 2015 - 2020 Intel Corporation. |
---|
3 | 3 | * |
---|
4 | 4 | * This file is provided under a dual BSD/GPLv2 license. When using or |
---|
5 | 5 | * redistributing this file, you may do so under either license. |
---|
.. | .. |
---|
48 | 48 | #include <linux/cpumask.h> |
---|
49 | 49 | #include <linux/module.h> |
---|
50 | 50 | #include <linux/interrupt.h> |
---|
| 51 | +#include <linux/numa.h> |
---|
51 | 52 | |
---|
52 | 53 | #include "hfi.h" |
---|
53 | 54 | #include "affinity.h" |
---|
.. | .. |
---|
63 | 64 | static const char * const irq_type_names[] = { |
---|
64 | 65 | "SDMA", |
---|
65 | 66 | "RCVCTXT", |
---|
| 67 | + "NETDEVCTXT", |
---|
66 | 68 | "GENERAL", |
---|
67 | 69 | "OTHER", |
---|
68 | 70 | }; |
---|
.. | .. |
---|
630 | 632 | */ |
---|
631 | 633 | int hfi1_dev_affinity_init(struct hfi1_devdata *dd) |
---|
632 | 634 | { |
---|
633 | | - int node = pcibus_to_node(dd->pcidev->bus); |
---|
634 | 635 | struct hfi1_affinity_node *entry; |
---|
635 | 636 | const struct cpumask *local_mask; |
---|
636 | 637 | int curr_cpu, possible, i, ret; |
---|
637 | 638 | 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; |
---|
648 | 639 | |
---|
649 | 640 | local_mask = cpumask_of_node(dd->node); |
---|
650 | 641 | if (cpumask_first(local_mask) >= nr_cpu_ids) |
---|
.. | .. |
---|
658 | 649 | * create an entry in the global affinity structure and initialize it. |
---|
659 | 650 | */ |
---|
660 | 651 | if (!entry) { |
---|
661 | | - entry = node_affinity_allocate(node); |
---|
| 652 | + entry = node_affinity_allocate(dd->node); |
---|
662 | 653 | if (!entry) { |
---|
663 | 654 | dd_dev_err(dd, |
---|
664 | 655 | "Unable to allocate global affinity node\n"); |
---|
.. | .. |
---|
749 | 740 | if (new_entry) |
---|
750 | 741 | node_affinity_add_tail(entry); |
---|
751 | 742 | |
---|
| 743 | + dd->affinity_entry = entry; |
---|
752 | 744 | mutex_unlock(&node_affinity.lock); |
---|
753 | 745 | |
---|
754 | 746 | return 0; |
---|
.. | .. |
---|
764 | 756 | { |
---|
765 | 757 | struct hfi1_affinity_node *entry; |
---|
766 | 758 | |
---|
767 | | - if (dd->node < 0) |
---|
768 | | - return; |
---|
769 | | - |
---|
770 | 759 | mutex_lock(&node_affinity.lock); |
---|
| 760 | + if (!dd->affinity_entry) |
---|
| 761 | + goto unlock; |
---|
771 | 762 | entry = node_affinity_lookup(dd->node); |
---|
772 | 763 | if (!entry) |
---|
773 | 764 | goto unlock; |
---|
.. | .. |
---|
778 | 769 | */ |
---|
779 | 770 | _dev_comp_vect_cpu_mask_clean_up(dd, entry); |
---|
780 | 771 | unlock: |
---|
| 772 | + dd->affinity_entry = NULL; |
---|
781 | 773 | mutex_unlock(&node_affinity.lock); |
---|
782 | | - dd->node = -1; |
---|
783 | 774 | } |
---|
784 | 775 | |
---|
785 | 776 | /* |
---|
.. | .. |
---|
819 | 810 | set = &entry->def_intr; |
---|
820 | 811 | cpumask_set_cpu(cpu, &set->mask); |
---|
821 | 812 | 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++) { |
---|
823 | 814 | struct hfi1_msix_entry *other_msix; |
---|
824 | 815 | |
---|
825 | | - other_msix = &dd->msix_entries[i]; |
---|
| 816 | + other_msix = &dd->msix_info.msix_entries[i]; |
---|
826 | 817 | if (other_msix->type != IRQ_SDMA || other_msix == msix) |
---|
827 | 818 | continue; |
---|
828 | 819 | |
---|
.. | .. |
---|
914 | 905 | set = &entry->rcv_intr; |
---|
915 | 906 | scnprintf(extra, 64, "ctxt %u", rcd->ctxt); |
---|
916 | 907 | 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; |
---|
917 | 913 | default: |
---|
918 | 914 | dd_dev_err(dd, "Invalid IRQ type %d\n", msix->type); |
---|
919 | 915 | return -EINVAL; |
---|
.. | .. |
---|
986 | 982 | if (rcd->ctxt != HFI1_CTRL_CTXT) |
---|
987 | 983 | set = &entry->rcv_intr; |
---|
988 | 984 | break; |
---|
| 985 | + case IRQ_NETDEVCTXT: |
---|
| 986 | + rcd = (struct hfi1_ctxtdata *)msix->arg; |
---|
| 987 | + set = &entry->def_intr; |
---|
| 988 | + break; |
---|
989 | 989 | default: |
---|
990 | 990 | mutex_unlock(&node_affinity.lock); |
---|
991 | 991 | return; |
---|
.. | .. |
---|
1039 | 1039 | struct hfi1_affinity_node *entry; |
---|
1040 | 1040 | cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask; |
---|
1041 | 1041 | const struct cpumask *node_mask, |
---|
1042 | | - *proc_mask = ¤t->cpus_allowed; |
---|
| 1042 | + *proc_mask = current->cpus_ptr; |
---|
1043 | 1043 | struct hfi1_affinity_node_list *affinity = &node_affinity; |
---|
1044 | 1044 | struct cpu_mask_set *set = &affinity->proc; |
---|
1045 | 1045 | |
---|
.. | .. |
---|
1047 | 1047 | * check whether process/context affinity has already |
---|
1048 | 1048 | * been set |
---|
1049 | 1049 | */ |
---|
1050 | | - if (cpumask_weight(proc_mask) == 1) { |
---|
| 1050 | + if (current->nr_cpus_allowed == 1) { |
---|
1051 | 1051 | hfi1_cdbg(PROC, "PID %u %s affinity set to CPU %*pbl", |
---|
1052 | 1052 | current->pid, current->comm, |
---|
1053 | 1053 | cpumask_pr_args(proc_mask)); |
---|
.. | .. |
---|
1058 | 1058 | cpu = cpumask_first(proc_mask); |
---|
1059 | 1059 | cpumask_set_cpu(cpu, &set->used); |
---|
1060 | 1060 | goto done; |
---|
1061 | | - } else if (cpumask_weight(proc_mask) < cpumask_weight(&set->mask)) { |
---|
| 1061 | + } else if (current->nr_cpus_allowed < cpumask_weight(&set->mask)) { |
---|
1062 | 1062 | hfi1_cdbg(PROC, "PID %u %s affinity set to CPU set(s) %*pbl", |
---|
1063 | 1063 | current->pid, current->comm, |
---|
1064 | 1064 | cpumask_pr_args(proc_mask)); |
---|