Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'perf-tools-fixes-for-v6.0-2022-08-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

- Fix alignment for cpu map masks in event encoding.

- Support reading PERF_FORMAT_LOST, perf tool counterpart for a feature
that was added in this merge window.

- Sync perf tools copies of kernel headers: socket, msr-index, fscrypt,
cpufeatures, i915_drm, kvm, vhost, perf_event.

* tag 'perf-tools-fixes-for-v6.0-2022-08-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
perf tools: Support reading PERF_FORMAT_LOST
libperf: Add a test case for read formats
libperf: Handle read format in perf_evsel__read()
tools headers UAPI: Sync linux/perf_event.h with the kernel sources
tools headers UAPI: Sync x86's asm/kvm.h with the kernel sources
tools headers UAPI: Sync KVM's vmx.h header with the kernel sources
tools include UAPI: Sync linux/vhost.h with the kernel sources
tools headers kvm s390: Sync headers with the kernel sources
tools headers UAPI: Sync linux/kvm.h with the kernel sources
tools headers UAPI: Sync drm/i915_drm.h with the kernel sources
tools headers cpufeatures: Sync with the kernel sources
tools headers UAPI: Sync linux/fscrypt.h with the kernel sources
tools arch x86: Sync the msr-index.h copy with the kernel sources
perf beauty: Update copy of linux/socket.h with the kernel sources
perf cpumap: Fix alignment for masks in event encoding
perf cpumap: Compute mask size in constant time
perf cpumap: Synthetic events and const/static
perf cpumap: Const map for max()

