53
53
#include "sdma.h"
54
54
#include "trace.h"
55
55
56
- struct cpu_mask_set {
57
- struct cpumask mask ;
58
- struct cpumask used ;
59
- uint gen ;
60
- };
61
-
62
- struct hfi1_affinity {
63
- struct cpu_mask_set def_intr ;
64
- struct cpu_mask_set rcv_intr ;
65
- struct cpu_mask_set proc ;
66
- /* spin lock to protect affinity struct */
67
- spinlock_t lock ;
68
- };
69
-
70
56
/* Name of IRQ types, indexed by enum irq_type */
71
57
static const char * const irq_type_names [] = {
72
58
"SDMA" ,
@@ -82,6 +68,48 @@ static inline void init_cpu_mask_set(struct cpu_mask_set *set)
82
68
set -> gen = 0 ;
83
69
}
84
70
71
+ /* Initialize non-HT cpu cores mask */
72
+ int init_real_cpu_mask (struct hfi1_devdata * dd )
73
+ {
74
+ struct hfi1_affinity * info ;
75
+ int possible , curr_cpu , i , ht ;
76
+
77
+ info = kzalloc (sizeof (* info ), GFP_KERNEL );
78
+ if (!info )
79
+ return - ENOMEM ;
80
+
81
+ cpumask_clear (& info -> real_cpu_mask );
82
+
83
+ /* Start with cpu online mask as the real cpu mask */
84
+ cpumask_copy (& info -> real_cpu_mask , cpu_online_mask );
85
+
86
+ /*
87
+ * Remove HT cores from the real cpu mask. Do this in two steps below.
88
+ */
89
+ possible = cpumask_weight (& info -> real_cpu_mask );
90
+ ht = cpumask_weight (topology_sibling_cpumask (
91
+ cpumask_first (& info -> real_cpu_mask )));
92
+ /*
93
+ * Step 1. Skip over the first N HT siblings and use them as the
94
+ * "real" cores. Assumes that HT cores are not enumerated in
95
+ * succession (except in the single core case).
96
+ */
97
+ curr_cpu = cpumask_first (& info -> real_cpu_mask );
98
+ for (i = 0 ; i < possible / ht ; i ++ )
99
+ curr_cpu = cpumask_next (curr_cpu , & info -> real_cpu_mask );
100
+ /*
101
+ * Step 2. Remove the remaining HT siblings. Use cpumask_next() to
102
+ * skip any gaps.
103
+ */
104
+ for (; i < possible ; i ++ ) {
105
+ cpumask_clear_cpu (curr_cpu , & info -> real_cpu_mask );
106
+ curr_cpu = cpumask_next (curr_cpu , & info -> real_cpu_mask );
107
+ }
108
+
109
+ dd -> affinity = info ;
110
+ return 0 ;
111
+ }
112
+
85
113
/*
86
114
* Interrupt affinity.
87
115
*
@@ -93,20 +121,17 @@ static inline void init_cpu_mask_set(struct cpu_mask_set *set)
93
121
* to the node relative 1 as necessary.
94
122
*
95
123
*/
96
- int hfi1_dev_affinity_init (struct hfi1_devdata * dd )
124
+ void hfi1_dev_affinity_init (struct hfi1_devdata * dd )
97
125
{
98
126
int node = pcibus_to_node (dd -> pcidev -> bus );
99
- struct hfi1_affinity * info ;
127
+ struct hfi1_affinity * info = dd -> affinity ;
100
128
const struct cpumask * local_mask ;
101
- int curr_cpu , possible , i , ht ;
129
+ int curr_cpu , possible , i ;
102
130
103
131
if (node < 0 )
104
132
node = numa_node_id ();
105
133
dd -> node = node ;
106
134
107
- info = kzalloc (sizeof (* info ), GFP_KERNEL );
108
- if (!info )
109
- return - ENOMEM ;
110
135
spin_lock_init (& info -> lock );
111
136
112
137
init_cpu_mask_set (& info -> def_intr );
@@ -116,30 +141,8 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
116
141
local_mask = cpumask_of_node (dd -> node );
117
142
if (cpumask_first (local_mask ) >= nr_cpu_ids )
118
143
local_mask = topology_core_cpumask (0 );
119
- /* use local mask as default */
120
- cpumask_copy (& info -> def_intr .mask , local_mask );
121
- /*
122
- * Remove HT cores from the default mask. Do this in two steps below.
123
- */
124
- possible = cpumask_weight (& info -> def_intr .mask );
125
- ht = cpumask_weight (topology_sibling_cpumask (
126
- cpumask_first (& info -> def_intr .mask )));
127
- /*
128
- * Step 1. Skip over the first N HT siblings and use them as the
129
- * "real" cores. Assumes that HT cores are not enumerated in
130
- * succession (except in the single core case).
131
- */
132
- curr_cpu = cpumask_first (& info -> def_intr .mask );
133
- for (i = 0 ; i < possible / ht ; i ++ )
134
- curr_cpu = cpumask_next (curr_cpu , & info -> def_intr .mask );
135
- /*
136
- * Step 2. Remove the remaining HT siblings. Use cpumask_next() to
137
- * skip any gaps.
138
- */
139
- for (; i < possible ; i ++ ) {
140
- cpumask_clear_cpu (curr_cpu , & info -> def_intr .mask );
141
- curr_cpu = cpumask_next (curr_cpu , & info -> def_intr .mask );
142
- }
144
+ /* Use the "real" cpu mask of this node as the default */
145
+ cpumask_and (& info -> def_intr .mask , & info -> real_cpu_mask , local_mask );
143
146
144
147
/* fill in the receive list */
145
148
possible = cpumask_weight (& info -> def_intr .mask );
@@ -167,8 +170,6 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
167
170
}
168
171
169
172
cpumask_copy (& info -> proc .mask , cpu_online_mask );
170
- dd -> affinity = info ;
171
- return 0 ;
172
173
}
173
174
174
175
void hfi1_dev_affinity_free (struct hfi1_devdata * dd )
0 commit comments