Messages in this thread | | | Date | Wed, 9 Jun 2021 16:57:41 +0800 | From | Leo Yan <> | Subject | Re: [PATCH v2 8/8] perf record: Directly bail out for compat case |
| |
Hi Adrian,
On Wed, Jun 09, 2021 at 11:23:25AM +0300, Adrian Hunter wrote:
[...]
> >> I was thinking we would separate out the compat case: > >> > >> #if BITS_PER_LONG == 32 > >> if (kernel_is_64_bit) > >> return compat_auxtrace_mmap__[read_head/write_tail]() > >> #endif > >> > >> So the non-compat cases would not be affected. > > > > Because I don't want to introduce the complexity for read/write head > > and tail, and we also need to handle the same issue for the perf ring > > buffer. So how about below change? > > > > The main idea for below change is it allows the perf to run normally > > on the compat mode and exitly if detects the buffer head is close to > > the low 32-bit's overflow: when detect the low 32-bit value is bigger > > than 0xf0000000 (so we have 256MiB margin to the overflow), it reports > > error and exit. > > > > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c > > index 1b4091a3b508..2a9965bfeab4 100644 > > --- a/tools/perf/util/auxtrace.c > > +++ b/tools/perf/util/auxtrace.c > > @@ -1693,6 +1693,14 @@ static int __auxtrace_mmap__read(struct mmap *map, > > pr_debug3("auxtrace idx %d old %#"PRIx64" head %#"PRIx64" diff %#"PRIx64"\n", > > mm->idx, old, head, head - old); > > > > +#ifdef BITS_PER_LONG == 32 > > + if (kernel_is_64bit() && head >= 0xf0000000) { > > You are assuming the head never increases by more than 256MiB which > means you should limit the buffer size to 256MiB maximum. > > To me this seems a bit too far from an ideal solution. > > I would have thought separating out the compat case makes things > simpler to understand.
Agreed. I will follow up the suggestions to add compat variants for accessing AUX head and tail, and will distinguish compat case with global env variable for 64-bit kernel.
After get ready, will send out for review. Thanks a lot for suggestions!
Leo
| |