diff --git a/executer/include/uprotocol.h b/executer/include/uprotocol.h index 5aebd6c2..9892a0ac 100644 --- a/executer/include/uprotocol.h +++ b/executer/include/uprotocol.h @@ -91,6 +91,7 @@ struct program_image_section { struct get_cpu_set_arg { int nr_processes; + int *process_rank; void *cpu_set; size_t cpu_set_size; // Size in bytes int *target_core; @@ -143,6 +144,7 @@ struct program_load_desc { long stack_premap; unsigned long mpol_bind_mask; int nr_processes; + int process_rank; char shell_path[SHELL_PATH_MAX_LEN]; __cpu_set_unit cpu_set[PLD_CPU_SET_SIZE]; int profile; diff --git a/executer/kernel/mcctrl/control.c b/executer/kernel/mcctrl/control.c index 195e012e..d08faae7 100644 --- a/executer/kernel/mcctrl/control.c +++ b/executer/kernel/mcctrl/control.c @@ -692,6 +692,7 @@ static long mcexec_get_cpuset(ihk_os_t os, unsigned long arg) wake_up_interruptible(&pli_next->pli_wq); /* Reset process counter */ pe->nr_processes_left = pe->nr_processes; + pe->process_rank = 0; } /* Wait for the rest if not the last or if the last but @@ -923,6 +924,15 @@ next_cpu: goto put_and_unlock_out; } + /* Copy rank */ + if (copy_to_user(req.process_rank, &pe->process_rank, + sizeof(int))) { + printk("%s: error copying process rank to user\n", + __FUNCTION__); + ret = -EINVAL; + goto put_and_unlock_out; + } + /* mcexec NUMA to bind to */ mcexec_linux_numa = cpu_to_node(mckernel_cpu_2_linux_cpu(udp, cpu)); if (copy_to_user(req.mcexec_linux_numa, &mcexec_linux_numa, @@ -970,6 +980,7 @@ next_cpu: } /* Otherwise wake up next process in list */ else { + ++pe->process_rank; pli_next = list_first_entry(&pe->pli_list, struct process_list_item, list); list_del(&pli_next->list); diff --git a/executer/kernel/mcctrl/mcctrl.h b/executer/kernel/mcctrl/mcctrl.h index e2724562..d7589dcd 100644 --- a/executer/kernel/mcctrl/mcctrl.h +++ b/executer/kernel/mcctrl/mcctrl.h @@ -314,6 +314,7 @@ struct mcctrl_part_exec { struct mutex lock; int nr_processes; int nr_processes_left; + int process_rank; cpumask_t cpus_used; struct list_head pli_list; }; diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 0a325822..8fc494e1 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -2416,6 +2416,7 @@ int main(int argc, char **argv) struct get_cpu_set_arg cpu_set_arg; int mcexec_linux_numa = 0; int ikc_mapped = 0; + int process_rank = -1; cpu_set_t mcexec_cpu_set; CPU_ZERO(&mcexec_cpu_set); @@ -2424,6 +2425,7 @@ int main(int argc, char **argv) cpu_set_arg.cpu_set_size = sizeof(desc->cpu_set); cpu_set_arg.nr_processes = nr_processes; cpu_set_arg.target_core = &target_core; + cpu_set_arg.process_rank = &process_rank; cpu_set_arg.mcexec_linux_numa = &mcexec_linux_numa; cpu_set_arg.mcexec_cpu_set = &mcexec_cpu_set; cpu_set_arg.mcexec_cpu_set_size = sizeof(mcexec_cpu_set); @@ -2436,6 +2438,7 @@ int main(int argc, char **argv) } desc->cpu = target_core; + desc->process_rank = process_rank; /* Bind to CPU cores where the LWK process' IKC target maps to */ if (ikc_mapped && !no_bind_ikc_map) { diff --git a/kernel/host.c b/kernel/host.c index e68776c4..77ff420e 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -482,6 +482,7 @@ static int process_msg_prepare_process(unsigned long rphys) proc->mpol_flags = pn->mpol_flags; proc->mpol_threshold = pn->mpol_threshold; proc->nr_processes = pn->nr_processes; + proc->process_rank = pn->process_rank; proc->heap_extension = pn->heap_extension; /* Update NUMA binding policy if requested */ diff --git a/kernel/include/process.h b/kernel/include/process.h index ec61c5b1..e290cff8 100644 --- a/kernel/include/process.h +++ b/kernel/include/process.h @@ -572,6 +572,7 @@ struct process { unsigned long profile_elapsed_ts; #endif // PROFILE_ENABLE int nr_processes; /* For partitioned execution */ + int process_rank; /* Rank in partition */ }; /* diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index 24a2833b..c85f5038 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -200,6 +200,7 @@ struct program_load_desc { long stack_premap; unsigned long mpol_bind_mask; int nr_processes; + int process_rank; char shell_path[SHELL_PATH_MAX_LEN]; __cpu_set_unit cpu_set[PLD_CPU_SET_SIZE]; int profile;