Lines Matching refs:thread_data

180 	struct record_thread	*thread_data;  member
231 struct record_thread *thread_data = rec->thread_data; in record__bytes_written() local
234 bytes_written += thread_data[t].bytes_written; in record__bytes_written()
945 static void record__thread_data_init_pipes(struct record_thread *thread_data) in record__thread_data_init_pipes() argument
947 thread_data->pipes.msg[0] = -1; in record__thread_data_init_pipes()
948 thread_data->pipes.msg[1] = -1; in record__thread_data_init_pipes()
949 thread_data->pipes.ack[0] = -1; in record__thread_data_init_pipes()
950 thread_data->pipes.ack[1] = -1; in record__thread_data_init_pipes()
953 static int record__thread_data_open_pipes(struct record_thread *thread_data) in record__thread_data_open_pipes() argument
955 if (pipe(thread_data->pipes.msg)) in record__thread_data_open_pipes()
958 if (pipe(thread_data->pipes.ack)) { in record__thread_data_open_pipes()
959 close(thread_data->pipes.msg[0]); in record__thread_data_open_pipes()
960 thread_data->pipes.msg[0] = -1; in record__thread_data_open_pipes()
961 close(thread_data->pipes.msg[1]); in record__thread_data_open_pipes()
962 thread_data->pipes.msg[1] = -1; in record__thread_data_open_pipes()
966 pr_debug2("thread_data[%p]: msg=[%d,%d], ack=[%d,%d]\n", thread_data, in record__thread_data_open_pipes()
967 thread_data->pipes.msg[0], thread_data->pipes.msg[1], in record__thread_data_open_pipes()
968 thread_data->pipes.ack[0], thread_data->pipes.ack[1]); in record__thread_data_open_pipes()
973 static void record__thread_data_close_pipes(struct record_thread *thread_data) in record__thread_data_close_pipes() argument
975 if (thread_data->pipes.msg[0] != -1) { in record__thread_data_close_pipes()
976 close(thread_data->pipes.msg[0]); in record__thread_data_close_pipes()
977 thread_data->pipes.msg[0] = -1; in record__thread_data_close_pipes()
979 if (thread_data->pipes.msg[1] != -1) { in record__thread_data_close_pipes()
980 close(thread_data->pipes.msg[1]); in record__thread_data_close_pipes()
981 thread_data->pipes.msg[1] = -1; in record__thread_data_close_pipes()
983 if (thread_data->pipes.ack[0] != -1) { in record__thread_data_close_pipes()
984 close(thread_data->pipes.ack[0]); in record__thread_data_close_pipes()
985 thread_data->pipes.ack[0] = -1; in record__thread_data_close_pipes()
987 if (thread_data->pipes.ack[1] != -1) { in record__thread_data_close_pipes()
988 close(thread_data->pipes.ack[1]); in record__thread_data_close_pipes()
989 thread_data->pipes.ack[1] = -1; in record__thread_data_close_pipes()
998 static int record__thread_data_init_maps(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_maps() argument
1007 thread_data->nr_mmaps = nr_mmaps; in record__thread_data_init_maps()
1009 thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, in record__thread_data_init_maps()
1010 thread_data->mask->maps.nbits); in record__thread_data_init_maps()
1012 thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1013 if (!thread_data->maps) in record__thread_data_init_maps()
1017 thread_data->overwrite_maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); in record__thread_data_init_maps()
1018 if (!thread_data->overwrite_maps) { in record__thread_data_init_maps()
1019 zfree(&thread_data->maps); in record__thread_data_init_maps()
1023 pr_debug2("thread_data[%p]: nr_mmaps=%d, maps=%p, ow_maps=%p\n", thread_data, in record__thread_data_init_maps()
1024 thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps); in record__thread_data_init_maps()
1026 for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) { in record__thread_data_init_maps()
1028 test_bit(perf_cpu_map__cpu(cpus, m).cpu, thread_data->mask->maps.bits)) { in record__thread_data_init_maps()
1029 if (thread_data->maps) { in record__thread_data_init_maps()
1030 thread_data->maps[tm] = &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()
1034 if (thread_data->overwrite_maps) { in record__thread_data_init_maps()
1035 thread_data->overwrite_maps[tm] = &overwrite_mmap[m]; in record__thread_data_init_maps()
1037 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); in record__thread_data_init_maps()
1046 static int record__thread_data_init_pollfd(struct record_thread *thread_data, struct evlist *evlist) in record__thread_data_init_pollfd() argument
1051 fdarray__init(&thread_data->pollfd, 64); in record__thread_data_init_pollfd()
1053 for (tm = 0; tm < thread_data->nr_mmaps; tm++) { in record__thread_data_init_pollfd()
1054 map = thread_data->maps ? thread_data->maps[tm] : NULL; in record__thread_data_init_pollfd()
1055 overwrite_map = thread_data->overwrite_maps ? in record__thread_data_init_pollfd()
1056 thread_data->overwrite_maps[tm] : NULL; in record__thread_data_init_pollfd()
1062 pos = fdarray__dup_entry_from(&thread_data->pollfd, f, in record__thread_data_init_pollfd()
1067 thread_data, pos, evlist->core.pollfd.entries[f].fd); in record__thread_data_init_pollfd()
1078 struct record_thread *thread_data = rec->thread_data; in record__free_thread_data() local
1080 if (thread_data == NULL) in record__free_thread_data()
1084 record__thread_data_close_pipes(&thread_data[t]); in record__free_thread_data()
1085 zfree(&thread_data[t].maps); in record__free_thread_data()
1086 zfree(&thread_data[t].overwrite_maps); in record__free_thread_data()
1087 fdarray__exit(&thread_data[t].pollfd); in record__free_thread_data()
1090 zfree(&rec->thread_data); in record__free_thread_data()
1109 struct record_thread *thread_data) in record__update_evlist_pollfd_from_thread() argument
1112 struct pollfd *t_entries = thread_data->pollfd.entries; in record__update_evlist_pollfd_from_thread()
1133 struct record_thread *thread_data) in record__dup_non_perf_events() argument
1141 ret = fdarray__dup_entry_from(&thread_data->pollfd, i, fda); in record__dup_non_perf_events()
1147 thread_data, ret, fda->entries[i].fd); in record__dup_non_perf_events()
1160 struct record_thread *thread_data; in record__alloc_thread_data() local
1162 rec->thread_data = zalloc(rec->nr_threads * sizeof(*(rec->thread_data))); in record__alloc_thread_data()
1163 if (!rec->thread_data) { in record__alloc_thread_data()
1167 thread_data = rec->thread_data; in record__alloc_thread_data()
1170 record__thread_data_init_pipes(&thread_data[t]); in record__alloc_thread_data()
1173 thread_data[t].rec = rec; in record__alloc_thread_data()
1174 thread_data[t].mask = &rec->thread_masks[t]; in record__alloc_thread_data()
1175 ret = record__thread_data_init_maps(&thread_data[t], evlist); in record__alloc_thread_data()
1180 ret = record__thread_data_init_pollfd(&thread_data[t], evlist); in record__alloc_thread_data()
1186 thread_data[t].tid = -1; in record__alloc_thread_data()
1187 ret = record__thread_data_open_pipes(&thread_data[t]); in record__alloc_thread_data()
1192 ret = fdarray__add(&thread_data[t].pollfd, thread_data[t].pipes.msg[0], in record__alloc_thread_data()
1198 thread_data[t].ctlfd_pos = ret; in record__alloc_thread_data()
1200 thread_data, thread_data[t].ctlfd_pos, in record__alloc_thread_data()
1201 thread_data[t].pipes.msg[0]); in record__alloc_thread_data()
1203 thread_data[t].tid = gettid(); in record__alloc_thread_data()
1205 ret = record__dup_non_perf_events(rec, evlist, &thread_data[t]); in record__alloc_thread_data()
1209 thread_data[t].ctlfd_pos = -1; /* Not used */ in record__alloc_thread_data()
2207 static int record__terminate_thread(struct record_thread *thread_data) in record__terminate_thread() argument
2211 pid_t tid = thread_data->tid; in record__terminate_thread()
2213 close(thread_data->pipes.msg[1]); in record__terminate_thread()
2214 thread_data->pipes.msg[1] = -1; in record__terminate_thread()
2215 err = read(thread_data->pipes.ack[0], &ack, sizeof(ack)); in record__terminate_thread()
2228 struct record_thread *thread_data = rec->thread_data; in record__start_threads() local
2233 thread = &thread_data[0]; in record__start_threads()
2252 MMAP_CPU_MASK_BYTES(&(thread_data[t].mask->affinity)), in record__start_threads()
2253 (cpu_set_t *)(thread_data[t].mask->affinity.bits)); in record__start_threads()
2255 if (pthread_create(&handle, &attrs, record__thread, &thread_data[t])) { in record__start_threads()
2257 record__terminate_thread(&thread_data[t]); in record__start_threads()
2263 err = read(thread_data[t].pipes.ack[0], &msg, sizeof(msg)); in record__start_threads()
2265 pr_debug2("threads[%d]: sent %s\n", rec->thread_data[t].tid, in record__start_threads()
2269 thread->tid, rec->thread_data[t].tid); in record__start_threads()
2291 struct record_thread *thread_data = rec->thread_data; in record__stop_threads() local
2294 record__terminate_thread(&thread_data[t]); in record__stop_threads()
2297 rec->samples += thread_data[t].samples; in record__stop_threads()
2300 rec->session->bytes_transferred += thread_data[t].bytes_transferred; in record__stop_threads()
2301 rec->session->bytes_compressed += thread_data[t].bytes_compressed; in record__stop_threads()
2302 pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid, in record__stop_threads()
2303 thread_data[t].samples, thread_data[t].waking); in record__stop_threads()
2304 if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed) in record__stop_threads()
2306 thread_data[t].bytes_transferred, thread_data[t].bytes_compressed); in record__stop_threads()
2308 pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written); in record__stop_threads()
2318 struct record_thread *thread_data = rec->thread_data; in record__waking() local
2321 waking += thread_data[t].waking; in record__waking()