@@ -188,19 +188,12 @@ static inline int amd_has_nb(struct cpu_hw_events *cpuc)
188188 return nb && nb -> nb_id != -1 ;
189189}
190190
191- static void amd_put_event_constraints (struct cpu_hw_events * cpuc ,
192- struct perf_event * event )
191+ static void __amd_put_nb_event_constraints (struct cpu_hw_events * cpuc ,
192+ struct perf_event * event )
193193{
194- struct hw_perf_event * hwc = & event -> hw ;
195194 struct amd_nb * nb = cpuc -> amd_nb ;
196195 int i ;
197196
198- /*
199- * only care about NB events
200- */
201- if (!(amd_has_nb (cpuc ) && amd_is_nb_event (hwc )))
202- return ;
203-
204197 /*
205198 * need to scan whole list because event may not have
206199 * been assigned during scheduling
@@ -247,24 +240,19 @@ static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
247240 *
248241 * Given that resources are allocated (cmpxchg), they must be
249242 * eventually freed for others to use. This is accomplished by
250- * calling amd_put_event_constraints().
243+ * calling __amd_put_nb_event_constraints()
251244 *
252245 * Non NB events are not impacted by this restriction.
253246 */
254247static struct event_constraint *
255- amd_get_event_constraints (struct cpu_hw_events * cpuc , struct perf_event * event )
248+ __amd_get_nb_event_constraints (struct cpu_hw_events * cpuc , struct perf_event * event ,
249+ struct event_constraint * c )
256250{
257251 struct hw_perf_event * hwc = & event -> hw ;
258252 struct amd_nb * nb = cpuc -> amd_nb ;
259253 struct perf_event * old ;
260254 int idx , new = -1 ;
261255
262- /*
263- * if not NB event or no NB, then no constraints
264- */
265- if (!(amd_has_nb (cpuc ) && amd_is_nb_event (hwc )))
266- return & unconstrained ;
267-
268256 /*
269257 * detect if already present, if so reuse
270258 *
@@ -275,7 +263,7 @@ amd_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
275263 * because of successive calls to x86_schedule_events() from
276264 * hw_perf_group_sched_in() without hw_perf_enable()
277265 */
278- for (idx = 0 ; idx < x86_pmu .num_counters ; idx ++ ) {
266+ for_each_set_bit (idx , c -> idxmsk , x86_pmu .num_counters ) {
279267 if (new == -1 || hwc -> idx == idx )
280268 /* assign free slot, prefer hwc->idx */
281269 old = cmpxchg (nb -> owners + idx , NULL , event );
@@ -391,6 +379,25 @@ static void amd_pmu_cpu_dead(int cpu)
391379 }
392380}
393381
382+ static struct event_constraint *
383+ amd_get_event_constraints (struct cpu_hw_events * cpuc , struct perf_event * event )
384+ {
385+ /*
386+ * if not NB event or no NB, then no constraints
387+ */
388+ if (!(amd_has_nb (cpuc ) && amd_is_nb_event (& event -> hw )))
389+ return & unconstrained ;
390+
391+ return __amd_get_nb_event_constraints (cpuc , event , & unconstrained );
392+ }
393+
394+ static void amd_put_event_constraints (struct cpu_hw_events * cpuc ,
395+ struct perf_event * event )
396+ {
397+ if (amd_has_nb (cpuc ) && amd_is_nb_event (& event -> hw ))
398+ __amd_put_nb_event_constraints (cpuc , event );
399+ }
400+
394401PMU_FORMAT_ATTR (event , "config:0-7,32-35" );
395402PMU_FORMAT_ATTR (umask , "config:8-15" );
396403PMU_FORMAT_ATTR (edge , "config:18" );
0 commit comments