Lines Matching refs:thread_data
182 struct record_thread *thread_data; member
1022 static void record__thread_data_init_pipes(struct record_thread *thread_data) in record__thread_data_init_pipes() argument
1024 thread_data->pipes.msg[0] = -1; in record__thread_data_init_pipes()
1025 thread_data->pipes.msg[1] = -1; in record__thread_data_init_pipes()
1026 thread_data->pipes.ack[0] = -1; in record__thread_data_init_pipes()
1027 thread_data->pipes.ack[1] = -1; in record__thread_data_init_pipes()
1030 static int record__thread_data_open_pipes(struct record_thread *thread_data) in record__thread_data_open_pipes() argument
1032 if (pipe(thread_data->pipes.msg)) in record__thread_data_open_pipes()
1035 if (pipe(thread_data->pipes.ack)) { in record__thread_data_open_pipes()
1036 close(thread_data->pipes.msg[0]); in record__thread_data_open_pipes()
1037 thread_data->pipes.msg[0] = -1; in record__thread_data_open_pipes()
1038 close(thread_data->pipes.msg[1]); in record__thread_data_open_pipes()
1039 thread_data->pipes.msg[1] = -1; in record__thread_data_open_pipes()
1043 pr_debug2("thread_data[%p]: msg=[%d,%d], ack=[%d,%d]\n", thread_data, in record__thread_data_open_pipes()
1044 thread_data->pipes.msg[0], thread_data->pipes.msg[1], in record__thread_data_open_pipes()
1045 thread_data->pipes.ack[0], thread_data->pipes.ack[1]); in record__thread_data_open_pipes()
1050 static void record__thread_data_close_pipes(struct record_thread *thread_data) in record__thread_data_close_pipes() argument
1052 if (thread_data->pipes.msg[0] != -1) { in record__thread_data_close_pipes()
1053 close(thread_data->pipes.msg[0]); in record__thread_data_close_pipes()
1054 thread_data->pipes.msg[0] = -1; in record__thread_data_close_pipes()
1056 if (thread_data->pipes.msg[1] != -1) { in record__thread_data_close_pipes()
1057 close(thread_data->pipes.msg[1]); in record__thread_data_close_pipes()
1058 thread_data->pipes.msg[1] = -1; in record__thread_data_close_pipes()
1060 if (thread_data->pipes.ack[0] != -1) { in record__thread_data_close_pipes()
1061 close(thread_data->pipes.ack[0]); in record__thread_data_close_pipes()
1062 thread_data->pipes.ack[0] = -1; in record__thread_data_close_pipes()
1064 if (thread_data->pipes.ack[1] != -1) { in record__thread_data_close_pipes()
1065 close(thread_data->pipes.ack[1]); in record__thread_data_close_pipes()
1066 thread_data->pipes.ack[1] = -1; in record__thread_data_close_pipes()
1075 static int record__thread_data_init_maps(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_maps() argument
1084 thread_data->nr_mmaps = nr_mmaps; in record__thread_data_init_maps()
1086 thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, in record__thread_data_init_maps()
1087 thread_data->mask->maps.nbits); in record__thread_data_init_maps()
1089 thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1090 if (!thread_data->maps) in record__thread_data_init_maps()
1094 thread_data->overwrite_maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1095 if (!thread_data->overwrite_maps) { in record__thread_data_init_maps()
1096 zfree(&thread_data->maps); in record__thread_data_init_maps()
1100 pr_debug2("thread_data[%p]: nr_mmaps=%d, maps=%p, ow_maps=%p\n", thread_data, in record__thread_data_init_maps()
1101 thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps); in record__thread_data_init_maps()
1103 for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) { in record__thread_data_init_maps()
1105 test_bit(perf_cpu_map__cpu(cpus, m).cpu, thread_data->mask->maps.bits)) { in record__thread_data_init_maps()
1106 if (thread_data->maps) { in record__thread_data_init_maps()
1107 thread_data->maps[tm] = &mmap[m]; in record__thread_data_init_maps()
1109 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1111 if (thread_data->overwrite_maps) { in record__thread_data_init_maps()
1112 thread_data->overwrite_maps[tm] = &overwrite_mmap[m]; in record__thread_data_init_maps()
1114 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1123 static int record__thread_data_init_pollfd(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_pollfd() argument
1128 fdarray__init(&thread_data->pollfd, 64); in record__thread_data_init_pollfd()
1130 for (tm = 0; tm < thread_data->nr_mmaps; tm++) { in record__thread_data_init_pollfd()
1131 map = thread_data->maps ? thread_data->maps[tm] : NULL; in record__thread_data_init_pollfd()
1132 overwrite_map = thread_data->overwrite_maps ? in record__thread_data_init_pollfd()
1133 thread_data->overwrite_maps[tm] : NULL; in record__thread_data_init_pollfd()
1139 pos = fdarray__dup_entry_from(&thread_data->pollfd, f, in record__thread_data_init_pollfd()
1144 thread_data, pos, evlist->core.pollfd.entries[f].fd); in record__thread_data_init_pollfd()
1155 struct record_thread *thread_data = rec->thread_data; in record__free_thread_data() local
1157 if (thread_data == NULL) in record__free_thread_data()
1161 record__thread_data_close_pipes(&thread_data[t]); in record__free_thread_data()
1162 zfree(&thread_data[t].maps); in record__free_thread_data()
1163 zfree(&thread_data[t].overwrite_maps); in record__free_thread_data()
1164 fdarray__exit(&thread_data[t].pollfd); in record__free_thread_data()
1167 zfree(&rec->thread_data); in record__free_thread_data()
1186 struct record_thread *thread_data) in record__update_evlist_pollfd_from_thread() argument
1189 struct pollfd *t_entries = thread_data->pollfd.entries; in record__update_evlist_pollfd_from_thread()
1210 struct record_thread *thread_data) in record__dup_non_perf_events() argument
1218 ret = fdarray__dup_entry_from(&thread_data->pollfd, i, fda); in record__dup_non_perf_events()
1224 thread_data, ret, fda->entries[i].fd); in record__dup_non_perf_events()
1237 struct record_thread *thread_data; in record__alloc_thread_data() local
1239 rec->thread_data = zalloc(rec->nr_threads * sizeof(*(rec->thread_data))); in record__alloc_thread_data()
1240 if (!rec->thread_data) { in record__alloc_thread_data()
1244 thread_data = rec->thread_data; in record__alloc_thread_data()
1247 record__thread_data_init_pipes(&thread_data[t]); in record__alloc_thread_data()
1250 thread_data[t].rec = rec; in record__alloc_thread_data()
1251 thread_data[t].mask = &rec->thread_masks[t]; in record__alloc_thread_data()
1252 ret = record__thread_data_init_maps(&thread_data[t], evlist); in record__alloc_thread_data()
1257 ret = record__thread_data_init_pollfd(&thread_data[t], evlist); in record__alloc_thread_data()
1263 thread_data[t].tid = -1; in record__alloc_thread_data()
1264 ret = record__thread_data_open_pipes(&thread_data[t]); in record__alloc_thread_data()
1269 ret = fdarray__add(&thread_data[t].pollfd, thread_data[t].pipes.msg[0], in record__alloc_thread_data()
1275 thread_data[t].ctlfd_pos = ret; in record__alloc_thread_data()
1277 thread_data, thread_data[t].ctlfd_pos, in record__alloc_thread_data()
1278 thread_data[t].pipes.msg[0]); in record__alloc_thread_data()
1280 thread_data[t].tid = gettid(); in record__alloc_thread_data()
1282 ret = record__dup_non_perf_events(rec, evlist, &thread_data[t]); in record__alloc_thread_data()
1286 thread_data[t].ctlfd_pos = -1; /* Not used */ in record__alloc_thread_data()
2241 static int record__terminate_thread(struct record_thread *thread_data) in record__terminate_thread() argument
2245 pid_t tid = thread_data->tid; in record__terminate_thread()
2247 close(thread_data->pipes.msg[1]); in record__terminate_thread()
2248 thread_data->pipes.msg[1] = -1; in record__terminate_thread()
2249 err = read(thread_data->pipes.ack[0], &ack, sizeof(ack)); in record__terminate_thread()
2262 struct record_thread *thread_data = rec->thread_data; in record__start_threads() local
2267 thread = &thread_data[0]; in record__start_threads()
2286 MMAP_CPU_MASK_BYTES(&(thread_data[t].mask->affinity)), in record__start_threads()
2287 (cpu_set_t *)(thread_data[t].mask->affinity.bits)); in record__start_threads()
2289 if (pthread_create(&handle, &attrs, record__thread, &thread_data[t])) { in record__start_threads()
2291 record__terminate_thread(&thread_data[t]); in record__start_threads()
2297 err = read(thread_data[t].pipes.ack[0], &msg, sizeof(msg)); in record__start_threads()
2299 pr_debug2("threads[%d]: sent %s\n", rec->thread_data[t].tid, in record__start_threads()
2303 thread->tid, rec->thread_data[t].tid); in record__start_threads()
2325 struct record_thread *thread_data = rec->thread_data; in record__stop_threads() local
2328 record__terminate_thread(&thread_data[t]); in record__stop_threads()
2331 rec->samples += thread_data[t].samples; in record__stop_threads()
2334 rec->session->bytes_transferred += thread_data[t].bytes_transferred; in record__stop_threads()
2335 rec->session->bytes_compressed += thread_data[t].bytes_compressed; in record__stop_threads()
2336 pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid, in record__stop_threads()
2337 thread_data[t].samples, thread_data[t].waking); in record__stop_threads()
2338 if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed) in record__stop_threads()
2340 thread_data[t].bytes_transferred, thread_data[t].bytes_compressed); in record__stop_threads()
2342 pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written); in record__stop_threads()
2352 struct record_thread *thread_data = rec->thread_data; in record__waking() local
2355 waking += thread_data[t].waking; in record__waking()