uti: Replace dead uti thread with new mcexec thread in proc->tids

Change-Id: Ic6e906dd1bfac1b07f1317732cbe0a5191831cd8
This commit is contained in:
Masamichi Takagi
2018-09-03 18:02:35 +09:00
parent 96aab7e215
commit 04d4145b3e
7 changed files with 68 additions and 16 deletions

View File

@@ -2391,7 +2391,7 @@ long
mcexec_util_thread1(ihk_os_t os, unsigned long arg, struct file *file)
{
void **__user uparam = (void ** __user)arg;
void *param[6];
void *param[7];
unsigned long p_rctx;
unsigned long phys;
void *__user u_rctx;
@@ -2401,7 +2401,7 @@ mcexec_util_thread1(ihk_os_t os, unsigned long arg, struct file *file)
unsigned long free_size;
unsigned long icurrent = (unsigned long)current;
if(copy_from_user(param, uparam, sizeof(void *) * 6)) {
if(copy_from_user(param, uparam, sizeof(void *) * 7)) {
return -EFAULT;
}
p_rctx = (unsigned long)param[0];
@@ -2422,6 +2422,7 @@ mcexec_util_thread1(ihk_os_t os, unsigned long arg, struct file *file)
((unsigned long *)rctx)[0] = free_address;
((unsigned long *)rctx)[1] = free_size;
((unsigned long *)rctx)[2] = (unsigned long)param[6];
#ifdef CONFIG_MIC
iounmap(rctx);

View File

@@ -1040,6 +1040,7 @@ pid_t master_tid;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_barrier_t init_ready;
pthread_barrier_t uti_init_ready;
pthread_attr_t watchdog_thread_attr;
pthread_t watchdog_thread;
@@ -1390,8 +1391,7 @@ void init_sigaction(void)
static int max_cpuid;
static int
create_worker_thread(pthread_barrier_t *init_ready)
static int create_worker_thread(struct thread_data_s **tp_out, pthread_barrier_t *init_ready)
{
struct thread_data_s *tp;
@@ -1409,6 +1409,10 @@ create_worker_thread(pthread_barrier_t *init_ready)
tp->next = thread_data;
thread_data = tp;
if (tp_out) {
*tp_out = tp;
}
return pthread_create(&tp->thread_id, NULL,
&main_loop_thread_func, tp);
}
@@ -1422,7 +1426,7 @@ int init_worker_threads(int fd)
max_cpuid = 0;
for (i = 0; i <= n_threads; ++i) {
int ret = create_worker_thread(&init_ready);
int ret = create_worker_thread(NULL, &init_ready);
if (ret) {
printf("ERROR: creating syscall threads (%d), check ulimit?\n", ret);
@@ -2882,10 +2886,18 @@ static long util_thread(struct thread_data_s *my_thread, unsigned long uctx_pa,
int i;
void *lctx;
void *rctx;
void *param[6];
void *param[7];
int rc = 0;
void *uti_wp = (void*)-1;
pthread_barrier_init(&uti_init_ready, NULL, 2);
if ((rc = create_worker_thread(&tp, &uti_init_ready))) {
printf("%s: Error: create_worker_thread failed (%d)\n", __FUNCTION__, rc);
goto out;
}
pthread_barrier_wait(&uti_init_ready);
__dprintf("%s: worker tid: %d\n", __FUNCTION__, tp->tid);
uti_desc = (struct uti_desc *)_uti_desc;
if (!uti_desc) {
fprintf(stderr, "%s: ERROR: uti_desc isn't set. Use mcexec.sh instead of mcexec\n", __FUNCTION__);
@@ -2916,8 +2928,8 @@ static long util_thread(struct thread_data_s *my_thread, unsigned long uctx_pa,
rctx = (char *)lctx + PAGE_SIZE;
#endif /* POSTK_DEBUG_ARCH_DEP_35 */
param[0] = (void *)uctx_pa;
param[1] = rctx;
param[0] = (void *)uctx_pa; /* Source address, kernel space */
param[1] = rctx; /* Destination address, user space */
param[2] = lctx;
param[4] = uti_desc->wp;
#ifdef POSTK_DEBUG_ARCH_DEP_35
@@ -2925,12 +2937,19 @@ static long util_thread(struct thread_data_s *my_thread, unsigned long uctx_pa,
#else /* POSTK_DEBUG_ARCH_DEP_35 */
param[5] = (void *)(PAGE_SIZE * 3);
#endif /* POSTK_DEBUG_ARCH_DEP_35 */
param[6] = (void *)tp->tid;
printf("%s: param[6]=%ld,tid=%ld\n", __FUNCTION__, (long)param[6], (long)((void *)tp->tid));
__dprintf("%s: before MCEXEC_UP_UTIL_THREAD1\n", __FUNCTION__);
/* 1. Copy context from kernel space to user space
2. Write uti_wp addr, its size for McKernel to uctx_pa
Note that this overwrites context */
if ((rc = ioctl(fd, MCEXEC_UP_UTIL_THREAD1, param)) == -1) {
fprintf(stderr, "util_thread1: %d errno=%d\n", rc, errno);
rc = -errno;
goto out;
}
create_worker_thread(NULL);
/* Record the info of the thread migrating to Linux */
uti_desc->wp = uti_wp;
@@ -3372,7 +3391,7 @@ int main_loop(struct thread_data_s *my_thread)
tids[i++] = tp->tid;
}
for (; i < ncpu; ++i) {
for (; i < w.sr.args[4]; ++i) {
tids[i] = 0;
}