Commit 32671e3
Peter Zijlstra
perf: Disallow mis-matched inherited group reads
Because group consistency is non-atomic between parent (filedesc) and children
(inherited) events, it is possible for PERF_FORMAT_GROUP read() to try and sum
non-matching counter groups -- with non-sensical results.
Add group_generation to distinguish the case where a parent group removes and
adds an event and thus has the same number, but a different configuration of
events as inherited groups.
This became a problem when commit fa8c269 ("perf/core: Invert
perf_read_group() loops") flipped the order of child_list and sibling_list.
Previously it would iterate the group (sibling_list) first, and for each
sibling traverse the child_list. In this order, only the group composition of
the parent is relevant. By flipping the order the group composition of the
child (inherited) events becomes an issue and the mis-match in group
composition becomes evident.
That said; even prior to this commit, while reading of a group that is not
equally inherited was not broken, it still made no sense.
(Ab)use ECHILD as error return to indicate issues with child process group
composition.
Fixes: fa8c269 ("perf/core: Invert perf_read_group() loops")
Reported-by: Budimir Markovic <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]1 parent 5872080 commit 32671e3
2 files changed
+34
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
| 707 | + | |
707 | 708 | | |
708 | 709 | | |
709 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1954 | 1954 | | |
1955 | 1955 | | |
1956 | 1956 | | |
| 1957 | + | |
1957 | 1958 | | |
1958 | 1959 | | |
1959 | 1960 | | |
| |||
2144 | 2145 | | |
2145 | 2146 | | |
2146 | 2147 | | |
| 2148 | + | |
2147 | 2149 | | |
2148 | 2150 | | |
2149 | 2151 | | |
| |||
5440 | 5442 | | |
5441 | 5443 | | |
5442 | 5444 | | |
5443 | | - | |
| 5445 | + | |
5444 | 5446 | | |
5445 | 5447 | | |
5446 | 5448 | | |
| |||
5450 | 5452 | | |
5451 | 5453 | | |
5452 | 5454 | | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
| 5458 | + | |
| 5459 | + | |
| 5460 | + | |
| 5461 | + | |
| 5462 | + | |
| 5463 | + | |
| 5464 | + | |
| 5465 | + | |
| 5466 | + | |
| 5467 | + | |
| 5468 | + | |
| 5469 | + | |
| 5470 | + | |
| 5471 | + | |
| 5472 | + | |
| 5473 | + | |
| 5474 | + | |
| 5475 | + | |
| 5476 | + | |
| 5477 | + | |
| 5478 | + | |
| 5479 | + | |
| 5480 | + | |
| 5481 | + | |
5453 | 5482 | | |
5454 | 5483 | | |
5455 | 5484 | | |
| |||
5483 | 5512 | | |
5484 | 5513 | | |
5485 | 5514 | | |
| 5515 | + | |
5486 | 5516 | | |
5487 | | - | |
| 5517 | + | |
5488 | 5518 | | |
5489 | 5519 | | |
5490 | 5520 | | |
| |||
5503 | 5533 | | |
5504 | 5534 | | |
5505 | 5535 | | |
5506 | | - | |
5507 | | - | |
5508 | | - | |
5509 | | - | |
5510 | 5536 | | |
5511 | 5537 | | |
5512 | 5538 | | |
| |||
13346 | 13372 | | |
13347 | 13373 | | |
13348 | 13374 | | |
| 13375 | + | |
13349 | 13376 | | |
13350 | 13377 | | |
13351 | 13378 | | |
| |||
0 commit comments