Tofu: initial version
Change-Id: I9c464d5af883c18715a97ca9e9981cf73b260f90
This commit is contained in:
committed by
Masamichi Takagi
parent
fe83deb3db
commit
92902d36fc
101
kernel/syscall.c
101
kernel/syscall.c
@ -220,6 +220,7 @@ long do_syscall(struct syscall_request *req, int cpu)
|
||||
req->ttid = 0;
|
||||
}
|
||||
res.req_thread_status = IHK_SCD_REQ_THREAD_SPINNING;
|
||||
res.pde_data = NULL;
|
||||
send_syscall(req, cpu, &res);
|
||||
|
||||
if (req->rtid == -1) {
|
||||
@ -380,6 +381,31 @@ long do_syscall(struct syscall_request *req, int cpu)
|
||||
|
||||
rc = res.ret;
|
||||
|
||||
if (req->number == __NR_ioctl && rc == 0) {
|
||||
if (cpu_local_var(current)->proc->enable_tofu &&
|
||||
res.pde_data &&
|
||||
!thread->proc->fd_pde_data[req->args[0]] &&
|
||||
!strncmp(thread->proc->fd_path[req->args[0]],
|
||||
"/proc/tofu/dev/", 15)) {
|
||||
|
||||
if (req->args[0] < MAX_FD_PDE) {
|
||||
unsigned long irqstate;
|
||||
|
||||
irqstate = ihk_mc_spinlock_lock(&thread->proc->mckfd_lock);
|
||||
thread->proc->fd_pde_data[req->args[0]] = res.pde_data;
|
||||
ihk_mc_spinlock_unlock(&thread->proc->mckfd_lock, irqstate);
|
||||
|
||||
kprintf("%s: PID: %d, ioctl fd: %d, filename: "
|
||||
"%s, pde_data: 0x%lx\n",
|
||||
__FUNCTION__,
|
||||
thread->proc->pid,
|
||||
req->args[0],
|
||||
thread->proc->fd_path[req->args[0]],
|
||||
res.pde_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(req->number != __NR_exit_group){
|
||||
--thread->in_syscall_offload;
|
||||
}
|
||||
@ -1265,6 +1291,23 @@ void terminate(int rc, int sig)
|
||||
mcs_rwlock_writer_unlock(&proc->threads_lock, &lock);
|
||||
mcs_rwlock_writer_unlock_noirq(&proc->update_lock, &updatelock);
|
||||
|
||||
#ifdef ENABLE_TOFU
|
||||
/* Tofu: clean up stags, must be done before mcexec is gone */
|
||||
if (proc->enable_tofu) {
|
||||
int fd;
|
||||
|
||||
for (fd = 0; fd < MAX_FD_PDE; ++fd) {
|
||||
/* Tofu? */
|
||||
if (proc->enable_tofu && proc->fd_pde_data[fd]) {
|
||||
extern void tof_utofu_release_cq(void *pde_data);
|
||||
|
||||
tof_utofu_release_cq(proc->fd_pde_data[fd]);
|
||||
proc->fd_pde_data[fd] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
terminate_mcexec(rc, sig);
|
||||
|
||||
mcs_rwlock_writer_lock(&proc->threads_lock, &lock);
|
||||
@ -1419,7 +1462,6 @@ void terminate(int rc, int sig)
|
||||
#endif
|
||||
|
||||
// clean up memory
|
||||
|
||||
finalize_process(proc);
|
||||
|
||||
preempt_disable();
|
||||
@ -1907,6 +1949,10 @@ straight_out:
|
||||
}
|
||||
|
||||
if (flags & (MAP_POPULATE | MAP_LOCKED)) {
|
||||
dkprintf("%s: 0x%lx:%lu %s%s|\n",
|
||||
__func__, addr, len,
|
||||
flags & MAP_POPULATE ? "|MAP_POPULATE" : "",
|
||||
flags & MAP_LOCKED ? "|MAP_LOCKED" : "");
|
||||
populated_mapping = 1;
|
||||
}
|
||||
|
||||
@ -3810,6 +3856,23 @@ SYSCALL_DECLARE(ioctl)
|
||||
break;
|
||||
ihk_mc_spinlock_unlock(&proc->mckfd_lock, irqstate);
|
||||
|
||||
#ifdef ENABLE_TOFU
|
||||
/* Tofu? */
|
||||
if (proc->enable_tofu &&
|
||||
fd < MAX_FD_PDE && thread->proc->fd_pde_data[fd]) {
|
||||
extern long tof_utofu_unlocked_ioctl_cq(int fd,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
rc = tof_utofu_unlocked_ioctl_cq(fd,
|
||||
ihk_mc_syscall_arg1(ctx),
|
||||
ihk_mc_syscall_arg2(ctx));
|
||||
|
||||
/* Do we need to offload? */
|
||||
if (rc != -ENOTSUPP)
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(fdp && fdp->ioctl_cb){
|
||||
//kprintf("ioctl: found system fd %d\n", fd);
|
||||
rc = fdp->ioctl_cb(fdp, ctx);
|
||||
@ -3817,6 +3880,7 @@ SYSCALL_DECLARE(ioctl)
|
||||
else{
|
||||
rc = syscall_generic_forwarding(__NR_ioctl, ctx);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -3852,7 +3916,12 @@ SYSCALL_DECLARE(open)
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(pathname);
|
||||
if (rc > 0 && rc < MAX_FD_PDE) {
|
||||
cpu_local_var(current)->proc->fd_path[rc] = pathname;
|
||||
}
|
||||
else {
|
||||
kfree(pathname);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -3888,7 +3957,12 @@ SYSCALL_DECLARE(openat)
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(pathname);
|
||||
if (rc > 0 && rc < MAX_FD_PDE) {
|
||||
cpu_local_var(current)->proc->fd_path[rc] = pathname;
|
||||
}
|
||||
else {
|
||||
kfree(pathname);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -3936,6 +4010,26 @@ SYSCALL_DECLARE(close)
|
||||
long irqstate;
|
||||
|
||||
irqstate = ihk_mc_spinlock_lock(&proc->mckfd_lock);
|
||||
|
||||
#ifdef ENABLE_TOFU
|
||||
/* Clear path and PDE data */
|
||||
if (fd >= 0 && fd < MAX_FD_PDE) {
|
||||
/* Tofu? */
|
||||
if (thread->proc->fd_pde_data[fd]) {
|
||||
extern void tof_utofu_release_cq(void *pde_data);
|
||||
|
||||
tof_utofu_release_cq(thread->proc->fd_pde_data[fd]);
|
||||
thread->proc->fd_pde_data[fd] = NULL;
|
||||
}
|
||||
|
||||
if (thread->proc->fd_path[fd]) {
|
||||
dkprintf("%s: %d -> %s\n", __func__, fd, thread->proc->fd_path[fd]);
|
||||
kfree(thread->proc->fd_path[fd]);
|
||||
thread->proc->fd_path[fd] = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for(fdp = proc->mckfd, fdq = NULL; fdp; fdq = fdp, fdp = fdp->next)
|
||||
if(fdp->fd == fd)
|
||||
break;
|
||||
@ -10682,6 +10776,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx)
|
||||
*/
|
||||
if (num < PROFILE_SYSCALL_MAX) {
|
||||
profile_event_add(num, (ts - thread->profile_start_ts));
|
||||
thread->profile_start_ts = rdtsc();
|
||||
}
|
||||
else {
|
||||
if (num != __NR_profile) {
|
||||
|
||||
Reference in New Issue
Block a user