diff options
author | Harish Chegondi <harish.chegondi@intel.com> | 2016-12-07 22:34:19 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-12-11 15:29:42 -0500 |
commit | 9d8145a604937780898c0e4bdb124a57988fc2ed (patch) | |
tree | d60b98fe47eedeb8bf830674fdbdcfe8d031bcd5 | |
parent | 0771da5a6e9d67e48207a81ddf6c8e739e9493bd (diff) |
IB/hfi1: Avoid credit return allocation for cpu-less NUMA nodes
Do not allocate credit return base and DMA memory for
NUMA nodes without CPUs.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Harish Chegondi <harish.chegondi@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/hw/hfi1/affinity.c | 3 | ||||
-rw-r--r-- | drivers/infiniband/hw/hfi1/affinity.h | 1 | ||||
-rw-r--r-- | drivers/infiniband/hw/hfi1/pio.c | 20 |
3 files changed, 6 insertions, 18 deletions
diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c index a26a9a0bfc41..4962b6ef1f34 100644 --- a/drivers/infiniband/hw/hfi1/affinity.c +++ b/drivers/infiniband/hw/hfi1/affinity.c | |||
@@ -125,6 +125,7 @@ int node_affinity_init(void) | |||
125 | cpumask_weight(topology_sibling_cpumask( | 125 | cpumask_weight(topology_sibling_cpumask( |
126 | cpumask_first(&node_affinity.proc.mask) | 126 | cpumask_first(&node_affinity.proc.mask) |
127 | )); | 127 | )); |
128 | node_affinity.num_possible_nodes = num_possible_nodes(); | ||
128 | node_affinity.num_online_nodes = num_online_nodes(); | 129 | node_affinity.num_online_nodes = num_online_nodes(); |
129 | node_affinity.num_online_cpus = num_online_cpus(); | 130 | node_affinity.num_online_cpus = num_online_cpus(); |
130 | 131 | ||
@@ -135,7 +136,7 @@ int node_affinity_init(void) | |||
135 | */ | 136 | */ |
136 | init_real_cpu_mask(); | 137 | init_real_cpu_mask(); |
137 | 138 | ||
138 | hfi1_per_node_cntr = kcalloc(num_possible_nodes(), | 139 | hfi1_per_node_cntr = kcalloc(node_affinity.num_possible_nodes, |
139 | sizeof(*hfi1_per_node_cntr), GFP_KERNEL); | 140 | sizeof(*hfi1_per_node_cntr), GFP_KERNEL); |
140 | if (!hfi1_per_node_cntr) | 141 | if (!hfi1_per_node_cntr) |
141 | return -ENOMEM; | 142 | return -ENOMEM; |
diff --git a/drivers/infiniband/hw/hfi1/affinity.h b/drivers/infiniband/hw/hfi1/affinity.h index ef4ebc358619..c9453b3d47b4 100644 --- a/drivers/infiniband/hw/hfi1/affinity.h +++ b/drivers/infiniband/hw/hfi1/affinity.h | |||
@@ -111,6 +111,7 @@ struct hfi1_affinity_node_list { | |||
111 | struct cpumask real_cpu_mask; | 111 | struct cpumask real_cpu_mask; |
112 | struct cpu_mask_set proc; | 112 | struct cpu_mask_set proc; |
113 | int num_core_siblings; | 113 | int num_core_siblings; |
114 | int num_possible_nodes; | ||
114 | int num_online_nodes; | 115 | int num_online_nodes; |
115 | int num_online_cpus; | 116 | int num_online_cpus; |
116 | struct mutex lock; /* protects affinity nodes */ | 117 | struct mutex lock; /* protects affinity nodes */ |
diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index 75c4dea84c4b..3d5dac2f5266 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c | |||
@@ -2036,21 +2036,10 @@ freesc15: | |||
2036 | int init_credit_return(struct hfi1_devdata *dd) | 2036 | int init_credit_return(struct hfi1_devdata *dd) |
2037 | { | 2037 | { |
2038 | int ret; | 2038 | int ret; |
2039 | int num_numa; | ||
2040 | int i; | 2039 | int i; |
2041 | 2040 | ||
2042 | num_numa = num_online_nodes(); | ||
2043 | /* enforce the expectation that the numas are compact */ | ||
2044 | for (i = 0; i < num_numa; i++) { | ||
2045 | if (!node_online(i)) { | ||
2046 | dd_dev_err(dd, "NUMA nodes are not compact\n"); | ||
2047 | ret = -EINVAL; | ||
2048 | goto done; | ||
2049 | } | ||
2050 | } | ||
2051 | |||
2052 | dd->cr_base = kcalloc( | 2041 | dd->cr_base = kcalloc( |
2053 | num_numa, | 2042 | node_affinity.num_possible_nodes, |
2054 | sizeof(struct credit_return_base), | 2043 | sizeof(struct credit_return_base), |
2055 | GFP_KERNEL); | 2044 | GFP_KERNEL); |
2056 | if (!dd->cr_base) { | 2045 | if (!dd->cr_base) { |
@@ -2058,7 +2047,7 @@ int init_credit_return(struct hfi1_devdata *dd) | |||
2058 | ret = -ENOMEM; | 2047 | ret = -ENOMEM; |
2059 | goto done; | 2048 | goto done; |
2060 | } | 2049 | } |
2061 | for (i = 0; i < num_numa; i++) { | 2050 | for_each_node_with_cpus(i) { |
2062 | int bytes = TXE_NUM_CONTEXTS * sizeof(struct credit_return); | 2051 | int bytes = TXE_NUM_CONTEXTS * sizeof(struct credit_return); |
2063 | 2052 | ||
2064 | set_dev_node(&dd->pcidev->dev, i); | 2053 | set_dev_node(&dd->pcidev->dev, i); |
@@ -2085,14 +2074,11 @@ done: | |||
2085 | 2074 | ||
2086 | void free_credit_return(struct hfi1_devdata *dd) | 2075 | void free_credit_return(struct hfi1_devdata *dd) |
2087 | { | 2076 | { |
2088 | int num_numa; | ||
2089 | int i; | 2077 | int i; |
2090 | 2078 | ||
2091 | if (!dd->cr_base) | 2079 | if (!dd->cr_base) |
2092 | return; | 2080 | return; |
2093 | 2081 | for (i = 0; i < node_affinity.num_possible_nodes; i++) { | |
2094 | num_numa = num_online_nodes(); | ||
2095 | for (i = 0; i < num_numa; i++) { | ||
2096 | if (dd->cr_base[i].va) { | 2082 | if (dd->cr_base[i].va) { |
2097 | dma_free_coherent(&dd->pcidev->dev, | 2083 | dma_free_coherent(&dd->pcidev->dev, |
2098 | TXE_NUM_CONTEXTS * | 2084 | TXE_NUM_CONTEXTS * |