uti: Replace dead uti thread with new mcexec thread in proc->tids
Change-Id: Ic6e906dd1bfac1b07f1317732cbe0a5191831cd8
This commit is contained in:
@@ -242,6 +242,11 @@ enum mpol_rebind_step {
|
||||
#define SPAWN_TO_REMOTE 1
|
||||
#define SPAWNING_TO_REMOTE 1001
|
||||
|
||||
#define UTI_STATE_DEAD 0
|
||||
#define UTI_STATE_PROLOGUE 1
|
||||
#define UTI_STATE_RUNNING_IN_LINUX 2
|
||||
#define UTI_STATE_EPILOGUE 3
|
||||
|
||||
#include <waitq.h>
|
||||
#include <futex.h>
|
||||
|
||||
@@ -690,10 +695,11 @@ struct thread {
|
||||
/* Syscall offload wait queue head */
|
||||
struct waitq scd_wq;
|
||||
|
||||
int thread_offloaded;
|
||||
int uti_state;
|
||||
int mod_clone;
|
||||
struct uti_attr *mod_clone_arg;
|
||||
int parent_cpuid;
|
||||
int uti_refill_tid;
|
||||
|
||||
// for performance counter
|
||||
unsigned long pmc_alloc_map;
|
||||
|
||||
@@ -2623,6 +2623,21 @@ void __release_tid(struct process *proc, struct thread *thread) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Replace tid specified by thread with tid specified by new_tid */
|
||||
void __find_and_replace_tid(struct process *proc, struct thread *thread, int new_tid) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < proc->nr_tids; ++i) {
|
||||
if (proc->tids[i].thread != thread) continue;
|
||||
|
||||
proc->tids[i].thread = NULL;
|
||||
proc->tids[i].tid = new_tid;
|
||||
kprintf("%s: tid %d (thread %p) has been relaced with tid %d\n",
|
||||
__FUNCTION__, thread->tid, thread, new_tid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void destroy_thread(struct thread *thread)
|
||||
{
|
||||
struct sig_pending *pending;
|
||||
@@ -2646,7 +2661,11 @@ void destroy_thread(struct thread *thread)
|
||||
|
||||
mcs_rwlock_writer_lock(&proc->threads_lock, &lock);
|
||||
list_del(&thread->siblings_list);
|
||||
__release_tid(proc, thread);
|
||||
if (thread->uti_state == UTI_STATE_EPILOGUE) {
|
||||
__find_and_replace_tid(proc, thread, thread->uti_refill_tid);
|
||||
} else {
|
||||
__release_tid(proc, thread);
|
||||
}
|
||||
mcs_rwlock_writer_unlock(&proc->threads_lock, &lock);
|
||||
|
||||
mcs_rwlock_writer_unlock(&proc->update_lock, &updatelock);
|
||||
|
||||
@@ -9127,6 +9127,8 @@ int util_thread(struct uti_attr *arg)
|
||||
struct uti_attr attr;
|
||||
} kattr;
|
||||
|
||||
thread->uti_state = UTI_STATE_PROLOGUE;
|
||||
|
||||
context = (volatile unsigned long *)ihk_mc_alloc_pages(1,
|
||||
IHK_MC_AP_NOWAIT);
|
||||
if (!context) {
|
||||
@@ -9154,15 +9156,20 @@ int util_thread(struct uti_attr *arg)
|
||||
}
|
||||
request.args[3] = (unsigned long)uti_clv;
|
||||
request.args[4] = uti_desc;
|
||||
thread->thread_offloaded = 1;
|
||||
thread->uti_state = UTI_STATE_RUNNING_IN_LINUX;
|
||||
rc = do_syscall(&request, ihk_mc_get_processor_id(), 0);
|
||||
dkprintf("%s: returned from do_syscall,tid=%d,rc=%lx\n", __FUNCTION__, thread->tid, rc);
|
||||
|
||||
thread->uti_state = UTI_STATE_EPILOGUE;
|
||||
|
||||
util_show_syscall_profile();
|
||||
|
||||
thread->thread_offloaded = 0;
|
||||
/* These are written by mcexec_util_thread1() */
|
||||
free_address = context[0];
|
||||
free_size = context[1];
|
||||
thread->uti_refill_tid = context[2];
|
||||
dkprintf("%s: mcexec worker tid=%d\n", __FUNCTION__, context[2]);
|
||||
|
||||
ihk_mc_free_pages((void *)context, 1);
|
||||
kfree(uti_clv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user