Lines Matching refs:ff

95 static int __do_write_fd(struct feat_fd *ff, const void *buf, size_t size)  in __do_write_fd()  argument
97 ssize_t ret = writen(ff->fd, buf, size); in __do_write_fd()
104 static int __do_write_buf(struct feat_fd *ff, const void *buf, size_t size) in __do_write_buf() argument
108 size_t new_size = ff->size; in __do_write_buf()
111 if (size + ff->offset > max_size) in __do_write_buf()
114 while (size > (new_size - ff->offset)) in __do_write_buf()
118 if (ff->size < new_size) { in __do_write_buf()
119 addr = realloc(ff->buf, new_size); in __do_write_buf()
122 ff->buf = addr; in __do_write_buf()
123 ff->size = new_size; in __do_write_buf()
126 memcpy(ff->buf + ff->offset, buf, size); in __do_write_buf()
127 ff->offset += size; in __do_write_buf()
133 int do_write(struct feat_fd *ff, const void *buf, size_t size) in do_write() argument
135 if (!ff->buf) in do_write()
136 return __do_write_fd(ff, buf, size); in do_write()
137 return __do_write_buf(ff, buf, size); in do_write()
141 static int do_write_bitmap(struct feat_fd *ff, unsigned long *set, u64 size) in do_write_bitmap() argument
146 ret = do_write(ff, &size, sizeof(size)); in do_write_bitmap()
151 ret = do_write(ff, p + i, sizeof(*p)); in do_write_bitmap()
160 int write_padded(struct feat_fd *ff, const void *bf, in write_padded() argument
164 int err = do_write(ff, bf, count); in write_padded()
167 err = do_write(ff, zero_buf, count_aligned - count); in write_padded()
176 static int do_write_string(struct feat_fd *ff, const char *str) in do_write_string() argument
185 ret = do_write(ff, &len, sizeof(len)); in do_write_string()
189 return write_padded(ff, str, olen, len); in do_write_string()
192 static int __do_read_fd(struct feat_fd *ff, void *addr, ssize_t size) in __do_read_fd() argument
194 ssize_t ret = readn(ff->fd, addr, size); in __do_read_fd()
201 static int __do_read_buf(struct feat_fd *ff, void *addr, ssize_t size) in __do_read_buf() argument
203 if (size > (ssize_t)ff->size - ff->offset) in __do_read_buf()
206 memcpy(addr, ff->buf + ff->offset, size); in __do_read_buf()
207 ff->offset += size; in __do_read_buf()
213 static int __do_read(struct feat_fd *ff, void *addr, ssize_t size) in __do_read() argument
215 if (!ff->buf) in __do_read()
216 return __do_read_fd(ff, addr, size); in __do_read()
217 return __do_read_buf(ff, addr, size); in __do_read()
220 static int do_read_u32(struct feat_fd *ff, u32 *addr) in do_read_u32() argument
224 ret = __do_read(ff, addr, sizeof(*addr)); in do_read_u32()
228 if (ff->ph->needs_swap) in do_read_u32()
233 static int do_read_u64(struct feat_fd *ff, u64 *addr) in do_read_u64() argument
237 ret = __do_read(ff, addr, sizeof(*addr)); in do_read_u64()
241 if (ff->ph->needs_swap) in do_read_u64()
246 static char *do_read_string(struct feat_fd *ff) in do_read_string() argument
251 if (do_read_u32(ff, &len)) in do_read_string()
258 if (!__do_read(ff, buf, len)) { in do_read_string()
272 static int do_read_bitmap(struct feat_fd *ff, unsigned long **pset, u64 *psize) in do_read_bitmap() argument
278 ret = do_read_u64(ff, &size); in do_read_bitmap()
289 ret = do_read_u64(ff, p + i); in do_read_bitmap()
301 static int write_tracing_data(struct feat_fd *ff, in write_tracing_data() argument
304 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) in write_tracing_data()
307 return read_tracing_data(ff->fd, &evlist->core.entries); in write_tracing_data()
310 static int write_build_id(struct feat_fd *ff, in write_build_id() argument
316 session = container_of(ff->ph, struct perf_session, header); in write_build_id()
321 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) in write_build_id()
324 err = perf_session__write_buildid_table(session, ff); in write_build_id()
334 static int write_hostname(struct feat_fd *ff, in write_hostname() argument
344 return do_write_string(ff, uts.nodename); in write_hostname()
347 static int write_osrelease(struct feat_fd *ff, in write_osrelease() argument
357 return do_write_string(ff, uts.release); in write_osrelease()
360 static int write_arch(struct feat_fd *ff, in write_arch() argument
370 return do_write_string(ff, uts.machine); in write_arch()
373 static int write_version(struct feat_fd *ff, in write_version() argument
376 return do_write_string(ff, perf_version_string); in write_version()
379 static int __write_cpudesc(struct feat_fd *ff, const char *cpuinfo_proc) in __write_cpudesc() argument
427 ret = do_write_string(ff, s); in __write_cpudesc()
434 static int write_cpudesc(struct feat_fd *ff, in write_cpudesc() argument
460 ret = __write_cpudesc(ff, cpuinfo_procs[i]); in write_cpudesc()
468 static int write_nrcpus(struct feat_fd *ff, in write_nrcpus() argument
483 ret = do_write(ff, &nrc, sizeof(nrc)); in write_nrcpus()
487 return do_write(ff, &nra, sizeof(nra)); in write_nrcpus()
490 static int write_event_desc(struct feat_fd *ff, in write_event_desc() argument
502 ret = do_write(ff, &nre, sizeof(nre)); in write_event_desc()
510 ret = do_write(ff, &sz, sizeof(sz)); in write_event_desc()
515 ret = do_write(ff, &evsel->core.attr, sz); in write_event_desc()
526 ret = do_write(ff, &nri, sizeof(nri)); in write_event_desc()
533 ret = do_write_string(ff, evsel__name(evsel)); in write_event_desc()
539 ret = do_write(ff, evsel->core.id, evsel->core.ids * sizeof(u64)); in write_event_desc()
546 static int write_cmdline(struct feat_fd *ff, in write_cmdline() argument
558 ret = do_write(ff, &n, sizeof(n)); in write_cmdline()
562 ret = do_write_string(ff, buf); in write_cmdline()
567 ret = do_write_string(ff, perf_env.cmdline_argv[i]); in write_cmdline()
575 static int write_cpu_topology(struct feat_fd *ff, in write_cpu_topology() argument
586 ret = do_write(ff, &tp->package_cpus_lists, sizeof(tp->package_cpus_lists)); in write_cpu_topology()
591 ret = do_write_string(ff, tp->package_cpus_list[i]); in write_cpu_topology()
595 ret = do_write(ff, &tp->core_cpus_lists, sizeof(tp->core_cpus_lists)); in write_cpu_topology()
600 ret = do_write_string(ff, tp->core_cpus_list[i]); in write_cpu_topology()
610 ret = do_write(ff, &perf_env.cpu[j].core_id, in write_cpu_topology()
614 ret = do_write(ff, &perf_env.cpu[j].socket_id, in write_cpu_topology()
623 ret = do_write(ff, &tp->die_cpus_lists, sizeof(tp->die_cpus_lists)); in write_cpu_topology()
628 ret = do_write_string(ff, tp->die_cpus_list[i]); in write_cpu_topology()
634 ret = do_write(ff, &perf_env.cpu[j].die_id, in write_cpu_topology()
647 static int write_total_mem(struct feat_fd *ff, in write_total_mem() argument
668 ret = do_write(ff, &mem, sizeof(mem)); in write_total_mem()
676 static int write_numa_topology(struct feat_fd *ff, in write_numa_topology() argument
687 ret = do_write(ff, &tp->nr, sizeof(u32)); in write_numa_topology()
694 ret = do_write(ff, &n->node, sizeof(u32)); in write_numa_topology()
698 ret = do_write(ff, &n->mem_total, sizeof(u64)); in write_numa_topology()
702 ret = do_write(ff, &n->mem_free, sizeof(u64)); in write_numa_topology()
706 ret = do_write_string(ff, n->cpus); in write_numa_topology()
730 static int write_pmu_mappings(struct feat_fd *ff, in write_pmu_mappings() argument
747 ret = do_write(ff, &pmu_num, sizeof(pmu_num)); in write_pmu_mappings()
755 ret = do_write(ff, &pmu->type, sizeof(pmu->type)); in write_pmu_mappings()
759 ret = do_write_string(ff, pmu->name); in write_pmu_mappings()
779 static int write_group_desc(struct feat_fd *ff, in write_group_desc() argument
786 ret = do_write(ff, &nr_groups, sizeof(nr_groups)); in write_group_desc()
796 ret = do_write_string(ff, name); in write_group_desc()
800 ret = do_write(ff, &leader_idx, sizeof(leader_idx)); in write_group_desc()
804 ret = do_write(ff, &nr_members, sizeof(nr_members)); in write_group_desc()
860 static int write_cpuid(struct feat_fd *ff, in write_cpuid() argument
870 return do_write_string(ff, buffer); in write_cpuid()
873 static int write_branch_stack(struct feat_fd *ff __maybe_unused, in write_branch_stack()
879 static int write_auxtrace(struct feat_fd *ff, in write_auxtrace() argument
885 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) in write_auxtrace()
888 session = container_of(ff->ph, struct perf_session, header); in write_auxtrace()
890 err = auxtrace_index__write(ff->fd, &session->auxtrace_index); in write_auxtrace()
896 static int write_clockid(struct feat_fd *ff, in write_clockid() argument
899 return do_write(ff, &ff->ph->env.clock.clockid_res_ns, in write_clockid()
900 sizeof(ff->ph->env.clock.clockid_res_ns)); in write_clockid()
903 static int write_clock_data(struct feat_fd *ff, in write_clock_data() argument
913 ret = do_write(ff, &data32, sizeof(data32)); in write_clock_data()
918 data32 = ff->ph->env.clock.clockid; in write_clock_data()
920 ret = do_write(ff, &data32, sizeof(data32)); in write_clock_data()
925 data64 = &ff->ph->env.clock.tod_ns; in write_clock_data()
927 ret = do_write(ff, data64, sizeof(*data64)); in write_clock_data()
932 data64 = &ff->ph->env.clock.clockid_ns; in write_clock_data()
934 return do_write(ff, data64, sizeof(*data64)); in write_clock_data()
937 static int write_hybrid_topology(struct feat_fd *ff, in write_hybrid_topology() argument
948 ret = do_write(ff, &tp->nr, sizeof(u32)); in write_hybrid_topology()
955 ret = do_write_string(ff, n->pmu_name); in write_hybrid_topology()
959 ret = do_write_string(ff, n->cpus); in write_hybrid_topology()
971 static int write_dir_format(struct feat_fd *ff, in write_dir_format() argument
977 session = container_of(ff->ph, struct perf_session, header); in write_dir_format()
983 return do_write(ff, &data->dir.version, sizeof(data->dir.version)); in write_dir_format()
1038 static int write_bpf_prog_info(struct feat_fd *ff, in write_bpf_prog_info() argument
1041 struct perf_env *env = &ff->ph->env; in write_bpf_prog_info()
1048 ret = do_write(ff, &env->bpf_progs.infos_cnt, in write_bpf_prog_info()
1066 ret = do_write(ff, node->info_linear, len); in write_bpf_prog_info()
1080 static int write_bpf_btf(struct feat_fd *ff, in write_bpf_btf() argument
1083 struct perf_env *env = &ff->ph->env; in write_bpf_btf()
1090 ret = do_write(ff, &env->bpf_progs.btfs_cnt, in write_bpf_btf()
1103 ret = do_write(ff, &node->id, in write_bpf_btf()
1246 static int write_cache(struct feat_fd *ff, in write_cache() argument
1260 ret = do_write(ff, &version, sizeof(u32)); in write_cache()
1264 ret = do_write(ff, &cnt, sizeof(u32)); in write_cache()
1272 ret = do_write(ff, &c->v, sizeof(u32)); \ in write_cache()
1283 ret = do_write_string(ff, (const char *) c->v); \ in write_cache()
1299 static int write_stat(struct feat_fd *ff __maybe_unused, in write_stat()
1305 static int write_sample_time(struct feat_fd *ff, in write_sample_time() argument
1310 ret = do_write(ff, &evlist->first_sample_time, in write_sample_time()
1315 return do_write(ff, &evlist->last_sample_time, in write_sample_time()
1441 static int write_mem_topology(struct feat_fd *ff __maybe_unused, in write_mem_topology()
1457 ret = do_write(ff, &version, sizeof(version)); in write_mem_topology()
1461 ret = do_write(ff, &bsize, sizeof(bsize)); in write_mem_topology()
1465 ret = do_write(ff, &nr, sizeof(nr)); in write_mem_topology()
1473 ret = do_write(ff, &n->v, sizeof(n->v)); \ in write_mem_topology()
1482 ret = do_write_bitmap(ff, n->set, n->size); in write_mem_topology()
1491 static int write_compressed(struct feat_fd *ff __maybe_unused, in write_compressed()
1496 ret = do_write(ff, &(ff->ph->env.comp_ver), sizeof(ff->ph->env.comp_ver)); in write_compressed()
1500 ret = do_write(ff, &(ff->ph->env.comp_type), sizeof(ff->ph->env.comp_type)); in write_compressed()
1504 ret = do_write(ff, &(ff->ph->env.comp_level), sizeof(ff->ph->env.comp_level)); in write_compressed()
1508 ret = do_write(ff, &(ff->ph->env.comp_ratio), sizeof(ff->ph->env.comp_ratio)); in write_compressed()
1512 return do_write(ff, &(ff->ph->env.comp_mmap_len), sizeof(ff->ph->env.comp_mmap_len)); in write_compressed()
1515 static int __write_pmu_caps(struct feat_fd *ff, struct perf_pmu *pmu, in __write_pmu_caps() argument
1521 ret = do_write(ff, &pmu->nr_caps, sizeof(pmu->nr_caps)); in __write_pmu_caps()
1526 ret = do_write_string(ff, caps->name); in __write_pmu_caps()
1530 ret = do_write_string(ff, caps->value); in __write_pmu_caps()
1536 ret = do_write_string(ff, pmu->name); in __write_pmu_caps()
1544 static int write_cpu_pmu_caps(struct feat_fd *ff, in write_cpu_pmu_caps() argument
1557 return __write_pmu_caps(ff, cpu_pmu, false); in write_cpu_pmu_caps()
1560 static int write_pmu_caps(struct feat_fd *ff, in write_pmu_caps() argument
1574 ret = do_write(ff, &nr_pmu, sizeof(nr_pmu)); in write_pmu_caps()
1587 ret = __write_pmu_caps(ff, pmu, true); in write_pmu_caps()
1598 ret = __write_pmu_caps(ff, pmu, true); in write_pmu_caps()
1605 static void print_hostname(struct feat_fd *ff, FILE *fp) in print_hostname() argument
1607 fprintf(fp, "# hostname : %s\n", ff->ph->env.hostname); in print_hostname()
1610 static void print_osrelease(struct feat_fd *ff, FILE *fp) in print_osrelease() argument
1612 fprintf(fp, "# os release : %s\n", ff->ph->env.os_release); in print_osrelease()
1615 static void print_arch(struct feat_fd *ff, FILE *fp) in print_arch() argument
1617 fprintf(fp, "# arch : %s\n", ff->ph->env.arch); in print_arch()
1620 static void print_cpudesc(struct feat_fd *ff, FILE *fp) in print_cpudesc() argument
1622 fprintf(fp, "# cpudesc : %s\n", ff->ph->env.cpu_desc); in print_cpudesc()
1625 static void print_nrcpus(struct feat_fd *ff, FILE *fp) in print_nrcpus() argument
1627 fprintf(fp, "# nrcpus online : %u\n", ff->ph->env.nr_cpus_online); in print_nrcpus()
1628 fprintf(fp, "# nrcpus avail : %u\n", ff->ph->env.nr_cpus_avail); in print_nrcpus()
1631 static void print_version(struct feat_fd *ff, FILE *fp) in print_version() argument
1633 fprintf(fp, "# perf version : %s\n", ff->ph->env.version); in print_version()
1636 static void print_cmdline(struct feat_fd *ff, FILE *fp) in print_cmdline() argument
1640 nr = ff->ph->env.nr_cmdline; in print_cmdline()
1645 char *argv_i = strdup(ff->ph->env.cmdline_argv[i]); in print_cmdline()
1647 fprintf(fp, "%s ", ff->ph->env.cmdline_argv[i]); in print_cmdline()
1665 static void print_cpu_topology(struct feat_fd *ff, FILE *fp) in print_cpu_topology() argument
1667 struct perf_header *ph = ff->ph; in print_cpu_topology()
1722 static void print_clockid(struct feat_fd *ff, FILE *fp) in print_clockid() argument
1725 ff->ph->env.clock.clockid_res_ns * 1000); in print_clockid()
1728 static void print_clock_data(struct feat_fd *ff, FILE *fp) in print_clock_data() argument
1737 if (!ff->ph->env.clock.enabled) { in print_clock_data()
1743 ref = ff->ph->env.clock.tod_ns; in print_clock_data()
1749 ref = ff->ph->env.clock.clockid_ns; in print_clock_data()
1754 clockid = ff->ph->env.clock.clockid; in print_clock_data()
1771 static void print_hybrid_topology(struct feat_fd *ff, FILE *fp) in print_hybrid_topology() argument
1777 for (i = 0; i < ff->ph->env.nr_hybrid_nodes; i++) { in print_hybrid_topology()
1778 n = &ff->ph->env.hybrid_nodes[i]; in print_hybrid_topology()
1783 static void print_dir_format(struct feat_fd *ff, FILE *fp) in print_dir_format() argument
1788 session = container_of(ff->ph, struct perf_session, header); in print_dir_format()
1795 static void print_bpf_prog_info(struct feat_fd *ff, FILE *fp) in print_bpf_prog_info() argument
1797 struct perf_env *env = &ff->ph->env; in print_bpf_prog_info()
1819 static void print_bpf_btf(struct feat_fd *ff, FILE *fp) in print_bpf_btf() argument
1821 struct perf_env *env = &ff->ph->env; in print_bpf_btf()
1891 static struct evsel *read_event_desc(struct feat_fd *ff) in read_event_desc() argument
1900 if (do_read_u32(ff, &nre)) in read_event_desc()
1903 if (do_read_u32(ff, &sz)) in read_event_desc()
1927 if (__do_read(ff, buf, sz)) in read_event_desc()
1930 if (ff->ph->needs_swap) in read_event_desc()
1938 if (do_read_u32(ff, &nr)) in read_event_desc()
1941 if (ff->ph->needs_swap) in read_event_desc()
1944 evsel->name = do_read_string(ff); in read_event_desc()
1958 if (do_read_u64(ff, id)) in read_event_desc()
1978 static void print_event_desc(struct feat_fd *ff, FILE *fp) in print_event_desc() argument
1984 if (ff->events) in print_event_desc()
1985 events = ff->events; in print_event_desc()
1987 events = read_event_desc(ff); in print_event_desc()
2013 ff->events = NULL; in print_event_desc()
2016 static void print_total_mem(struct feat_fd *ff, FILE *fp) in print_total_mem() argument
2018 fprintf(fp, "# total memory : %llu kB\n", ff->ph->env.total_mem); in print_total_mem()
2021 static void print_numa_topology(struct feat_fd *ff, FILE *fp) in print_numa_topology() argument
2026 for (i = 0; i < ff->ph->env.nr_numa_nodes; i++) { in print_numa_topology()
2027 n = &ff->ph->env.numa_nodes[i]; in print_numa_topology()
2038 static void print_cpuid(struct feat_fd *ff, FILE *fp) in print_cpuid() argument
2040 fprintf(fp, "# cpuid : %s\n", ff->ph->env.cpuid); in print_cpuid()
2043 static void print_branch_stack(struct feat_fd *ff __maybe_unused, FILE *fp) in print_branch_stack()
2048 static void print_auxtrace(struct feat_fd *ff __maybe_unused, FILE *fp) in print_auxtrace()
2053 static void print_stat(struct feat_fd *ff __maybe_unused, FILE *fp) in print_stat()
2058 static void print_cache(struct feat_fd *ff, FILE *fp __maybe_unused) in print_cache() argument
2063 for (i = 0; i < ff->ph->env.caches_cnt; i++) { in print_cache()
2065 cpu_cache_level__fprintf(fp, &ff->ph->env.caches[i]); in print_cache()
2069 static void print_compressed(struct feat_fd *ff, FILE *fp) in print_compressed() argument
2072 ff->ph->env.comp_type == PERF_COMP_ZSTD ? "Zstd" : "Unknown", in print_compressed()
2073 ff->ph->env.comp_level, ff->ph->env.comp_ratio); in print_compressed()
2095 static void print_cpu_pmu_caps(struct feat_fd *ff, FILE *fp) in print_cpu_pmu_caps() argument
2097 __print_pmu_caps(fp, ff->ph->env.nr_cpu_pmu_caps, in print_cpu_pmu_caps()
2098 ff->ph->env.cpu_pmu_caps, (char *)"cpu"); in print_cpu_pmu_caps()
2101 static void print_pmu_caps(struct feat_fd *ff, FILE *fp) in print_pmu_caps() argument
2105 for (int i = 0; i < ff->ph->env.nr_pmus_with_caps; i++) { in print_pmu_caps()
2106 pmu_caps = &ff->ph->env.pmu_caps[i]; in print_pmu_caps()
2112 static void print_pmu_mappings(struct feat_fd *ff, FILE *fp) in print_pmu_mappings() argument
2119 pmu_num = ff->ph->env.nr_pmu_mappings; in print_pmu_mappings()
2125 str = ff->ph->env.pmu_mappings; in print_pmu_mappings()
2148 static void print_group_desc(struct feat_fd *ff, FILE *fp) in print_group_desc() argument
2154 session = container_of(ff->ph, struct perf_session, header); in print_group_desc()
2170 static void print_sample_time(struct feat_fd *ff, FILE *fp) in print_sample_time() argument
2176 session = container_of(ff->ph, struct perf_session, header); in print_sample_time()
2205 static void print_mem_topology(struct feat_fd *ff, FILE *fp) in print_mem_topology() argument
2210 nodes = ff->ph->env.memory_nodes; in print_mem_topology()
2211 nr = ff->ph->env.nr_memory_nodes; in print_mem_topology()
2214 nr, ff->ph->env.memory_bsize); in print_mem_topology()
2217 memory_node__fprintf(&nodes[i], ff->ph->env.memory_bsize, fp); in print_mem_topology()
2383 static int process_##__feat(struct feat_fd *ff, void *data __maybe_unused) \
2385 free(ff->ph->env.__feat_env); \
2386 ff->ph->env.__feat_env = do_read_string(ff); \
2387 return ff->ph->env.__feat_env ? 0 : -ENOMEM; \
2397 static int process_tracing_data(struct feat_fd *ff, void *data) in process_tracing_data() argument
2399 ssize_t ret = trace_report(ff->fd, data, false); in process_tracing_data()
2404 static int process_build_id(struct feat_fd *ff, void *data __maybe_unused) in process_build_id() argument
2406 if (perf_header__read_build_ids(ff->ph, ff->fd, ff->offset, ff->size)) in process_build_id()
2411 static int process_nrcpus(struct feat_fd *ff, void *data __maybe_unused) in process_nrcpus() argument
2416 ret = do_read_u32(ff, &nr_cpus_avail); in process_nrcpus()
2420 ret = do_read_u32(ff, &nr_cpus_online); in process_nrcpus()
2423 ff->ph->env.nr_cpus_avail = (int)nr_cpus_avail; in process_nrcpus()
2424 ff->ph->env.nr_cpus_online = (int)nr_cpus_online; in process_nrcpus()
2428 static int process_total_mem(struct feat_fd *ff, void *data __maybe_unused) in process_total_mem() argument
2433 ret = do_read_u64(ff, &total_mem); in process_total_mem()
2436 ff->ph->env.total_mem = (unsigned long long)total_mem; in process_total_mem()
2470 process_event_desc(struct feat_fd *ff, void *data __maybe_unused) in process_event_desc() argument
2473 struct evsel *evsel, *events = read_event_desc(ff); in process_event_desc()
2478 session = container_of(ff->ph, struct perf_session, header); in process_event_desc()
2483 ff->events = events; in process_event_desc()
2495 static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused) in process_cmdline() argument
2500 if (do_read_u32(ff, &nr)) in process_cmdline()
2503 ff->ph->env.nr_cmdline = nr; in process_cmdline()
2505 cmdline = zalloc(ff->size + nr + 1); in process_cmdline()
2514 str = do_read_string(ff); in process_cmdline()
2523 ff->ph->env.cmdline = cmdline; in process_cmdline()
2524 ff->ph->env.cmdline_argv = (const char **) argv; in process_cmdline()
2533 static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused) in process_cpu_topology() argument
2538 int cpu_nr = ff->ph->env.nr_cpus_avail; in process_cpu_topology()
2540 struct perf_header *ph = ff->ph; in process_cpu_topology()
2547 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2556 str = do_read_string(ff); in process_cpu_topology()
2568 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2575 str = do_read_string(ff); in process_cpu_topology()
2591 if (ff->size <= size) { in process_cpu_topology()
2606 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2612 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2629 if (ff->size <= size) in process_cpu_topology()
2632 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2639 str = do_read_string(ff); in process_cpu_topology()
2652 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2667 static int process_numa_topology(struct feat_fd *ff, void *data __maybe_unused) in process_numa_topology() argument
2674 if (do_read_u32(ff, &nr)) in process_numa_topology()
2685 if (do_read_u32(ff, &n->node)) in process_numa_topology()
2688 if (do_read_u64(ff, &n->mem_total)) in process_numa_topology()
2691 if (do_read_u64(ff, &n->mem_free)) in process_numa_topology()
2694 str = do_read_string(ff); in process_numa_topology()
2704 ff->ph->env.nr_numa_nodes = nr; in process_numa_topology()
2705 ff->ph->env.numa_nodes = nodes; in process_numa_topology()
2713 static int process_pmu_mappings(struct feat_fd *ff, void *data __maybe_unused) in process_pmu_mappings() argument
2720 if (do_read_u32(ff, &pmu_num)) in process_pmu_mappings()
2728 ff->ph->env.nr_pmu_mappings = pmu_num; in process_pmu_mappings()
2733 if (do_read_u32(ff, &type)) in process_pmu_mappings()
2736 name = do_read_string(ff); in process_pmu_mappings()
2747 ff->ph->env.msr_pmu_type = type; in process_pmu_mappings()
2752 ff->ph->env.pmu_mappings = strbuf_detach(&sb, NULL); in process_pmu_mappings()
2760 static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) in process_group_desc() argument
2772 if (do_read_u32(ff, &nr_groups)) in process_group_desc()
2775 ff->ph->env.nr_groups = nr_groups; in process_group_desc()
2786 desc[i].name = do_read_string(ff); in process_group_desc()
2790 if (do_read_u32(ff, &desc[i].leader_idx)) in process_group_desc()
2793 if (do_read_u32(ff, &desc[i].nr_members)) in process_group_desc()
2800 session = container_of(ff->ph, struct perf_session, header); in process_group_desc()
2844 static int process_auxtrace(struct feat_fd *ff, void *data __maybe_unused) in process_auxtrace() argument
2849 session = container_of(ff->ph, struct perf_session, header); in process_auxtrace()
2851 err = auxtrace_index__process(ff->fd, ff->size, session, in process_auxtrace()
2852 ff->ph->needs_swap); in process_auxtrace()
2858 static int process_cache(struct feat_fd *ff, void *data __maybe_unused) in process_cache() argument
2863 if (do_read_u32(ff, &version)) in process_cache()
2869 if (do_read_u32(ff, &cnt)) in process_cache()
2880 if (do_read_u32(ff, &c.v))\ in process_cache()
2890 c.v = do_read_string(ff); \ in process_cache()
2902 ff->ph->env.caches = caches; in process_cache()
2903 ff->ph->env.caches_cnt = cnt; in process_cache()
2910 static int process_sample_time(struct feat_fd *ff, void *data __maybe_unused) in process_sample_time() argument
2916 session = container_of(ff->ph, struct perf_session, header); in process_sample_time()
2918 ret = do_read_u64(ff, &first_sample_time); in process_sample_time()
2922 ret = do_read_u64(ff, &last_sample_time); in process_sample_time()
2931 static int process_mem_topology(struct feat_fd *ff, in process_mem_topology() argument
2938 if (do_read_u64(ff, &version)) in process_mem_topology()
2944 if (do_read_u64(ff, &bsize)) in process_mem_topology()
2947 if (do_read_u64(ff, &nr)) in process_mem_topology()
2958 if (do_read_u64(ff, &n.v)) \ in process_mem_topology()
2966 if (do_read_bitmap(ff, &n.set, &n.size)) in process_mem_topology()
2972 ff->ph->env.memory_bsize = bsize; in process_mem_topology()
2973 ff->ph->env.memory_nodes = nodes; in process_mem_topology()
2974 ff->ph->env.nr_memory_nodes = nr; in process_mem_topology()
2983 static int process_clockid(struct feat_fd *ff, in process_clockid() argument
2986 if (do_read_u64(ff, &ff->ph->env.clock.clockid_res_ns)) in process_clockid()
2992 static int process_clock_data(struct feat_fd *ff, in process_clock_data() argument
2999 if (do_read_u32(ff, &data32)) in process_clock_data()
3006 if (do_read_u32(ff, &data32)) in process_clock_data()
3009 ff->ph->env.clock.clockid = data32; in process_clock_data()
3012 if (do_read_u64(ff, &data64)) in process_clock_data()
3015 ff->ph->env.clock.tod_ns = data64; in process_clock_data()
3018 if (do_read_u64(ff, &data64)) in process_clock_data()
3021 ff->ph->env.clock.clockid_ns = data64; in process_clock_data()
3022 ff->ph->env.clock.enabled = true; in process_clock_data()
3026 static int process_hybrid_topology(struct feat_fd *ff, in process_hybrid_topology() argument
3033 if (do_read_u32(ff, &nr)) in process_hybrid_topology()
3043 n->pmu_name = do_read_string(ff); in process_hybrid_topology()
3047 n->cpus = do_read_string(ff); in process_hybrid_topology()
3052 ff->ph->env.nr_hybrid_nodes = nr; in process_hybrid_topology()
3053 ff->ph->env.hybrid_nodes = nodes; in process_hybrid_topology()
3066 static int process_dir_format(struct feat_fd *ff, in process_dir_format() argument
3072 session = container_of(ff->ph, struct perf_session, header); in process_dir_format()
3078 return do_read_u64(ff, &data->dir.version); in process_dir_format()
3082 static int process_bpf_prog_info(struct feat_fd *ff, void *data __maybe_unused) in process_bpf_prog_info() argument
3085 struct perf_env *env = &ff->ph->env; in process_bpf_prog_info()
3090 if (ff->ph->needs_swap) { in process_bpf_prog_info()
3095 if (do_read_u32(ff, &count)) in process_bpf_prog_info()
3105 if (do_read_u32(ff, &info_len)) in process_bpf_prog_info()
3107 if (do_read_u32(ff, &data_len)) in process_bpf_prog_info()
3121 if (do_read_u64(ff, (u64 *)(&info_linear->arrays))) in process_bpf_prog_info()
3123 if (__do_read(ff, &info_linear->info, info_len)) in process_bpf_prog_info()
3129 if (__do_read(ff, info_linear->data, data_len)) in process_bpf_prog_info()
3151 static int process_bpf_btf(struct feat_fd *ff, void *data __maybe_unused) in process_bpf_btf() argument
3153 struct perf_env *env = &ff->ph->env; in process_bpf_btf()
3158 if (ff->ph->needs_swap) { in process_bpf_btf()
3163 if (do_read_u32(ff, &count)) in process_bpf_btf()
3171 if (do_read_u32(ff, &id)) in process_bpf_btf()
3173 if (do_read_u32(ff, &data_size)) in process_bpf_btf()
3183 if (__do_read(ff, node->data, data_size)) in process_bpf_btf()
3198 static int process_compressed(struct feat_fd *ff, in process_compressed() argument
3201 if (do_read_u32(ff, &(ff->ph->env.comp_ver))) in process_compressed()
3204 if (do_read_u32(ff, &(ff->ph->env.comp_type))) in process_compressed()
3207 if (do_read_u32(ff, &(ff->ph->env.comp_level))) in process_compressed()
3210 if (do_read_u32(ff, &(ff->ph->env.comp_ratio))) in process_compressed()
3213 if (do_read_u32(ff, &(ff->ph->env.comp_mmap_len))) in process_compressed()
3219 static int __process_pmu_caps(struct feat_fd *ff, int *nr_caps, in __process_pmu_caps() argument
3228 if (do_read_u32(ff, &nr_pmu_caps)) in __process_pmu_caps()
3239 name = do_read_string(ff); in __process_pmu_caps()
3243 value = do_read_string(ff); in __process_pmu_caps()
3274 static int process_cpu_pmu_caps(struct feat_fd *ff, in process_cpu_pmu_caps() argument
3277 int ret = __process_pmu_caps(ff, &ff->ph->env.nr_cpu_pmu_caps, in process_cpu_pmu_caps()
3278 &ff->ph->env.cpu_pmu_caps, in process_cpu_pmu_caps()
3279 &ff->ph->env.max_branches); in process_cpu_pmu_caps()
3281 if (!ret && !ff->ph->env.cpu_pmu_caps) in process_cpu_pmu_caps()
3286 static int process_pmu_caps(struct feat_fd *ff, void *data __maybe_unused) in process_pmu_caps() argument
3293 if (do_read_u32(ff, &nr_pmu)) in process_pmu_caps()
3306 ret = __process_pmu_caps(ff, &pmu_caps[i].nr_caps, in process_pmu_caps()
3312 pmu_caps[i].pmu_name = do_read_string(ff); in process_pmu_caps()
3323 ff->ph->env.nr_pmus_with_caps = nr_pmu; in process_pmu_caps()
3324 ff->ph->env.pmu_caps = pmu_caps; in process_pmu_caps()
3414 struct feat_fd ff; in perf_file_section__fprintf_info() local
3428 ff = (struct feat_fd) { in perf_file_section__fprintf_info()
3434 feat_ops[feat].print(&ff, hd->fp); in perf_file_section__fprintf_info()
3484 struct feat_fd *ff; member
3491 return do_write(h->ff, buf, sz); in feat_writer_cb()
3494 static int do_write_feat(struct feat_fd *ff, int type, in do_write_feat() argument
3502 if (perf_header__has_feat(ff->ph, type)) { in do_write_feat()
3506 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) in do_write_feat()
3509 (*p)->offset = lseek(ff->fd, 0, SEEK_CUR); in do_write_feat()
3518 .ff = ff, in do_write_feat()
3527 err = feat_ops[type].write(ff, evlist); in do_write_feat()
3532 lseek(ff->fd, (*p)->offset, SEEK_SET); in do_write_feat()
3536 (*p)->size = lseek(ff->fd, 0, SEEK_CUR) - (*p)->offset; in do_write_feat()
3547 struct feat_fd ff; in perf_header__adds_write() local
3554 ff = (struct feat_fd){ in perf_header__adds_write()
3573 if (do_write_feat(&ff, feat, &p, evlist, fc)) in perf_header__adds_write()
3582 err = do_write(&ff, feat_sec, sec_size); in perf_header__adds_write()
3592 struct feat_fd ff; in perf_header__write_pipe() local
3595 ff = (struct feat_fd){ .fd = fd }; in perf_header__write_pipe()
3602 err = do_write(&ff, &f_header, sizeof(f_header)); in perf_header__write_pipe()
3620 struct feat_fd ff; in perf_session__do_write_header() local
3624 ff = (struct feat_fd){ .fd = fd}; in perf_session__do_write_header()
3629 err = do_write(&ff, evsel->core.id, evsel->core.ids * sizeof(u64)); in perf_session__do_write_header()
3636 attr_offset = lseek(ff.fd, 0, SEEK_CUR); in perf_session__do_write_header()
3654 err = do_write(&ff, &f_attr, sizeof(f_attr)); in perf_session__do_write_header()
3689 err = do_write(&ff, &f_header, sizeof(f_header)); in perf_session__do_write_header()
4001 struct feat_fd ff = { in perf_file_header__read_pipe() local
4019 if (repipe && do_write(&ff, header, sizeof(*header)) < 0) in perf_file_header__read_pipe()
4253 struct feat_fd ff = { .fd = 0 }; in perf_event__process_feature() local
4271 ff.buf = (void *)fe->data; in perf_event__process_feature()
4272 ff.size = event->header.size - sizeof(*fe); in perf_event__process_feature()
4273 ff.ph = &session->header; in perf_event__process_feature()
4275 if (feat_ops[feat].process(&ff, NULL)) { in perf_event__process_feature()
4285 feat_ops[feat].print(&ff, stdout); in perf_event__process_feature()
4291 free_event_desc(ff.events); in perf_event__process_feature()