Lines Matching refs:thread_data
180 struct record_thread *thread_data; member
940 static void record__thread_data_init_pipes(struct record_thread *thread_data) in record__thread_data_init_pipes() argument
942 thread_data->pipes.msg[0] = -1; in record__thread_data_init_pipes()
943 thread_data->pipes.msg[1] = -1; in record__thread_data_init_pipes()
944 thread_data->pipes.ack[0] = -1; in record__thread_data_init_pipes()
945 thread_data->pipes.ack[1] = -1; in record__thread_data_init_pipes()
948 static int record__thread_data_open_pipes(struct record_thread *thread_data) in record__thread_data_open_pipes() argument
950 if (pipe(thread_data->pipes.msg)) in record__thread_data_open_pipes()
953 if (pipe(thread_data->pipes.ack)) { in record__thread_data_open_pipes()
954 close(thread_data->pipes.msg[0]); in record__thread_data_open_pipes()
955 thread_data->pipes.msg[0] = -1; in record__thread_data_open_pipes()
956 close(thread_data->pipes.msg[1]); in record__thread_data_open_pipes()
957 thread_data->pipes.msg[1] = -1; in record__thread_data_open_pipes()
961 pr_debug2("thread_data[%p]: msg=[%d,%d], ack=[%d,%d]\n", thread_data, in record__thread_data_open_pipes()
962 thread_data->pipes.msg[0], thread_data->pipes.msg[1], in record__thread_data_open_pipes()
963 thread_data->pipes.ack[0], thread_data->pipes.ack[1]); in record__thread_data_open_pipes()
968 static void record__thread_data_close_pipes(struct record_thread *thread_data) in record__thread_data_close_pipes() argument
970 if (thread_data->pipes.msg[0] != -1) { in record__thread_data_close_pipes()
971 close(thread_data->pipes.msg[0]); in record__thread_data_close_pipes()
972 thread_data->pipes.msg[0] = -1; in record__thread_data_close_pipes()
974 if (thread_data->pipes.msg[1] != -1) { in record__thread_data_close_pipes()
975 close(thread_data->pipes.msg[1]); in record__thread_data_close_pipes()
976 thread_data->pipes.msg[1] = -1; in record__thread_data_close_pipes()
978 if (thread_data->pipes.ack[0] != -1) { in record__thread_data_close_pipes()
979 close(thread_data->pipes.ack[0]); in record__thread_data_close_pipes()
980 thread_data->pipes.ack[0] = -1; in record__thread_data_close_pipes()
982 if (thread_data->pipes.ack[1] != -1) { in record__thread_data_close_pipes()
983 close(thread_data->pipes.ack[1]); in record__thread_data_close_pipes()
984 thread_data->pipes.ack[1] = -1; in record__thread_data_close_pipes()
993 static int record__thread_data_init_maps(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_maps() argument
1002 thread_data->nr_mmaps = nr_mmaps; in record__thread_data_init_maps()
1004 thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, in record__thread_data_init_maps()
1005 thread_data->mask->maps.nbits); in record__thread_data_init_maps()
1007 thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1008 if (!thread_data->maps) in record__thread_data_init_maps()
1012 thread_data->overwrite_maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1013 if (!thread_data->overwrite_maps) { in record__thread_data_init_maps()
1014 zfree(&thread_data->maps); in record__thread_data_init_maps()
1018 pr_debug2("thread_data[%p]: nr_mmaps=%d, maps=%p, ow_maps=%p\n", thread_data, in record__thread_data_init_maps()
1019 thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps); in record__thread_data_init_maps()
1021 for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) { in record__thread_data_init_maps()
1023 test_bit(perf_cpu_map__cpu(cpus, m).cpu, thread_data->mask->maps.bits)) { in record__thread_data_init_maps()
1024 if (thread_data->maps) { in record__thread_data_init_maps()
1025 thread_data->maps[tm] = &mmap[m]; in record__thread_data_init_maps()
1027 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1029 if (thread_data->overwrite_maps) { in record__thread_data_init_maps()
1030 thread_data->overwrite_maps[tm] = &overwrite_mmap[m]; in record__thread_data_init_maps()
1032 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1041 static int record__thread_data_init_pollfd(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_pollfd() argument
1046 fdarray__init(&thread_data->pollfd, 64); in record__thread_data_init_pollfd()
1048 for (tm = 0; tm < thread_data->nr_mmaps; tm++) { in record__thread_data_init_pollfd()
1049 map = thread_data->maps ? thread_data->maps[tm] : NULL; in record__thread_data_init_pollfd()
1050 overwrite_map = thread_data->overwrite_maps ? in record__thread_data_init_pollfd()
1051 thread_data->overwrite_maps[tm] : NULL; in record__thread_data_init_pollfd()
1057 pos = fdarray__dup_entry_from(&thread_data->pollfd, f, in record__thread_data_init_pollfd()
1062 thread_data, pos, evlist->core.pollfd.entries[f].fd); in record__thread_data_init_pollfd()
1073 struct record_thread *thread_data = rec->thread_data; in record__free_thread_data() local
1075 if (thread_data == NULL) in record__free_thread_data()
1079 record__thread_data_close_pipes(&thread_data[t]); in record__free_thread_data()
1080 zfree(&thread_data[t].maps); in record__free_thread_data()
1081 zfree(&thread_data[t].overwrite_maps); in record__free_thread_data()
1082 fdarray__exit(&thread_data[t].pollfd); in record__free_thread_data()
1085 zfree(&rec->thread_data); in record__free_thread_data()
1104 struct record_thread *thread_data) in record__update_evlist_pollfd_from_thread() argument
1107 struct pollfd *t_entries = thread_data->pollfd.entries; in record__update_evlist_pollfd_from_thread()
1128 struct record_thread *thread_data) in record__dup_non_perf_events() argument
1136 ret = fdarray__dup_entry_from(&thread_data->pollfd, i, fda); in record__dup_non_perf_events()
1142 thread_data, ret, fda->entries[i].fd); in record__dup_non_perf_events()
1155 struct record_thread *thread_data; in record__alloc_thread_data() local
1157 rec->thread_data = zalloc(rec->nr_threads * sizeof(*(rec->thread_data))); in record__alloc_thread_data()
1158 if (!rec->thread_data) { in record__alloc_thread_data()
1162 thread_data = rec->thread_data; in record__alloc_thread_data()
1165 record__thread_data_init_pipes(&thread_data[t]); in record__alloc_thread_data()
1168 thread_data[t].rec = rec; in record__alloc_thread_data()
1169 thread_data[t].mask = &rec->thread_masks[t]; in record__alloc_thread_data()
1170 ret = record__thread_data_init_maps(&thread_data[t], evlist); in record__alloc_thread_data()
1175 ret = record__thread_data_init_pollfd(&thread_data[t], evlist); in record__alloc_thread_data()
1181 thread_data[t].tid = -1; in record__alloc_thread_data()
1182 ret = record__thread_data_open_pipes(&thread_data[t]); in record__alloc_thread_data()
1187 ret = fdarray__add(&thread_data[t].pollfd, thread_data[t].pipes.msg[0], in record__alloc_thread_data()
1193 thread_data[t].ctlfd_pos = ret; in record__alloc_thread_data()
1195 thread_data, thread_data[t].ctlfd_pos, in record__alloc_thread_data()
1196 thread_data[t].pipes.msg[0]); in record__alloc_thread_data()
1198 thread_data[t].tid = gettid(); in record__alloc_thread_data()
1200 ret = record__dup_non_perf_events(rec, evlist, &thread_data[t]); in record__alloc_thread_data()
1204 thread_data[t].ctlfd_pos = -1; /* Not used */ in record__alloc_thread_data()
2213 static int record__terminate_thread(struct record_thread *thread_data) in record__terminate_thread() argument
2217 pid_t tid = thread_data->tid; in record__terminate_thread()
2219 close(thread_data->pipes.msg[1]); in record__terminate_thread()
2220 thread_data->pipes.msg[1] = -1; in record__terminate_thread()
2221 err = read(thread_data->pipes.ack[0], &ack, sizeof(ack)); in record__terminate_thread()
2234 struct record_thread *thread_data = rec->thread_data; in record__start_threads() local
2239 thread = &thread_data[0]; in record__start_threads()
2258 MMAP_CPU_MASK_BYTES(&(thread_data[t].mask->affinity)), in record__start_threads()
2259 (cpu_set_t *)(thread_data[t].mask->affinity.bits)); in record__start_threads()
2261 if (pthread_create(&handle, &attrs, record__thread, &thread_data[t])) { in record__start_threads()
2263 record__terminate_thread(&thread_data[t]); in record__start_threads()
2269 err = read(thread_data[t].pipes.ack[0], &msg, sizeof(msg)); in record__start_threads()
2271 pr_debug2("threads[%d]: sent %s\n", rec->thread_data[t].tid, in record__start_threads()
2275 thread->tid, rec->thread_data[t].tid); in record__start_threads()
2297 struct record_thread *thread_data = rec->thread_data; in record__stop_threads() local
2300 record__terminate_thread(&thread_data[t]); in record__stop_threads()
2303 rec->samples += thread_data[t].samples; in record__stop_threads()
2306 rec->session->bytes_transferred += thread_data[t].bytes_transferred; in record__stop_threads()
2307 rec->session->bytes_compressed += thread_data[t].bytes_compressed; in record__stop_threads()
2308 pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid, in record__stop_threads()
2309 thread_data[t].samples, thread_data[t].waking); in record__stop_threads()
2310 if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed) in record__stop_threads()
2312 thread_data[t].bytes_transferred, thread_data[t].bytes_compressed); in record__stop_threads()
2314 pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written); in record__stop_threads()
2324 struct record_thread *thread_data = rec->thread_data; in record__waking() local
2327 waking += thread_data[t].waking; in record__waking()