6
6
#include "idxd.h"
7
7
#include "perfmon.h"
8
8
9
- static ssize_t cpumask_show (struct device * dev , struct device_attribute * attr ,
10
- char * buf );
11
-
12
- static cpumask_t perfmon_dsa_cpu_mask ;
13
- static bool cpuhp_set_up ;
14
- static enum cpuhp_state cpuhp_slot ;
15
-
16
- /*
17
- * perf userspace reads this attribute to determine which cpus to open
18
- * counters on. It's connected to perfmon_dsa_cpu_mask, which is
19
- * maintained by the cpu hotplug handlers.
20
- */
21
- static DEVICE_ATTR_RO (cpumask );
22
-
23
- static struct attribute * perfmon_cpumask_attrs [] = {
24
- & dev_attr_cpumask .attr ,
25
- NULL ,
26
- };
27
-
28
- static struct attribute_group cpumask_attr_group = {
29
- .attrs = perfmon_cpumask_attrs ,
30
- };
31
-
32
9
/*
33
10
* These attributes specify the bits in the config word that the perf
34
11
* syscall uses to pass the event ids and categories to perfmon.
@@ -67,16 +44,9 @@ static struct attribute_group perfmon_format_attr_group = {
67
44
68
45
static const struct attribute_group * perfmon_attr_groups [] = {
69
46
& perfmon_format_attr_group ,
70
- & cpumask_attr_group ,
71
47
NULL ,
72
48
};
73
49
74
- static ssize_t cpumask_show (struct device * dev , struct device_attribute * attr ,
75
- char * buf )
76
- {
77
- return cpumap_print_to_pagebuf (true, buf , & perfmon_dsa_cpu_mask );
78
- }
79
-
80
50
static bool is_idxd_event (struct idxd_pmu * idxd_pmu , struct perf_event * event )
81
51
{
82
52
return & idxd_pmu -> pmu == event -> pmu ;
@@ -217,7 +187,6 @@ static int perfmon_pmu_event_init(struct perf_event *event)
217
187
return - EINVAL ;
218
188
219
189
event -> hw .event_base = ioread64 (PERFMON_TABLE_OFFSET (idxd ));
220
- event -> cpu = idxd -> idxd_pmu -> cpu ;
221
190
event -> hw .config = event -> attr .config ;
222
191
223
192
if (event -> group_leader != event )
@@ -488,6 +457,7 @@ static void idxd_pmu_init(struct idxd_pmu *idxd_pmu)
488
457
idxd_pmu -> pmu .stop = perfmon_pmu_event_stop ;
489
458
idxd_pmu -> pmu .read = perfmon_pmu_event_update ;
490
459
idxd_pmu -> pmu .capabilities = PERF_PMU_CAP_NO_EXCLUDE ;
460
+ idxd_pmu -> pmu .scope = PERF_PMU_SCOPE_SYS_WIDE ;
491
461
idxd_pmu -> pmu .module = THIS_MODULE ;
492
462
}
493
463
@@ -496,59 +466,17 @@ void perfmon_pmu_remove(struct idxd_device *idxd)
496
466
if (!idxd -> idxd_pmu )
497
467
return ;
498
468
499
- cpuhp_state_remove_instance (cpuhp_slot , & idxd -> idxd_pmu -> cpuhp_node );
500
469
perf_pmu_unregister (& idxd -> idxd_pmu -> pmu );
501
470
kfree (idxd -> idxd_pmu );
502
471
idxd -> idxd_pmu = NULL ;
503
472
}
504
473
505
- static int perf_event_cpu_online (unsigned int cpu , struct hlist_node * node )
506
- {
507
- struct idxd_pmu * idxd_pmu ;
508
-
509
- idxd_pmu = hlist_entry_safe (node , typeof (* idxd_pmu ), cpuhp_node );
510
-
511
- /* select the first online CPU as the designated reader */
512
- if (cpumask_empty (& perfmon_dsa_cpu_mask )) {
513
- cpumask_set_cpu (cpu , & perfmon_dsa_cpu_mask );
514
- idxd_pmu -> cpu = cpu ;
515
- }
516
-
517
- return 0 ;
518
- }
519
-
520
- static int perf_event_cpu_offline (unsigned int cpu , struct hlist_node * node )
521
- {
522
- struct idxd_pmu * idxd_pmu ;
523
- unsigned int target ;
524
-
525
- idxd_pmu = hlist_entry_safe (node , typeof (* idxd_pmu ), cpuhp_node );
526
-
527
- if (!cpumask_test_and_clear_cpu (cpu , & perfmon_dsa_cpu_mask ))
528
- return 0 ;
529
-
530
- target = cpumask_any_but (cpu_online_mask , cpu );
531
- /* migrate events if there is a valid target */
532
- if (target < nr_cpu_ids ) {
533
- cpumask_set_cpu (target , & perfmon_dsa_cpu_mask );
534
- perf_pmu_migrate_context (& idxd_pmu -> pmu , cpu , target );
535
- }
536
-
537
- return 0 ;
538
- }
539
-
540
474
int perfmon_pmu_init (struct idxd_device * idxd )
541
475
{
542
476
union idxd_perfcap perfcap ;
543
477
struct idxd_pmu * idxd_pmu ;
544
478
int rc = - ENODEV ;
545
479
546
- /*
547
- * perfmon module initialization failed, nothing to do
548
- */
549
- if (!cpuhp_set_up )
550
- return - ENODEV ;
551
-
552
480
/*
553
481
* If perfmon_offset or num_counters is 0, it means perfmon is
554
482
* not supported on this hardware.
@@ -624,11 +552,6 @@ int perfmon_pmu_init(struct idxd_device *idxd)
624
552
if (rc )
625
553
goto free ;
626
554
627
- rc = cpuhp_state_add_instance (cpuhp_slot , & idxd_pmu -> cpuhp_node );
628
- if (rc ) {
629
- perf_pmu_unregister (& idxd -> idxd_pmu -> pmu );
630
- goto free ;
631
- }
632
555
out :
633
556
return rc ;
634
557
free :
@@ -637,22 +560,3 @@ int perfmon_pmu_init(struct idxd_device *idxd)
637
560
638
561
goto out ;
639
562
}
640
-
641
- void __init perfmon_init (void )
642
- {
643
- int rc = cpuhp_setup_state_multi (CPUHP_AP_ONLINE_DYN ,
644
- "driver/dma/idxd/perf:online" ,
645
- perf_event_cpu_online ,
646
- perf_event_cpu_offline );
647
- if (WARN_ON (rc < 0 ))
648
- return ;
649
-
650
- cpuhp_slot = rc ;
651
- cpuhp_set_up = true;
652
- }
653
-
654
- void __exit perfmon_exit (void )
655
- {
656
- if (cpuhp_set_up )
657
- cpuhp_remove_multi_state (cpuhp_slot );
658
- }
0 commit comments