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