Commit bdae2a0
perf/core: fix userpage->time_enabled of inactive events
[ Upstream commit f792565 ]
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.com
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 57c7ca3 commit bdae2a0
2 files changed
Lines changed: 33 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
686 | 688 | | |
687 | 689 | | |
688 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3695 | 3695 | | |
3696 | 3696 | | |
3697 | 3697 | | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
3698 | 3721 | | |
3699 | 3722 | | |
3700 | 3723 | | |
| |||
3713 | 3736 | | |
3714 | 3737 | | |
3715 | 3738 | | |
| 3739 | + | |
3716 | 3740 | | |
3717 | 3741 | | |
3718 | 3742 | | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
3719 | 3747 | | |
3720 | | - | |
3721 | | - | |
3722 | | - | |
3723 | | - | |
3724 | 3748 | | |
3725 | 3749 | | |
3726 | 3750 | | |
| |||
6239 | 6263 | | |
6240 | 6264 | | |
6241 | 6265 | | |
| 6266 | + | |
| 6267 | + | |
6242 | 6268 | | |
6243 | 6269 | | |
6244 | 6270 | | |
| |||
0 commit comments