| @@ -127,6 +127,9 @@ static void test_perf_event_all_cpu(struct perf_event_attr *attr) · 126 unmodified lines |
| 127 | int *pmu_fd = malloc(nr_cpus * sizeof(int)); | 127 | int *pmu_fd = malloc(nr_cpus * sizeof(int)); |
| 128 | int i, error = 0; | 128 | int i, error = 0; |
| 129 | | 129 | |
| | 130 | /* system wide perf event, no need to inherit */ |
| | 131 | attr->inherit = 0; |
| | 132 | |
| 130 | /* open perf_event on all cpus */ | 133 | /* open perf_event on all cpus */ |
| 131 | for (i = 0; i < nr_cpus; i++) { | 134 | for (i = 0; i < nr_cpus; i++) { |
| 132 | pmu_fd[i] = sys_perf_event_open(attr, -1, i, -1, 0); | 135 | pmu_fd[i] = sys_perf_event_open(attr, -1, i, -1, 0); |
| @@ -154,6 +157,11 @@ static void test_perf_event_task(struct perf_event_attr *attr) · 21 unmodified lines |
| 154 | { | 157 | { |
| 155 | int pmu_fd; | 158 | int pmu_fd; |
| 156 | | 159 | |
| | 160 | /* per task perf event, enable inherit so the "dd ..." command can be traced properly. |
| | 161 | * Enabling inherit will cause bpf_perf_prog_read_time helper failure. |
| | 162 | */ |
| | 163 | attr->inherit = 1; |
| | 164 | |
| 157 | /* open task bound event */ | 165 | /* open task bound event */ |
| 158 | pmu_fd = sys_perf_event_open(attr, 0, -1, -1, 0); | 166 | pmu_fd = sys_perf_event_open(attr, 0, -1, -1, 0); |
| 159 | if (pmu_fd < 0) { | 167 | if (pmu_fd < 0) { |
| @@ -175,14 +183,12 @@ static void test_bpf_perf_event(void) · 15 unmodified lines |
| 175 | .freq = 1, | 183 | .freq = 1, |
| 176 | .type = PERF_TYPE_HARDWARE, | 184 | .type = PERF_TYPE_HARDWARE, |
| 177 | .config = PERF_COUNT_HW_CPU_CYCLES, | 185 | .config = PERF_COUNT_HW_CPU_CYCLES, |
| 178 | .inherit = 1, | | |
| 179 | }; | 186 | }; |
| 180 | struct perf_event_attr attr_type_sw = { | 187 | struct perf_event_attr attr_type_sw = { |
| 181 | .sample_freq = SAMPLE_FREQ, | 188 | .sample_freq = SAMPLE_FREQ, |
| 182 | .freq = 1, | 189 | .freq = 1, |
| 183 | .type = PERF_TYPE_SOFTWARE, | 190 | .type = PERF_TYPE_SOFTWARE, |
| 184 | .config = PERF_COUNT_SW_CPU_CLOCK, | 191 | .config = PERF_COUNT_SW_CPU_CLOCK, |
| 185 | .inherit = 1, | | |
| 186 | }; | 192 | }; |
| 187 | struct perf_event_attr attr_hw_cache_l1d = { | 193 | struct perf_event_attr attr_hw_cache_l1d = { |
| 188 | .sample_freq = SAMPLE_FREQ, | 194 | .sample_freq = SAMPLE_FREQ, |
| @@ -192,7 +198,6 @@ static void test_bpf_perf_event(void) · 3 unmodified lines |
| 192 | PERF_COUNT_HW_CACHE_L1D | | 198 | PERF_COUNT_HW_CACHE_L1D | |
| 193 | (PERF_COUNT_HW_CACHE_OP_READ << 8) | | 199 | (PERF_COUNT_HW_CACHE_OP_READ << 8) | |
| 194 | (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), | 200 | (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), |
| 195 | .inherit = 1, | | |
| 196 | }; | 201 | }; |
| 197 | struct perf_event_attr attr_hw_cache_branch_miss = { | 202 | struct perf_event_attr attr_hw_cache_branch_miss = { |
| 198 | .sample_freq = SAMPLE_FREQ, | 203 | .sample_freq = SAMPLE_FREQ, |
| @@ -202,7 +207,6 @@ static void test_bpf_perf_event(void) · 3 unmodified lines |
| 202 | PERF_COUNT_HW_CACHE_BPU | | 207 | PERF_COUNT_HW_CACHE_BPU | |
| 203 | (PERF_COUNT_HW_CACHE_OP_READ << 8) | | 208 | (PERF_COUNT_HW_CACHE_OP_READ << 8) | |
| 204 | (PERF_COUNT_HW_CACHE_RESULT_MISS << 16), | 209 | (PERF_COUNT_HW_CACHE_RESULT_MISS << 16), |
| 205 | .inherit = 1, | | |
| 206 | }; | 210 | }; |
| 207 | struct perf_event_attr attr_type_raw = { | 211 | struct perf_event_attr attr_type_raw = { |
| 208 | .sample_freq = SAMPLE_FREQ, | 212 | .sample_freq = SAMPLE_FREQ, |
| @@ -210,7 +214,6 @@ static void test_bpf_perf_event(void) · 1 unmodified line |
| 210 | .type = PERF_TYPE_RAW, | 214 | .type = PERF_TYPE_RAW, |
| 211 | /* Intel Instruction Retired */ | 215 | /* Intel Instruction Retired */ |
| 212 | .config = 0xc0, | 216 | .config = 0xc0, |
| 213 | .inherit = 1, | | |
| 214 | }; | 217 | }; |
| 215 | | 218 | |
| 216 | printf("Test HW_CPU_CYCLES\n"); | 219 | printf("Test HW_CPU_CYCLES\n"); |