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()
987 static int write_bpf_prog_info(struct feat_fd *ff, in write_bpf_prog_info() argument
990 struct perf_env *env = &ff->ph->env; in write_bpf_prog_info()
997 ret = do_write(ff, &env->bpf_progs.infos_cnt, in write_bpf_prog_info()
1015 ret = do_write(ff, node->info_linear, len); in write_bpf_prog_info()
1029 static int write_bpf_btf(struct feat_fd *ff, in write_bpf_btf() argument
1032 struct perf_env *env = &ff->ph->env; in write_bpf_btf()
1039 ret = do_write(ff, &env->bpf_progs.btfs_cnt, in write_bpf_btf()
1052 ret = do_write(ff, &node->id, in write_bpf_btf()
1195 static int write_cache(struct feat_fd *ff, in write_cache() argument
1209 ret = do_write(ff, &version, sizeof(u32)); in write_cache()
1213 ret = do_write(ff, &cnt, sizeof(u32)); in write_cache()
1221 ret = do_write(ff, &c->v, sizeof(u32)); \ in write_cache()
1232 ret = do_write_string(ff, (const char *) c->v); \ in write_cache()
1248 static int write_stat(struct feat_fd *ff __maybe_unused, in write_stat()
1254 static int write_sample_time(struct feat_fd *ff, in write_sample_time() argument
1259 ret = do_write(ff, &evlist->first_sample_time, in write_sample_time()
1264 return do_write(ff, &evlist->last_sample_time, in write_sample_time()
1390 static int write_mem_topology(struct feat_fd *ff __maybe_unused, in write_mem_topology()
1406 ret = do_write(ff, &version, sizeof(version)); in write_mem_topology()
1410 ret = do_write(ff, &bsize, sizeof(bsize)); in write_mem_topology()
1414 ret = do_write(ff, &nr, sizeof(nr)); in write_mem_topology()
1422 ret = do_write(ff, &n->v, sizeof(n->v)); \ in write_mem_topology()
1431 ret = do_write_bitmap(ff, n->set, n->size); in write_mem_topology()
1440 static int write_compressed(struct feat_fd *ff __maybe_unused, in write_compressed()
1445 ret = do_write(ff, &(ff->ph->env.comp_ver), sizeof(ff->ph->env.comp_ver)); in write_compressed()
1449 ret = do_write(ff, &(ff->ph->env.comp_type), sizeof(ff->ph->env.comp_type)); in write_compressed()
1453 ret = do_write(ff, &(ff->ph->env.comp_level), sizeof(ff->ph->env.comp_level)); in write_compressed()
1457 ret = do_write(ff, &(ff->ph->env.comp_ratio), sizeof(ff->ph->env.comp_ratio)); in write_compressed()
1461 return do_write(ff, &(ff->ph->env.comp_mmap_len), sizeof(ff->ph->env.comp_mmap_len)); in write_compressed()
1464 static int write_per_cpu_pmu_caps(struct feat_fd *ff, struct perf_pmu *pmu, in write_per_cpu_pmu_caps() argument
1475 ret = do_write(ff, &nr_caps, sizeof(nr_caps)); in write_per_cpu_pmu_caps()
1480 ret = do_write_string(ff, caps->name); in write_per_cpu_pmu_caps()
1484 ret = do_write_string(ff, caps->value); in write_per_cpu_pmu_caps()
1490 ret = do_write_string(ff, pmu->name); in write_per_cpu_pmu_caps()
1498 static int write_cpu_pmu_caps(struct feat_fd *ff, in write_cpu_pmu_caps() argument
1506 return write_per_cpu_pmu_caps(ff, cpu_pmu, false); in write_cpu_pmu_caps()
1509 static int write_hybrid_cpu_pmu_caps(struct feat_fd *ff, in write_hybrid_cpu_pmu_caps() argument
1519 ret = do_write(ff, &nr_pmu, sizeof(nr_pmu)); in write_hybrid_cpu_pmu_caps()
1524 ret = write_per_cpu_pmu_caps(ff, pmu, true); in write_hybrid_cpu_pmu_caps()
1532 static void print_hostname(struct feat_fd *ff, FILE *fp) in print_hostname() argument
1534 fprintf(fp, "# hostname : %s\n", ff->ph->env.hostname); in print_hostname()
1537 static void print_osrelease(struct feat_fd *ff, FILE *fp) in print_osrelease() argument
1539 fprintf(fp, "# os release : %s\n", ff->ph->env.os_release); in print_osrelease()
1542 static void print_arch(struct feat_fd *ff, FILE *fp) in print_arch() argument
1544 fprintf(fp, "# arch : %s\n", ff->ph->env.arch); in print_arch()
1547 static void print_cpudesc(struct feat_fd *ff, FILE *fp) in print_cpudesc() argument
1549 fprintf(fp, "# cpudesc : %s\n", ff->ph->env.cpu_desc); in print_cpudesc()
1552 static void print_nrcpus(struct feat_fd *ff, FILE *fp) in print_nrcpus() argument
1554 fprintf(fp, "# nrcpus online : %u\n", ff->ph->env.nr_cpus_online); in print_nrcpus()
1555 fprintf(fp, "# nrcpus avail : %u\n", ff->ph->env.nr_cpus_avail); in print_nrcpus()
1558 static void print_version(struct feat_fd *ff, FILE *fp) in print_version() argument
1560 fprintf(fp, "# perf version : %s\n", ff->ph->env.version); in print_version()
1563 static void print_cmdline(struct feat_fd *ff, FILE *fp) in print_cmdline() argument
1567 nr = ff->ph->env.nr_cmdline; in print_cmdline()
1572 char *argv_i = strdup(ff->ph->env.cmdline_argv[i]); in print_cmdline()
1574 fprintf(fp, "%s ", ff->ph->env.cmdline_argv[i]); in print_cmdline()
1592 static void print_cpu_topology(struct feat_fd *ff, FILE *fp) in print_cpu_topology() argument
1594 struct perf_header *ph = ff->ph; in print_cpu_topology()
1649 static void print_clockid(struct feat_fd *ff, FILE *fp) in print_clockid() argument
1652 ff->ph->env.clock.clockid_res_ns * 1000); in print_clockid()
1655 static void print_clock_data(struct feat_fd *ff, FILE *fp) in print_clock_data() argument
1664 if (!ff->ph->env.clock.enabled) { in print_clock_data()
1670 ref = ff->ph->env.clock.tod_ns; in print_clock_data()
1676 ref = ff->ph->env.clock.clockid_ns; in print_clock_data()
1681 clockid = ff->ph->env.clock.clockid; in print_clock_data()
1698 static void print_hybrid_topology(struct feat_fd *ff, FILE *fp) in print_hybrid_topology() argument
1704 for (i = 0; i < ff->ph->env.nr_hybrid_nodes; i++) { in print_hybrid_topology()
1705 n = &ff->ph->env.hybrid_nodes[i]; in print_hybrid_topology()
1710 static void print_dir_format(struct feat_fd *ff, FILE *fp) in print_dir_format() argument
1715 session = container_of(ff->ph, struct perf_session, header); in print_dir_format()
1722 static void print_bpf_prog_info(struct feat_fd *ff, FILE *fp) in print_bpf_prog_info() argument
1724 struct perf_env *env = &ff->ph->env; in print_bpf_prog_info()
1746 static void print_bpf_btf(struct feat_fd *ff, FILE *fp) in print_bpf_btf() argument
1748 struct perf_env *env = &ff->ph->env; in print_bpf_btf()
1818 static struct evsel *read_event_desc(struct feat_fd *ff) in read_event_desc() argument
1827 if (do_read_u32(ff, &nre)) in read_event_desc()
1830 if (do_read_u32(ff, &sz)) in read_event_desc()
1854 if (__do_read(ff, buf, sz)) in read_event_desc()
1857 if (ff->ph->needs_swap) in read_event_desc()
1865 if (do_read_u32(ff, &nr)) in read_event_desc()
1868 if (ff->ph->needs_swap) in read_event_desc()
1871 evsel->name = do_read_string(ff); in read_event_desc()
1885 if (do_read_u64(ff, id)) in read_event_desc()
1905 static void print_event_desc(struct feat_fd *ff, FILE *fp) in print_event_desc() argument
1911 if (ff->events) in print_event_desc()
1912 events = ff->events; in print_event_desc()
1914 events = read_event_desc(ff); in print_event_desc()
1940 ff->events = NULL; in print_event_desc()
1943 static void print_total_mem(struct feat_fd *ff, FILE *fp) in print_total_mem() argument
1945 fprintf(fp, "# total memory : %llu kB\n", ff->ph->env.total_mem); in print_total_mem()
1948 static void print_numa_topology(struct feat_fd *ff, FILE *fp) in print_numa_topology() argument
1953 for (i = 0; i < ff->ph->env.nr_numa_nodes; i++) { in print_numa_topology()
1954 n = &ff->ph->env.numa_nodes[i]; in print_numa_topology()
1965 static void print_cpuid(struct feat_fd *ff, FILE *fp) in print_cpuid() argument
1967 fprintf(fp, "# cpuid : %s\n", ff->ph->env.cpuid); in print_cpuid()
1970 static void print_branch_stack(struct feat_fd *ff __maybe_unused, FILE *fp) in print_branch_stack()
1975 static void print_auxtrace(struct feat_fd *ff __maybe_unused, FILE *fp) in print_auxtrace()
1980 static void print_stat(struct feat_fd *ff __maybe_unused, FILE *fp) in print_stat()
1985 static void print_cache(struct feat_fd *ff, FILE *fp __maybe_unused) in print_cache() argument
1990 for (i = 0; i < ff->ph->env.caches_cnt; i++) { in print_cache()
1992 cpu_cache_level__fprintf(fp, &ff->ph->env.caches[i]); in print_cache()
1996 static void print_compressed(struct feat_fd *ff, FILE *fp) in print_compressed() argument
1999 ff->ph->env.comp_type == PERF_COMP_ZSTD ? "Zstd" : "Unknown", in print_compressed()
2000 ff->ph->env.comp_level, ff->ph->env.comp_ratio); in print_compressed()
2034 static void print_cpu_pmu_caps(struct feat_fd *ff, FILE *fp) in print_cpu_pmu_caps() argument
2036 print_per_cpu_pmu_caps(fp, ff->ph->env.nr_cpu_pmu_caps, in print_cpu_pmu_caps()
2037 ff->ph->env.cpu_pmu_caps, NULL); in print_cpu_pmu_caps()
2040 static void print_hybrid_cpu_pmu_caps(struct feat_fd *ff, FILE *fp) in print_hybrid_cpu_pmu_caps() argument
2044 for (int i = 0; i < ff->ph->env.nr_hybrid_cpc_nodes; i++) { in print_hybrid_cpu_pmu_caps()
2045 n = &ff->ph->env.hybrid_cpc_nodes[i]; in print_hybrid_cpu_pmu_caps()
2052 static void print_pmu_mappings(struct feat_fd *ff, FILE *fp) in print_pmu_mappings() argument
2059 pmu_num = ff->ph->env.nr_pmu_mappings; in print_pmu_mappings()
2065 str = ff->ph->env.pmu_mappings; in print_pmu_mappings()
2088 static void print_group_desc(struct feat_fd *ff, FILE *fp) in print_group_desc() argument
2094 session = container_of(ff->ph, struct perf_session, header); in print_group_desc()
2110 static void print_sample_time(struct feat_fd *ff, FILE *fp) in print_sample_time() argument
2116 session = container_of(ff->ph, struct perf_session, header); in print_sample_time()
2145 static void print_mem_topology(struct feat_fd *ff, FILE *fp) in print_mem_topology() argument
2150 nodes = ff->ph->env.memory_nodes; in print_mem_topology()
2151 nr = ff->ph->env.nr_memory_nodes; in print_mem_topology()
2154 nr, ff->ph->env.memory_bsize); in print_mem_topology()
2157 memory_node__fprintf(&nodes[i], ff->ph->env.memory_bsize, fp); in print_mem_topology()
2322 static int process_##__feat(struct feat_fd *ff, void *data __maybe_unused) \
2324 free(ff->ph->env.__feat_env); \
2325 ff->ph->env.__feat_env = do_read_string(ff); \
2326 return ff->ph->env.__feat_env ? 0 : -ENOMEM; \
2336 static int process_tracing_data(struct feat_fd *ff, void *data) in process_tracing_data() argument
2338 ssize_t ret = trace_report(ff->fd, data, false); in process_tracing_data()
2343 static int process_build_id(struct feat_fd *ff, void *data __maybe_unused) in process_build_id() argument
2345 if (perf_header__read_build_ids(ff->ph, ff->fd, ff->offset, ff->size)) in process_build_id()
2350 static int process_nrcpus(struct feat_fd *ff, void *data __maybe_unused) in process_nrcpus() argument
2355 ret = do_read_u32(ff, &nr_cpus_avail); in process_nrcpus()
2359 ret = do_read_u32(ff, &nr_cpus_online); in process_nrcpus()
2362 ff->ph->env.nr_cpus_avail = (int)nr_cpus_avail; in process_nrcpus()
2363 ff->ph->env.nr_cpus_online = (int)nr_cpus_online; in process_nrcpus()
2367 static int process_total_mem(struct feat_fd *ff, void *data __maybe_unused) in process_total_mem() argument
2372 ret = do_read_u64(ff, &total_mem); in process_total_mem()
2375 ff->ph->env.total_mem = (unsigned long long)total_mem; in process_total_mem()
2409 process_event_desc(struct feat_fd *ff, void *data __maybe_unused) in process_event_desc() argument
2412 struct evsel *evsel, *events = read_event_desc(ff); in process_event_desc()
2417 session = container_of(ff->ph, struct perf_session, header); in process_event_desc()
2422 ff->events = events; in process_event_desc()
2434 static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused) in process_cmdline() argument
2439 if (do_read_u32(ff, &nr)) in process_cmdline()
2442 ff->ph->env.nr_cmdline = nr; in process_cmdline()
2444 cmdline = zalloc(ff->size + nr + 1); in process_cmdline()
2453 str = do_read_string(ff); in process_cmdline()
2462 ff->ph->env.cmdline = cmdline; in process_cmdline()
2463 ff->ph->env.cmdline_argv = (const char **) argv; in process_cmdline()
2472 static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused) in process_cpu_topology() argument
2477 int cpu_nr = ff->ph->env.nr_cpus_avail; in process_cpu_topology()
2479 struct perf_header *ph = ff->ph; in process_cpu_topology()
2486 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2495 str = do_read_string(ff); in process_cpu_topology()
2507 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2514 str = do_read_string(ff); in process_cpu_topology()
2530 if (ff->size <= size) { in process_cpu_topology()
2545 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2551 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2568 if (ff->size <= size) in process_cpu_topology()
2571 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2578 str = do_read_string(ff); in process_cpu_topology()
2591 if (do_read_u32(ff, &nr)) in process_cpu_topology()
2606 static int process_numa_topology(struct feat_fd *ff, void *data __maybe_unused) in process_numa_topology() argument
2613 if (do_read_u32(ff, &nr)) in process_numa_topology()
2624 if (do_read_u32(ff, &n->node)) in process_numa_topology()
2627 if (do_read_u64(ff, &n->mem_total)) in process_numa_topology()
2630 if (do_read_u64(ff, &n->mem_free)) in process_numa_topology()
2633 str = do_read_string(ff); in process_numa_topology()
2643 ff->ph->env.nr_numa_nodes = nr; in process_numa_topology()
2644 ff->ph->env.numa_nodes = nodes; in process_numa_topology()
2652 static int process_pmu_mappings(struct feat_fd *ff, void *data __maybe_unused) in process_pmu_mappings() argument
2659 if (do_read_u32(ff, &pmu_num)) in process_pmu_mappings()
2667 ff->ph->env.nr_pmu_mappings = pmu_num; in process_pmu_mappings()
2672 if (do_read_u32(ff, &type)) in process_pmu_mappings()
2675 name = do_read_string(ff); in process_pmu_mappings()
2686 ff->ph->env.msr_pmu_type = type; in process_pmu_mappings()
2691 ff->ph->env.pmu_mappings = strbuf_detach(&sb, NULL); in process_pmu_mappings()
2699 static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) in process_group_desc() argument
2711 if (do_read_u32(ff, &nr_groups)) in process_group_desc()
2714 ff->ph->env.nr_groups = nr_groups; in process_group_desc()
2725 desc[i].name = do_read_string(ff); in process_group_desc()
2729 if (do_read_u32(ff, &desc[i].leader_idx)) in process_group_desc()
2732 if (do_read_u32(ff, &desc[i].nr_members)) in process_group_desc()
2739 session = container_of(ff->ph, struct perf_session, header); in process_group_desc()
2783 static int process_auxtrace(struct feat_fd *ff, void *data __maybe_unused) in process_auxtrace() argument
2788 session = container_of(ff->ph, struct perf_session, header); in process_auxtrace()
2790 err = auxtrace_index__process(ff->fd, ff->size, session, in process_auxtrace()
2791 ff->ph->needs_swap); in process_auxtrace()
2797 static int process_cache(struct feat_fd *ff, void *data __maybe_unused) in process_cache() argument
2802 if (do_read_u32(ff, &version)) in process_cache()
2808 if (do_read_u32(ff, &cnt)) in process_cache()
2819 if (do_read_u32(ff, &c.v))\ in process_cache()
2829 c.v = do_read_string(ff); \ in process_cache()
2841 ff->ph->env.caches = caches; in process_cache()
2842 ff->ph->env.caches_cnt = cnt; in process_cache()
2849 static int process_sample_time(struct feat_fd *ff, void *data __maybe_unused) in process_sample_time() argument
2855 session = container_of(ff->ph, struct perf_session, header); in process_sample_time()
2857 ret = do_read_u64(ff, &first_sample_time); in process_sample_time()
2861 ret = do_read_u64(ff, &last_sample_time); in process_sample_time()
2870 static int process_mem_topology(struct feat_fd *ff, in process_mem_topology() argument
2877 if (do_read_u64(ff, &version)) in process_mem_topology()
2883 if (do_read_u64(ff, &bsize)) in process_mem_topology()
2886 if (do_read_u64(ff, &nr)) in process_mem_topology()
2897 if (do_read_u64(ff, &n.v)) \ in process_mem_topology()
2905 if (do_read_bitmap(ff, &n.set, &n.size)) in process_mem_topology()
2911 ff->ph->env.memory_bsize = bsize; in process_mem_topology()
2912 ff->ph->env.memory_nodes = nodes; in process_mem_topology()
2913 ff->ph->env.nr_memory_nodes = nr; in process_mem_topology()
2922 static int process_clockid(struct feat_fd *ff, in process_clockid() argument
2925 if (do_read_u64(ff, &ff->ph->env.clock.clockid_res_ns)) in process_clockid()
2931 static int process_clock_data(struct feat_fd *ff, in process_clock_data() argument
2938 if (do_read_u32(ff, &data32)) in process_clock_data()
2945 if (do_read_u32(ff, &data32)) in process_clock_data()
2948 ff->ph->env.clock.clockid = data32; in process_clock_data()
2951 if (do_read_u64(ff, &data64)) in process_clock_data()
2954 ff->ph->env.clock.tod_ns = data64; in process_clock_data()
2957 if (do_read_u64(ff, &data64)) in process_clock_data()
2960 ff->ph->env.clock.clockid_ns = data64; in process_clock_data()
2961 ff->ph->env.clock.enabled = true; in process_clock_data()
2965 static int process_hybrid_topology(struct feat_fd *ff, in process_hybrid_topology() argument
2972 if (do_read_u32(ff, &nr)) in process_hybrid_topology()
2982 n->pmu_name = do_read_string(ff); in process_hybrid_topology()
2986 n->cpus = do_read_string(ff); in process_hybrid_topology()
2991 ff->ph->env.nr_hybrid_nodes = nr; in process_hybrid_topology()
2992 ff->ph->env.hybrid_nodes = nodes; in process_hybrid_topology()
3005 static int process_dir_format(struct feat_fd *ff, in process_dir_format() argument
3011 session = container_of(ff->ph, struct perf_session, header); in process_dir_format()
3017 return do_read_u64(ff, &data->dir.version); in process_dir_format()
3021 static int process_bpf_prog_info(struct feat_fd *ff, void *data __maybe_unused) in process_bpf_prog_info() argument
3024 struct perf_env *env = &ff->ph->env; in process_bpf_prog_info()
3029 if (ff->ph->needs_swap) { in process_bpf_prog_info()
3034 if (do_read_u32(ff, &count)) in process_bpf_prog_info()
3044 if (do_read_u32(ff, &info_len)) in process_bpf_prog_info()
3046 if (do_read_u32(ff, &data_len)) in process_bpf_prog_info()
3060 if (do_read_u64(ff, (u64 *)(&info_linear->arrays))) in process_bpf_prog_info()
3062 if (__do_read(ff, &info_linear->info, info_len)) in process_bpf_prog_info()
3068 if (__do_read(ff, info_linear->data, data_len)) in process_bpf_prog_info()
3090 static int process_bpf_btf(struct feat_fd *ff, void *data __maybe_unused) in process_bpf_btf() argument
3092 struct perf_env *env = &ff->ph->env; in process_bpf_btf()
3097 if (ff->ph->needs_swap) { in process_bpf_btf()
3102 if (do_read_u32(ff, &count)) in process_bpf_btf()
3110 if (do_read_u32(ff, &id)) in process_bpf_btf()
3112 if (do_read_u32(ff, &data_size)) in process_bpf_btf()
3122 if (__do_read(ff, node->data, data_size)) in process_bpf_btf()
3137 static int process_compressed(struct feat_fd *ff, in process_compressed() argument
3140 if (do_read_u32(ff, &(ff->ph->env.comp_ver))) in process_compressed()
3143 if (do_read_u32(ff, &(ff->ph->env.comp_type))) in process_compressed()
3146 if (do_read_u32(ff, &(ff->ph->env.comp_level))) in process_compressed()
3149 if (do_read_u32(ff, &(ff->ph->env.comp_ratio))) in process_compressed()
3152 if (do_read_u32(ff, &(ff->ph->env.comp_mmap_len))) in process_compressed()
3158 static int process_per_cpu_pmu_caps(struct feat_fd *ff, int *nr_cpu_pmu_caps, in process_per_cpu_pmu_caps() argument
3166 if (do_read_u32(ff, &nr_caps)) in process_per_cpu_pmu_caps()
3180 name = do_read_string(ff); in process_per_cpu_pmu_caps()
3184 value = do_read_string(ff); in process_per_cpu_pmu_caps()
3213 static int process_cpu_pmu_caps(struct feat_fd *ff, in process_cpu_pmu_caps() argument
3216 return process_per_cpu_pmu_caps(ff, &ff->ph->env.nr_cpu_pmu_caps, in process_cpu_pmu_caps()
3217 &ff->ph->env.cpu_pmu_caps, in process_cpu_pmu_caps()
3218 &ff->ph->env.max_branches); in process_cpu_pmu_caps()
3221 static int process_hybrid_cpu_pmu_caps(struct feat_fd *ff, in process_hybrid_cpu_pmu_caps() argument
3228 if (do_read_u32(ff, &nr_pmu)) in process_hybrid_cpu_pmu_caps()
3243 ret = process_per_cpu_pmu_caps(ff, &n->nr_cpu_pmu_caps, in process_hybrid_cpu_pmu_caps()
3249 n->pmu_name = do_read_string(ff); in process_hybrid_cpu_pmu_caps()
3256 ff->ph->env.nr_hybrid_cpc_nodes = nr_pmu; in process_hybrid_cpu_pmu_caps()
3257 ff->ph->env.hybrid_cpc_nodes = nodes; in process_hybrid_cpu_pmu_caps()
3345 struct feat_fd ff; in perf_file_section__fprintf_info() local
3359 ff = (struct feat_fd) { in perf_file_section__fprintf_info()
3365 feat_ops[feat].print(&ff, hd->fp); in perf_file_section__fprintf_info()
3413 static int do_write_feat(struct feat_fd *ff, int type, in do_write_feat() argument
3420 if (perf_header__has_feat(ff->ph, type)) { in do_write_feat()
3424 if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) in do_write_feat()
3427 (*p)->offset = lseek(ff->fd, 0, SEEK_CUR); in do_write_feat()
3429 err = feat_ops[type].write(ff, evlist); in do_write_feat()
3434 lseek(ff->fd, (*p)->offset, SEEK_SET); in do_write_feat()
3438 (*p)->size = lseek(ff->fd, 0, SEEK_CUR) - (*p)->offset; in do_write_feat()
3448 struct feat_fd ff; in perf_header__adds_write() local
3455 ff = (struct feat_fd){ in perf_header__adds_write()
3474 if (do_write_feat(&ff, feat, &p, evlist)) in perf_header__adds_write()
3483 err = do_write(&ff, feat_sec, sec_size); in perf_header__adds_write()
3493 struct feat_fd ff; in perf_header__write_pipe() local
3496 ff = (struct feat_fd){ .fd = fd }; in perf_header__write_pipe()
3503 err = do_write(&ff, &f_header, sizeof(f_header)); in perf_header__write_pipe()
3520 struct feat_fd ff; in perf_session__write_header() local
3524 ff = (struct feat_fd){ .fd = fd}; in perf_session__write_header()
3529 err = do_write(&ff, evsel->core.id, evsel->core.ids * sizeof(u64)); in perf_session__write_header()
3536 attr_offset = lseek(ff.fd, 0, SEEK_CUR); in perf_session__write_header()
3554 err = do_write(&ff, &f_attr, sizeof(f_attr)); in perf_session__write_header()
3589 err = do_write(&ff, &f_header, sizeof(f_header)); in perf_session__write_header()
3872 struct feat_fd ff = { in perf_file_header__read_pipe() local
3890 if (repipe && do_write(&ff, header, sizeof(*header)) < 0) in perf_file_header__read_pipe()
4124 struct feat_fd ff = { .fd = 0 }; in perf_event__process_feature() local
4142 ff.buf = (void *)fe->data; in perf_event__process_feature()
4143 ff.size = event->header.size - sizeof(*fe); in perf_event__process_feature()
4144 ff.ph = &session->header; in perf_event__process_feature()
4146 if (feat_ops[feat].process(&ff, NULL)) { in perf_event__process_feature()
4156 feat_ops[feat].print(&ff, stdout); in perf_event__process_feature()
4162 free_event_desc(ff.events); in perf_event__process_feature()