Message ID | 20210711104105.505728-8-leo.yan@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | perf: Refine barriers for AUX ring buffer | expand |
On 11/07/21 1:41 pm, Leo Yan wrote: > Since the function auxtrace_mmap__read_snapshot_head() is exactly same > with auxtrace_mmap__read_head(), whether the session is in snapshot mode > or not, it's unified to use function auxtrace_mmap__read_head() for > reading AUX buffer head. > > And the function auxtrace_mmap__read_snapshot_head() is unused so this > patch removes it. > > Signed-off-by: Leo Yan <leo.yan@linaro.org> > --- > tools/perf/util/auxtrace.c | 5 ++--- > tools/perf/util/auxtrace.h | 10 ---------- > 2 files changed, 2 insertions(+), 13 deletions(-) > > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c > index cb19669d2a5b..7958e17229ea 100644 > --- a/tools/perf/util/auxtrace.c > +++ b/tools/perf/util/auxtrace.c > @@ -1686,13 +1686,12 @@ static int __auxtrace_mmap__read(struct mmap *map, > union perf_event ev; > void *data1, *data2; > > + head = auxtrace_mmap__read_head(mm); > + > if (snapshot) { > - head = auxtrace_mmap__read_snapshot_head(mm); > if (auxtrace_record__find_snapshot(itr, mm->idx, mm, data, > &head, &old)) That leaves a nested 'if' which is not kernel style i.e. could be if (snapshot && auxtrace_record__find_snapshot(itr, mm->idx, mm, data, &head, &old)) > return -1; > - } else { > - head = auxtrace_mmap__read_head(mm); > } > > if (old == head) > diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h > index 4f9176368134..d68a5e80b217 100644 > --- a/tools/perf/util/auxtrace.h > +++ b/tools/perf/util/auxtrace.h > @@ -440,16 +440,6 @@ struct auxtrace_cache; > > #ifdef HAVE_AUXTRACE_SUPPORT > > -static inline u64 auxtrace_mmap__read_snapshot_head(struct auxtrace_mmap *mm) > -{ > - struct perf_event_mmap_page *pc = mm->userpg; > - u64 head = READ_ONCE(pc->aux_head); > - > - /* Ensure all reads are done after we read the head */ > - smp_rmb(); > - return head; > -} > - > static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm) > { > struct perf_event_mmap_page *pc = mm->userpg; >
On Mon, Jul 12, 2021 at 05:32:11PM +0300, Adrian Hunter wrote: [...] > > --- a/tools/perf/util/auxtrace.c > > +++ b/tools/perf/util/auxtrace.c > > @@ -1686,13 +1686,12 @@ static int __auxtrace_mmap__read(struct mmap *map, > > union perf_event ev; > > void *data1, *data2; > > > > + head = auxtrace_mmap__read_head(mm); > > + > > if (snapshot) { > > - head = auxtrace_mmap__read_snapshot_head(mm); > > if (auxtrace_record__find_snapshot(itr, mm->idx, mm, data, > > &head, &old)) > > That leaves a nested 'if' which is not kernel style i.e. could be > > if (snapshot && > auxtrace_record__find_snapshot(itr, mm->idx, mm, data, &head, &old)) Will refine in next spin, thanks for suggestion! > > return -1; > > - } else { > > - head = auxtrace_mmap__read_head(mm); > > } > > > > if (old == head)
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index cb19669d2a5b..7958e17229ea 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1686,13 +1686,12 @@ static int __auxtrace_mmap__read(struct mmap *map, union perf_event ev; void *data1, *data2; + head = auxtrace_mmap__read_head(mm); + if (snapshot) { - head = auxtrace_mmap__read_snapshot_head(mm); if (auxtrace_record__find_snapshot(itr, mm->idx, mm, data, &head, &old)) return -1; - } else { - head = auxtrace_mmap__read_head(mm); } if (old == head) diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 4f9176368134..d68a5e80b217 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -440,16 +440,6 @@ struct auxtrace_cache; #ifdef HAVE_AUXTRACE_SUPPORT -static inline u64 auxtrace_mmap__read_snapshot_head(struct auxtrace_mmap *mm) -{ - struct perf_event_mmap_page *pc = mm->userpg; - u64 head = READ_ONCE(pc->aux_head); - - /* Ensure all reads are done after we read the head */ - smp_rmb(); - return head; -} - static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm) { struct perf_event_mmap_page *pc = mm->userpg;
Since the function auxtrace_mmap__read_snapshot_head() is exactly same with auxtrace_mmap__read_head(), whether the session is in snapshot mode or not, it's unified to use function auxtrace_mmap__read_head() for reading AUX buffer head. And the function auxtrace_mmap__read_snapshot_head() is unused so this patch removes it. Signed-off-by: Leo Yan <leo.yan@linaro.org> --- tools/perf/util/auxtrace.c | 5 ++--- tools/perf/util/auxtrace.h | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-)