• Home
  • Raw
  • Download

Lines Matching refs:tip

126 	struct thr_info *tip;  member
265 static inline int is_send_done(struct thr_info *tip) in is_send_done() argument
267 return signal_done || tip->send_done; in is_send_done()
274 static inline int is_reap_done(struct thr_info *tip) in is_reap_done() argument
276 return signal_done || (tip->send_done && tip->naios_out == 0); in is_reap_done()
541 static void pin_to_cpu(struct thr_info *tip) in pin_to_cpu() argument
549 assert(0 <= tip->cpu && tip->cpu < ncpus); in pin_to_cpu()
552 CPU_SET_S(tip->cpu, size, cpus); in pin_to_cpu()
557 assert(tip->cpu == sched_getcpu()); in pin_to_cpu()
564 fprintf(tip->vfp, "Pinned to CPU %02d ", tip->cpu); in pin_to_cpu()
566 fprintf(tip->vfp, "%1d", CPU_ISSET_S(i, size, now)); in pin_to_cpu()
567 fprintf(tip->vfp, "\n"); in pin_to_cpu()
716 static void iocb_init(struct thr_info *tip, struct iocb_pkt *iocbp) in iocb_init() argument
718 iocbp->tip = tip; in iocb_init()
754 io_prep_pread(iop, iocbp->tip->ofd, buf, n, off); in iocb_setup()
757 io_prep_pwrite(iop, iocbp->tip->ofd, buf, n, off); in iocb_setup()
773 static void tip_init(struct thr_info *tip) in tip_init() argument
777 INIT_LIST_HEAD(&tip->free_iocbs); in tip_init()
778 INIT_LIST_HEAD(&tip->used_iocbs); in tip_init()
780 pthread_mutex_init(&tip->mutex, NULL); in tip_init()
781 pthread_cond_init(&tip->cond, NULL); in tip_init()
783 if (io_setup(naios, &tip->ctx)) { in tip_init()
788 tip->ofd = -1; in tip_init()
789 tip->naios_out = 0; in tip_init()
790 tip->send_done = tip->reap_done = 0; in tip_init()
791 tip->send_wait = tip->reap_wait = 0; in tip_init()
793 memset(&tip->sub_thread, 0, sizeof(tip->sub_thread)); in tip_init()
794 memset(&tip->rec_thread, 0, sizeof(tip->rec_thread)); in tip_init()
799 iocb_init(tip, iocbp); in tip_init()
800 list_add_tail(&iocbp->head, &tip->free_iocbs); in tip_init()
802 tip->naios_free = naios; in tip_init()
807 sprintf(fn, "%s/%s.%s.%d.rep", idir, tip->devnm, ibase, in tip_init()
808 tip->cpu); in tip_init()
809 tip->vfp = fopen(fn, "w"); in tip_init()
810 if (!tip->vfp) { in tip_init()
815 setlinebuf(tip->vfp); in tip_init()
818 if (pthread_create(&tip->sub_thread, NULL, replay_sub, tip)) { in tip_init()
824 if (pthread_create(&tip->rec_thread, NULL, replay_rec, tip)) { in tip_init()
834 static void tip_release(struct thr_info *tip) in tip_release() argument
838 assert(tip->send_done); in tip_release()
839 assert(tip->reap_done); in tip_release()
840 assert(list_len(&tip->used_iocbs) == 0); in tip_release()
841 assert(tip->naios_free == naios); in tip_release()
843 if (pthread_join(tip->sub_thread, NULL)) { in tip_release()
847 if (pthread_join(tip->rec_thread, NULL)) { in tip_release()
852 io_destroy(tip->ctx); in tip_release()
854 list_splice(&tip->used_iocbs, &tip->free_iocbs); in tip_release()
855 list_for_each_safe(p, q, &tip->free_iocbs) { in tip_release()
864 pthread_cond_destroy(&tip->cond); in tip_release()
865 pthread_mutex_destroy(&tip->mutex); in tip_release()
878 struct thr_info *tip = buf_alloc(sizeof(*tip)); in add_input_file() local
884 memset(tip, 0, sizeof(*tip)); in add_input_file()
885 tip->cpu = cpu % cpus_to_use; in add_input_file()
886 tip->iterations = def_iterations; in add_input_file()
888 tip->ifd = open(file_name, O_RDONLY); in add_input_file()
889 if (tip->ifd < 0) { in add_input_file()
893 if (fstat(tip->ifd, &buf) < 0) { in add_input_file()
903 if (read(tip->ifd, &hdr, sizeof(hdr)) != sizeof(hdr)) { in add_input_file()
922 close(tip->ifd); in add_input_file()
923 free(tip); in add_input_file()
935 tip->devnm = strdup(devnm); in add_input_file()
936 tip->file_name = strdup(file_name); in add_input_file()
938 list_add_tail(&tip->head, &input_files); in add_input_file()
949 static void rem_input_file(struct thr_info *tip) in rem_input_file() argument
951 list_del(&tip->head); in rem_input_file()
953 tip_release(tip); in rem_input_file()
955 close(tip->ofd); in rem_input_file()
956 close(tip->ifd); in rem_input_file()
957 free(tip->file_name); in rem_input_file()
958 free(tip->devnm); in rem_input_file()
959 free(tip); in rem_input_file()
1024 static int reap_wait_aios(struct thr_info *tip) in reap_wait_aios() argument
1028 if (!is_reap_done(tip)) { in reap_wait_aios()
1029 pthread_mutex_lock(&tip->mutex); in reap_wait_aios()
1030 while (tip->naios_out == 0) { in reap_wait_aios()
1031 tip->reap_wait = 1; in reap_wait_aios()
1032 if (pthread_cond_wait(&tip->cond, &tip->mutex)) { in reap_wait_aios()
1038 naios = tip->naios_out; in reap_wait_aios()
1039 pthread_mutex_unlock(&tip->mutex); in reap_wait_aios()
1041 assert(is_reap_done(tip) || naios > 0); in reap_wait_aios()
1043 return is_reap_done(tip) ? 0 : naios; in reap_wait_aios()
1051 static void reclaim_ios(struct thr_info *tip, long naios_out) in reclaim_ios() argument
1059 ndone = io_getevents(tip->ctx, 1, naios_out, events, NULL); in reclaim_ios()
1071 pthread_mutex_lock(&tip->mutex); in reclaim_ios()
1084 list_move_tail(&iocbp->head, &tip->free_iocbs); in reclaim_ios()
1087 tip->naios_free += ndone; in reclaim_ios()
1088 tip->naios_out -= ndone; in reclaim_ios()
1089 naios_out = minl(naios_out, tip->naios_out); in reclaim_ios()
1091 if (tip->send_wait) { in reclaim_ios()
1092 tip->send_wait = 0; in reclaim_ios()
1093 pthread_cond_signal(&tip->cond); in reclaim_ios()
1095 pthread_mutex_unlock(&tip->mutex); in reclaim_ios()
1111 struct thr_info *tip = arg; in replay_rec() local
1113 while ((naios_out = reap_wait_aios(tip)) > 0) in replay_rec()
1114 reclaim_ios(tip, naios_out); in replay_rec()
1116 assert(tip->send_done); in replay_rec()
1117 tip->reap_done = 1; in replay_rec()
1136 static int next_bunch(struct thr_info *tip, struct io_bunch *bunch) in next_bunch() argument
1140 result = read(tip->ifd, &bunch->hdr, sizeof(bunch->hdr)); in next_bunch()
1145 fatal(tip->file_name, ERR_SYSCALL, "Short hdr(%ld)\n", in next_bunch()
1152 result = read(tip->ifd, &bunch->pkts, count); in next_bunch()
1154 fatal(tip->file_name, ERR_SYSCALL, "Short pkts(%ld/%ld)\n", in next_bunch()
1169 static int nfree_current(struct thr_info *tip) in nfree_current() argument
1173 pthread_mutex_lock(&tip->mutex); in nfree_current()
1174 while (!is_send_done(tip) && ((nfree = tip->naios_free) == 0)) { in nfree_current()
1175 tip->send_wait = 1; in nfree_current()
1176 if (pthread_cond_wait(&tip->cond, &tip->mutex)) { in nfree_current()
1182 pthread_mutex_unlock(&tip->mutex); in nfree_current()
1192 static void stall(struct thr_info *tip, long long oclock) in stall() argument
1200 fprintf(tip->vfp, " stall(%lld.%09lld, %lld.%09lld)\n", in stall()
1204 while (!is_send_done(tip) && tclock < oclock) { in stall()
1210 fprintf(tip->vfp, "++ stall(%lld.%09lld) ++\n", in stall()
1229 static void iocbs_map(struct thr_info *tip, struct iocb **list, in iocbs_map() argument
1237 pthread_mutex_lock(&tip->mutex); in iocbs_map()
1238 assert(ntodo <= list_len(&tip->free_iocbs)); in iocbs_map()
1247 fprintf(tip->vfp, "\t%10llu + %10llu %c%c\n", in iocbs_map()
1253 iocbp = list_entry(tip->free_iocbs.next, struct iocb_pkt, head); in iocbs_map()
1256 list_move_tail(&iocbp->head, &tip->used_iocbs); in iocbs_map()
1260 tip->naios_free -= ntodo; in iocbs_map()
1261 assert(tip->naios_free >= 0); in iocbs_map()
1262 pthread_mutex_unlock(&tip->mutex); in iocbs_map()
1270 static void process_bunch(struct thr_info *tip, struct io_bunch *bunch) in process_bunch() argument
1276 while (!is_send_done(tip) && (i < bunch->hdr.npkts)) { in process_bunch()
1278 int ntodo = min(nfree_current(tip), bunch->hdr.npkts - i); in process_bunch()
1281 iocbs_map(tip, list, &bunch->pkts[i], ntodo); in process_bunch()
1283 stall(tip, bunch->hdr.time_stamp - genesis); in process_bunch()
1287 fprintf(tip->vfp, "submit(%d)\n", ntodo); in process_bunch()
1288 ndone = io_submit(tip->ctx, ntodo, list); in process_bunch()
1292 tip->cpu, ntodo, ndone, in process_bunch()
1297 pthread_mutex_lock(&tip->mutex); in process_bunch()
1298 tip->naios_out += ndone; in process_bunch()
1299 assert(tip->naios_out <= naios); in process_bunch()
1300 if (tip->reap_wait) { in process_bunch()
1301 tip->reap_wait = 0; in process_bunch()
1302 pthread_cond_signal(&tip->cond); in process_bunch()
1304 pthread_mutex_unlock(&tip->mutex); in process_bunch()
1318 static void reset_input_file(struct thr_info *tip) in reset_input_file() argument
1322 lseek(tip->ifd, 0, 0); in reset_input_file()
1324 if (read(tip->ifd, &hdr, sizeof(hdr)) != sizeof(hdr)) { in reset_input_file()
1325 fatal(tip->file_name, ERR_ARGS, "Header reread failed\n"); in reset_input_file()
1339 struct thr_info *tip = arg; in replay_sub() local
1342 pin_to_cpu(tip); in replay_sub()
1344 mdev = map_dev(tip->devnm); in replay_sub()
1358 tip->ofd = open(path, O_RDWR | O_DIRECT | oflags); in replay_sub()
1359 if (tip->ofd < 0) { in replay_sub()
1365 while (!is_send_done(tip) && tip->iterations--) { in replay_sub()
1368 fprintf(tip->vfp, "\n=== %d ===\n", tip->iterations); in replay_sub()
1369 while (!is_send_done(tip) && next_bunch(tip, &bunch)) in replay_sub()
1370 process_bunch(tip, &bunch); in replay_sub()
1372 reset_input_file(tip); in replay_sub()
1374 tip->send_done = 1; in replay_sub()