CSTUB_FN(int, tmerge)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, td_t td_into, char *param, int len) { int ret; long fault = 0; struct __sg_tmerge_data *d; cbuf_t cb; int sz = len + sizeof(struct __sg_tmerge_data); assert(param && len > 0); assert(param[len-1] == '\0'); d = cbuf_alloc_ext(sz, &cb, CBUF_TMEM); if (!d) return -1; d->td = td; d->td_into = td_into; d->len[0] = 0; d->len[1] = len; memcpy(&d->data[0], param, len); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); cbuf_free(cb); return ret; }
CSTUB_FN(int, twmeta)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, const char *key, unsigned int klen, const char *val, unsigned int vlen) { int ret; long fault = 0; cbuf_t cb; int sz = sizeof(struct __sg_twmeta_data) + klen + vlen + 1; struct __sg_twmeta_data *d; assert(key && val && klen > 0 && vlen > 0); assert(key[klen] == '\0' && val[vlen] == '\0' && sz <= PAGE_SIZE); d = cbuf_alloc_ext(sz, &cb, CBUF_TMEM); if (!d) assert(0); //return -1; d->td = td; d->klen = klen; d->vlen = vlen; memcpy(&d->data[0], key, klen + 1); memcpy(&d->data[klen + 1], val, vlen + 1); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); cbuf_free(cb); return ret; }
CSTUB_FN(int, trmeta)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, const char *key, unsigned int klen, char *retval, unsigned int max_rval_len) { int ret; long fault = 0; cbuf_t cb; int sz = sizeof(struct __sg_trmeta_data) + klen + max_rval_len + 1; struct __sg_trmeta_data *d; assert(key && retval && klen > 0 && max_rval_len > 0); assert(key[klen] == '\0' && sz <= PAGE_SIZE); d = cbuf_alloc_ext(sz, &cb, CBUF_TMEM); if (!d) return -1; d->td = td; d->klen = klen; d->retval_len = max_rval_len; memcpy(&d->data[0], key, klen + 1); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); if (ret >= 0) { if ((unsigned int)ret > max_rval_len) { // as ret >= 0, cast it to unsigned int to omit compiler warning cbuf_free(cb); return -EIO; } memcpy(retval, &d->data[klen + 1], ret + 1); } cbuf_free(cb); return ret; }
CSTUB_FN(void, trelease)(struct usr_inv_cap *uc, spdid_t spdid, td_t tid) { int ret; long fault = 0; printc("<<<rtorrent In: call trelease (thread %d) >>>\n", cos_get_thd_id()); struct rec_data_tor *rd; redo: /* printc("<<< In: call trelease (thread %d) >>>\n", cos_get_thd_id()); */ rd = rd_update(tid, STATE_TRELEASE); assert(rd); CSTUB_INVOKE(ret, fault, uc, 2, spdid, rd->s_tid); if (unlikely(fault)) { CSTUB_FAULT_UPDATE(); goto redo; } map_rd_delete(rd->c_tid); return; }
/* Here we have reset the owner to be 0 on the client side, so we do * not goto redo */ CSTUB_FN(int, lock_component_release) (struct usr_inv_cap *uc, spdid_t spdid, unsigned long lock_id) { long fault = 0; int ret; struct rec_data_lk *rd = NULL; redo: rd = rd_update(lock_id, LOCK_RELEASE); assert(rd); /* if (!rd) { */ /* printc("try to release a non-tracking lock\n"); */ /* return -1; */ /* } */ CSTUB_INVOKE(ret, fault, uc, 2, spdid, rd->s_lkid); if (unlikely (fault)){ /* printc("cli:thd %d see a fault in lock_component_release!\n", */ /* cos_get_thd_id()); */ CSTUB_FAULT_UPDATE(); goto redo; } if (ret == -EINVAL) { /* printc("cli:thd %d lock_component_release return EINVAL\n", cos_get_thd_id()); */ /* rd_recover_state(rd); */ /* goto redo; */ ret = 0; } /* printc("cli:thd %d lock_component_release return %d\n", cos_get_thd_id(), ret); */ return ret; }
CSTUB_FN(vaddr_t, mman_get_page) (struct usr_inv_cap *uc, spdid_t spdid, vaddr_t addr, int flags) { long fault = 0; long ret; if (first == 0 && cos_spd_id() != 5) { cvect_init_static(&rec_mm_vect); cvect_init_static(&parent_rec_mm_vect); first = 1; } unsigned long long start, end; redo: if (cos_spd_id() != 5) { printc("cli: (spd %ld) call mman_get_page addr %p\n", cos_spd_id(), addr); } CSTUB_INVOKE(ret, fault, uc, 3, spdid,addr, flags); if (unlikely (fault)){ printc("found a fault in mman_get_page!!!!!\n"); CSTUB_FAULT_UPDATE(); goto redo; } if (cos_spd_id() != 5) { printc("cli: (in spd %ld) mman_get_page return ret %p\n", cos_spd_id(), ret); } return ret; }
CSTUB_FN(td_t, tsplit)(struct usr_inv_cap *uc, spdid_t spdid, td_t tid, char * param, int len, tor_flags_t tflags, long evtid) { long fault = 0; td_t ret; struct __sg_tsplit_data *d; cbuf_t cb; int sz = len + sizeof(struct __sg_tsplit_data); assert(param && len >= 0); assert(param[len] == '\0'); d = cbuf_alloc_ext(sz, &cb, CBUF_TMEM); if (!d) return -6; d->tid = tid; d->tflags = tflags; d->evtid = evtid; d->len[0] = 0; d->len[1] = len; memcpy(&d->data[0], param, len + 1); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); cbuf_free(cb); return ret; }
CSTUB_FN(int, twrite)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, int cbid, int sz) { int ret; long fault = 0; CSTUB_INVOKE(ret, fault, uc, 4, spdid, td, cbid, sz); return ret; }
CSTUB_FN(unsigned long, lock_component_alloc) (struct usr_inv_cap *uc, spdid_t spdid) { long fault; unsigned long ret; struct rec_data_lk *rd = NULL; unsigned long ser_lkid, cli_lkid; if (first == 0) { cos_map_init_static(&uniq_lkids); first = 1; } #ifdef BENCHMARK_MEAS_CREATION_TIME rdtscll(meas_start); #endif redo: #ifdef BENCHMARK_MEAS_ALLOC rdtscll(meas_end); if (test_flag) { test_flag = 0; printc("recovery a lock cost: %llu\n", meas_end - meas_start); } #endif CSTUB_INVOKE(ret, fault, uc, 1, spdid); if (unlikely (fault)){ #ifdef BENCHMARK_MEAS_ALLOC test_flag = 1; rdtscll(meas_start); #endif CSTUB_FAULT_UPDATE(); goto redo; } assert(ret > 0); cli_lkid = rdlk_alloc(); assert(cli_lkid >= 1); rd = rdlk_lookup(cli_lkid); assert(rd); rd_cons(rd, cos_spd_id(), cli_lkid, ret, LOCK_ALLOC); ret = cli_lkid; #ifdef BENCHMARK_MEAS_CREATION_TIME rdtscll(meas_end); printc("creating a lock costs %llu\n", meas_end - meas_start); #endif return ret; }
transition|terminal // block_cli_if_invoke pred 6 end // block_cli_if_invoke 6 start static inline int block_cli_if_invoke_IDL_fname(IDL_parsdecl, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, IDL_pars_len, IDL_params); *fault = __fault; return ret; }
__attribute__((regparm(1))) int SS_ipc_client_marshal_args(struct usr_inv_cap *uc, long p0, long p1, long p2, long p3) { int ret, done; do { CSTUB_INVOKE(ret, done, uc, 4, p0, p1, p2, p3); } while (unlikely(done != 1)); return ret; }
CSTUB_FN(int, lock_component_take) (struct usr_inv_cap *uc, spdid_t spdid, unsigned long lock_id, unsigned short int thd) { long fault = 0; int ret; struct rec_data_lk *rd = NULL; redo: rd = rd_update(lock_id, LOCK_TAKE); assert(rd); #ifdef BENCHMARK_MEAS_TAKE rdtscll(meas_end); /* printc("now take again(thd %d, end %llu)!!!!\n", cos_get_thd_id(), meas_end); */ if (test_flag) { test_flag = 0; printc("recovery a lock cost: %llu\n", meas_end - meas_start); } #endif CSTUB_INVOKE(ret, fault, uc, 3, spdid, rd->s_lkid, thd); if (unlikely (fault)){ /* printc("cli:thd %d see a fault in lock_component_take!\n", cos_get_thd_id()); */ lock_component_take_ubenchmark_flag = 1; rdtscll(ubenchmark_start); #ifdef BENCHMARK_MEAS_TAKE test_flag = 1; rdtscll(meas_start); /* printc("a fault(thd %d start %llu)!!!!\n", cos_get_thd_id(), meas_start); */ #endif CSTUB_FAULT_UPDATE(); goto redo; /* rd = rd_update(lock_id, LOCK_TAKE); */ /* ret = 0; */ /* rdtscll(ubenchmark_end); */ /* if (lock_component_take_ubenchmark_flag) { */ /* lock_component_take_ubenchmark_flag = 0; */ /* printc */ /* ("lock_component_take(C3):recover per object end-end cost: %llu\n", */ /* ubenchmark_end - ubenchmark_start); */ /* } */ } if (ret == -EINVAL) { /* printc("cli:thd %d lock_component_take return EINVAL\n", cos_get_thd_id()); */ rd_recover_state(rd); goto redo; } /* printc("cli:thd %d lock_component_take return %d\n", cos_get_thd_id(), ret); */ return ret; }
static inline int block_cli_if_invoke_sched_wakeup(spdid_t spdid, u16_t thdid, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, 2, spdid, thdid); *fault = __fault; return ret; }
// block_cli_if_invoke pred 3 start desc_dep_create_none creation // block_cli_if_invoke pred 3 end // block_cli_if_invoke 3 start static inline int block_cli_if_invoke_IDL_fname(IDL_parsdecl, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, IDL_pars_len, IDL_params); *fault = __fault; return ret; }
static inline int block_cli_if_invoke_sched_timeout(spdid_t spdid, ul_t amnt, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, 2, spdid, amnt); *fault = __fault; return ret; }
CSTUB_FN(int, twritep)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, int cbuf_id, int start, int sz) { int ret; long fault = 0; int temp = (td << 16) | (cbuf_id & 0xFFFF); CSTUB_INVOKE(ret, fault, uc, 4, spdid, temp, start, sz); return ret; }
transition|terminal // block_cli_if_invoke pred 5 end // block_cli_if_invoke 5 start static inline int block_cli_if_invoke_IDL_fname(IDL_parsdecl, int ret, long *fault, struct usr_inv_cap *uc) { struct desc_track *desc = call_desc_lookup(IDL_id); long __fault = 0; if (desc) { // might be created in the same component CSTUB_INVOKE(ret, __fault, uc, IDL_pars_len, IDL_server_id_params); } else { // might be created in different component CSTUB_INVOKE(ret, __fault, uc, IDL_pars_len, IDL_params); if (ret == -1) { // desc not exist TODO: change to error code block_cli_if_recover(IDL_id);// need upcall assert((desc = call_desc_lookup(IDL_id))); CSTUB_INVOKE(ret, __fault, uc, IDL_pars_len, IDL_params); } } *fault = __fault; return ret; }
static inline int block_cli_if_invoke_sched_block(spdid_t spdid, u16_t dependency_thd, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, 2, spdid, dependency_thd); *fault = __fault; return ret; }
static inline int block_cli_if_invoke_sched_component_take(spdid_t spdid, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, 1, spdid); *fault = __fault; return ret; }
static inline int block_cli_if_invoke_sched_create_thd(spdid_t spdid, u32_t sched_param0, u32_t sched_param1, u32_t sched_param2, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, 4, spdid, sched_param0, sched_param1, sched_param2); *fault = __fault; return ret; }
static inline int block_cli_if_invoke_evt_trigger(spdid_t spdid, long evtid, int ret, long *fault, struct usr_inv_cap *uc) { long __fault = 0; struct desc_track *desc = call_desc_lookup(evtid); //if (desc) { // might be created in the same component // CSTUB_INVOKE(ret, __fault, uc, 2, spdid, evtid); //} else { // might be created in different component CSTUB_INVOKE(ret, __fault, uc, 2, spdid, evtid); if (ret == -1) { // desc not exist TODO: change to error code block_cli_if_recover(evtid); // need upcall assert((desc = call_desc_lookup(evtid))); CSTUB_INVOKE(ret, __fault, uc, 2, spdid, evtid); } *fault = __fault; return ret; }
CSTUB_FN(vaddr_t, mman_revoke_page) (struct usr_inv_cap *uc, spdid_t spdid, vaddr_t addr, int flags) { long fault = 0; long ret; struct rec_data_mm *rd = NULL; if (first == 0 && cos_spd_id() != 5) { cvect_init_static(&rec_mm_vect); cvect_init_static(&parent_rec_mm_vect); first = 1; } if (cos_spd_id() == 5) goto con; redo: rd_update(addr, PAGE_STATE_REVOKE); printc("cli: mman_revoke_page 1\n"); con: CSTUB_INVOKE(ret, fault, uc, 3, spdid, addr, flags); if (unlikely (fault)){ printc("found a fault in mman_revoke_page!!!!\n"); CSTUB_FAULT_UPDATE(); goto redo; } if (cos_spd_id() == 5) goto done; if (ret == -EINVAL) { rd_update_subtree(addr, PAGE_STATE_REVOKE); goto redo; } /* here is one issue: if we always remove all tracking * descriptors here, a page that was aliased (and tracked) in * another component might not be removed explicitly through * the revoke functoin. So we do non remove the descriptors*/ /* rd_remove(addr);*/ /* revoke does not reomve itself, only subtree. So the created * rd is not reomved here. release_page does.*/ /* rdmm_dealloc(rd); */ done: printc("cli: mman_revoke_page return %d\n", ret); return ret; }
static inline int block_cli_if_invoke_evt_split(spdid_t spdid, long parent_evtid, int grp, int ret, long *fault, struct usr_inv_cap *uc) { struct desc_track *parent_desc = NULL; if ((parent_evtid > 1) && (parent_desc = call_desc_lookup(parent_evtid))) { parent_evtid = parent_desc->evtid; } long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, 3, spdid, parent_evtid, grp); *fault = __fault; return ret; }
CSTUB_FN(int, tmerge)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, td_t td_into, char * param, int len) { long fault = 0; td_t ret; struct __sg_tmerge_data *d; struct rec_data_tor *rd; cbuf_t cb; int sz = len + sizeof(struct __sg_tmerge_data); /* printc("<<< rtorrent In: call tmerge (thread %d) >>>\n", cos_get_thd_id()); */ assert(param && len > 0); assert(param[len] == '\0'); redo: /* printc("<<< In: call tmerge (thread %d) >>>\n", cos_get_thd_id()); */ rd = rd_update(td, STATE_TMERGE); assert(rd); d = cbuf_alloc(sz, &cb); if (!d) return -1; /* printc("c: tmerge td %d (server td %d) len %d param %s\n", td, rd->s_tid, len, param); */ d->td = rd->s_tid; /* actual server side torrent id */ d->td_into = td_into; d->len[0] = 0; d->len[1] = len; memcpy(&d->data[0], param, len); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); if (unlikely(fault)) { CSTUB_FAULT_UPDATE(); cbuf_free(cb); goto redo; } cbuf_free(cb); if (!ret) map_rd_delete(rd->c_tid); return ret; }
// block_cli_if_invoke pred 2 start desc_dep_create_diff creation // block_cli_if_invoke pred 2 end // block_cli_if_invoke 2 start static inline int block_cli_if_invoke_IDL_fname(IDL_parsdecl, int ret, long *fault, struct usr_inv_cap *uc) { struct desc_track *parent_desc = NULL; if ((IDL_parent_id > 1) && (parent_desc = call_desc_lookup(IDL_parent_id))) { IDL_parent_id = parent_desc->IDL_server_id; } /* else { // td_root, or in a different component */ /* IDL_parent_id = IDL_parent_id; */ /* } */ long __fault = 0; CSTUB_INVOKE(ret, __fault, uc, IDL_pars_len, IDL_params); *fault = __fault; return ret; }
CSTUB_FN(int, trmeta)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, const char *key, unsigned int klen, char *retval, unsigned int max_rval_len) { int ret; long fault = 0; cbuf_t cb; int sz = sizeof(struct __sg_trmeta_data) + klen + max_rval_len + 1; struct __sg_trmeta_data *d; struct rec_data_tor *rd; assert(key && retval && klen > 0 && max_rval_len > 0); assert(key[klen] == '\0' && sz <= PAGE_SIZE); redo: printc("<<< In: call trmeta (thread %d) >>>\n", cos_get_thd_id()); rd = rd_update(td, STATE_TRMETA); assert(rd); d = cbuf_alloc(sz, &cb); if (!d) return -1; d->td = rd->s_tid; d->klen = klen; d->retval_len = max_rval_len; memcpy(&d->data[0], key, klen + 1); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); if (unlikely(fault)) { CSTUB_FAULT_UPDATE(); goto redo; } if (ret >= 0) { if ((unsigned int)ret > max_rval_len) { // as ret >= 0, cast it to unsigned int to omit compiler warning cbuf_free(cb); return -EIO; } memcpy(retval, &d->data[klen + 1], ret + 1); } cbuf_free(cb); return ret; }
CSTUB_FN(int, lock_component_pretake) (struct usr_inv_cap *uc, spdid_t spdid, unsigned long lock_id, unsigned short int thd) { long fault = 0; int ret; struct rec_data_lk *rd = NULL; redo: rd = rd_update(lock_id, LOCK_PRETAKE); assert(rd); #ifdef BENCHMARK_MEAS_PRETAKE rdtscll(meas_end); if (test_flag) { test_flag = 0; printc("recovery a lock cost: %llu\n", meas_end - meas_start); } #endif CSTUB_INVOKE(ret, fault, uc, 3, spdid, rd->s_lkid, thd); if (unlikely(fault)){ printc("cli:thd %d see a fault in lock_component_pretake!\n", cos_get_thd_id()); #ifdef BENCHMARK_MEAS_PRETAKE test_flag = 1; rdtscll(meas_start); #endif CSTUB_FAULT_UPDATE(); goto redo; // update the generation number } if (ret == -EINVAL) { /* printc("cli:thd %d lock_component_pretake return EINVAL\n", cos_get_thd_id()); */ rd_recover_state(rd); goto redo; } /* printc("cli:thd %d lock_component_pretake return %d\n", cos_get_thd_id(), ret); */ return ret; }
CSTUB_FN(int, twmeta)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, const char *key, unsigned int klen, const char *val, unsigned int vlen) { int ret; long fault = 0; cbuf_t cb; int sz = sizeof(struct __sg_twmeta_data) + klen + vlen + 1; struct __sg_twmeta_data *d; struct rec_data_tor *rd; assert(key && val && klen > 0 && vlen > 0); assert(key[klen] == '\0' && val[vlen] == '\0' && sz <= PAGE_SIZE); redo: printc("<<< In: call twmeta (thread %d) >>>\n", cos_get_thd_id()); rd = rd_update(td, STATE_TWMETA); assert(rd); d = cbuf_alloc(sz, &cb); if (!d) assert(0); //return -1; d->td = td; // do not pass rd->s_tid since this is only for recovery d->klen = klen; d->vlen = vlen; memcpy(&d->data[0], key, klen + 1); memcpy(&d->data[klen + 1], val, vlen + 1); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); if (unlikely(fault)) { CSTUB_FAULT_UPDATE(); goto redo; } cbuf_free(cb); return ret; }
CSTUB_FN(int, twritep)(struct usr_inv_cap *uc, spdid_t spdid, td_t td, int cb, int sz) { long fault = 0; td_t ret; struct rec_data_tor *rd; redo: /* printc("<<< In: call twrite (thread %d) >>>\n", cos_get_thd_id()); */ rd = rd_update(td, STATE_TWRITE); assert(rd); CSTUB_INVOKE(ret, fault, uc, 4, spdid, rd->s_tid, cb, sz); if (unlikely(fault)) { CSTUB_FAULT_UPDATE(); goto redo; } /* we can not save the infor here since we need track the offset and * uniq file id any way */ return ret; }
CSTUB_FN(td_t, tsplit)(struct usr_inv_cap *uc, spdid_t spdid, td_t parent_tid, char * param, int len, tor_flags_t tflags, long evtid) { long fault = 0; td_t ret; struct __sg_tsplit_data *d = NULL; cbuf_t cb = 0; struct rec_data_tor *rd = NULL; int sz = len + sizeof(struct __sg_tsplit_data); td_t curr_ptid = 0; td_t cli_tid = 0; td_t ser_tid = 0; /* printc("cli: tsplit passed in param %s\n", param); */ assert(parent_tid >= 1); assert(param && len >= 0); assert(param[len] == '\0'); if (first == 0) { cos_map_init_static(&uniq_tids); first = 1; } redo: /* printc("<<< cli rtorrent: call tsplit (thread %d, spd %ld and parent tid %d) >>>\n", */ /* cos_get_thd_id(), cos_spd_id(), parent_tid); */ rd = rd_update(parent_tid, STATE_TSPLIT_PARENT); if (rd) { curr_ptid = rd->s_tid; } else { curr_ptid = parent_tid; } /* printc("<<< In: call tsplit (thread %d, , spd %ld and curr_parent tid %d) >>>\n", */ /* cos_get_thd_id(), cos_spd_id(), curr_ptid); */ d = cbuf_alloc(sz, &cb); assert(d); if (!d) return -1; d->parent_tid = curr_ptid; d->tflags = tflags; d->evtid = evtid; d->len[0] = 0; d->len[1] = len; memcpy(&d->data[0], param, len + 1); CSTUB_INVOKE(ret, fault, uc, 3, spdid, cb, sz); if (unlikely(fault)) { CSTUB_FAULT_UPDATE(); memset(&d->data[0], 0, len); cbuf_free(cb); printc("tsplit found a fault and ready to go to redo\n"); goto redo; } cbuf_free(cb); ser_tid = ret; /* printc("passed in param %s (ser_tid %d)\n", param, ser_tid); */ assert(ser_tid >= 1); char *l_param = ""; if (len > 0) { l_param = param_save(param, len); assert(l_param); } cli_tid = map_rd_create(); assert(cli_tid >= 2); rd = map_rd_lookup(cli_tid); assert(rd); rd_cons(rd, curr_ptid, cli_tid, ser_tid, l_param, len, tflags, evtid); /* printc("tsplit done!!! return new client tid %d\n\n", cli_tid); */ return cli_tid; }