History

perf/core: Add PERF_SAMPLE_WEIGHT_STRUCT

Current PERF_SAMPLE_WEIGHT sample type is very useful to expresses the cost of an action represented by the sample. This allows the profiler to scale the samples to be more informative to the programmer. It could also help to locate a hotspot, e.g., when profiling by memory latencies, the expensive load appear higher up in the histograms. But current PERF_SAMPLE_WEIGHT sample type is solely determined by one factor. This could be a problem, if users want two or more factors to contribute to the weight. For example, Golden Cove core PMU can provide both the instruction latency and the cache Latency information as factors for the memory profiling. For current X86 platforms, although meminfo::latency is defined as a u64, only the lower 32 bits include the valid data in practice (No memory access could last than 4G cycles). The higher 32 bits can be used to store new factors. Add a new sample type, PERF_SAMPLE_WEIGHT_STRUCT, to indicate the new sample weight structure. It shares the same space as the PERF_SAMPLE_WEIGHT sample type. Users can apply either the PERF_SAMPLE_WEIGHT sample type or the PERF_SAMPLE_WEIGHT_STRUCT sample type to retrieve the sample weight, but they cannot apply both sample types simultaneously. Currently, only X86 and PowerPC use the PERF_SAMPLE_WEIGHT sample type. - For PowerPC, there is nothing changed for the PERF_SAMPLE_WEIGHT sample type. There is no effect for the new PERF_SAMPLE_WEIGHT_STRUCT sample type. PowerPC can re-struct the weight field similarly later. - For X86, the same value will be dumped for the PERF_SAMPLE_WEIGHT sample type or the PERF_SAMPLE_WEIGHT_STRUCT sample type for now. The following patches will apply the new factors for the PERF_SAMPLE_WEIGHT_STRUCT sample type. The field in the union perf_sample_weight should be shared among different architectures. A generic name is required, but it's hard to abstract a name that applies to all architectures. For example, on X86, the fields are to store all kinds of latency. While on PowerPC, it stores MMCRA[TECX/TECM], which should not be latency. So a general name prefix 'var$NUM' is used here.

Kan Liang committed 5 years ago

Commit 2a6c6b71 parent 3daa96d5 files · +59 −17Browse files

Showing the changes to include/uapi (1 of 5 files). Show all

Unified · Split

include/uapi/linux/perf_event.h+40−2
@@ -145,12 +145,14 @@ enum perf_event_sample_format { · 144 unmodified lines
145 PERF_SAMPLE_CGROUP = 1U << 21,145 PERF_SAMPLE_CGROUP = 1U << 21,
146 PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22,146 PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22,
147 PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,147 PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,
148 PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24,
148 149
149 PERF_SAMPLE_MAX = 1U << 24, /* non-ABI */150 PERF_SAMPLE_MAX = 1U << 25, /* non-ABI */
150 151
151 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */152 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */
152};153};
153 154
155#define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT)
154/*156/*
155 * values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set157 * values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set
156 *158 *
@@ -890,7 +892,24 @@ enum perf_event_type { · 733 unmodified lines
890 * char data[size];892 * char data[size];
891 * u64 dyn_size; } && PERF_SAMPLE_STACK_USER893 * u64 dyn_size; } && PERF_SAMPLE_STACK_USER
892 *894 *
893 * { u64 weight; } && PERF_SAMPLE_WEIGHT895 * { union perf_sample_weight
896 * {
897 * u64 full; && PERF_SAMPLE_WEIGHT
898 * #if defined(__LITTLE_ENDIAN_BITFIELD)
899 * struct {
900 * u32 var1_dw;
901 * u16 var2_w;
902 * u16 var3_w;
903 * } && PERF_SAMPLE_WEIGHT_STRUCT
904 * #elif defined(__BIG_ENDIAN_BITFIELD)
905 * struct {
906 * u16 var3_w;
907 * u16 var2_w;
908 * u32 var1_dw;
909 * } && PERF_SAMPLE_WEIGHT_STRUCT
910 * #endif
911 * }
912 * }
894 * { u64 data_src; } && PERF_SAMPLE_DATA_SRC913 * { u64 data_src; } && PERF_SAMPLE_DATA_SRC
895 * { u64 transaction; } && PERF_SAMPLE_TRANSACTION914 * { u64 transaction; } && PERF_SAMPLE_TRANSACTION
896 * { u64 abi; # enum perf_sample_regs_abi915 * { u64 abi; # enum perf_sample_regs_abi
@@ -1248,4 +1267,23 @@ struct perf_branch_entry { · 351 unmodified lines
1248 reserved:40;1267 reserved:40;
1249};1268};
1250 1269
1270union perf_sample_weight {
1271 __u64 full;
1272#if defined(__LITTLE_ENDIAN_BITFIELD)
1273 struct {
1274 __u32 var1_dw;
1275 __u16 var2_w;
1276 __u16 var3_w;
1277 };
1278#elif defined(__BIG_ENDIAN_BITFIELD)
1279 struct {
1280 __u16 var3_w;
1281 __u16 var2_w;
1282 __u32 var1_dw;
1283 };
1284#else
1285#error "Unknown endianness"
1286#endif
1287};
1288
1251#endif /* _UAPI_LINUX_PERF_EVENT_H */1289#endif /* _UAPI_LINUX_PERF_EVENT_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t