Merge remote branch 'origin/master' into gdb

This commit is contained in:
Naoki Hamada
2014-08-01 11:19:18 +09:00
2 changed files with 20 additions and 7 deletions

View File

@ -72,21 +72,31 @@ int obtain_clone_cpuid() {
retry: retry:
/* Try to obtain next physical core */ /* Try to obtain next physical core */
cpuid = cpuid_head; cpuid = cpuid_head;
cpuid_head += 4;
/* A hyper-threading core on the same physical core as
the parent process might be chosen. Use sched_setaffinity
if you want to skip that kind of busy physical core for
performance reason. */
cpuid_head += 1;
if(cpuid_head >= cpu_info->ncpus) { if(cpuid_head >= cpu_info->ncpus) {
cpuid_head = ((cpuid_head % 4) + 1) % 4; cpuid_head = 0;
} }
/* Don't use a physical core with a system process (e.g. MPI)
because using it degrades performance */ /* A hyper-threading core whose parent physical core has a
if((cpu_info->ncpus - 3 <= cpuid && cpuid <= cpu_info->ncpus - 1) || process on one of its hyper-threading core might
get_cpu_local_var(cpuid)->status != CPU_STATUS_IDLE) { be chosen. Use sched_setaffinity if you want to skip that
kind of busy physical core for performance reason. */
if(get_cpu_local_var(cpuid)->status != CPU_STATUS_IDLE) {
nretry++; nretry++;
if(nretry >= cpu_info->ncpus) { if(nretry >= cpu_info->ncpus) {
panic("there is no cpu with empty runq\n"); cpuid = -1;
ihk_mc_spinlock_unlock_noirq(&cpuid_head_lock);
goto out;
} }
goto retry; goto retry;
} }
ihk_mc_spinlock_unlock_noirq(&cpuid_head_lock); ihk_mc_spinlock_unlock_noirq(&cpuid_head_lock);
out:
return cpuid; return cpuid;
} }

View File

@ -1290,6 +1290,9 @@ SYSCALL_DECLARE(clone)
(unsigned long)ihk_mc_syscall_sp(ctx)); (unsigned long)ihk_mc_syscall_sp(ctx));
cpuid = obtain_clone_cpuid(); cpuid = obtain_clone_cpuid();
if (cpuid == -1) {
return -EAGAIN;
}
new = clone_process(cpu_local_var(current), ihk_mc_syscall_pc(ctx), new = clone_process(cpu_local_var(current), ihk_mc_syscall_pc(ctx),
ihk_mc_syscall_arg1(ctx) ? ihk_mc_syscall_arg1(ctx) : ihk_mc_syscall_arg1(ctx) ? ihk_mc_syscall_arg1(ctx) :