2 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
4 * Parts came from builtin-{top,stat,record}.c, see those files for further
7 * Released under the GPL v2. (and only v2, not any later version)
16 #include "thread_map.h"
18 #include "../../include/linux/perf_event.h"
20 #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
21 #define GROUP_FD(group_fd, cpu) (*(int *)xyarray__entry(group_fd, cpu, 0))
23 int __perf_evsel__sample_size(u64 sample_type
)
25 u64 mask
= sample_type
& PERF_SAMPLE_MASK
;
29 for (i
= 0; i
< 64; i
++) {
30 if (mask
& (1ULL << i
))
39 void hists__init(struct hists
*hists
)
41 memset(hists
, 0, sizeof(*hists
));
42 hists
->entries_in_array
[0] = hists
->entries_in_array
[1] = RB_ROOT
;
43 hists
->entries_in
= &hists
->entries_in_array
[0];
44 hists
->entries_collapsed
= RB_ROOT
;
45 hists
->entries
= RB_ROOT
;
46 pthread_mutex_init(&hists
->lock
, NULL
);
49 void perf_evsel__init(struct perf_evsel
*evsel
,
50 struct perf_event_attr
*attr
, int idx
)
54 INIT_LIST_HEAD(&evsel
->node
);
55 hists__init(&evsel
->hists
);
58 struct perf_evsel
*perf_evsel__new(struct perf_event_attr
*attr
, int idx
)
60 struct perf_evsel
*evsel
= zalloc(sizeof(*evsel
));
63 perf_evsel__init(evsel
, attr
, idx
);
68 static const char *perf_evsel__hw_names
[PERF_COUNT_HW_MAX
] = {
76 "stalled-cycles-frontend",
77 "stalled-cycles-backend",
81 static const char *__perf_evsel__hw_name(u64 config
)
83 if (config
< PERF_COUNT_HW_MAX
&& perf_evsel__hw_names
[config
])
84 return perf_evsel__hw_names
[config
];
86 return "unknown-hardware";
89 static int perf_evsel__add_modifiers(struct perf_evsel
*evsel
, char *bf
, size_t size
)
92 struct perf_event_attr
*attr
= &evsel
->attr
;
93 bool exclude_guest_default
= false;
95 #define MOD_PRINT(context, mod) do { \
96 if (!attr->exclude_##context) { \
97 if (!colon) colon = ++r; \
98 r += scnprintf(bf + r, size - r, "%c", mod); \
101 if (attr
->exclude_kernel
|| attr
->exclude_user
|| attr
->exclude_hv
) {
102 MOD_PRINT(kernel
, 'k');
103 MOD_PRINT(user
, 'u');
105 exclude_guest_default
= true;
108 if (attr
->precise_ip
) {
111 r
+= scnprintf(bf
+ r
, size
- r
, "%.*s", attr
->precise_ip
, "ppp");
112 exclude_guest_default
= true;
115 if (attr
->exclude_host
|| attr
->exclude_guest
== exclude_guest_default
) {
116 MOD_PRINT(host
, 'H');
117 MOD_PRINT(guest
, 'G');
125 static int perf_evsel__hw_name(struct perf_evsel
*evsel
, char *bf
, size_t size
)
127 int r
= scnprintf(bf
, size
, "%s", __perf_evsel__hw_name(evsel
->attr
.config
));
128 return r
+ perf_evsel__add_modifiers(evsel
, bf
+ r
, size
- r
);
131 static const char *perf_evsel__sw_names
[PERF_COUNT_SW_MAX
] = {
143 static const char *__perf_evsel__sw_name(u64 config
)
145 if (config
< PERF_COUNT_SW_MAX
&& perf_evsel__sw_names
[config
])
146 return perf_evsel__sw_names
[config
];
147 return "unknown-software";
150 static int perf_evsel__sw_name(struct perf_evsel
*evsel
, char *bf
, size_t size
)
152 int r
= scnprintf(bf
, size
, "%s", __perf_evsel__sw_name(evsel
->attr
.config
));
153 return r
+ perf_evsel__add_modifiers(evsel
, bf
+ r
, size
- r
);
156 const char *perf_evsel__hw_cache
[PERF_COUNT_HW_CACHE_MAX
]
157 [PERF_EVSEL__MAX_ALIASES
] = {
158 { "L1-dcache", "l1-d", "l1d", "L1-data", },
159 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
161 { "dTLB", "d-tlb", "Data-TLB", },
162 { "iTLB", "i-tlb", "Instruction-TLB", },
163 { "branch", "branches", "bpu", "btb", "bpc", },
167 const char *perf_evsel__hw_cache_op
[PERF_COUNT_HW_CACHE_OP_MAX
]
168 [PERF_EVSEL__MAX_ALIASES
] = {
169 { "load", "loads", "read", },
170 { "store", "stores", "write", },
171 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
174 const char *perf_evsel__hw_cache_result
[PERF_COUNT_HW_CACHE_RESULT_MAX
]
175 [PERF_EVSEL__MAX_ALIASES
] = {
176 { "refs", "Reference", "ops", "access", },
177 { "misses", "miss", },
180 #define C(x) PERF_COUNT_HW_CACHE_##x
181 #define CACHE_READ (1 << C(OP_READ))
182 #define CACHE_WRITE (1 << C(OP_WRITE))
183 #define CACHE_PREFETCH (1 << C(OP_PREFETCH))
184 #define COP(x) (1 << x)
187 * cache operartion stat
188 * L1I : Read and prefetch only
189 * ITLB and BPU : Read-only
191 static unsigned long perf_evsel__hw_cache_stat
[C(MAX
)] = {
192 [C(L1D
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
193 [C(L1I
)] = (CACHE_READ
| CACHE_PREFETCH
),
194 [C(LL
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
195 [C(DTLB
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
196 [C(ITLB
)] = (CACHE_READ
),
197 [C(BPU
)] = (CACHE_READ
),
198 [C(NODE
)] = (CACHE_READ
| CACHE_WRITE
| CACHE_PREFETCH
),
201 bool perf_evsel__is_cache_op_valid(u8 type
, u8 op
)
203 if (perf_evsel__hw_cache_stat
[type
] & COP(op
))
204 return true; /* valid */
206 return false; /* invalid */
209 int __perf_evsel__hw_cache_type_op_res_name(u8 type
, u8 op
, u8 result
,
210 char *bf
, size_t size
)
213 return scnprintf(bf
, size
, "%s-%s-%s", perf_evsel__hw_cache
[type
][0],
214 perf_evsel__hw_cache_op
[op
][0],
215 perf_evsel__hw_cache_result
[result
][0]);
218 return scnprintf(bf
, size
, "%s-%s", perf_evsel__hw_cache
[type
][0],
219 perf_evsel__hw_cache_op
[op
][1]);
222 static int __perf_evsel__hw_cache_name(u64 config
, char *bf
, size_t size
)
224 u8 op
, result
, type
= (config
>> 0) & 0xff;
225 const char *err
= "unknown-ext-hardware-cache-type";
227 if (type
> PERF_COUNT_HW_CACHE_MAX
)
230 op
= (config
>> 8) & 0xff;
231 err
= "unknown-ext-hardware-cache-op";
232 if (op
> PERF_COUNT_HW_CACHE_OP_MAX
)
235 result
= (config
>> 16) & 0xff;
236 err
= "unknown-ext-hardware-cache-result";
237 if (result
> PERF_COUNT_HW_CACHE_RESULT_MAX
)
240 err
= "invalid-cache";
241 if (!perf_evsel__is_cache_op_valid(type
, op
))
244 return __perf_evsel__hw_cache_type_op_res_name(type
, op
, result
, bf
, size
);
246 return scnprintf(bf
, size
, "%s", err
);
249 static int perf_evsel__hw_cache_name(struct perf_evsel
*evsel
, char *bf
, size_t size
)
251 int ret
= __perf_evsel__hw_cache_name(evsel
->attr
.config
, bf
, size
);
252 return ret
+ perf_evsel__add_modifiers(evsel
, bf
+ ret
, size
- ret
);
255 static int perf_evsel__raw_name(struct perf_evsel
*evsel
, char *bf
, size_t size
)
257 int ret
= scnprintf(bf
, size
, "raw 0x%" PRIx64
, evsel
->attr
.config
);
258 return ret
+ perf_evsel__add_modifiers(evsel
, bf
+ ret
, size
- ret
);
261 const char *perf_evsel__name(struct perf_evsel
*evsel
)
268 switch (evsel
->attr
.type
) {
270 perf_evsel__raw_name(evsel
, bf
, sizeof(bf
));
273 case PERF_TYPE_HARDWARE
:
274 perf_evsel__hw_name(evsel
, bf
, sizeof(bf
));
277 case PERF_TYPE_HW_CACHE
:
278 perf_evsel__hw_cache_name(evsel
, bf
, sizeof(bf
));
281 case PERF_TYPE_SOFTWARE
:
282 perf_evsel__sw_name(evsel
, bf
, sizeof(bf
));
285 case PERF_TYPE_TRACEPOINT
:
286 scnprintf(bf
, sizeof(bf
), "%s", "unknown tracepoint");
290 scnprintf(bf
, sizeof(bf
), "%s", "unknown attr type");
294 evsel
->name
= strdup(bf
);
296 return evsel
->name
?: "unknown";
299 void perf_evsel__config(struct perf_evsel
*evsel
, struct perf_record_opts
*opts
,
300 struct perf_evsel
*first
)
302 struct perf_event_attr
*attr
= &evsel
->attr
;
303 int track
= !evsel
->idx
; /* only the first counter needs these */
306 attr
->sample_id_all
= opts
->sample_id_all_missing
? 0 : 1;
307 attr
->inherit
= !opts
->no_inherit
;
308 attr
->read_format
= PERF_FORMAT_TOTAL_TIME_ENABLED
|
309 PERF_FORMAT_TOTAL_TIME_RUNNING
|
312 attr
->sample_type
|= PERF_SAMPLE_IP
| PERF_SAMPLE_TID
;
315 * We default some events to a 1 default interval. But keep
316 * it a weak assumption overridable by the user.
318 if (!attr
->sample_period
|| (opts
->user_freq
!= UINT_MAX
&&
319 opts
->user_interval
!= ULLONG_MAX
)) {
321 attr
->sample_type
|= PERF_SAMPLE_PERIOD
;
323 attr
->sample_freq
= opts
->freq
;
325 attr
->sample_period
= opts
->default_interval
;
329 if (opts
->no_samples
)
330 attr
->sample_freq
= 0;
332 if (opts
->inherit_stat
)
333 attr
->inherit_stat
= 1;
335 if (opts
->sample_address
) {
336 attr
->sample_type
|= PERF_SAMPLE_ADDR
;
337 attr
->mmap_data
= track
;
340 if (opts
->call_graph
)
341 attr
->sample_type
|= PERF_SAMPLE_CALLCHAIN
;
343 if (perf_target__has_cpu(&opts
->target
))
344 attr
->sample_type
|= PERF_SAMPLE_CPU
;
347 attr
->sample_type
|= PERF_SAMPLE_PERIOD
;
349 if (!opts
->sample_id_all_missing
&&
350 (opts
->sample_time
|| !opts
->no_inherit
||
351 perf_target__has_cpu(&opts
->target
)))
352 attr
->sample_type
|= PERF_SAMPLE_TIME
;
354 if (opts
->raw_samples
) {
355 attr
->sample_type
|= PERF_SAMPLE_TIME
;
356 attr
->sample_type
|= PERF_SAMPLE_RAW
;
357 attr
->sample_type
|= PERF_SAMPLE_CPU
;
360 if (opts
->no_delay
) {
362 attr
->wakeup_events
= 1;
364 if (opts
->branch_stack
) {
365 attr
->sample_type
|= PERF_SAMPLE_BRANCH_STACK
;
366 attr
->branch_sample_type
= opts
->branch_stack
;
372 if (perf_target__none(&opts
->target
) &&
373 (!opts
->group
|| evsel
== first
)) {
374 attr
->enable_on_exec
= 1;
378 int perf_evsel__alloc_fd(struct perf_evsel
*evsel
, int ncpus
, int nthreads
)
381 evsel
->fd
= xyarray__new(ncpus
, nthreads
, sizeof(int));
384 for (cpu
= 0; cpu
< ncpus
; cpu
++) {
385 for (thread
= 0; thread
< nthreads
; thread
++) {
386 FD(evsel
, cpu
, thread
) = -1;
391 return evsel
->fd
!= NULL
? 0 : -ENOMEM
;
394 int perf_evsel__alloc_id(struct perf_evsel
*evsel
, int ncpus
, int nthreads
)
396 evsel
->sample_id
= xyarray__new(ncpus
, nthreads
, sizeof(struct perf_sample_id
));
397 if (evsel
->sample_id
== NULL
)
400 evsel
->id
= zalloc(ncpus
* nthreads
* sizeof(u64
));
401 if (evsel
->id
== NULL
) {
402 xyarray__delete(evsel
->sample_id
);
403 evsel
->sample_id
= NULL
;
410 int perf_evsel__alloc_counts(struct perf_evsel
*evsel
, int ncpus
)
412 evsel
->counts
= zalloc((sizeof(*evsel
->counts
) +
413 (ncpus
* sizeof(struct perf_counts_values
))));
414 return evsel
->counts
!= NULL
? 0 : -ENOMEM
;
417 void perf_evsel__free_fd(struct perf_evsel
*evsel
)
419 xyarray__delete(evsel
->fd
);
423 void perf_evsel__free_id(struct perf_evsel
*evsel
)
425 xyarray__delete(evsel
->sample_id
);
426 evsel
->sample_id
= NULL
;
431 void perf_evsel__close_fd(struct perf_evsel
*evsel
, int ncpus
, int nthreads
)
435 for (cpu
= 0; cpu
< ncpus
; cpu
++)
436 for (thread
= 0; thread
< nthreads
; ++thread
) {
437 close(FD(evsel
, cpu
, thread
));
438 FD(evsel
, cpu
, thread
) = -1;
442 void perf_evsel__exit(struct perf_evsel
*evsel
)
444 assert(list_empty(&evsel
->node
));
445 xyarray__delete(evsel
->fd
);
446 xyarray__delete(evsel
->sample_id
);
450 void perf_evsel__delete(struct perf_evsel
*evsel
)
452 perf_evsel__exit(evsel
);
453 close_cgroup(evsel
->cgrp
);
458 int __perf_evsel__read_on_cpu(struct perf_evsel
*evsel
,
459 int cpu
, int thread
, bool scale
)
461 struct perf_counts_values count
;
462 size_t nv
= scale
? 3 : 1;
464 if (FD(evsel
, cpu
, thread
) < 0)
467 if (evsel
->counts
== NULL
&& perf_evsel__alloc_counts(evsel
, cpu
+ 1) < 0)
470 if (readn(FD(evsel
, cpu
, thread
), &count
, nv
* sizeof(u64
)) < 0)
476 else if (count
.run
< count
.ena
)
477 count
.val
= (u64
)((double)count
.val
* count
.ena
/ count
.run
+ 0.5);
479 count
.ena
= count
.run
= 0;
481 evsel
->counts
->cpu
[cpu
] = count
;
485 int __perf_evsel__read(struct perf_evsel
*evsel
,
486 int ncpus
, int nthreads
, bool scale
)
488 size_t nv
= scale
? 3 : 1;
490 struct perf_counts_values
*aggr
= &evsel
->counts
->aggr
, count
;
492 aggr
->val
= aggr
->ena
= aggr
->run
= 0;
494 for (cpu
= 0; cpu
< ncpus
; cpu
++) {
495 for (thread
= 0; thread
< nthreads
; thread
++) {
496 if (FD(evsel
, cpu
, thread
) < 0)
499 if (readn(FD(evsel
, cpu
, thread
),
500 &count
, nv
* sizeof(u64
)) < 0)
503 aggr
->val
+= count
.val
;
505 aggr
->ena
+= count
.ena
;
506 aggr
->run
+= count
.run
;
511 evsel
->counts
->scaled
= 0;
513 if (aggr
->run
== 0) {
514 evsel
->counts
->scaled
= -1;
519 if (aggr
->run
< aggr
->ena
) {
520 evsel
->counts
->scaled
= 1;
521 aggr
->val
= (u64
)((double)aggr
->val
* aggr
->ena
/ aggr
->run
+ 0.5);
524 aggr
->ena
= aggr
->run
= 0;
529 static int __perf_evsel__open(struct perf_evsel
*evsel
, struct cpu_map
*cpus
,
530 struct thread_map
*threads
, bool group
,
531 struct xyarray
*group_fds
)
534 unsigned long flags
= 0;
537 if (evsel
->fd
== NULL
&&
538 perf_evsel__alloc_fd(evsel
, cpus
->nr
, threads
->nr
) < 0)
542 flags
= PERF_FLAG_PID_CGROUP
;
543 pid
= evsel
->cgrp
->fd
;
546 for (cpu
= 0; cpu
< cpus
->nr
; cpu
++) {
547 int group_fd
= group_fds
? GROUP_FD(group_fds
, cpu
) : -1;
549 for (thread
= 0; thread
< threads
->nr
; thread
++) {
552 pid
= threads
->map
[thread
];
554 FD(evsel
, cpu
, thread
) = sys_perf_event_open(&evsel
->attr
,
558 if (FD(evsel
, cpu
, thread
) < 0) {
563 if (group
&& group_fd
== -1)
564 group_fd
= FD(evsel
, cpu
, thread
);
572 while (--thread
>= 0) {
573 close(FD(evsel
, cpu
, thread
));
574 FD(evsel
, cpu
, thread
) = -1;
576 thread
= threads
->nr
;
577 } while (--cpu
>= 0);
581 void perf_evsel__close(struct perf_evsel
*evsel
, int ncpus
, int nthreads
)
583 if (evsel
->fd
== NULL
)
586 perf_evsel__close_fd(evsel
, ncpus
, nthreads
);
587 perf_evsel__free_fd(evsel
);
600 struct thread_map map
;
602 } empty_thread_map
= {
607 int perf_evsel__open(struct perf_evsel
*evsel
, struct cpu_map
*cpus
,
608 struct thread_map
*threads
, bool group
,
609 struct xyarray
*group_fd
)
612 /* Work around old compiler warnings about strict aliasing */
613 cpus
= &empty_cpu_map
.map
;
617 threads
= &empty_thread_map
.map
;
619 return __perf_evsel__open(evsel
, cpus
, threads
, group
, group_fd
);
622 int perf_evsel__open_per_cpu(struct perf_evsel
*evsel
,
623 struct cpu_map
*cpus
, bool group
,
624 struct xyarray
*group_fd
)
626 return __perf_evsel__open(evsel
, cpus
, &empty_thread_map
.map
, group
,
630 int perf_evsel__open_per_thread(struct perf_evsel
*evsel
,
631 struct thread_map
*threads
, bool group
,
632 struct xyarray
*group_fd
)
634 return __perf_evsel__open(evsel
, &empty_cpu_map
.map
, threads
, group
,
638 static int perf_event__parse_id_sample(const union perf_event
*event
, u64 type
,
639 struct perf_sample
*sample
,
642 const u64
*array
= event
->sample
.array
;
645 array
+= ((event
->header
.size
-
646 sizeof(event
->header
)) / sizeof(u64
)) - 1;
648 if (type
& PERF_SAMPLE_CPU
) {
651 /* undo swap of u64, then swap on individual u32s */
652 u
.val64
= bswap_64(u
.val64
);
653 u
.val32
[0] = bswap_32(u
.val32
[0]);
656 sample
->cpu
= u
.val32
[0];
660 if (type
& PERF_SAMPLE_STREAM_ID
) {
661 sample
->stream_id
= *array
;
665 if (type
& PERF_SAMPLE_ID
) {
670 if (type
& PERF_SAMPLE_TIME
) {
671 sample
->time
= *array
;
675 if (type
& PERF_SAMPLE_TID
) {
678 /* undo swap of u64, then swap on individual u32s */
679 u
.val64
= bswap_64(u
.val64
);
680 u
.val32
[0] = bswap_32(u
.val32
[0]);
681 u
.val32
[1] = bswap_32(u
.val32
[1]);
684 sample
->pid
= u
.val32
[0];
685 sample
->tid
= u
.val32
[1];
691 static bool sample_overlap(const union perf_event
*event
,
692 const void *offset
, u64 size
)
694 const void *base
= event
;
696 if (offset
+ size
> base
+ event
->header
.size
)
702 int perf_event__parse_sample(const union perf_event
*event
, u64 type
,
703 int sample_size
, bool sample_id_all
,
704 struct perf_sample
*data
, bool swapped
)
709 * used for cross-endian analysis. See git commit 65014ab3
710 * for why this goofiness is needed.
714 memset(data
, 0, sizeof(*data
));
715 data
->cpu
= data
->pid
= data
->tid
= -1;
716 data
->stream_id
= data
->id
= data
->time
= -1ULL;
719 if (event
->header
.type
!= PERF_RECORD_SAMPLE
) {
722 return perf_event__parse_id_sample(event
, type
, data
, swapped
);
725 array
= event
->sample
.array
;
727 if (sample_size
+ sizeof(event
->header
) > event
->header
.size
)
730 if (type
& PERF_SAMPLE_IP
) {
731 data
->ip
= event
->ip
.ip
;
735 if (type
& PERF_SAMPLE_TID
) {
738 /* undo swap of u64, then swap on individual u32s */
739 u
.val64
= bswap_64(u
.val64
);
740 u
.val32
[0] = bswap_32(u
.val32
[0]);
741 u
.val32
[1] = bswap_32(u
.val32
[1]);
744 data
->pid
= u
.val32
[0];
745 data
->tid
= u
.val32
[1];
749 if (type
& PERF_SAMPLE_TIME
) {
755 if (type
& PERF_SAMPLE_ADDR
) {
761 if (type
& PERF_SAMPLE_ID
) {
766 if (type
& PERF_SAMPLE_STREAM_ID
) {
767 data
->stream_id
= *array
;
771 if (type
& PERF_SAMPLE_CPU
) {
775 /* undo swap of u64, then swap on individual u32s */
776 u
.val64
= bswap_64(u
.val64
);
777 u
.val32
[0] = bswap_32(u
.val32
[0]);
780 data
->cpu
= u
.val32
[0];
784 if (type
& PERF_SAMPLE_PERIOD
) {
785 data
->period
= *array
;
789 if (type
& PERF_SAMPLE_READ
) {
790 fprintf(stderr
, "PERF_SAMPLE_READ is unsupported for now\n");
794 if (type
& PERF_SAMPLE_CALLCHAIN
) {
795 if (sample_overlap(event
, array
, sizeof(data
->callchain
->nr
)))
798 data
->callchain
= (struct ip_callchain
*)array
;
800 if (sample_overlap(event
, array
, data
->callchain
->nr
))
803 array
+= 1 + data
->callchain
->nr
;
806 if (type
& PERF_SAMPLE_RAW
) {
810 if (WARN_ONCE(swapped
,
811 "Endianness of raw data not corrected!\n")) {
812 /* undo swap of u64, then swap on individual u32s */
813 u
.val64
= bswap_64(u
.val64
);
814 u
.val32
[0] = bswap_32(u
.val32
[0]);
815 u
.val32
[1] = bswap_32(u
.val32
[1]);
818 if (sample_overlap(event
, array
, sizeof(u32
)))
821 data
->raw_size
= u
.val32
[0];
822 pdata
= (void *) array
+ sizeof(u32
);
824 if (sample_overlap(event
, pdata
, data
->raw_size
))
827 data
->raw_data
= (void *) pdata
;
829 array
= (void *)array
+ data
->raw_size
+ sizeof(u32
);
832 if (type
& PERF_SAMPLE_BRANCH_STACK
) {
835 data
->branch_stack
= (struct branch_stack
*)array
;
838 sz
= data
->branch_stack
->nr
* sizeof(struct branch_entry
);
845 int perf_event__synthesize_sample(union perf_event
*event
, u64 type
,
846 const struct perf_sample
*sample
,
852 * used for cross-endian analysis. See git commit 65014ab3
853 * for why this goofiness is needed.
857 array
= event
->sample
.array
;
859 if (type
& PERF_SAMPLE_IP
) {
860 event
->ip
.ip
= sample
->ip
;
864 if (type
& PERF_SAMPLE_TID
) {
865 u
.val32
[0] = sample
->pid
;
866 u
.val32
[1] = sample
->tid
;
869 * Inverse of what is done in perf_event__parse_sample
871 u
.val32
[0] = bswap_32(u
.val32
[0]);
872 u
.val32
[1] = bswap_32(u
.val32
[1]);
873 u
.val64
= bswap_64(u
.val64
);
880 if (type
& PERF_SAMPLE_TIME
) {
881 *array
= sample
->time
;
885 if (type
& PERF_SAMPLE_ADDR
) {
886 *array
= sample
->addr
;
890 if (type
& PERF_SAMPLE_ID
) {
895 if (type
& PERF_SAMPLE_STREAM_ID
) {
896 *array
= sample
->stream_id
;
900 if (type
& PERF_SAMPLE_CPU
) {
901 u
.val32
[0] = sample
->cpu
;
904 * Inverse of what is done in perf_event__parse_sample
906 u
.val32
[0] = bswap_32(u
.val32
[0]);
907 u
.val64
= bswap_64(u
.val64
);
913 if (type
& PERF_SAMPLE_PERIOD
) {
914 *array
= sample
->period
;