2
2
#include "debug.h"
3
3
#include "evlist.h"
4
4
#include "evsel.h"
5
+ #include "evsel_config.h"
5
6
#include "parse-events.h"
6
7
#include <errno.h>
7
8
#include <limits.h>
@@ -33,11 +34,24 @@ static struct evsel *evsel__read_sampler(struct evsel *evsel, struct evlist *evl
33
34
return leader ;
34
35
}
35
36
37
+ static u64 evsel__config_term_mask (struct evsel * evsel )
38
+ {
39
+ struct evsel_config_term * term ;
40
+ struct list_head * config_terms = & evsel -> config_terms ;
41
+ u64 term_types = 0 ;
42
+
43
+ list_for_each_entry (term , config_terms , list ) {
44
+ term_types |= 1 << term -> type ;
45
+ }
46
+ return term_types ;
47
+ }
48
+
36
49
static void evsel__config_leader_sampling (struct evsel * evsel , struct evlist * evlist )
37
50
{
38
51
struct perf_event_attr * attr = & evsel -> core .attr ;
39
52
struct evsel * leader = evsel -> leader ;
40
53
struct evsel * read_sampler ;
54
+ u64 term_types , freq_mask ;
41
55
42
56
if (!leader -> sample_read )
43
57
return ;
@@ -47,16 +61,20 @@ static void evsel__config_leader_sampling(struct evsel *evsel, struct evlist *ev
47
61
if (evsel == read_sampler )
48
62
return ;
49
63
64
+ term_types = evsel__config_term_mask (evsel );
50
65
/*
51
- * Disable sampling for all group members other than the leader in
52
- * case the leader 'leads' the sampling, except when the leader is an
53
- * AUX area event, in which case the 2nd event in the group is the one
54
- * that 'leads' the sampling.
66
+ * Disable sampling for all group members except those with explicit
67
+ * config terms or the leader. In the case of an AUX area event, the 2nd
68
+ * event in the group is the one that 'leads' the sampling.
55
69
*/
56
- attr -> freq = 0 ;
57
- attr -> sample_freq = 0 ;
58
- attr -> sample_period = 0 ;
59
- attr -> write_backward = 0 ;
70
+ freq_mask = (1 << EVSEL__CONFIG_TERM_FREQ ) | (1 << EVSEL__CONFIG_TERM_PERIOD );
71
+ if ((term_types & freq_mask ) == 0 ) {
72
+ attr -> freq = 0 ;
73
+ attr -> sample_freq = 0 ;
74
+ attr -> sample_period = 0 ;
75
+ }
76
+ if ((term_types & (1 << EVSEL__CONFIG_TERM_OVERWRITE )) == 0 )
77
+ attr -> write_backward = 0 ;
60
78
61
79
/*
62
80
* We don't get a sample for slave events, we make them when delivering
0 commit comments