Do not disable IRQs to protect cur_ctx
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 7 Dec 2015 23:36:28 +0000 (18:36 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 10 Dec 2015 16:23:30 +0000 (11:23 -0500)
Back in the day, current_ctx needed to be protected against interrupts.
That was when the process management kernel messages were IMMEDIATE.
Nowadays, they are ROUTINE, and you don't need IRQ protections.

I think.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/schedule.c
kern/src/syscall.c

index 83fc2bc..0bc5bf0 100644 (file)
@@ -290,13 +290,9 @@ static bool __schedule_scp(void)
        struct proc *p;
        uint32_t pcoreid = core_id();
        struct per_cpu_info *pcpui = &per_cpu_info[pcoreid];
        struct proc *p;
        uint32_t pcoreid = core_id();
        struct per_cpu_info *pcpui = &per_cpu_info[pcoreid];
-       int8_t state = 0;
        /* if there are any runnables, run them here and put any currently running
         * SCP on the tail of the runnable queue. */
        if ((p = TAILQ_FIRST(&runnable_scps))) {
        /* if there are any runnables, run them here and put any currently running
         * SCP on the tail of the runnable queue. */
        if ((p = TAILQ_FIRST(&runnable_scps))) {
-               /* protect owning proc, cur_ctx, etc.  note this nests with the
-                * calls in proc_yield_s */
-               disable_irqsave(&state);
                /* someone is currently running, dequeue them */
                if (pcpui->owning_proc) {
                        spin_lock(&pcpui->owning_proc->proc_lock);
                /* someone is currently running, dequeue them */
                if (pcpui->owning_proc) {
                        spin_lock(&pcpui->owning_proc->proc_lock);
@@ -306,7 +302,6 @@ static bool __schedule_scp(void)
                                send_kernel_message(core_id(), __just_sched, 0, 0, 0,
                                                    KMSG_ROUTINE);
                                spin_unlock(&pcpui->owning_proc->proc_lock);
                                send_kernel_message(core_id(), __just_sched, 0, 0, 0,
                                                    KMSG_ROUTINE);
                                spin_unlock(&pcpui->owning_proc->proc_lock);
-                               enable_irqsave(&state);
                                return FALSE;
                        }
                        printd("Descheduled %d in favor of %d\n", pcpui->owning_proc->pid,
                                return FALSE;
                        }
                        printd("Descheduled %d in favor of %d\n", pcpui->owning_proc->pid,
@@ -335,7 +330,6 @@ static bool __schedule_scp(void)
                switch_lists(p, &runnable_scps, &unrunnable_scps);
                printd("PID of the SCP i'm running: %d\n", p->pid);
                proc_run_s(p);  /* gives it core we're running on */
                switch_lists(p, &runnable_scps, &unrunnable_scps);
                printd("PID of the SCP i'm running: %d\n", p->pid);
                proc_run_s(p);  /* gives it core we're running on */
-               enable_irqsave(&state);
                return TRUE;
        }
        return FALSE;
                return TRUE;
        }
        return FALSE;
index 70fe938..5677f5e 100644 (file)
@@ -713,7 +713,6 @@ static int sys_change_vcore(struct proc *p, uint32_t vcoreid,
 static ssize_t sys_fork(env_t* e)
 {
        uintptr_t temp;
 static ssize_t sys_fork(env_t* e)
 {
        uintptr_t temp;
-       int8_t state = 0;
        int ret;
 
        // TODO: right now we only support fork for single-core processes
        int ret;
 
        // TODO: right now we only support fork for single-core processes
@@ -727,17 +726,14 @@ static ssize_t sys_fork(env_t* e)
        assert(env != NULL);
        proc_set_progname(env, e->progname);
 
        assert(env != NULL);
        proc_set_progname(env, e->progname);
 
-       disable_irqsave(&state);        /* protect cur_ctx */
        /* Can't really fork if we don't have a current_ctx to fork */
        if (!current_ctx) {
        /* Can't really fork if we don't have a current_ctx to fork */
        if (!current_ctx) {
-               enable_irqsave(&state);
                proc_destroy(env);
                proc_decref(env);
                set_errno(EINVAL);
                return -1;
        }
        copy_current_ctx_to(&env->scp_ctx);
                proc_destroy(env);
                proc_decref(env);
                set_errno(EINVAL);
                return -1;
        }
        copy_current_ctx_to(&env->scp_ctx);
-       enable_irqsave(&state);
 
        env->cache_colors_map = cache_colors_map_alloc();
        for (int i = 0; i < llc_cache->num_colors; i++)
 
        env->cache_colors_map = cache_colors_map_alloc();
        for (int i = 0; i < llc_cache->num_colors; i++)
@@ -799,7 +795,6 @@ static int sys_exec(struct proc *p, char *path, size_t path_l,
        char *t_path = NULL;
        struct file *program;
        struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
        char *t_path = NULL;
        struct file *program;
        struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
-       int8_t state = 0;
        int argc, envc;
        char **argv, **envp;
        struct argenv *kargenv;
        int argc, envc;
        char **argv, **envp;
        struct argenv *kargenv;
@@ -814,11 +809,9 @@ static int sys_exec(struct proc *p, char *path, size_t path_l,
                return -1;
        }
 
                return -1;
        }
 
-       disable_irqsave(&state);        /* protect cur_ctx */
        /* Can't exec if we don't have a current_ctx to restart (if we fail).  This
         * isn't 100% true, but I'm okay with it. */
        if (!pcpui->cur_ctx) {
        /* Can't exec if we don't have a current_ctx to restart (if we fail).  This
         * isn't 100% true, but I'm okay with it. */
        if (!pcpui->cur_ctx) {
-               enable_irqsave(&state);
                set_errno(EINVAL);
                return -1;
        }
                set_errno(EINVAL);
                return -1;
        }
@@ -833,7 +826,6 @@ static int sys_exec(struct proc *p, char *path, size_t path_l,
         * Note that we will 'hard block' if we block at all.  We can't return to
         * userspace and then asynchronously finish the exec later. */
        clear_owning_proc(core_id());
         * Note that we will 'hard block' if we block at all.  We can't return to
         * userspace and then asynchronously finish the exec later. */
        clear_owning_proc(core_id());
-       enable_irqsave(&state);
 
        /* Check the size of the argenv array, error out if too large. */
        if ((argenv_l < sizeof(struct argenv)) || (argenv_l > ARG_MAX)) {
 
        /* Check the size of the argenv array, error out if too large. */
        if ((argenv_l < sizeof(struct argenv)) || (argenv_l > ARG_MAX)) {