X-Git-Url: http://akaros.cs.berkeley.edu/gitweb/?p=akaros.git;a=blobdiff_plain;f=kern%2Fsrc%2Fkthread.c;h=908a40ffd62c2e4d2783cabaf6798b8551bddec3;hp=518f37ab40958cf1a82ffcc926612e60f51f8672;hb=31e572ba36f16f7f17724bc3703977f6b9789d86;hpb=43bd877c94aea5e7686ca37eee8a36631b5b302d diff --git a/kern/src/kthread.c b/kern/src/kthread.c index 518f37a..908a40f 100644 --- a/kern/src/kthread.c +++ b/kern/src/kthread.c @@ -154,7 +154,13 @@ void restart_kthread(struct kthread *kthread) proc_decref(kthread->proc); kthread->proc = 0; } else { - /* Load our page tables before potentially decreffing cur_proc */ + /* Load our page tables before potentially decreffing cur_proc. + * + * We don't need to do an EPT flush here. The EPT is flushed and + * managed in sync with the VMCS. We won't run a different VM (and + * thus *need* a different EPT) without first removing the old GPC, + * which ultimately will result in a flushed EPT (on x86, this + * actually happens when we clear_owning_proc()). */ lcr3(kthread->proc->env_cr3); /* Might have to clear out an existing current. If they need to be * set later (like in restartcore), it'll be done on demand. */ @@ -587,11 +593,34 @@ static void debug_upped_sem(struct semaphore *sem) #endif /* CONFIG_SEMAPHORE_DEBUG */ -void print_sem_info(struct semaphore *sem) +static bool __sem_has_pid(struct semaphore *sem, pid_t pid) { struct kthread *kth_i; + + if (pid == -1) + return TRUE; + TAILQ_FOREACH(kth_i, &sem->waiters, link) { + if (kth_i->proc) { + if (kth_i->proc->pid == pid) + return TRUE; + } else { + if (pid == 0) + return TRUE; + } + } + return FALSE; +} + +static void print_sem_info(struct semaphore *sem, pid_t pid) +{ + struct kthread *kth_i; + /* Always safe to irqsave */ spin_lock_irqsave(&sem->lock); + if (!__sem_has_pid(sem, pid)) { + spin_unlock_irqsave(&sem->lock); + return; + } printk("Semaphore %p has %d signals (neg = waiters)\n", sem, sem->nr_signals); TAILQ_FOREACH(kth_i, &sem->waiters, link) @@ -603,14 +632,14 @@ void print_sem_info(struct semaphore *sem) spin_unlock_irqsave(&sem->lock); } -void print_all_sem_info(void) +void print_all_sem_info(pid_t pid) { #ifdef CONFIG_SEMAPHORE_DEBUG struct semaphore *sem_i; printk("All sems with waiters:\n"); spin_lock_irqsave(&sems_with_waiters_lock); TAILQ_FOREACH(sem_i, &sems_with_waiters, link) - print_sem_info(sem_i); + print_sem_info(sem_i, pid); spin_unlock_irqsave(&sems_with_waiters_lock); #else printk("Failed to print all sems: build with CONFIG_SEMAPHORE_DEBUG\n");