Lines Matching refs:thread_data
186 struct record_thread *thread_data;
1043 static void record__thread_data_init_pipes(struct record_thread *thread_data)
1045 thread_data->pipes.msg[0] = -1;
1046 thread_data->pipes.msg[1] = -1;
1047 thread_data->pipes.ack[0] = -1;
1048 thread_data->pipes.ack[1] = -1;
1051 static int record__thread_data_open_pipes(struct record_thread *thread_data)
1053 if (pipe(thread_data->pipes.msg))
1056 if (pipe(thread_data->pipes.ack)) {
1057 close(thread_data->pipes.msg[0]);
1058 thread_data->pipes.msg[0] = -1;
1059 close(thread_data->pipes.msg[1]);
1060 thread_data->pipes.msg[1] = -1;
1064 pr_debug2("thread_data[%p]: msg=[%d,%d], ack=[%d,%d]\n", thread_data,
1065 thread_data->pipes.msg[0], thread_data->pipes.msg[1],
1066 thread_data->pipes.ack[0], thread_data->pipes.ack[1]);
1071 static void record__thread_data_close_pipes(struct record_thread *thread_data)
1073 if (thread_data->pipes.msg[0] != -1) {
1074 close(thread_data->pipes.msg[0]);
1075 thread_data->pipes.msg[0] = -1;
1077 if (thread_data->pipes.msg[1] != -1) {
1078 close(thread_data->pipes.msg[1]);
1079 thread_data->pipes.msg[1] = -1;
1081 if (thread_data->pipes.ack[0] != -1) {
1082 close(thread_data->pipes.ack[0]);
1083 thread_data->pipes.ack[0] = -1;
1085 if (thread_data->pipes.ack[1] != -1) {
1086 close(thread_data->pipes.ack[1]);
1087 thread_data->pipes.ack[1] = -1;
1096 static int record__thread_data_init_maps(struct record_thread *thread_data, struct evlist *evlist)
1105 thread_data->nr_mmaps = nr_mmaps;
1107 thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits,
1108 thread_data->mask->maps.nbits);
1110 thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *));
1111 if (!thread_data->maps)
1115 thread_data->overwrite_maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *));
1116 if (!thread_data->overwrite_maps) {
1117 zfree(&thread_data->maps);
1121 pr_debug2("thread_data[%p]: nr_mmaps=%d, maps=%p, ow_maps=%p\n", thread_data,
1122 thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps);
1124 for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) {
1126 test_bit(perf_cpu_map__cpu(cpus, m).cpu, thread_data->mask->maps.bits)) {
1127 if (thread_data->maps) {
1128 thread_data->maps[tm] = &mmap[m];
1129 pr_debug2("thread_data[%p]: cpu%d: maps[%d] -> mmap[%d]\n",
1130 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m);
1132 if (thread_data->overwrite_maps) {
1133 thread_data->overwrite_maps[tm] = &overwrite_mmap[m];
1134 pr_debug2("thread_data[%p]: cpu%d: ow_maps[%d] -> ow_mmap[%d]\n",
1135 thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m);
1144 static int record__thread_data_init_pollfd(struct record_thread *thread_data, struct evlist *evlist)
1149 fdarray__init(&thread_data->pollfd, 64);
1151 for (tm = 0; tm < thread_data->nr_mmaps; tm++) {
1152 map = thread_data->maps ? thread_data->maps[tm] : NULL;
1153 overwrite_map = thread_data->overwrite_maps ?
1154 thread_data->overwrite_maps[tm] : NULL;
1160 pos = fdarray__dup_entry_from(&thread_data->pollfd, f,
1164 pr_debug2("thread_data[%p]: pollfd[%d] <- event_fd=%d\n",
1165 thread_data, pos, evlist->core.pollfd.entries[f].fd);
1176 struct record_thread *thread_data = rec->thread_data;
1178 if (thread_data == NULL)
1182 record__thread_data_close_pipes(&thread_data[t]);
1183 zfree(&thread_data[t].maps);
1184 zfree(&thread_data[t].overwrite_maps);
1185 fdarray__exit(&thread_data[t].pollfd);
1188 zfree(&rec->thread_data);
1207 struct record_thread *thread_data)
1210 struct pollfd *t_entries = thread_data->pollfd.entries;
1231 struct record_thread *thread_data)
1239 ret = fdarray__dup_entry_from(&thread_data->pollfd, i, fda);
1244 pr_debug2("thread_data[%p]: pollfd[%d] <- non_perf_event fd=%d\n",
1245 thread_data, ret, fda->entries[i].fd);
1258 struct record_thread *thread_data;
1260 rec->thread_data = zalloc(rec->nr_threads * sizeof(*(rec->thread_data)));
1261 if (!rec->thread_data) {
1265 thread_data = rec->thread_data;
1268 record__thread_data_init_pipes(&thread_data[t]);
1271 thread_data[t].rec = rec;
1272 thread_data[t].mask = &rec->thread_masks[t];
1273 ret = record__thread_data_init_maps(&thread_data[t], evlist);
1278 ret = record__thread_data_init_pollfd(&thread_data[t], evlist);
1284 thread_data[t].tid = -1;
1285 ret = record__thread_data_open_pipes(&thread_data[t]);
1290 ret = fdarray__add(&thread_data[t].pollfd, thread_data[t].pipes.msg[0],
1296 thread_data[t].ctlfd_pos = ret;
1297 pr_debug2("thread_data[%p]: pollfd[%d] <- ctl_fd=%d\n",
1298 thread_data, thread_data[t].ctlfd_pos,
1299 thread_data[t].pipes.msg[0]);
1301 thread_data[t].tid = gettid();
1303 ret = record__dup_non_perf_events(rec, evlist, &thread_data[t]);
1307 thread_data[t].ctlfd_pos = -1; /* Not used */
2272 static int record__terminate_thread(struct record_thread *thread_data)
2276 pid_t tid = thread_data->tid;
2278 close(thread_data->pipes.msg[1]);
2279 thread_data->pipes.msg[1] = -1;
2280 err = read(thread_data->pipes.ack[0], &ack, sizeof(ack));
2293 struct record_thread *thread_data = rec->thread_data;
2298 thread = &thread_data[0];
2317 MMAP_CPU_MASK_BYTES(&(thread_data[t].mask->affinity)),
2318 (cpu_set_t *)(thread_data[t].mask->affinity.bits));
2320 if (pthread_create(&handle, &attrs, record__thread, &thread_data[t])) {
2322 record__terminate_thread(&thread_data[t]);
2328 err = read(thread_data[t].pipes.ack[0], &msg, sizeof(msg));
2330 pr_debug2("threads[%d]: sent %s\n", rec->thread_data[t].tid,
2334 thread->tid, rec->thread_data[t].tid);
2356 struct record_thread *thread_data = rec->thread_data;
2359 record__terminate_thread(&thread_data[t]);
2362 rec->samples += thread_data[t].samples;
2365 rec->session->bytes_transferred += thread_data[t].bytes_transferred;
2366 rec->session->bytes_compressed += thread_data[t].bytes_compressed;
2367 pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid,
2368 thread_data[t].samples, thread_data[t].waking);
2369 if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed)
2371 thread_data[t].bytes_transferred, thread_data[t].bytes_compressed);
2373 pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written);
2383 struct record_thread *thread_data = rec->thread_data;
2386 waking += thread_data[t].waking;