+982 -241
+1
tools/arch/s390/include/uapi/asm/kvm.h
··· 74 74 #define KVM_S390_VM_CRYPTO 2 75 75 #define KVM_S390_VM_CPU_MODEL 3 76 76 #define KVM_S390_VM_MIGRATION 4 77 + #define KVM_S390_VM_CPU_TOPOLOGY 5 77 78 78 79 /* kvm attributes for mem_ctrl */ 79 80 #define KVM_S390_VM_MEM_ENABLE_CMMA 0
+4 -2
tools/arch/x86/include/asm/cpufeatures.h
··· 219 219 #define X86_FEATURE_IBRS ( 7*32+25) /* Indirect Branch Restricted Speculation */ 220 220 #define X86_FEATURE_IBPB ( 7*32+26) /* Indirect Branch Prediction Barrier */ 221 221 #define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */ 222 - #define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 or above (Zen) */ 222 + #define X86_FEATURE_ZEN (7*32+28) /* "" CPU based on Zen microarchitecture */ 223 223 #define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */ 224 224 #define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */ 225 225 #define X86_FEATURE_MSR_IA32_FEAT_CTL ( 7*32+31) /* "" MSR IA32_FEAT_CTL configured */ ··· 303 303 #define X86_FEATURE_RETHUNK (11*32+14) /* "" Use REturn THUNK */ 304 304 #define X86_FEATURE_UNRET (11*32+15) /* "" AMD BTB untrain return */ 305 305 #define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime firmware calls */ 306 - #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17) /* "" Fill RSB on VM-Exit when EIBRS is enabled */ 306 + #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17) /* "" Fill RSB on VM exit when EIBRS is enabled */ 307 307 308 308 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ 309 309 #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ ··· 354 354 #define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ 355 355 #define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */ 356 356 #define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ 357 + #define X86_FEATURE_X2AVIC (15*32+18) /* Virtual x2apic */ 357 358 #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* Virtual SPEC_CTRL */ 358 359 #define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* "" SVME addr check */ 359 360 ··· 458 457 #define X86_BUG_SRBDS X86_BUG(24) /* CPU may leak RNG bits if not mitigated */ 459 458 #define X86_BUG_MMIO_STALE_DATA X86_BUG(25) /* CPU is affected by Processor MMIO Stale Data vulnerabilities */ 460 459 #define X86_BUG_RETBLEED X86_BUG(26) /* CPU is affected by RETBleed */ 460 + #define X86_BUG_EIBRS_PBRSB X86_BUG(27) /* EIBRS is vulnerable to Post Barrier RSB Predictions */ 461 461 462 462 #endif /* _ASM_X86_CPUFEATURES_H */
+8
tools/arch/x86/include/asm/msr-index.h
··· 235 235 #define PERF_CAP_PT_IDX 16 236 236 237 237 #define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6 238 + #define PERF_CAP_PEBS_TRAP BIT_ULL(6) 239 + #define PERF_CAP_ARCH_REG BIT_ULL(7) 240 + #define PERF_CAP_PEBS_FORMAT 0xf00 241 + #define PERF_CAP_PEBS_BASELINE BIT_ULL(14) 242 + #define PERF_CAP_PEBS_MASK (PERF_CAP_PEBS_TRAP | PERF_CAP_ARCH_REG | \ 243 + PERF_CAP_PEBS_FORMAT | PERF_CAP_PEBS_BASELINE) 238 244 239 245 #define MSR_IA32_RTIT_CTL 0x00000570 240 246 #define RTIT_CTL_TRACEEN BIT(0) ··· 398 392 #define MSR_TURBO_ACTIVATION_RATIO 0x0000064C 399 393 400 394 #define MSR_PLATFORM_ENERGY_STATUS 0x0000064D 395 + #define MSR_SECONDARY_TURBO_RATIO_LIMIT 0x00000650 401 396 402 397 #define MSR_PKG_WEIGHTED_CORE_C0_RES 0x00000658 403 398 #define MSR_PKG_ANY_CORE_C0_RES 0x00000659 ··· 1029 1022 #define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x0000048f 1030 1023 #define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490 1031 1024 #define MSR_IA32_VMX_VMFUNC 0x00000491 1025 + #define MSR_IA32_VMX_PROCBASED_CTLS3 0x00000492 1032 1026 1033 1027 /* VMX_BASIC bits and bitmasks */ 1034 1028 #define VMX_BASIC_VMCS_SIZE_SHIFT 32
+8 -2
tools/arch/x86/include/uapi/asm/kvm.h
··· 306 306 struct kvm_pit_channel_state channels[3]; 307 307 }; 308 308 309 - #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 309 + #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 310 + #define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002 310 311 311 312 struct kvm_pit_state2 { 312 313 struct kvm_pit_channel_state channels[3]; ··· 326 325 #define KVM_VCPUEVENT_VALID_SHADOW 0x00000004 327 326 #define KVM_VCPUEVENT_VALID_SMM 0x00000008 328 327 #define KVM_VCPUEVENT_VALID_PAYLOAD 0x00000010 328 + #define KVM_VCPUEVENT_VALID_TRIPLE_FAULT 0x00000020 329 329 330 330 /* Interrupt shadow states */ 331 331 #define KVM_X86_SHADOW_INT_MOV_SS 0x01 ··· 361 359 __u8 smm_inside_nmi; 362 360 __u8 latched_init; 363 361 } smi; 364 - __u8 reserved[27]; 362 + struct { 363 + __u8 pending; 364 + } triple_fault; 365 + __u8 reserved[26]; 365 366 __u8 exception_has_payload; 366 367 __u64 exception_payload; 367 368 }; ··· 439 434 #define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) 440 435 #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) 441 436 #define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5) 437 + #define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6) 442 438 443 439 #define KVM_STATE_NESTED_FORMAT_VMX 0 444 440 #define KVM_STATE_NESTED_FORMAT_SVM 1
+3 -1
tools/arch/x86/include/uapi/asm/vmx.h
··· 91 91 #define EXIT_REASON_UMWAIT 67 92 92 #define EXIT_REASON_TPAUSE 68 93 93 #define EXIT_REASON_BUS_LOCK 74 94 + #define EXIT_REASON_NOTIFY 75 94 95 95 96 #define VMX_EXIT_REASONS \ 96 97 { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ ··· 154 153 { EXIT_REASON_XRSTORS, "XRSTORS" }, \ 155 154 { EXIT_REASON_UMWAIT, "UMWAIT" }, \ 156 155 { EXIT_REASON_TPAUSE, "TPAUSE" }, \ 157 - { EXIT_REASON_BUS_LOCK, "BUS_LOCK" } 156 + { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \ 157 + { EXIT_REASON_NOTIFY, "NOTIFY" } 158 158 159 159 #define VMX_EXIT_REASON_FLAGS \ 160 160 { VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }
+305 -92
tools/include/uapi/drm/i915_drm.h
··· 751 751 752 752 /* Must be kept compact -- no holes and well documented */ 753 753 754 - typedef struct drm_i915_getparam { 754 + /** 755 + * struct drm_i915_getparam - Driver parameter query structure. 756 + */ 757 + struct drm_i915_getparam { 758 + /** @param: Driver parameter to query. */ 755 759 __s32 param; 756 - /* 760 + 761 + /** 762 + * @value: Address of memory where queried value should be put. 763 + * 757 764 * WARNING: Using pointers instead of fixed-size u64 means we need to write 758 765 * compat32 code. Don't repeat this mistake. 759 766 */ 760 767 int __user *value; 761 - } drm_i915_getparam_t; 768 + }; 769 + 770 + /** 771 + * typedef drm_i915_getparam_t - Driver parameter query structure. 772 + * See struct drm_i915_getparam. 773 + */ 774 + typedef struct drm_i915_getparam drm_i915_getparam_t; 762 775 763 776 /* Ioctl to set kernel params: 764 777 */ ··· 1252 1239 __u64 rsvd2; 1253 1240 }; 1254 1241 1242 + /** 1243 + * struct drm_i915_gem_exec_fence - An input or output fence for the execbuf 1244 + * ioctl. 1245 + * 1246 + * The request will wait for input fence to signal before submission. 1247 + * 1248 + * The returned output fence will be signaled after the completion of the 1249 + * request. 1250 + */ 1255 1251 struct drm_i915_gem_exec_fence { 1256 - /** 1257 - * User's handle for a drm_syncobj to wait on or signal. 1258 - */ 1252 + /** @handle: User's handle for a drm_syncobj to wait on or signal. */ 1259 1253 __u32 handle; 1260 1254 1255 + /** 1256 + * @flags: Supported flags are: 1257 + * 1258 + * I915_EXEC_FENCE_WAIT: 1259 + * Wait for the input fence before request submission. 1260 + * 1261 + * I915_EXEC_FENCE_SIGNAL: 1262 + * Return request completion fence as output 1263 + */ 1264 + __u32 flags; 1261 1265 #define I915_EXEC_FENCE_WAIT (1<<0) 1262 1266 #define I915_EXEC_FENCE_SIGNAL (1<<1) 1263 1267 #define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1)) 1264 - __u32 flags; 1265 1268 }; 1266 1269 1267 - /* 1268 - * See drm_i915_gem_execbuffer_ext_timeline_fences. 1269 - */ 1270 - #define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0 1271 - 1272 - /* 1270 + /** 1271 + * struct drm_i915_gem_execbuffer_ext_timeline_fences - Timeline fences 1272 + * for execbuf ioctl. 1273 + * 1273 1274 * This structure describes an array of drm_syncobj and associated points for 1274 1275 * timeline variants of drm_syncobj. It is invalid to append this structure to 1275 1276 * the execbuf if I915_EXEC_FENCE_ARRAY is set. 1276 1277 */ 1277 1278 struct drm_i915_gem_execbuffer_ext_timeline_fences { 1279 + #define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0 1280 + /** @base: Extension link. See struct i915_user_extension. */ 1278 1281 struct i915_user_extension base; 1279 1282 1280 1283 /** 1281 - * Number of element in the handles_ptr & value_ptr arrays. 1284 + * @fence_count: Number of elements in the @handles_ptr & @value_ptr 1285 + * arrays. 1282 1286 */ 1283 1287 __u64 fence_count; 1284 1288 1285 1289 /** 1286 - * Pointer to an array of struct drm_i915_gem_exec_fence of length 1287 - * fence_count. 1290 + * @handles_ptr: Pointer to an array of struct drm_i915_gem_exec_fence 1291 + * of length @fence_count. 1288 1292 */ 1289 1293 __u64 handles_ptr; 1290 1294 1291 1295 /** 1292 - * Pointer to an array of u64 values of length fence_count. Values 1293 - * must be 0 for a binary drm_syncobj. A Value of 0 for a timeline 1294 - * drm_syncobj is invalid as it turns a drm_syncobj into a binary one. 1296 + * @values_ptr: Pointer to an array of u64 values of length 1297 + * @fence_count. 1298 + * Values must be 0 for a binary drm_syncobj. A Value of 0 for a 1299 + * timeline drm_syncobj is invalid as it turns a drm_syncobj into a 1300 + * binary one. 1295 1301 */ 1296 1302 __u64 values_ptr; 1297 1303 }; 1298 1304 1305 + /** 1306 + * struct drm_i915_gem_execbuffer2 - Structure for DRM_I915_GEM_EXECBUFFER2 1307 + * ioctl. 1308 + */ 1299 1309 struct drm_i915_gem_execbuffer2 { 1300 - /** 1301 - * List of gem_exec_object2 structs 1302 - */ 1310 + /** @buffers_ptr: Pointer to a list of gem_exec_object2 structs */ 1303 1311 __u64 buffers_ptr; 1312 + 1313 + /** @buffer_count: Number of elements in @buffers_ptr array */ 1304 1314 __u32 buffer_count; 1305 1315 1306 - /** Offset in the batchbuffer to start execution from. */ 1307 - __u32 batch_start_offset; 1308 - /** Bytes used in batchbuffer from batch_start_offset */ 1309 - __u32 batch_len; 1310 - __u32 DR1; 1311 - __u32 DR4; 1312 - __u32 num_cliprects; 1313 1316 /** 1314 - * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY 1315 - * & I915_EXEC_USE_EXTENSIONS are not set. 1317 + * @batch_start_offset: Offset in the batchbuffer to start execution 1318 + * from. 1319 + */ 1320 + __u32 batch_start_offset; 1321 + 1322 + /** 1323 + * @batch_len: Length in bytes of the batch buffer, starting from the 1324 + * @batch_start_offset. If 0, length is assumed to be the batch buffer 1325 + * object size. 1326 + */ 1327 + __u32 batch_len; 1328 + 1329 + /** @DR1: deprecated */ 1330 + __u32 DR1; 1331 + 1332 + /** @DR4: deprecated */ 1333 + __u32 DR4; 1334 + 1335 + /** @num_cliprects: See @cliprects_ptr */ 1336 + __u32 num_cliprects; 1337 + 1338 + /** 1339 + * @cliprects_ptr: Kernel clipping was a DRI1 misfeature. 1340 + * 1341 + * It is invalid to use this field if I915_EXEC_FENCE_ARRAY or 1342 + * I915_EXEC_USE_EXTENSIONS flags are not set. 1316 1343 * 1317 1344 * If I915_EXEC_FENCE_ARRAY is set, then this is a pointer to an array 1318 - * of struct drm_i915_gem_exec_fence and num_cliprects is the length 1319 - * of the array. 1345 + * of &drm_i915_gem_exec_fence and @num_cliprects is the length of the 1346 + * array. 1320 1347 * 1321 1348 * If I915_EXEC_USE_EXTENSIONS is set, then this is a pointer to a 1322 - * single struct i915_user_extension and num_cliprects is 0. 1349 + * single &i915_user_extension and num_cliprects is 0. 1323 1350 */ 1324 1351 __u64 cliprects_ptr; 1352 + 1353 + /** @flags: Execbuf flags */ 1354 + __u64 flags; 1325 1355 #define I915_EXEC_RING_MASK (0x3f) 1326 1356 #define I915_EXEC_DEFAULT (0<<0) 1327 1357 #define I915_EXEC_RENDER (1<<0) ··· 1382 1326 #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */ 1383 1327 #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6) 1384 1328 #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */ 1385 - __u64 flags; 1386 - __u64 rsvd1; /* now used for context info */ 1387 - __u64 rsvd2; 1388 - }; 1389 1329 1390 1330 /** Resets the SO write offset registers for transform feedback on gen7. */ 1391 1331 #define I915_EXEC_GEN7_SOL_RESET (1<<8) ··· 1484 1432 * drm_i915_gem_execbuffer_ext enum. 1485 1433 */ 1486 1434 #define I915_EXEC_USE_EXTENSIONS (1 << 21) 1487 - 1488 1435 #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_USE_EXTENSIONS << 1)) 1436 + 1437 + /** @rsvd1: Context id */ 1438 + __u64 rsvd1; 1439 + 1440 + /** 1441 + * @rsvd2: in and out sync_file file descriptors. 1442 + * 1443 + * When I915_EXEC_FENCE_IN or I915_EXEC_FENCE_SUBMIT flag is set, the 1444 + * lower 32 bits of this field will have the in sync_file fd (input). 1445 + * 1446 + * When I915_EXEC_FENCE_OUT flag is set, the upper 32 bits of this 1447 + * field will have the out sync_file fd (output). 1448 + */ 1449 + __u64 rsvd2; 1450 + }; 1489 1451 1490 1452 #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) 1491 1453 #define i915_execbuffer2_set_context_id(eb2, context) \ ··· 1880 1814 __u32 pad; 1881 1815 }; 1882 1816 1817 + /** 1818 + * struct drm_i915_gem_context_create_ext - Structure for creating contexts. 1819 + */ 1883 1820 struct drm_i915_gem_context_create_ext { 1884 - __u32 ctx_id; /* output: id of new context*/ 1821 + /** @ctx_id: Id of the created context (output) */ 1822 + __u32 ctx_id; 1823 + 1824 + /** 1825 + * @flags: Supported flags are: 1826 + * 1827 + * I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS: 1828 + * 1829 + * Extensions may be appended to this structure and driver must check 1830 + * for those. See @extensions. 1831 + * 1832 + * I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE 1833 + * 1834 + * Created context will have single timeline. 1835 + */ 1885 1836 __u32 flags; 1886 1837 #define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0) 1887 1838 #define I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE (1u << 1) 1888 1839 #define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \ 1889 1840 (-(I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE << 1)) 1841 + 1842 + /** 1843 + * @extensions: Zero-terminated chain of extensions. 1844 + * 1845 + * I915_CONTEXT_CREATE_EXT_SETPARAM: 1846 + * Context parameter to set or query during context creation. 1847 + * See struct drm_i915_gem_context_create_ext_setparam. 1848 + * 1849 + * I915_CONTEXT_CREATE_EXT_CLONE: 1850 + * This extension has been removed. On the off chance someone somewhere 1851 + * has attempted to use it, never re-use this extension number. 1852 + */ 1890 1853 __u64 extensions; 1854 + #define I915_CONTEXT_CREATE_EXT_SETPARAM 0 1855 + #define I915_CONTEXT_CREATE_EXT_CLONE 1 1891 1856 }; 1892 1857 1858 + /** 1859 + * struct drm_i915_gem_context_param - Context parameter to set or query. 1860 + */ 1893 1861 struct drm_i915_gem_context_param { 1862 + /** @ctx_id: Context id */ 1894 1863 __u32 ctx_id; 1864 + 1865 + /** @size: Size of the parameter @value */ 1895 1866 __u32 size; 1867 + 1868 + /** @param: Parameter to set or query */ 1896 1869 __u64 param; 1897 1870 #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 1898 1871 /* I915_CONTEXT_PARAM_NO_ZEROMAP has been removed. On the off chance ··· 2078 1973 #define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd 2079 1974 /* Must be kept compact -- no holes and well documented */ 2080 1975 1976 + /** @value: Context parameter value to be set or queried */ 2081 1977 __u64 value; 2082 1978 }; 2083 1979 ··· 2477 2371 struct i915_engine_class_instance engines[N__]; \ 2478 2372 } __attribute__((packed)) name__ 2479 2373 2374 + /** 2375 + * struct drm_i915_gem_context_create_ext_setparam - Context parameter 2376 + * to set or query during context creation. 2377 + */ 2480 2378 struct drm_i915_gem_context_create_ext_setparam { 2481 - #define I915_CONTEXT_CREATE_EXT_SETPARAM 0 2379 + /** @base: Extension link. See struct i915_user_extension. */ 2482 2380 struct i915_user_extension base; 2381 + 2382 + /** 2383 + * @param: Context parameter to set or query. 2384 + * See struct drm_i915_gem_context_param. 2385 + */ 2483 2386 struct drm_i915_gem_context_param param; 2484 2387 }; 2485 - 2486 - /* This API has been removed. On the off chance someone somewhere has 2487 - * attempted to use it, never re-use this extension number. 2488 - */ 2489 - #define I915_CONTEXT_CREATE_EXT_CLONE 1 2490 2388 2491 2389 struct drm_i915_gem_context_destroy { 2492 2390 __u32 ctx_id; 2493 2391 __u32 pad; 2494 2392 }; 2495 2393 2496 - /* 2394 + /** 2395 + * struct drm_i915_gem_vm_control - Structure to create or destroy VM. 2396 + * 2497 2397 * DRM_I915_GEM_VM_CREATE - 2498 2398 * 2499 2399 * Create a new virtual memory address space (ppGTT) for use within a context ··· 2509 2397 * The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is 2510 2398 * returned in the outparam @id. 2511 2399 * 2512 - * No flags are defined, with all bits reserved and must be zero. 2513 - * 2514 2400 * An extension chain maybe provided, starting with @extensions, and terminated 2515 2401 * by the @next_extension being 0. Currently, no extensions are defined. 2516 2402 * 2517 2403 * DRM_I915_GEM_VM_DESTROY - 2518 2404 * 2519 - * Destroys a previously created VM id, specified in @id. 2405 + * Destroys a previously created VM id, specified in @vm_id. 2520 2406 * 2521 2407 * No extensions or flags are allowed currently, and so must be zero. 2522 2408 */ 2523 2409 struct drm_i915_gem_vm_control { 2410 + /** @extensions: Zero-terminated chain of extensions. */ 2524 2411 __u64 extensions; 2412 + 2413 + /** @flags: reserved for future usage, currently MBZ */ 2525 2414 __u32 flags; 2415 + 2416 + /** @vm_id: Id of the VM created or to be destroyed */ 2526 2417 __u32 vm_id; 2527 2418 }; 2528 2419 ··· 3322 3207 * struct drm_i915_memory_region_info - Describes one region as known to the 3323 3208 * driver. 3324 3209 * 3325 - * Note that we reserve some stuff here for potential future work. As an example 3326 - * we might want expose the capabilities for a given region, which could include 3327 - * things like if the region is CPU mappable/accessible, what are the supported 3328 - * mapping types etc. 3329 - * 3330 - * Note that to extend struct drm_i915_memory_region_info and struct 3331 - * drm_i915_query_memory_regions in the future the plan is to do the following: 3332 - * 3333 - * .. code-block:: C 3334 - * 3335 - * struct drm_i915_memory_region_info { 3336 - * struct drm_i915_gem_memory_class_instance region; 3337 - * union { 3338 - * __u32 rsvd0; 3339 - * __u32 new_thing1; 3340 - * }; 3341 - * ... 3342 - * union { 3343 - * __u64 rsvd1[8]; 3344 - * struct { 3345 - * __u64 new_thing2; 3346 - * __u64 new_thing3; 3347 - * ... 3348 - * }; 3349 - * }; 3350 - * }; 3351 - * 3352 - * With this things should remain source compatible between versions for 3353 - * userspace, even as we add new fields. 3354 - * 3355 3210 * Note this is using both struct drm_i915_query_item and struct drm_i915_query. 3356 3211 * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS 3357 3212 * at &drm_i915_query_item.query_id. ··· 3333 3248 /** @rsvd0: MBZ */ 3334 3249 __u32 rsvd0; 3335 3250 3336 - /** @probed_size: Memory probed by the driver (-1 = unknown) */ 3251 + /** 3252 + * @probed_size: Memory probed by the driver 3253 + * 3254 + * Note that it should not be possible to ever encounter a zero value 3255 + * here, also note that no current region type will ever return -1 here. 3256 + * Although for future region types, this might be a possibility. The 3257 + * same applies to the other size fields. 3258 + */ 3337 3259 __u64 probed_size; 3338 3260 3339 - /** @unallocated_size: Estimate of memory remaining (-1 = unknown) */ 3261 + /** 3262 + * @unallocated_size: Estimate of memory remaining 3263 + * 3264 + * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting. 3265 + * Without this (or if this is an older kernel) the value here will 3266 + * always equal the @probed_size. Note this is only currently tracked 3267 + * for I915_MEMORY_CLASS_DEVICE regions (for other types the value here 3268 + * will always equal the @probed_size). 3269 + */ 3340 3270 __u64 unallocated_size; 3341 3271 3342 - /** @rsvd1: MBZ */ 3343 - __u64 rsvd1[8]; 3272 + union { 3273 + /** @rsvd1: MBZ */ 3274 + __u64 rsvd1[8]; 3275 + struct { 3276 + /** 3277 + * @probed_cpu_visible_size: Memory probed by the driver 3278 + * that is CPU accessible. 3279 + * 3280 + * This will be always be <= @probed_size, and the 3281 + * remainder (if there is any) will not be CPU 3282 + * accessible. 3283 + * 3284 + * On systems without small BAR, the @probed_size will 3285 + * always equal the @probed_cpu_visible_size, since all 3286 + * of it will be CPU accessible. 3287 + * 3288 + * Note this is only tracked for 3289 + * I915_MEMORY_CLASS_DEVICE regions (for other types the 3290 + * value here will always equal the @probed_size). 3291 + * 3292 + * Note that if the value returned here is zero, then 3293 + * this must be an old kernel which lacks the relevant 3294 + * small-bar uAPI support (including 3295 + * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on 3296 + * such systems we should never actually end up with a 3297 + * small BAR configuration, assuming we are able to load 3298 + * the kernel module. Hence it should be safe to treat 3299 + * this the same as when @probed_cpu_visible_size == 3300 + * @probed_size. 3301 + */ 3302 + __u64 probed_cpu_visible_size; 3303 + 3304 + /** 3305 + * @unallocated_cpu_visible_size: Estimate of CPU 3306 + * visible memory remaining. 3307 + * 3308 + * Note this is only tracked for 3309 + * I915_MEMORY_CLASS_DEVICE regions (for other types the 3310 + * value here will always equal the 3311 + * @probed_cpu_visible_size). 3312 + * 3313 + * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable 3314 + * accounting. Without this the value here will always 3315 + * equal the @probed_cpu_visible_size. Note this is only 3316 + * currently tracked for I915_MEMORY_CLASS_DEVICE 3317 + * regions (for other types the value here will also 3318 + * always equal the @probed_cpu_visible_size). 3319 + * 3320 + * If this is an older kernel the value here will be 3321 + * zero, see also @probed_cpu_visible_size. 3322 + */ 3323 + __u64 unallocated_cpu_visible_size; 3324 + }; 3325 + }; 3344 3326 }; 3345 3327 3346 3328 /** ··· 3481 3329 * struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added 3482 3330 * extension support using struct i915_user_extension. 3483 3331 * 3484 - * Note that in the future we want to have our buffer flags here, at least for 3485 - * the stuff that is immutable. Previously we would have two ioctls, one to 3486 - * create the object with gem_create, and another to apply various parameters, 3487 - * however this creates some ambiguity for the params which are considered 3488 - * immutable. Also in general we're phasing out the various SET/GET ioctls. 3332 + * Note that new buffer flags should be added here, at least for the stuff that 3333 + * is immutable. Previously we would have two ioctls, one to create the object 3334 + * with gem_create, and another to apply various parameters, however this 3335 + * creates some ambiguity for the params which are considered immutable. Also in 3336 + * general we're phasing out the various SET/GET ioctls. 3489 3337 */ 3490 3338 struct drm_i915_gem_create_ext { 3491 3339 /** 3492 3340 * @size: Requested size for the object. 3493 3341 * 3494 3342 * The (page-aligned) allocated size for the object will be returned. 3495 - * 3496 3343 * 3497 3344 * DG2 64K min page size implications: 3498 3345 * ··· 3504 3353 * 3505 3354 * Note that the returned size here will always reflect any required 3506 3355 * rounding up done by the kernel, i.e 4K will now become 64K on devices 3507 - * such as DG2. 3356 + * such as DG2. The kernel will always select the largest minimum 3357 + * page-size for the set of possible placements as the value to use when 3358 + * rounding up the @size. 3508 3359 * 3509 3360 * Special DG2 GTT address alignment requirement: 3510 3361 * ··· 3530 3377 * is deemed to be a good compromise. 3531 3378 */ 3532 3379 __u64 size; 3380 + 3533 3381 /** 3534 3382 * @handle: Returned handle for the object. 3535 3383 * 3536 3384 * Object handles are nonzero. 3537 3385 */ 3538 3386 __u32 handle; 3539 - /** @flags: MBZ */ 3387 + 3388 + /** 3389 + * @flags: Optional flags. 3390 + * 3391 + * Supported values: 3392 + * 3393 + * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that 3394 + * the object will need to be accessed via the CPU. 3395 + * 3396 + * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only 3397 + * strictly required on configurations where some subset of the device 3398 + * memory is directly visible/mappable through the CPU (which we also 3399 + * call small BAR), like on some DG2+ systems. Note that this is quite 3400 + * undesirable, but due to various factors like the client CPU, BIOS etc 3401 + * it's something we can expect to see in the wild. See 3402 + * &drm_i915_memory_region_info.probed_cpu_visible_size for how to 3403 + * determine if this system applies. 3404 + * 3405 + * Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to 3406 + * ensure the kernel can always spill the allocation to system memory, 3407 + * if the object can't be allocated in the mappable part of 3408 + * I915_MEMORY_CLASS_DEVICE. 3409 + * 3410 + * Also note that since the kernel only supports flat-CCS on objects 3411 + * that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore 3412 + * don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with 3413 + * flat-CCS. 3414 + * 3415 + * Without this hint, the kernel will assume that non-mappable 3416 + * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the 3417 + * kernel can still migrate the object to the mappable part, as a last 3418 + * resort, if userspace ever CPU faults this object, but this might be 3419 + * expensive, and so ideally should be avoided. 3420 + * 3421 + * On older kernels which lack the relevant small-bar uAPI support (see 3422 + * also &drm_i915_memory_region_info.probed_cpu_visible_size), 3423 + * usage of the flag will result in an error, but it should NEVER be 3424 + * possible to end up with a small BAR configuration, assuming we can 3425 + * also successfully load the i915 kernel module. In such cases the 3426 + * entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as 3427 + * such there are zero restrictions on where the object can be placed. 3428 + */ 3429 + #define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0) 3540 3430 __u32 flags; 3431 + 3541 3432 /** 3542 3433 * @extensions: The chain of extensions to apply to this object. 3543 3434 * ··· 3640 3443 * At which point we get the object handle in &drm_i915_gem_create_ext.handle, 3641 3444 * along with the final object size in &drm_i915_gem_create_ext.size, which 3642 3445 * should account for any rounding up, if required. 3446 + * 3447 + * Note that userspace has no means of knowing the current backing region 3448 + * for objects where @num_regions is larger than one. The kernel will only 3449 + * ensure that the priority order of the @regions array is honoured, either 3450 + * when initially placing the object, or when moving memory around due to 3451 + * memory pressure 3452 + * 3453 + * On Flat-CCS capable HW, compression is supported for the objects residing 3454 + * in I915_MEMORY_CLASS_DEVICE. When such objects (compressed) have other 3455 + * memory class in @regions and migrated (by i915, due to memory 3456 + * constraints) to the non I915_MEMORY_CLASS_DEVICE region, then i915 needs to 3457 + * decompress the content. But i915 doesn't have the required information to 3458 + * decompress the userspace compressed objects. 3459 + * 3460 + * So i915 supports Flat-CCS, on the objects which can reside only on 3461 + * I915_MEMORY_CLASS_DEVICE regions. 3643 3462 */ 3644 3463 struct drm_i915_gem_create_ext_memory_regions { 3645 3464 /** @base: Extension link. See struct i915_user_extension. */
+2 -1
tools/include/uapi/linux/fscrypt.h
··· 27 27 #define FSCRYPT_MODE_AES_128_CBC 5 28 28 #define FSCRYPT_MODE_AES_128_CTS 6 29 29 #define FSCRYPT_MODE_ADIANTUM 9 30 - /* If adding a mode number > 9, update FSCRYPT_MODE_MAX in fscrypt_private.h */ 30 + #define FSCRYPT_MODE_AES_256_HCTR2 10 31 + /* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */ 31 32 32 33 /* 33 34 * Legacy policy version; ad-hoc KDF and no key verification.
+108
tools/include/uapi/linux/kvm.h
··· 270 270 #define KVM_EXIT_X86_BUS_LOCK 33 271 271 #define KVM_EXIT_XEN 34 272 272 #define KVM_EXIT_RISCV_SBI 35 273 + #define KVM_EXIT_RISCV_CSR 36 274 + #define KVM_EXIT_NOTIFY 37 273 275 274 276 /* For KVM_EXIT_INTERNAL_ERROR */ 275 277 /* Emulate instruction failed. */ ··· 498 496 unsigned long args[6]; 499 497 unsigned long ret[2]; 500 498 } riscv_sbi; 499 + /* KVM_EXIT_RISCV_CSR */ 500 + struct { 501 + unsigned long csr_num; 502 + unsigned long new_value; 503 + unsigned long write_mask; 504 + unsigned long ret_value; 505 + } riscv_csr; 506 + /* KVM_EXIT_NOTIFY */ 507 + struct { 508 + #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0) 509 + __u32 flags; 510 + } notify; 501 511 /* Fix the size of the union. */ 502 512 char padding[256]; 503 513 }; ··· 1171 1157 #define KVM_CAP_VM_TSC_CONTROL 214 1172 1158 #define KVM_CAP_SYSTEM_EVENT_DATA 215 1173 1159 #define KVM_CAP_ARM_SYSTEM_SUSPEND 216 1160 + #define KVM_CAP_S390_PROTECTED_DUMP 217 1161 + #define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218 1162 + #define KVM_CAP_X86_NOTIFY_VMEXIT 219 1163 + #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 1164 + #define KVM_CAP_S390_ZPCI_OP 221 1165 + #define KVM_CAP_S390_CPU_TOPOLOGY 222 1174 1166 1175 1167 #ifdef KVM_CAP_IRQ_ROUTING 1176 1168 ··· 1680 1660 __u64 tweak; 1681 1661 }; 1682 1662 1663 + enum pv_cmd_dmp_id { 1664 + KVM_PV_DUMP_INIT, 1665 + KVM_PV_DUMP_CONFIG_STOR_STATE, 1666 + KVM_PV_DUMP_COMPLETE, 1667 + KVM_PV_DUMP_CPU, 1668 + }; 1669 + 1670 + struct kvm_s390_pv_dmp { 1671 + __u64 subcmd; 1672 + __u64 buff_addr; 1673 + __u64 buff_len; 1674 + __u64 gaddr; /* For dump storage state */ 1675 + __u64 reserved[4]; 1676 + }; 1677 + 1678 + enum pv_cmd_info_id { 1679 + KVM_PV_INFO_VM, 1680 + KVM_PV_INFO_DUMP, 1681 + }; 1682 + 1683 + struct kvm_s390_pv_info_dump { 1684 + __u64 dump_cpu_buffer_len; 1685 + __u64 dump_config_mem_buffer_per_1m; 1686 + __u64 dump_config_finalize_len; 1687 + }; 1688 + 1689 + struct kvm_s390_pv_info_vm { 1690 + __u64 inst_calls_list[4]; 1691 + __u64 max_cpus; 1692 + __u64 max_guests; 1693 + __u64 max_guest_addr; 1694 + __u64 feature_indication; 1695 + }; 1696 + 1697 + struct kvm_s390_pv_info_header { 1698 + __u32 id; 1699 + __u32 len_max; 1700 + __u32 len_written; 1701 + __u32 reserved; 1702 + }; 1703 + 1704 + struct kvm_s390_pv_info { 1705 + struct kvm_s390_pv_info_header header; 1706 + union { 1707 + struct kvm_s390_pv_info_dump dump; 1708 + struct kvm_s390_pv_info_vm vm; 1709 + }; 1710 + }; 1711 + 1683 1712 enum pv_cmd_id { 1684 1713 KVM_PV_ENABLE, 1685 1714 KVM_PV_DISABLE, ··· 1737 1668 KVM_PV_VERIFY, 1738 1669 KVM_PV_PREP_RESET, 1739 1670 KVM_PV_UNSHARE_ALL, 1671 + KVM_PV_INFO, 1672 + KVM_PV_DUMP, 1740 1673 }; 1741 1674 1742 1675 struct kvm_pv_cmd { ··· 2189 2118 2190 2119 /* Available with KVM_CAP_XSAVE2 */ 2191 2120 #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave) 2121 + 2122 + /* Available with KVM_CAP_S390_PROTECTED_DUMP */ 2123 + #define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) 2124 + 2125 + /* Available with KVM_CAP_X86_NOTIFY_VMEXIT */ 2126 + #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0) 2127 + #define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1) 2128 + 2129 + /* Available with KVM_CAP_S390_ZPCI_OP */ 2130 + #define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op) 2131 + 2132 + struct kvm_s390_zpci_op { 2133 + /* in */ 2134 + __u32 fh; /* target device */ 2135 + __u8 op; /* operation to perform */ 2136 + __u8 pad[3]; 2137 + union { 2138 + /* for KVM_S390_ZPCIOP_REG_AEN */ 2139 + struct { 2140 + __u64 ibv; /* Guest addr of interrupt bit vector */ 2141 + __u64 sb; /* Guest addr of summary bit */ 2142 + __u32 flags; 2143 + __u32 noi; /* Number of interrupts */ 2144 + __u8 isc; /* Guest interrupt subclass */ 2145 + __u8 sbo; /* Offset of guest summary bit vector */ 2146 + __u16 pad; 2147 + } reg_aen; 2148 + __u64 reserved[8]; 2149 + } u; 2150 + }; 2151 + 2152 + /* types for kvm_s390_zpci_op->op */ 2153 + #define KVM_S390_ZPCIOP_REG_AEN 0 2154 + #define KVM_S390_ZPCIOP_DEREG_AEN 1 2155 + 2156 + /* flags for kvm_s390_zpci_op->u.reg_aen.flags */ 2157 + #define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0) 2192 2158 2193 2159 #endif /* __LINUX_KVM_H */
+4 -1
tools/include/uapi/linux/perf_event.h
··· 301 301 * { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED 302 302 * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING 303 303 * { u64 id; } && PERF_FORMAT_ID 304 + * { u64 lost; } && PERF_FORMAT_LOST 304 305 * } && !PERF_FORMAT_GROUP 305 306 * 306 307 * { u64 nr; ··· 309 308 * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING 310 309 * { u64 value; 311 310 * { u64 id; } && PERF_FORMAT_ID 311 + * { u64 lost; } && PERF_FORMAT_LOST 312 312 * } cntr[nr]; 313 313 * } && PERF_FORMAT_GROUP 314 314 * }; ··· 319 317 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1, 320 318 PERF_FORMAT_ID = 1U << 2, 321 319 PERF_FORMAT_GROUP = 1U << 3, 320 + PERF_FORMAT_LOST = 1U << 4, 322 321 323 - PERF_FORMAT_MAX = 1U << 4, /* non-ABI */ 322 + PERF_FORMAT_MAX = 1U << 5, /* non-ABI */ 324 323 }; 325 324 326 325 #define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
+9
tools/include/uapi/linux/vhost.h
··· 171 171 #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ 172 172 struct vhost_vring_state) 173 173 174 + /* Suspend a device so it does not process virtqueue requests anymore 175 + * 176 + * After the return of ioctl the device must preserve all the necessary state 177 + * (the virtqueue vring base plus the possible device specific states) that is 178 + * required for restoring in the future. The device must not change its 179 + * configuration after that point. 180 + */ 181 + #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) 182 + 174 183 #endif
+1 -1
tools/lib/perf/cpumap.c
··· 309 309 return perf_cpu_map__idx(cpus, cpu) != -1; 310 310 } 311 311 312 - struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map) 312 + struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map) 313 313 { 314 314 struct perf_cpu result = { 315 315 .cpu = -1
+78 -1
tools/lib/perf/evsel.c
··· 305 305 if (read_format & PERF_FORMAT_ID) 306 306 entry += sizeof(u64); 307 307 308 + if (read_format & PERF_FORMAT_LOST) 309 + entry += sizeof(u64); 310 + 308 311 if (read_format & PERF_FORMAT_GROUP) { 309 312 nr = evsel->nr_members; 310 313 size += sizeof(u64); ··· 317 314 return size; 318 315 } 319 316 317 + /* This only reads values for the leader */ 318 + static int perf_evsel__read_group(struct perf_evsel *evsel, int cpu_map_idx, 319 + int thread, struct perf_counts_values *count) 320 + { 321 + size_t size = perf_evsel__read_size(evsel); 322 + int *fd = FD(evsel, cpu_map_idx, thread); 323 + u64 read_format = evsel->attr.read_format; 324 + u64 *data; 325 + int idx = 1; 326 + 327 + if (fd == NULL || *fd < 0) 328 + return -EINVAL; 329 + 330 + data = calloc(1, size); 331 + if (data == NULL) 332 + return -ENOMEM; 333 + 334 + if (readn(*fd, data, size) <= 0) { 335 + free(data); 336 + return -errno; 337 + } 338 + 339 + /* 340 + * This reads only the leader event intentionally since we don't have 341 + * perf counts values for sibling events. 342 + */ 343 + if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) 344 + count->ena = data[idx++]; 345 + if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) 346 + count->run = data[idx++]; 347 + 348 + /* value is always available */ 349 + count->val = data[idx++]; 350 + if (read_format & PERF_FORMAT_ID) 351 + count->id = data[idx++]; 352 + if (read_format & PERF_FORMAT_LOST) 353 + count->lost = data[idx++]; 354 + 355 + free(data); 356 + return 0; 357 + } 358 + 359 + /* 360 + * The perf read format is very flexible. It needs to set the proper 361 + * values according to the read format. 362 + */ 363 + static void perf_evsel__adjust_values(struct perf_evsel *evsel, u64 *buf, 364 + struct perf_counts_values *count) 365 + { 366 + u64 read_format = evsel->attr.read_format; 367 + int n = 0; 368 + 369 + count->val = buf[n++]; 370 + 371 + if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) 372 + count->ena = buf[n++]; 373 + 374 + if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) 375 + count->run = buf[n++]; 376 + 377 + if (read_format & PERF_FORMAT_ID) 378 + count->id = buf[n++]; 379 + 380 + if (read_format & PERF_FORMAT_LOST) 381 + count->lost = buf[n++]; 382 + } 383 + 320 384 int perf_evsel__read(struct perf_evsel *evsel, int cpu_map_idx, int thread, 321 385 struct perf_counts_values *count) 322 386 { 323 387 size_t size = perf_evsel__read_size(evsel); 324 388 int *fd = FD(evsel, cpu_map_idx, thread); 389 + u64 read_format = evsel->attr.read_format; 390 + struct perf_counts_values buf; 325 391 326 392 memset(count, 0, sizeof(*count)); 327 393 328 394 if (fd == NULL || *fd < 0) 329 395 return -EINVAL; 330 396 397 + if (read_format & PERF_FORMAT_GROUP) 398 + return perf_evsel__read_group(evsel, cpu_map_idx, thread, count); 399 + 331 400 if (MMAP(evsel, cpu_map_idx, thread) && 401 + !(read_format & (PERF_FORMAT_ID | PERF_FORMAT_LOST)) && 332 402 !perf_mmap__read_self(MMAP(evsel, cpu_map_idx, thread), count)) 333 403 return 0; 334 404 335 - if (readn(*fd, count->values, size) <= 0) 405 + if (readn(*fd, buf.values, size) <= 0) 336 406 return -errno; 337 407 408 + perf_evsel__adjust_values(evsel, buf.values, count); 338 409 return 0; 339 410 } 340 411
+1 -1
tools/lib/perf/include/perf/cpumap.h
··· 23 23 LIBPERF_API struct perf_cpu perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); 24 24 LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); 25 25 LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map); 26 - LIBPERF_API struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map); 26 + LIBPERF_API struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map); 27 27 LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, struct perf_cpu cpu); 28 28 29 29 #define perf_cpu_map__for_each_cpu(cpu, idx, cpus) \
+46 -6
tools/lib/perf/include/perf/event.h
··· 6 6 #include <linux/types.h> 7 7 #include <linux/limits.h> 8 8 #include <linux/bpf.h> 9 + #include <linux/compiler.h> 9 10 #include <sys/types.h> /* pid_t */ 10 11 11 12 #define event_contains(obj, mem) ((obj).header.size > offsetof(typeof(obj), mem)) ··· 77 76 }; 78 77 79 78 /* 80 - * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID 79 + * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID | PERF_FORMAT_LOST 81 80 */ 82 81 struct perf_record_read { 83 82 struct perf_event_header header; ··· 86 85 __u64 time_enabled; 87 86 __u64 time_running; 88 87 __u64 id; 88 + __u64 lost; 89 89 }; 90 90 91 91 struct perf_record_throttle { ··· 155 153 PERF_CPU_MAP__MASK = 1, 156 154 }; 157 155 156 + /* 157 + * Array encoding of a perf_cpu_map where nr is the number of entries in cpu[] 158 + * and each entry is a value for a CPU in the map. 159 + */ 158 160 struct cpu_map_entries { 159 161 __u16 nr; 160 162 __u16 cpu[]; 161 163 }; 162 164 163 - struct perf_record_record_cpu_map { 165 + /* Bitmap encoding of a perf_cpu_map where bitmap entries are 32-bit. */ 166 + struct perf_record_mask_cpu_map32 { 167 + /* Number of mask values. */ 164 168 __u16 nr; 169 + /* Constant 4. */ 165 170 __u16 long_size; 166 - unsigned long mask[]; 171 + /* Bitmap data. */ 172 + __u32 mask[]; 167 173 }; 168 174 169 - struct perf_record_cpu_map_data { 170 - __u16 type; 171 - char data[]; 175 + /* Bitmap encoding of a perf_cpu_map where bitmap entries are 64-bit. */ 176 + struct perf_record_mask_cpu_map64 { 177 + /* Number of mask values. */ 178 + __u16 nr; 179 + /* Constant 8. */ 180 + __u16 long_size; 181 + /* Legacy padding. */ 182 + char __pad[4]; 183 + /* Bitmap data. */ 184 + __u64 mask[]; 172 185 }; 186 + 187 + /* 188 + * 'struct perf_record_cpu_map_data' is packed as unfortunately an earlier 189 + * version had unaligned data and we wish to retain file format compatibility. 190 + * -irogers 191 + */ 192 + #pragma GCC diagnostic push 193 + #pragma GCC diagnostic ignored "-Wpacked" 194 + #pragma GCC diagnostic ignored "-Wattributes" 195 + 196 + struct __packed perf_record_cpu_map_data { 197 + __u16 type; 198 + union { 199 + /* Used when type == PERF_CPU_MAP__CPUS. */ 200 + struct cpu_map_entries cpus_data; 201 + /* Used when type == PERF_CPU_MAP__MASK and long_size == 4. */ 202 + struct perf_record_mask_cpu_map32 mask32_data; 203 + /* Used when type == PERF_CPU_MAP__MASK and long_size == 8. */ 204 + struct perf_record_mask_cpu_map64 mask64_data; 205 + }; 206 + }; 207 + 208 + #pragma GCC diagnostic pop 173 209 174 210 struct perf_record_cpu_map { 175 211 struct perf_event_header header;
+3 -1
tools/lib/perf/include/perf/evsel.h
··· 18 18 uint64_t val; 19 19 uint64_t ena; 20 20 uint64_t run; 21 + uint64_t id; 22 + uint64_t lost; 21 23 }; 22 - uint64_t values[3]; 24 + uint64_t values[5]; 23 25 }; 24 26 }; 25 27
+161
tools/lib/perf/tests/test-evsel.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <stdarg.h> 3 3 #include <stdio.h> 4 + #include <string.h> 4 5 #include <linux/perf_event.h> 6 + #include <linux/kernel.h> 5 7 #include <perf/cpumap.h> 6 8 #include <perf/threadmap.h> 7 9 #include <perf/evsel.h> 10 + #include <internal/evsel.h> 8 11 #include <internal/tests.h> 9 12 #include "tests.h" 10 13 ··· 192 189 return 0; 193 190 } 194 191 192 + static int test_stat_read_format_single(struct perf_event_attr *attr, struct perf_thread_map *threads) 193 + { 194 + struct perf_evsel *evsel; 195 + struct perf_counts_values counts; 196 + volatile int count = 0x100000; 197 + int err; 198 + 199 + evsel = perf_evsel__new(attr); 200 + __T("failed to create evsel", evsel); 201 + 202 + /* skip old kernels that don't support the format */ 203 + err = perf_evsel__open(evsel, NULL, threads); 204 + if (err < 0) 205 + return 0; 206 + 207 + while (count--) ; 208 + 209 + memset(&counts, -1, sizeof(counts)); 210 + perf_evsel__read(evsel, 0, 0, &counts); 211 + 212 + __T("failed to read value", counts.val); 213 + if (attr->read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) 214 + __T("failed to read TOTAL_TIME_ENABLED", counts.ena); 215 + if (attr->read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) 216 + __T("failed to read TOTAL_TIME_RUNNING", counts.run); 217 + if (attr->read_format & PERF_FORMAT_ID) 218 + __T("failed to read ID", counts.id); 219 + if (attr->read_format & PERF_FORMAT_LOST) 220 + __T("failed to read LOST", counts.lost == 0); 221 + 222 + perf_evsel__close(evsel); 223 + perf_evsel__delete(evsel); 224 + return 0; 225 + } 226 + 227 + static int test_stat_read_format_group(struct perf_event_attr *attr, struct perf_thread_map *threads) 228 + { 229 + struct perf_evsel *leader, *member; 230 + struct perf_counts_values counts; 231 + volatile int count = 0x100000; 232 + int err; 233 + 234 + attr->read_format |= PERF_FORMAT_GROUP; 235 + leader = perf_evsel__new(attr); 236 + __T("failed to create leader", leader); 237 + 238 + attr->read_format &= ~PERF_FORMAT_GROUP; 239 + member = perf_evsel__new(attr); 240 + __T("failed to create member", member); 241 + 242 + member->leader = leader; 243 + leader->nr_members = 2; 244 + 245 + /* skip old kernels that don't support the format */ 246 + err = perf_evsel__open(leader, NULL, threads); 247 + if (err < 0) 248 + return 0; 249 + err = perf_evsel__open(member, NULL, threads); 250 + if (err < 0) 251 + return 0; 252 + 253 + while (count--) ; 254 + 255 + memset(&counts, -1, sizeof(counts)); 256 + perf_evsel__read(leader, 0, 0, &counts); 257 + 258 + __T("failed to read leader value", counts.val); 259 + if (attr->read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) 260 + __T("failed to read leader TOTAL_TIME_ENABLED", counts.ena); 261 + if (attr->read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) 262 + __T("failed to read leader TOTAL_TIME_RUNNING", counts.run); 263 + if (attr->read_format & PERF_FORMAT_ID) 264 + __T("failed to read leader ID", counts.id); 265 + if (attr->read_format & PERF_FORMAT_LOST) 266 + __T("failed to read leader LOST", counts.lost == 0); 267 + 268 + memset(&counts, -1, sizeof(counts)); 269 + perf_evsel__read(member, 0, 0, &counts); 270 + 271 + __T("failed to read member value", counts.val); 272 + if (attr->read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) 273 + __T("failed to read member TOTAL_TIME_ENABLED", counts.ena); 274 + if (attr->read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) 275 + __T("failed to read member TOTAL_TIME_RUNNING", counts.run); 276 + if (attr->read_format & PERF_FORMAT_ID) 277 + __T("failed to read member ID", counts.id); 278 + if (attr->read_format & PERF_FORMAT_LOST) 279 + __T("failed to read member LOST", counts.lost == 0); 280 + 281 + perf_evsel__close(member); 282 + perf_evsel__close(leader); 283 + perf_evsel__delete(member); 284 + perf_evsel__delete(leader); 285 + return 0; 286 + } 287 + 288 + static int test_stat_read_format(void) 289 + { 290 + struct perf_thread_map *threads; 291 + struct perf_event_attr attr = { 292 + .type = PERF_TYPE_SOFTWARE, 293 + .config = PERF_COUNT_SW_TASK_CLOCK, 294 + }; 295 + int err, i; 296 + 297 + #define FMT(_fmt) PERF_FORMAT_ ## _fmt 298 + #define FMT_TIME (FMT(TOTAL_TIME_ENABLED) | FMT(TOTAL_TIME_RUNNING)) 299 + 300 + uint64_t test_formats [] = { 301 + 0, 302 + FMT_TIME, 303 + FMT(ID), 304 + FMT(LOST), 305 + FMT_TIME | FMT(ID), 306 + FMT_TIME | FMT(LOST), 307 + FMT_TIME | FMT(ID) | FMT(LOST), 308 + FMT(ID) | FMT(LOST), 309 + }; 310 + 311 + #undef FMT 312 + #undef FMT_TIME 313 + 314 + threads = perf_thread_map__new_dummy(); 315 + __T("failed to create threads", threads); 316 + 317 + perf_thread_map__set_pid(threads, 0, 0); 318 + 319 + for (i = 0; i < (int)ARRAY_SIZE(test_formats); i++) { 320 + attr.read_format = test_formats[i]; 321 + __T_VERBOSE("testing single read with read_format: %lx\n", 322 + (unsigned long)test_formats[i]); 323 + 324 + err = test_stat_read_format_single(&attr, threads); 325 + __T("failed to read single format", err == 0); 326 + } 327 + 328 + perf_thread_map__put(threads); 329 + 330 + threads = perf_thread_map__new_array(2, NULL); 331 + __T("failed to create threads", threads); 332 + 333 + perf_thread_map__set_pid(threads, 0, 0); 334 + perf_thread_map__set_pid(threads, 1, 0); 335 + 336 + for (i = 0; i < (int)ARRAY_SIZE(test_formats); i++) { 337 + attr.read_format = test_formats[i]; 338 + __T_VERBOSE("testing group read with read_format: %lx\n", 339 + (unsigned long)test_formats[i]); 340 + 341 + err = test_stat_read_format_group(&attr, threads); 342 + __T("failed to read group format", err == 0); 343 + } 344 + 345 + perf_thread_map__put(threads); 346 + return 0; 347 + } 348 + 195 349 int test_evsel(int argc, char **argv) 196 350 { 197 351 __T_START; ··· 360 200 test_stat_thread_enable(); 361 201 test_stat_user_read(PERF_COUNT_HW_INSTRUCTIONS); 362 202 test_stat_user_read(PERF_COUNT_HW_CPU_CYCLES); 203 + test_stat_read_format(); 363 204 364 205 __T_END; 365 206 return tests_failed == 0 ? 0 : -1;
+9 -10
tools/perf/tests/cpumap.c
··· 17 17 struct machine *machine __maybe_unused) 18 18 { 19 19 struct perf_record_cpu_map *map_event = &event->cpu_map; 20 - struct perf_record_record_cpu_map *mask; 21 20 struct perf_record_cpu_map_data *data; 22 21 struct perf_cpu_map *map; 23 22 int i; 23 + unsigned int long_size; 24 24 25 25 data = &map_event->data; 26 26 27 27 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK); 28 28 29 - mask = (struct perf_record_record_cpu_map *)data->data; 29 + long_size = data->mask32_data.long_size; 30 30 31 - TEST_ASSERT_VAL("wrong nr", mask->nr == 1); 31 + TEST_ASSERT_VAL("wrong long_size", long_size == 4 || long_size == 8); 32 + 33 + TEST_ASSERT_VAL("wrong nr", data->mask32_data.nr == 1); 32 34 33 35 for (i = 0; i < 20; i++) { 34 - TEST_ASSERT_VAL("wrong cpu", test_bit(i, mask->mask)); 36 + TEST_ASSERT_VAL("wrong cpu", perf_record_cpu_map_data__test_bit(i, data)); 35 37 } 36 38 37 39 map = cpu_map__new_data(data); ··· 53 51 struct machine *machine __maybe_unused) 54 52 { 55 53 struct perf_record_cpu_map *map_event = &event->cpu_map; 56 - struct cpu_map_entries *cpus; 57 54 struct perf_record_cpu_map_data *data; 58 55 struct perf_cpu_map *map; 59 56 ··· 60 59 61 60 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__CPUS); 62 61 63 - cpus = (struct cpu_map_entries *)data->data; 64 - 65 - TEST_ASSERT_VAL("wrong nr", cpus->nr == 2); 66 - TEST_ASSERT_VAL("wrong cpu", cpus->cpu[0] == 1); 67 - TEST_ASSERT_VAL("wrong cpu", cpus->cpu[1] == 256); 62 + TEST_ASSERT_VAL("wrong nr", data->cpus_data.nr == 2); 63 + TEST_ASSERT_VAL("wrong cpu", data->cpus_data.cpu[0] == 1); 64 + TEST_ASSERT_VAL("wrong cpu", data->cpus_data.cpu[1] == 256); 68 65 69 66 map = cpu_map__new_data(data); 70 67 TEST_ASSERT_VAL("wrong nr", perf_cpu_map__nr(map) == 2);
+10 -4
tools/perf/tests/sample-parsing.c
··· 86 86 COMP(read.time_running); 87 87 /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */ 88 88 if (read_format & PERF_FORMAT_GROUP) { 89 - for (i = 0; i < s1->read.group.nr; i++) 90 - MCOMP(read.group.values[i]); 89 + for (i = 0; i < s1->read.group.nr; i++) { 90 + /* FIXME: check values without LOST */ 91 + if (read_format & PERF_FORMAT_LOST) 92 + MCOMP(read.group.values[i]); 93 + } 91 94 } else { 92 95 COMP(read.one.id); 96 + if (read_format & PERF_FORMAT_LOST) 97 + COMP(read.one.lost); 93 98 } 94 99 } 95 100 ··· 268 263 .data = (void *)aux_data, 269 264 }, 270 265 }; 271 - struct sample_read_value values[] = {{1, 5}, {9, 3}, {2, 7}, {6, 4},}; 266 + struct sample_read_value values[] = {{1, 5, 0}, {9, 3, 0}, {2, 7, 0}, {6, 4, 1},}; 272 267 struct perf_sample sample_out, sample_out_endian; 273 268 size_t i, sz, bufsz; 274 269 int err, ret = -1; ··· 291 286 } else { 292 287 sample.read.one.value = 0x08789faeb786aa87ULL; 293 288 sample.read.one.id = 99; 289 + sample.read.one.lost = 1; 294 290 } 295 291 296 292 sz = perf_event__sample_event_size(&sample, sample_type, read_format); ··· 376 370 */ 377 371 static int test__sample_parsing(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 378 372 { 379 - const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15}; 373 + const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 28, 29, 30, 31}; 380 374 u64 sample_type; 381 375 u64 sample_regs; 382 376 size_t i;
+8 -8
tools/perf/trace/beauty/include/linux/socket.h
··· 14 14 struct pid; 15 15 struct cred; 16 16 struct socket; 17 + struct sock; 18 + struct sk_buff; 17 19 18 20 #define __sockaddr_check_size(size) \ 19 21 BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage))) ··· 71 69 unsigned int msg_flags; /* flags on received message */ 72 70 __kernel_size_t msg_controllen; /* ancillary data buffer length */ 73 71 struct kiocb *msg_iocb; /* ptr to iocb for async requests */ 72 + struct ubuf_info *msg_ubuf; 73 + int (*sg_from_iter)(struct sock *sk, struct sk_buff *skb, 74 + struct iov_iter *from, size_t length); 74 75 }; 75 76 76 77 struct user_msghdr { ··· 421 416 struct user_msghdr __user *umsg, unsigned flags, 422 417 struct sockaddr __user **uaddr, 423 418 struct iovec **iov); 424 - extern int __copy_msghdr_from_user(struct msghdr *kmsg, 425 - struct user_msghdr __user *umsg, 426 - struct sockaddr __user **save_addr, 427 - struct iovec __user **uiov, size_t *nsegs); 419 + extern int __copy_msghdr(struct msghdr *kmsg, 420 + struct user_msghdr *umsg, 421 + struct sockaddr __user **save_addr); 428 422 429 423 /* helpers which do the actual work for syscalls */ 430 424 extern int __sys_recvfrom(int fd, void __user *ubuf, size_t size, ··· 432 428 extern int __sys_sendto(int fd, void __user *buff, size_t len, 433 429 unsigned int flags, struct sockaddr __user *addr, 434 430 int addr_len); 435 - extern int __sys_accept4_file(struct file *file, unsigned file_flags, 436 - struct sockaddr __user *upeer_sockaddr, 437 - int __user *upeer_addrlen, int flags, 438 - unsigned long nofile); 439 431 extern struct file *do_accept(struct file *file, unsigned file_flags, 440 432 struct sockaddr __user *upeer_sockaddr, 441 433 int __user *upeer_addrlen, int flags);
+64 -16
tools/perf/util/cpumap.c
··· 22 22 */ 23 23 static int *cpunode_map; 24 24 25 - static struct perf_cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus) 25 + bool perf_record_cpu_map_data__test_bit(int i, 26 + const struct perf_record_cpu_map_data *data) 27 + { 28 + int bit_word32 = i / 32; 29 + __u32 bit_mask32 = 1U << (i & 31); 30 + int bit_word64 = i / 64; 31 + __u64 bit_mask64 = ((__u64)1) << (i & 63); 32 + 33 + return (data->mask32_data.long_size == 4) 34 + ? (bit_word32 < data->mask32_data.nr) && 35 + (data->mask32_data.mask[bit_word32] & bit_mask32) != 0 36 + : (bit_word64 < data->mask64_data.nr) && 37 + (data->mask64_data.mask[bit_word64] & bit_mask64) != 0; 38 + } 39 + 40 + /* Read ith mask value from data into the given 64-bit sized bitmap */ 41 + static void perf_record_cpu_map_data__read_one_mask(const struct perf_record_cpu_map_data *data, 42 + int i, unsigned long *bitmap) 43 + { 44 + #if __SIZEOF_LONG__ == 8 45 + if (data->mask32_data.long_size == 4) 46 + bitmap[0] = data->mask32_data.mask[i]; 47 + else 48 + bitmap[0] = data->mask64_data.mask[i]; 49 + #else 50 + if (data->mask32_data.long_size == 4) { 51 + bitmap[0] = data->mask32_data.mask[i]; 52 + bitmap[1] = 0; 53 + } else { 54 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 55 + bitmap[0] = (unsigned long)(data->mask64_data.mask[i] >> 32); 56 + bitmap[1] = (unsigned long)data->mask64_data.mask[i]; 57 + #else 58 + bitmap[0] = (unsigned long)data->mask64_data.mask[i]; 59 + bitmap[1] = (unsigned long)(data->mask64_data.mask[i] >> 32); 60 + #endif 61 + } 62 + #endif 63 + } 64 + static struct perf_cpu_map *cpu_map__from_entries(const struct perf_record_cpu_map_data *data) 26 65 { 27 66 struct perf_cpu_map *map; 28 67 29 - map = perf_cpu_map__empty_new(cpus->nr); 68 + map = perf_cpu_map__empty_new(data->cpus_data.nr); 30 69 if (map) { 31 70 unsigned i; 32 71 33 - for (i = 0; i < cpus->nr; i++) { 72 + for (i = 0; i < data->cpus_data.nr; i++) { 34 73 /* 35 74 * Special treatment for -1, which is not real cpu number, 36 75 * and we need to use (int) -1 to initialize map[i], 37 76 * otherwise it would become 65535. 38 77 */ 39 - if (cpus->cpu[i] == (u16) -1) 78 + if (data->cpus_data.cpu[i] == (u16) -1) 40 79 map->map[i].cpu = -1; 41 80 else 42 - map->map[i].cpu = (int) cpus->cpu[i]; 81 + map->map[i].cpu = (int) data->cpus_data.cpu[i]; 43 82 } 44 83 } 45 84 46 85 return map; 47 86 } 48 87 49 - static struct perf_cpu_map *cpu_map__from_mask(struct perf_record_record_cpu_map *mask) 88 + static struct perf_cpu_map *cpu_map__from_mask(const struct perf_record_cpu_map_data *data) 50 89 { 90 + DECLARE_BITMAP(local_copy, 64); 91 + int weight = 0, mask_nr = data->mask32_data.nr; 51 92 struct perf_cpu_map *map; 52 - int nr, nbits = mask->nr * mask->long_size * BITS_PER_BYTE; 53 93 54 - nr = bitmap_weight(mask->mask, nbits); 94 + for (int i = 0; i < mask_nr; i++) { 95 + perf_record_cpu_map_data__read_one_mask(data, i, local_copy); 96 + weight += bitmap_weight(local_copy, 64); 97 + } 55 98 56 - map = perf_cpu_map__empty_new(nr); 57 - if (map) { 58 - int cpu, i = 0; 99 + map = perf_cpu_map__empty_new(weight); 100 + if (!map) 101 + return NULL; 59 102 60 - for_each_set_bit(cpu, mask->mask, nbits) 61 - map->map[i++].cpu = cpu; 103 + for (int i = 0, j = 0; i < mask_nr; i++) { 104 + int cpus_per_i = (i * data->mask32_data.long_size * BITS_PER_BYTE); 105 + int cpu; 106 + 107 + perf_record_cpu_map_data__read_one_mask(data, i, local_copy); 108 + for_each_set_bit(cpu, local_copy, 64) 109 + map->map[j++].cpu = cpu + cpus_per_i; 62 110 } 63 111 return map; 64 112 65 113 } 66 114 67 - struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data) 115 + struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *data) 68 116 { 69 117 if (data->type == PERF_CPU_MAP__CPUS) 70 - return cpu_map__from_entries((struct cpu_map_entries *)data->data); 118 + return cpu_map__from_entries(data); 71 119 else 72 - return cpu_map__from_mask((struct perf_record_record_cpu_map *)data->data); 120 + return cpu_map__from_mask(data); 73 121 } 74 122 75 123 size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp)
+3 -1
tools/perf/util/cpumap.h
··· 37 37 38 38 struct perf_record_cpu_map_data; 39 39 40 + bool perf_record_cpu_map_data__test_bit(int i, const struct perf_record_cpu_map_data *data); 41 + 40 42 struct perf_cpu_map *perf_cpu_map__empty_new(int nr); 41 43 42 - struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data); 44 + struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *data); 43 45 size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); 44 46 size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); 45 47 size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp);
+20 -5
tools/perf/util/event.h
··· 65 65 66 66 struct sample_read_value { 67 67 u64 value; 68 - u64 id; 68 + u64 id; /* only if PERF_FORMAT_ID */ 69 + u64 lost; /* only if PERF_FORMAT_LOST */ 69 70 }; 70 71 71 72 struct sample_read { ··· 80 79 struct sample_read_value one; 81 80 }; 82 81 }; 82 + 83 + static inline size_t sample_read_value_size(u64 read_format) 84 + { 85 + /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */ 86 + if (read_format & PERF_FORMAT_LOST) 87 + return sizeof(struct sample_read_value); 88 + else 89 + return offsetof(struct sample_read_value, lost); 90 + } 91 + 92 + static inline struct sample_read_value * 93 + next_sample_read_value(struct sample_read_value *v, u64 read_format) 94 + { 95 + return (void *)v + sample_read_value_size(read_format); 96 + } 97 + 98 + #define sample_read_group__for_each(v, nr, rf) \ 99 + for (int __i = 0; __i < (int)nr; v = next_sample_read_value(v, rf), __i++) 83 100 84 101 struct ip_callchain { 85 102 u64 nr; ··· 481 462 482 463 int kallsyms__get_function_start(const char *kallsyms_filename, 483 464 const char *symbol_name, u64 *addr); 484 - 485 - void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max); 486 - void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map, 487 - u16 type, int max); 488 465 489 466 void event_attr_init(struct perf_event_attr *attr); 490 467
+18 -11
tools/perf/util/evsel.c
··· 1541 1541 } 1542 1542 1543 1543 static void evsel__set_count(struct evsel *counter, int cpu_map_idx, int thread, 1544 - u64 val, u64 ena, u64 run) 1544 + u64 val, u64 ena, u64 run, u64 lost) 1545 1545 { 1546 1546 struct perf_counts_values *count; 1547 1547 ··· 1550 1550 count->val = val; 1551 1551 count->ena = ena; 1552 1552 count->run = run; 1553 + count->lost = lost; 1553 1554 1554 1555 perf_counts__set_loaded(counter->counts, cpu_map_idx, thread, true); 1555 1556 } ··· 1559 1558 { 1560 1559 u64 read_format = leader->core.attr.read_format; 1561 1560 struct sample_read_value *v; 1562 - u64 nr, ena = 0, run = 0, i; 1561 + u64 nr, ena = 0, run = 0, lost = 0; 1563 1562 1564 1563 nr = *data++; 1565 1564 ··· 1572 1571 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) 1573 1572 run = *data++; 1574 1573 1575 - v = (struct sample_read_value *) data; 1576 - 1577 - evsel__set_count(leader, cpu_map_idx, thread, v[0].value, ena, run); 1578 - 1579 - for (i = 1; i < nr; i++) { 1574 + v = (void *)data; 1575 + sample_read_group__for_each(v, nr, read_format) { 1580 1576 struct evsel *counter; 1581 1577 1582 - counter = evlist__id2evsel(leader->evlist, v[i].id); 1578 + counter = evlist__id2evsel(leader->evlist, v->id); 1583 1579 if (!counter) 1584 1580 return -EINVAL; 1585 1581 1586 - evsel__set_count(counter, cpu_map_idx, thread, v[i].value, ena, run); 1582 + if (read_format & PERF_FORMAT_LOST) 1583 + lost = v->lost; 1584 + 1585 + evsel__set_count(counter, cpu_map_idx, thread, v->value, ena, run, lost); 1587 1586 } 1588 1587 1589 1588 return 0; ··· 2476 2475 2477 2476 if (data->read.group.nr > max_group_nr) 2478 2477 return -EFAULT; 2479 - sz = data->read.group.nr * 2480 - sizeof(struct sample_read_value); 2478 + 2479 + sz = data->read.group.nr * sample_read_value_size(read_format); 2481 2480 OVERFLOW_CHECK(array, sz, max_size); 2482 2481 data->read.group.values = 2483 2482 (struct sample_read_value *)array; ··· 2486 2485 OVERFLOW_CHECK_u64(array); 2487 2486 data->read.one.id = *array; 2488 2487 array++; 2488 + 2489 + if (read_format & PERF_FORMAT_LOST) { 2490 + OVERFLOW_CHECK_u64(array); 2491 + data->read.one.lost = *array; 2492 + array++; 2493 + } 2489 2494 } 2490 2495 } 2491 2496
+14 -5
tools/perf/util/scripting-engines/trace-event-python.c
··· 642 642 return pylist; 643 643 } 644 644 645 - static PyObject *get_sample_value_as_tuple(struct sample_read_value *value) 645 + static PyObject *get_sample_value_as_tuple(struct sample_read_value *value, 646 + u64 read_format) 646 647 { 647 648 PyObject *t; 648 649 649 - t = PyTuple_New(2); 650 + t = PyTuple_New(3); 650 651 if (!t) 651 652 Py_FatalError("couldn't create Python tuple"); 652 653 PyTuple_SetItem(t, 0, PyLong_FromUnsignedLongLong(value->id)); 653 654 PyTuple_SetItem(t, 1, PyLong_FromUnsignedLongLong(value->value)); 655 + if (read_format & PERF_FORMAT_LOST) 656 + PyTuple_SetItem(t, 2, PyLong_FromUnsignedLongLong(value->lost)); 657 + 654 658 return t; 655 659 } 656 660 ··· 685 681 Py_FatalError("couldn't create Python list"); 686 682 687 683 if (read_format & PERF_FORMAT_GROUP) { 688 - for (i = 0; i < sample->read.group.nr; i++) { 689 - PyObject *t = get_sample_value_as_tuple(&sample->read.group.values[i]); 684 + struct sample_read_value *v = sample->read.group.values; 685 + 686 + i = 0; 687 + sample_read_group__for_each(v, sample->read.group.nr, read_format) { 688 + PyObject *t = get_sample_value_as_tuple(v, read_format); 690 689 PyList_SET_ITEM(values, i, t); 690 + i++; 691 691 } 692 692 } else { 693 - PyObject *t = get_sample_value_as_tuple(&sample->read.one); 693 + PyObject *t = get_sample_value_as_tuple(&sample->read.one, 694 + read_format); 694 695 PyList_SET_ITEM(values, 0, t); 695 696 } 696 697 pydict_set_item_string_decref(dict_sample, "values", values);
+36 -29
tools/perf/util/session.c
··· 916 916 bool sample_id_all __maybe_unused) 917 917 { 918 918 struct perf_record_cpu_map_data *data = &event->cpu_map.data; 919 - struct cpu_map_entries *cpus; 920 - struct perf_record_record_cpu_map *mask; 921 - unsigned i; 922 919 923 920 data->type = bswap_16(data->type); 924 921 925 922 switch (data->type) { 926 923 case PERF_CPU_MAP__CPUS: 927 - cpus = (struct cpu_map_entries *)data->data; 924 + data->cpus_data.nr = bswap_16(data->cpus_data.nr); 928 925 929 - cpus->nr = bswap_16(cpus->nr); 930 - 931 - for (i = 0; i < cpus->nr; i++) 932 - cpus->cpu[i] = bswap_16(cpus->cpu[i]); 926 + for (unsigned i = 0; i < data->cpus_data.nr; i++) 927 + data->cpus_data.cpu[i] = bswap_16(data->cpus_data.cpu[i]); 933 928 break; 934 929 case PERF_CPU_MAP__MASK: 935 - mask = (struct perf_record_record_cpu_map *)data->data; 930 + data->mask32_data.long_size = bswap_16(data->mask32_data.long_size); 936 931 937 - mask->nr = bswap_16(mask->nr); 938 - mask->long_size = bswap_16(mask->long_size); 939 - 940 - switch (mask->long_size) { 941 - case 4: mem_bswap_32(&mask->mask, mask->nr); break; 942 - case 8: mem_bswap_64(&mask->mask, mask->nr); break; 932 + switch (data->mask32_data.long_size) { 933 + case 4: 934 + data->mask32_data.nr = bswap_16(data->mask32_data.nr); 935 + for (unsigned i = 0; i < data->mask32_data.nr; i++) 936 + data->mask32_data.mask[i] = bswap_32(data->mask32_data.mask[i]); 937 + break; 938 + case 8: 939 + data->mask64_data.nr = bswap_16(data->mask64_data.nr); 940 + for (unsigned i = 0; i < data->mask64_data.nr; i++) 941 + data->mask64_data.mask[i] = bswap_64(data->mask64_data.mask[i]); 942 + break; 943 943 default: 944 944 pr_err("cpu_map swap: unsupported long size\n"); 945 945 } ··· 1283 1283 sample->read.time_running); 1284 1284 1285 1285 if (read_format & PERF_FORMAT_GROUP) { 1286 - u64 i; 1286 + struct sample_read_value *value = sample->read.group.values; 1287 1287 1288 1288 printf(".... group nr %" PRIu64 "\n", sample->read.group.nr); 1289 1289 1290 - for (i = 0; i < sample->read.group.nr; i++) { 1291 - struct sample_read_value *value; 1292 - 1293 - value = &sample->read.group.values[i]; 1290 + sample_read_group__for_each(value, sample->read.group.nr, read_format) { 1294 1291 printf("..... id %016" PRIx64 1295 - ", value %016" PRIx64 "\n", 1292 + ", value %016" PRIx64, 1296 1293 value->id, value->value); 1294 + if (read_format & PERF_FORMAT_LOST) 1295 + printf(", lost %" PRIu64, value->lost); 1296 + printf("\n"); 1297 1297 } 1298 - } else 1299 - printf("..... id %016" PRIx64 ", value %016" PRIx64 "\n", 1298 + } else { 1299 + printf("..... id %016" PRIx64 ", value %016" PRIx64, 1300 1300 sample->read.one.id, sample->read.one.value); 1301 + if (read_format & PERF_FORMAT_LOST) 1302 + printf(", lost %" PRIu64, sample->read.one.lost); 1303 + printf("\n"); 1304 + } 1301 1305 } 1302 1306 1303 1307 static void dump_event(struct evlist *evlist, union perf_event *event, ··· 1415 1411 1416 1412 if (read_format & PERF_FORMAT_ID) 1417 1413 printf("... id : %" PRI_lu64 "\n", read_event->id); 1414 + 1415 + if (read_format & PERF_FORMAT_LOST) 1416 + printf("... lost : %" PRI_lu64 "\n", read_event->lost); 1418 1417 } 1419 1418 1420 1419 static struct machine *machines__find_for_cpumode(struct machines *machines, ··· 1486 1479 struct perf_tool *tool, 1487 1480 union perf_event *event, 1488 1481 struct perf_sample *sample, 1489 - struct machine *machine) 1482 + struct machine *machine, 1483 + u64 read_format) 1490 1484 { 1491 1485 int ret = -EINVAL; 1492 - u64 i; 1486 + struct sample_read_value *v = sample->read.group.values; 1493 1487 1494 - for (i = 0; i < sample->read.group.nr; i++) { 1495 - ret = deliver_sample_value(evlist, tool, event, sample, 1496 - &sample->read.group.values[i], 1488 + sample_read_group__for_each(v, sample->read.group.nr, read_format) { 1489 + ret = deliver_sample_value(evlist, tool, event, sample, v, 1497 1490 machine); 1498 1491 if (ret) 1499 1492 break; ··· 1517 1510 /* For PERF_SAMPLE_READ we have either single or group mode. */ 1518 1511 if (read_format & PERF_FORMAT_GROUP) 1519 1512 return deliver_sample_group(evlist, tool, event, sample, 1520 - machine); 1513 + machine, read_format); 1521 1514 else 1522 1515 return deliver_sample_value(evlist, tool, event, sample, 1523 1516 &sample->read.one, machine);
+57 -42
tools/perf/util/synthetic-events.c
··· 1184 1184 return err; 1185 1185 } 1186 1186 1187 - static void synthesize_cpus(struct cpu_map_entries *cpus, 1188 - struct perf_cpu_map *map) 1187 + static void synthesize_cpus(struct perf_record_cpu_map_data *data, 1188 + const struct perf_cpu_map *map) 1189 1189 { 1190 1190 int i, map_nr = perf_cpu_map__nr(map); 1191 1191 1192 - cpus->nr = map_nr; 1192 + data->cpus_data.nr = map_nr; 1193 1193 1194 1194 for (i = 0; i < map_nr; i++) 1195 - cpus->cpu[i] = perf_cpu_map__cpu(map, i).cpu; 1195 + data->cpus_data.cpu[i] = perf_cpu_map__cpu(map, i).cpu; 1196 1196 } 1197 1197 1198 - static void synthesize_mask(struct perf_record_record_cpu_map *mask, 1199 - struct perf_cpu_map *map, int max) 1198 + static void synthesize_mask(struct perf_record_cpu_map_data *data, 1199 + const struct perf_cpu_map *map, int max) 1200 1200 { 1201 - int i; 1201 + int idx; 1202 + struct perf_cpu cpu; 1202 1203 1203 - mask->nr = BITS_TO_LONGS(max); 1204 - mask->long_size = sizeof(long); 1204 + /* Due to padding, the 4bytes per entry mask variant is always smaller. */ 1205 + data->mask32_data.nr = BITS_TO_U32(max); 1206 + data->mask32_data.long_size = 4; 1205 1207 1206 - for (i = 0; i < perf_cpu_map__nr(map); i++) 1207 - set_bit(perf_cpu_map__cpu(map, i).cpu, mask->mask); 1208 + perf_cpu_map__for_each_cpu(cpu, idx, map) { 1209 + int bit_word = cpu.cpu / 32; 1210 + __u32 bit_mask = 1U << (cpu.cpu & 31); 1211 + 1212 + data->mask32_data.mask[bit_word] |= bit_mask; 1213 + } 1208 1214 } 1209 1215 1210 - static size_t cpus_size(struct perf_cpu_map *map) 1216 + static size_t cpus_size(const struct perf_cpu_map *map) 1211 1217 { 1212 1218 return sizeof(struct cpu_map_entries) + perf_cpu_map__nr(map) * sizeof(u16); 1213 1219 } 1214 1220 1215 - static size_t mask_size(struct perf_cpu_map *map, int *max) 1221 + static size_t mask_size(const struct perf_cpu_map *map, int *max) 1216 1222 { 1217 - int i; 1218 - 1219 - *max = 0; 1220 - 1221 - for (i = 0; i < perf_cpu_map__nr(map); i++) { 1222 - /* bit position of the cpu is + 1 */ 1223 - int bit = perf_cpu_map__cpu(map, i).cpu + 1; 1224 - 1225 - if (bit > *max) 1226 - *max = bit; 1227 - } 1228 - 1229 - return sizeof(struct perf_record_record_cpu_map) + BITS_TO_LONGS(*max) * sizeof(long); 1223 + *max = perf_cpu_map__max(map).cpu; 1224 + return sizeof(struct perf_record_mask_cpu_map32) + BITS_TO_U32(*max) * sizeof(__u32); 1230 1225 } 1231 1226 1232 - void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max) 1227 + static void *cpu_map_data__alloc(const struct perf_cpu_map *map, size_t *size, 1228 + u16 *type, int *max) 1233 1229 { 1234 1230 size_t size_cpus, size_mask; 1235 1231 bool is_dummy = perf_cpu_map__empty(map); ··· 1254 1258 *type = PERF_CPU_MAP__MASK; 1255 1259 } 1256 1260 1257 - *size += sizeof(struct perf_record_cpu_map_data); 1261 + *size += sizeof(__u16); /* For perf_record_cpu_map_data.type. */ 1258 1262 *size = PERF_ALIGN(*size, sizeof(u64)); 1259 1263 return zalloc(*size); 1260 1264 } 1261 1265 1262 - void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map, 1263 - u16 type, int max) 1266 + static void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, 1267 + const struct perf_cpu_map *map, 1268 + u16 type, int max) 1264 1269 { 1265 1270 data->type = type; 1266 1271 1267 1272 switch (type) { 1268 1273 case PERF_CPU_MAP__CPUS: 1269 - synthesize_cpus((struct cpu_map_entries *) data->data, map); 1274 + synthesize_cpus(data, map); 1270 1275 break; 1271 1276 case PERF_CPU_MAP__MASK: 1272 - synthesize_mask((struct perf_record_record_cpu_map *)data->data, map, max); 1277 + synthesize_mask(data, map, max); 1273 1278 default: 1274 1279 break; 1275 1280 } 1276 1281 } 1277 1282 1278 - static struct perf_record_cpu_map *cpu_map_event__new(struct perf_cpu_map *map) 1283 + static struct perf_record_cpu_map *cpu_map_event__new(const struct perf_cpu_map *map) 1279 1284 { 1280 - size_t size = sizeof(struct perf_record_cpu_map); 1285 + size_t size = sizeof(struct perf_event_header); 1281 1286 struct perf_record_cpu_map *event; 1282 1287 int max; 1283 1288 u16 type; ··· 1296 1299 } 1297 1300 1298 1301 int perf_event__synthesize_cpu_map(struct perf_tool *tool, 1299 - struct perf_cpu_map *map, 1302 + const struct perf_cpu_map *map, 1300 1303 perf_event__handler_t process, 1301 1304 struct machine *machine) 1302 1305 { ··· 1429 1432 result += sizeof(u64); 1430 1433 /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */ 1431 1434 if (read_format & PERF_FORMAT_GROUP) { 1432 - sz = sample->read.group.nr * 1433 - sizeof(struct sample_read_value); 1434 - result += sz; 1435 + sz = sample_read_value_size(read_format); 1436 + result += sz * sample->read.group.nr; 1435 1437 } else { 1436 1438 result += sizeof(u64); 1439 + if (read_format & PERF_FORMAT_LOST) 1440 + result += sizeof(u64); 1437 1441 } 1438 1442 } 1439 1443 ··· 1519 1521 *array = data->weight; 1520 1522 } 1521 1523 1524 + static __u64 *copy_read_group_values(__u64 *array, __u64 read_format, 1525 + const struct perf_sample *sample) 1526 + { 1527 + size_t sz = sample_read_value_size(read_format); 1528 + struct sample_read_value *v = sample->read.group.values; 1529 + 1530 + sample_read_group__for_each(v, sample->read.group.nr, read_format) { 1531 + /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */ 1532 + memcpy(array, v, sz); 1533 + array = (void *)array + sz; 1534 + } 1535 + return array; 1536 + } 1537 + 1522 1538 int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, 1523 1539 const struct perf_sample *sample) 1524 1540 { ··· 1614 1602 1615 1603 /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */ 1616 1604 if (read_format & PERF_FORMAT_GROUP) { 1617 - sz = sample->read.group.nr * 1618 - sizeof(struct sample_read_value); 1619 - memcpy(array, sample->read.group.values, sz); 1620 - array = (void *)array + sz; 1605 + array = copy_read_group_values(array, read_format, 1606 + sample); 1621 1607 } else { 1622 1608 *array = sample->read.one.id; 1623 1609 array++; 1610 + 1611 + if (read_format & PERF_FORMAT_LOST) { 1612 + *array = sample->read.one.lost; 1613 + array++; 1614 + } 1624 1615 } 1625 1616 } 1626 1617
+1 -1
tools/perf/util/synthetic-events.h
··· 46 46 int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process); 47 47 int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process); 48 48 int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine); 49 - int perf_event__synthesize_cpu_map(struct perf_tool *tool, struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); 49 + int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); 50 50 int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process); 51 51 int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process); 52 52 int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);