aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_counter.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r--kernel/perf_counter.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 23614adab475..02994a719e27 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1753,6 +1753,14 @@ int perf_counter_task_disable(void)
1753 return 0; 1753 return 0;
1754} 1754}
1755 1755
1756static int perf_counter_index(struct perf_counter *counter)
1757{
1758 if (counter->state != PERF_COUNTER_STATE_ACTIVE)
1759 return 0;
1760
1761 return counter->hw.idx + 1 - PERF_COUNTER_INDEX_OFFSET;
1762}
1763
1756/* 1764/*
1757 * Callers need to ensure there can be no nesting of this function, otherwise 1765 * Callers need to ensure there can be no nesting of this function, otherwise
1758 * the seqlock logic goes bad. We can not serialize this because the arch 1766 * the seqlock logic goes bad. We can not serialize this because the arch
@@ -1777,7 +1785,7 @@ void perf_counter_update_userpage(struct perf_counter *counter)
1777 preempt_disable(); 1785 preempt_disable();
1778 ++userpg->lock; 1786 ++userpg->lock;
1779 barrier(); 1787 barrier();
1780 userpg->index = counter->hw.idx; 1788 userpg->index = perf_counter_index(counter);
1781 userpg->offset = atomic64_read(&counter->count); 1789 userpg->offset = atomic64_read(&counter->count);
1782 if (counter->state == PERF_COUNTER_STATE_ACTIVE) 1790 if (counter->state == PERF_COUNTER_STATE_ACTIVE)
1783 userpg->offset -= atomic64_read(&counter->hw.prev_count); 1791 userpg->offset -= atomic64_read(&counter->hw.prev_count);