Re: [PATCH 01/16] perf: Unified API to record selective sets of arch registers

From: Stephane Eranian
Date: Thu May 24 2012 - 08:13:18 EST


2012/5/24 Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>:
> On Wed, 2012-05-23 at 21:32 +0200, Jiri Olsa wrote:
>> +enum perf_event_x86_32_regs {
>> + Â Â Â PERF_X86_32_REG_EAX,
>> + Â Â Â PERF_X86_32_REG_EBX,
>> + Â Â Â PERF_X86_32_REG_ECX,
>> + Â Â Â PERF_X86_32_REG_EDX,
>> + Â Â Â PERF_X86_32_REG_ESI,
>> + Â Â Â PERF_X86_32_REG_EDI,
>> + Â Â Â PERF_X86_32_REG_EBP,
>> + Â Â Â PERF_X86_32_REG_ESP,
>> + Â Â Â PERF_X86_32_REG_EIP,
>> + Â Â Â PERF_X86_32_REG_FLAGS,
>> + Â Â Â PERF_X86_32_REG_CS,
>> + Â Â Â PERF_X86_32_REG_DS,
>> + Â Â Â PERF_X86_32_REG_ES,
>> + Â Â Â PERF_X86_32_REG_FS,
>> + Â Â Â PERF_X86_32_REG_GS,
>> +
>> + Â Â Â /* Non ABI */
>> + Â Â Â PERF_X86_32_REG_MAX,
>> +};
>
>> +enum perf_event_x86_64_regs {
>> + Â Â Â PERF_X86_64_REG_RAX,
>> + Â Â Â PERF_X86_64_REG_RBX,
>> + Â Â Â PERF_X86_64_REG_RCX,
>> + Â Â Â PERF_X86_64_REG_RDX,
>> + Â Â Â PERF_X86_64_REG_RSI,
>> + Â Â Â PERF_X86_64_REG_RDI,
>> + Â Â Â PERF_X86_64_REG_R8,
>> + Â Â Â PERF_X86_64_REG_R9,
>> + Â Â Â PERF_X86_64_REG_R10,
>> + Â Â Â PERF_X86_64_REG_R11,
>> + Â Â Â PERF_X86_64_REG_R12,
>> + Â Â Â PERF_X86_64_REG_R13,
>> + Â Â Â PERF_X86_64_REG_R14,
>> + Â Â Â PERF_X86_64_REG_R15,
>> + Â Â Â PERF_X86_64_REG_RBP,
>> + Â Â Â PERF_X86_64_REG_RSP,
>> + Â Â Â PERF_X86_64_REG_RIP,
>> + Â Â Â PERF_X86_64_REG_FLAGS,
>> + Â Â Â PERF_X86_64_REG_CS,
>> + Â Â Â PERF_X86_64_REG_SS,
>> +
>> + Â Â Â /* Non ABI */
>> + Â Â Â PERF_X86_64_REG_MAX,
>> +};
>
> So why bother with two different APIs? Why not have only the x86_64 one
> and maybe add a warning/error/fail whatever when x86_64 regs are
> selected on i386/compat tasks.
>
>
I agree with Peter here especially after our earlier discussion about how
to handle 32-bit ABI threads on a 64-bit ABI kernel. You should simply
fill in the record with zeroes when the register does not exists. You cannot
predict what will be sampled in system-wide mode.

The only sanity check you can do is on 32-bit ABI kernel, reject any 64-bit
ABI only regs but then that would require invoking arch specific code from
perf_copy_attr()....
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/