add new cpu state CPU_STATUS_RESERVED
This commit is contained in:
@@ -95,6 +95,7 @@ int obtain_clone_cpuid() {
|
|||||||
}
|
}
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
get_cpu_local_var(cpuid)->status = CPU_STATUS_RESERVED;
|
||||||
ihk_mc_spinlock_unlock_noirq(&cpuid_head_lock);
|
ihk_mc_spinlock_unlock_noirq(&cpuid_head_lock);
|
||||||
out:
|
out:
|
||||||
return cpuid;
|
return cpuid;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ struct malloc_header {
|
|||||||
#define CPU_STATUS_DISABLE (0)
|
#define CPU_STATUS_DISABLE (0)
|
||||||
#define CPU_STATUS_IDLE (1)
|
#define CPU_STATUS_IDLE (1)
|
||||||
#define CPU_STATUS_RUNNING (2)
|
#define CPU_STATUS_RUNNING (2)
|
||||||
|
#define CPU_STATUS_RESERVED (3)
|
||||||
extern ihk_spinlock_t cpu_status_lock;
|
extern ihk_spinlock_t cpu_status_lock;
|
||||||
|
|
||||||
#define CPU_FLAG_NEED_RESCHED 0x1U
|
#define CPU_FLAG_NEED_RESCHED 0x1U
|
||||||
|
|||||||
@@ -444,5 +444,6 @@ void cpu_clear(int cpu, cpu_set_t *cpu_set, ihk_spinlock_t *lock);
|
|||||||
|
|
||||||
struct process *findthread_and_lock(int pid, int tid, ihk_spinlock_t **savelock, unsigned long *irqstate);
|
struct process *findthread_and_lock(int pid, int tid, ihk_spinlock_t **savelock, unsigned long *irqstate);
|
||||||
void process_unlock(void *savelock, unsigned long irqstate);
|
void process_unlock(void *savelock, unsigned long irqstate);
|
||||||
|
void release_cpuid(int cpuid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1996,7 +1996,8 @@ static void idle(void)
|
|||||||
{
|
{
|
||||||
struct cpu_local_var *v = get_this_cpu_local_var();
|
struct cpu_local_var *v = get_this_cpu_local_var();
|
||||||
|
|
||||||
v->status = CPU_STATUS_IDLE;
|
if(v->status == CPU_STATUS_RUNNING)
|
||||||
|
v->status = CPU_STATUS_IDLE;
|
||||||
cpu_enable_interrupt();
|
cpu_enable_interrupt();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -2021,7 +2022,8 @@ static void idle(void)
|
|||||||
* 4) The idle process was resumed, and halted for waiting for
|
* 4) The idle process was resumed, and halted for waiting for
|
||||||
* the interrupt that had already been handled.
|
* the interrupt that had already been handled.
|
||||||
*/
|
*/
|
||||||
if (v->status == CPU_STATUS_IDLE) {
|
if (v->status == CPU_STATUS_IDLE ||
|
||||||
|
v->status == CPU_STATUS_RESERVED) {
|
||||||
long s;
|
long s;
|
||||||
struct process *p;
|
struct process *p;
|
||||||
|
|
||||||
@@ -2034,7 +2036,8 @@ static void idle(void)
|
|||||||
}
|
}
|
||||||
ihk_mc_spinlock_unlock(&v->runq_lock, s);
|
ihk_mc_spinlock_unlock(&v->runq_lock, s);
|
||||||
}
|
}
|
||||||
if (v->status == CPU_STATUS_IDLE) {
|
if (v->status == CPU_STATUS_IDLE ||
|
||||||
|
v->status == CPU_STATUS_RESERVED) {
|
||||||
cpu_safe_halt();
|
cpu_safe_halt();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2189,19 +2192,8 @@ redo:
|
|||||||
|
|
||||||
/* No process? Run idle.. */
|
/* No process? Run idle.. */
|
||||||
if (!next) {
|
if (!next) {
|
||||||
list_for_each_entry_safe(proc, tmp, &(v->runq), sched_list) {
|
next = &cpu_local_var(idle);
|
||||||
if (proc->ftn->status & (PS_INTERRUPTIBLE |
|
v->status = v->runq_len? CPU_STATUS_RESERVED: CPU_STATUS_IDLE;
|
||||||
PS_UNINTERRUPTIBLE |
|
|
||||||
PS_STOPPED |
|
|
||||||
PS_TRACED)) {
|
|
||||||
next = proc;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!next) {
|
|
||||||
next = &cpu_local_var(idle);
|
|
||||||
v->status = CPU_STATUS_IDLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2258,6 +2250,13 @@ redo:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
release_cpuid(int cpuid)
|
||||||
|
{
|
||||||
|
if (!get_cpu_local_var(cpuid)->runq_len)
|
||||||
|
get_cpu_local_var(cpuid)->status = CPU_STATUS_IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
void check_need_resched(void)
|
void check_need_resched(void)
|
||||||
{
|
{
|
||||||
struct cpu_local_var *v = get_this_cpu_local_var();
|
struct cpu_local_var *v = get_this_cpu_local_var();
|
||||||
|
|||||||
@@ -1745,6 +1745,7 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
|
|||||||
clone_flags);
|
clone_flags);
|
||||||
|
|
||||||
if (!new) {
|
if (!new) {
|
||||||
|
release_cpuid(cpuid);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1764,6 +1765,7 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
|
|||||||
kprintf("ERROR: forking host process\n");
|
kprintf("ERROR: forking host process\n");
|
||||||
|
|
||||||
/* TODO: clean-up new */
|
/* TODO: clean-up new */
|
||||||
|
release_cpuid(cpuid);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1811,6 +1813,7 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
|
|||||||
if (ihk_mc_pt_virt_to_phys(new->vm->page_table,
|
if (ihk_mc_pt_virt_to_phys(new->vm->page_table,
|
||||||
(void *)child_tidptr, &phys)) {
|
(void *)child_tidptr, &phys)) {
|
||||||
kprintf("ERROR: looking up physical addr for child process\n");
|
kprintf("ERROR: looking up physical addr for child process\n");
|
||||||
|
release_cpuid(cpuid);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user