Lines Matching refs:thread_data

186 	struct record_thread	*thread_data;  member
1006 static void record__thread_data_init_pipes(struct record_thread *thread_data) in record__thread_data_init_pipes() argument
1008 thread_data->pipes.msg[0] = -1; in record__thread_data_init_pipes()
1009 thread_data->pipes.msg[1] = -1; in record__thread_data_init_pipes()
1010 thread_data->pipes.ack[0] = -1; in record__thread_data_init_pipes()
1011 thread_data->pipes.ack[1] = -1; in record__thread_data_init_pipes()
1014 static int record__thread_data_open_pipes(struct record_thread *thread_data) in record__thread_data_open_pipes() argument
1016 if (pipe(thread_data->pipes.msg)) in record__thread_data_open_pipes()
1019 if (pipe(thread_data->pipes.ack)) { in record__thread_data_open_pipes()
1020 close(thread_data->pipes.msg[0]); in record__thread_data_open_pipes()
1021 thread_data->pipes.msg[0] = -1; in record__thread_data_open_pipes()
1022 close(thread_data->pipes.msg[1]); in record__thread_data_open_pipes()
1023 thread_data->pipes.msg[1] = -1; in record__thread_data_open_pipes()
1027 pr_debug2("thread_data[%p]: msg=[%d,%d], ack=[%d,%d]\n", thread_data, in record__thread_data_open_pipes()
1028 thread_data->pipes.msg[0], thread_data->pipes.msg[1], in record__thread_data_open_pipes()
1029 thread_data->pipes.ack[0], thread_data->pipes.ack[1]); in record__thread_data_open_pipes()
1034 static void record__thread_data_close_pipes(struct record_thread *thread_data) in record__thread_data_close_pipes() argument
1036 if (thread_data->pipes.msg[0] != -1) { in record__thread_data_close_pipes()
1037 close(thread_data->pipes.msg[0]); in record__thread_data_close_pipes()
1038 thread_data->pipes.msg[0] = -1; in record__thread_data_close_pipes()
1040 if (thread_data->pipes.msg[1] != -1) { in record__thread_data_close_pipes()
1041 close(thread_data->pipes.msg[1]); in record__thread_data_close_pipes()
1042 thread_data->pipes.msg[1] = -1; in record__thread_data_close_pipes()
1044 if (thread_data->pipes.ack[0] != -1) { in record__thread_data_close_pipes()
1045 close(thread_data->pipes.ack[0]); in record__thread_data_close_pipes()
1046 thread_data->pipes.ack[0] = -1; in record__thread_data_close_pipes()
1048 if (thread_data->pipes.ack[1] != -1) { in record__thread_data_close_pipes()
1049 close(thread_data->pipes.ack[1]); in record__thread_data_close_pipes()
1050 thread_data->pipes.ack[1] = -1; in record__thread_data_close_pipes()
1059 static int record__thread_data_init_maps(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_maps() argument
1068 thread_data->nr_mmaps = nr_mmaps; in record__thread_data_init_maps()
1070 thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, in record__thread_data_init_maps()
1071 thread_data->mask->maps.nbits); in record__thread_data_init_maps()
1073 thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1074 if (!thread_data->maps) in record__thread_data_init_maps()
1078 thread_data->overwrite_maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1079 if (!thread_data->overwrite_maps) { in record__thread_data_init_maps()
1080 zfree(&thread_data->maps); in record__thread_data_init_maps()
1084 pr_debug2("thread_data[%p]: nr_mmaps=%d, maps=%p, ow_maps=%p\n", thread_data, in record__thread_data_init_maps()
1085 thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps); in record__thread_data_init_maps()
1087 for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) { in record__thread_data_init_maps()
1089 test_bit(perf_cpu_map__cpu(cpus, m).cpu, thread_data->mask->maps.bits)) { in record__thread_data_init_maps()
1090 if (thread_data->maps) { in record__thread_data_init_maps()
1091 thread_data->maps[tm] = &mmap[m]; in record__thread_data_init_maps()
1093 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1095 if (thread_data->overwrite_maps) { in record__thread_data_init_maps()
1096 thread_data->overwrite_maps[tm] = &overwrite_mmap[m]; in record__thread_data_init_maps()
1098 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1107 static int record__thread_data_init_pollfd(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_pollfd() argument
1112 fdarray__init(&thread_data->pollfd, 64); in record__thread_data_init_pollfd()
1114 for (tm = 0; tm < thread_data->nr_mmaps; tm++) { in record__thread_data_init_pollfd()
1115 map = thread_data->maps ? thread_data->maps[tm] : NULL; in record__thread_data_init_pollfd()
1116 overwrite_map = thread_data->overwrite_maps ? in record__thread_data_init_pollfd()
1117 thread_data->overwrite_maps[tm] : NULL; in record__thread_data_init_pollfd()
1123 pos = fdarray__dup_entry_from(&thread_data->pollfd, f, in record__thread_data_init_pollfd()
1128 thread_data, pos, evlist->core.pollfd.entries[f].fd); in record__thread_data_init_pollfd()
1139 struct record_thread *thread_data = rec->thread_data; in record__free_thread_data() local
1141 if (thread_data == NULL) in record__free_thread_data()
1145 record__thread_data_close_pipes(&thread_data[t]); in record__free_thread_data()
1146 zfree(&thread_data[t].maps); in record__free_thread_data()
1147 zfree(&thread_data[t].overwrite_maps); in record__free_thread_data()
1148 fdarray__exit(&thread_data[t].pollfd); in record__free_thread_data()
1151 zfree(&rec->thread_data); in record__free_thread_data()
1170 struct record_thread *thread_data) in record__update_evlist_pollfd_from_thread() argument
1173 struct pollfd *t_entries = thread_data->pollfd.entries; in record__update_evlist_pollfd_from_thread()
1194 struct record_thread *thread_data) in record__dup_non_perf_events() argument
1202 ret = fdarray__dup_entry_from(&thread_data->pollfd, i, fda); in record__dup_non_perf_events()
1208 thread_data, ret, fda->entries[i].fd); in record__dup_non_perf_events()
1221 struct record_thread *thread_data; in record__alloc_thread_data() local
1223 rec->thread_data = zalloc(rec->nr_threads * sizeof(*(rec->thread_data))); in record__alloc_thread_data()
1224 if (!rec->thread_data) { in record__alloc_thread_data()
1228 thread_data = rec->thread_data; in record__alloc_thread_data()
1231 record__thread_data_init_pipes(&thread_data[t]); in record__alloc_thread_data()
1234 thread_data[t].rec = rec; in record__alloc_thread_data()
1235 thread_data[t].mask = &rec->thread_masks[t]; in record__alloc_thread_data()
1236 ret = record__thread_data_init_maps(&thread_data[t], evlist); in record__alloc_thread_data()
1241 ret = record__thread_data_init_pollfd(&thread_data[t], evlist); in record__alloc_thread_data()
1247 thread_data[t].tid = -1; in record__alloc_thread_data()
1248 ret = record__thread_data_open_pipes(&thread_data[t]); in record__alloc_thread_data()
1253 ret = fdarray__add(&thread_data[t].pollfd, thread_data[t].pipes.msg[0], in record__alloc_thread_data()
1259 thread_data[t].ctlfd_pos = ret; in record__alloc_thread_data()
1261 thread_data, thread_data[t].ctlfd_pos, in record__alloc_thread_data()
1262 thread_data[t].pipes.msg[0]); in record__alloc_thread_data()
1264 thread_data[t].tid = gettid(); in record__alloc_thread_data()
1266 ret = record__dup_non_perf_events(rec, evlist, &thread_data[t]); in record__alloc_thread_data()
1270 thread_data[t].ctlfd_pos = -1; /* Not used */ in record__alloc_thread_data()
2308 static int record__terminate_thread(struct record_thread *thread_data) in record__terminate_thread() argument
2312 pid_t tid = thread_data->tid; in record__terminate_thread()
2314 close(thread_data->pipes.msg[1]); in record__terminate_thread()
2315 thread_data->pipes.msg[1] = -1; in record__terminate_thread()
2316 err = read(thread_data->pipes.ack[0], &ack, sizeof(ack)); in record__terminate_thread()
2329 struct record_thread *thread_data = rec->thread_data; in record__start_threads() local
2334 thread = &thread_data[0]; in record__start_threads()
2353 MMAP_CPU_MASK_BYTES(&(thread_data[t].mask->affinity)), in record__start_threads()
2354 (cpu_set_t *)(thread_data[t].mask->affinity.bits)); in record__start_threads()
2356 if (pthread_create(&handle, &attrs, record__thread, &thread_data[t])) { in record__start_threads()
2358 record__terminate_thread(&thread_data[t]); in record__start_threads()
2364 err = read(thread_data[t].pipes.ack[0], &msg, sizeof(msg)); in record__start_threads()
2366 pr_debug2("threads[%d]: sent %s\n", rec->thread_data[t].tid, in record__start_threads()
2370 thread->tid, rec->thread_data[t].tid); in record__start_threads()
2392 struct record_thread *thread_data = rec->thread_data; in record__stop_threads() local
2395 record__terminate_thread(&thread_data[t]); in record__stop_threads()
2398 rec->samples += thread_data[t].samples; in record__stop_threads()
2401 rec->session->bytes_transferred += thread_data[t].bytes_transferred; in record__stop_threads()
2402 rec->session->bytes_compressed += thread_data[t].bytes_compressed; in record__stop_threads()
2403 pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid, in record__stop_threads()
2404 thread_data[t].samples, thread_data[t].waking); in record__stop_threads()
2405 if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed) in record__stop_threads()
2407 thread_data[t].bytes_transferred, thread_data[t].bytes_compressed); in record__stop_threads()
2409 pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written); in record__stop_threads()
2419 struct record_thread *thread_data = rec->thread_data; in record__waking() local
2422 waking += thread_data[t].waking; in record__waking()