On 2/06/21 3:38 pm, Leo Yan wrote:
Hi Adrain,
On Wed, Jun 02, 2021 at 02:18:47PM +0300, Adrian Hunter wrote:
On 2/06/21 1:30 pm, Leo Yan wrote:
Since the 64-bit atomicity is not promised in 32-bit perf, directly report the error and bail out for this case.
Now only applies on x86_64 and Arm64 platforms.
Suggested-by: Adrian Hunter adrian.hunter@intel.com
Maybe we can do better for the compat case.
We can assume the upper 32-bits change very seldom, and always increase. So for the 'read' case:
u64 first, second, last; u64 mask = (u64)((u32)-1) << 32;
do { first = READ_ONCE(pc->aux_head); rmb(); second = READ_ONCE(pc->aux_head); rmb(); last = READ_ONCE(pc->aux_head); } while ((first & mask) != (last & mask)); return second;
For the write case, we can cause a fatal error only if the new tail has non-zero upper 32-bits. That gives up to 4GiB of data before aborting:
if (tail & mask) return -1; smp_mb(); WRITE_ONCE(pc->aux_tail, tail);
Seems to me, it's pointless to only support aux_head for 64-bit and support aux_tail for 32-bit. I understand this can be helpful for the snapshot mode which only uses aux_head, but it still fails to support the normal case for AUX ring buffer using 64-bit head/tail.
I am not sure why you say it is pointless. 'perf record' would still be able to capture up to 4GiB of data. Do you mean you usually capture more than 4GiB of data?
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.