trace-cmd: question about explicit host endianness setting
Wenjun Huo <[email protected]> Tue, 23 Dec 2025 22:42:21 +0800
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
Dear Tracers, While reading the trace-cmd code, I noticed a detail in tracecmd_alloc_fd() regarding endianness handling and wanted to double-check my understanding. In tracecmd_alloc_fd(), after tep_alloc() and plugin loading, trace-cmd explicitly sets both file and local endianness: tep_set_file_bigendian(handle->pevent, buf[0]); tep_set_local_bigendian(handle->pevent, tracecmd_host_bigendian()); I understand that setting the file endianness here is required, since it is read from the trace file header. For the local/host endianness, tep_alloc() already initializes host_bigendian via tep_is_bigendian(), and in the common case tracecmd_host_bigendian() resolves to the same value. So in practice this explicit call usually does not change the value. My understanding is that this is intentional, and that the call to tep_set_local_bigendian() serves as an explicit binding step, making it clear that trace-cmd confirms the local execution endianness after parsing the trace header and loading plugins, rather than relying on tep_alloc() defaults. Could you please confirm if this interpretation is correct, and whether this explicit setting is mainly for clarity / defensive API usage rather than functional necessity? If maintainers think there is a better way to clarify or improve this behavior (for example via comments, documentation, or code adjustments), I would be very happy to help by preparing and sending a patch based on your guidance. Thanks for your time. Best regards, Wenjun Huo