Commit f792565
perf/core: fix userpage->time_enabled of inactive events
Users of rdpmc rely on the mmapped user page to calculate accurate
time_enabled. Currently, userpage->time_enabled is only updated when the
event is added to the pmu. As a result, inactive event (due to counter
multiplexing) does not have accurate userpage->time_enabled. This can
be reproduced with something like:
/* open 20 task perf_event "cycles", to create multiplexing */
fd = perf_event_open(); /* open task perf_event "cycles" */
userpage = mmap(fd); /* use mmap and rdmpc */
while (true) {
time_enabled_mmap = xxx; /* use logic in perf_event_mmap_page */
time_enabled_read = read(fd).time_enabled;
if (time_enabled_mmap > time_enabled_read)
BUG();
}
Fix this by updating userpage for inactive events in merge_sched_in.
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reported-and-tested-by: Lucian Grijincu <lucian@fb.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210929194313.2398474-1-songliubraving@fb.com1 parent ecc2123 commit f792565
2 files changed
+33
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
686 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
687 | 689 | | |
688 | 690 | | |
689 | 691 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3707 | 3707 | | |
3708 | 3708 | | |
3709 | 3709 | | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
3710 | 3733 | | |
3711 | 3734 | | |
3712 | 3735 | | |
| |||
3725 | 3748 | | |
3726 | 3749 | | |
3727 | 3750 | | |
| 3751 | + | |
3728 | 3752 | | |
3729 | 3753 | | |
3730 | 3754 | | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
3731 | 3759 | | |
3732 | | - | |
3733 | | - | |
3734 | | - | |
3735 | | - | |
3736 | 3760 | | |
3737 | 3761 | | |
3738 | 3762 | | |
| |||
6324 | 6348 | | |
6325 | 6349 | | |
6326 | 6350 | | |
| 6351 | + | |
| 6352 | + | |
6327 | 6353 | | |
6328 | 6354 | | |
6329 | 6355 | | |
| |||
0 commit comments