From 4f6f4197d794403edec36db6fb1c0d1987bdda9d Mon Sep 17 00:00:00 2001 From: Adrien Lebre Date: Wed, 13 May 2015 14:37:31 +0200 Subject: [PATCH] More progress toward the atomic simcall for vm migration - Ad(rien) --- src/msg/msg_vm.c | 22 ++++++++++++---------- src/simix/libsmx.c | 4 ---- src/simix/popping_accessors.h | 12 ++++++------ src/simix/popping_bodies.c | 10 +++++----- src/simix/simcalls.in | 2 +- src/simix/smx_vm.c | 25 +++++++++++++++++++++++++ 6 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index ee3bd5430c..ac42d90c75 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -392,16 +392,18 @@ static int migration_rx_fun(int argc, char *argv[]) msg_host_t dst_pm = ms-> dst_pm; msg_host_priv_t priv = msg_host_resource_priv(vm); -// TODO: we have an issue, if the DST node is turning off during the three next calls, then the VM is in an inconsistent state -// I should check with Takahiro in order to make this portion of code atomic - /* deinstall the current affinity setting for the CPU */ - simcall_vm_set_affinity(vm, src_pm, 0); - - /* Update the vm location */ - simcall_vm_migrate(vm, dst_pm); - - /* Resume the VM */ - simcall_vm_resume(vm); +// // TODO: we have an issue, if the DST node is turning off during the three next calls, then the VM is in an inconsistent state +// // I should check with Takahiro in order to make this portion of code atomic +// /* deinstall the current affinity setting for the CPU */ +// simcall_vm_set_affinity(vm, src_pm, 0); +// +// /* Update the vm location */ +// simcall_vm_migrate(vm, dst_pm); +// +// /* Resume the VM */ +// simcall_vm_resume(vm); +// + simcall_vm_migratefrom_resumeto(vm, src_pm, dst_pm); /* install the affinity setting of the VM on the destination pm */ { diff --git a/src/simix/libsmx.c b/src/simix/libsmx.c index b3c48f3158..d5a78fabd7 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@ -532,7 +532,6 @@ void simcall_vm_destroy(smx_host_t vm) simcall_BODY_vm_destroy(vm); } -Proc - vm_migratefrom_resumeto (void) (ind_vm, void*, smx_host_t)(ind_src_pm, void*, smx_host_t) (ind_dst_pm, void*, smx_host_t) /** * \ingroup simix_vm_management * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration @@ -546,15 +545,12 @@ Proc - vm_migratefrom_resumeto (void) (ind_vm, void*, smx_host_t)(ind_src_pm, vo * \param vm VM to migrate * \param src_pm Source physical host * \param dst_pmt Destination physical host - */ void simcall_vm_migratefrom_resumeto(smx_host_t vm, smx_host_t src_pm, smx_host_t dst_pm) { simcall_BODY_vm_migratefrom_resumeto(vm, src_pm, dst_pm); } - - /** * \ingroup simix_process_management * \brief Creates and runs a new SIMIX process. diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index b307993b00..e5515011cf 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -584,22 +584,22 @@ static inline void simcall_vm_restore__set__ind_vm(smx_simcall_t simcall, void* simcall->args[0].dp = arg; } -static inline smx_host_t simcall_vm_migratefrom_resumeto__get__ind_vm(smx_simcall_t simcall) { +static inline smx_host_t simcall_vm_migratefrom_resumeto__get__vm(smx_simcall_t simcall) { return (smx_host_t) simcall->args[0].dp; } -static inline void simcall_vm_migratefrom_resumeto__set__ind_vm(smx_simcall_t simcall, void* arg) { +static inline void simcall_vm_migratefrom_resumeto__set__vm(smx_simcall_t simcall, void* arg) { simcall->args[0].dp = arg; } -static inline smx_host_t simcall_vm_migratefrom_resumeto__get__ind_src_pm(smx_simcall_t simcall) { +static inline smx_host_t simcall_vm_migratefrom_resumeto__get__src_pm(smx_simcall_t simcall) { return (smx_host_t) simcall->args[1].dp; } -static inline void simcall_vm_migratefrom_resumeto__set__ind_src_pm(smx_simcall_t simcall, void* arg) { +static inline void simcall_vm_migratefrom_resumeto__set__src_pm(smx_simcall_t simcall, void* arg) { simcall->args[1].dp = arg; } -static inline smx_host_t simcall_vm_migratefrom_resumeto__get__ind_dst_pm(smx_simcall_t simcall) { +static inline smx_host_t simcall_vm_migratefrom_resumeto__get__dst_pm(smx_simcall_t simcall) { return (smx_host_t) simcall->args[2].dp; } -static inline void simcall_vm_migratefrom_resumeto__set__ind_dst_pm(smx_simcall_t simcall, void* arg) { +static inline void simcall_vm_migratefrom_resumeto__set__dst_pm(smx_simcall_t simcall, void* arg) { simcall->args[2].dp = arg; } diff --git a/src/simix/popping_bodies.c b/src/simix/popping_bodies.c index e538690a8f..7b4a39c15a 100644 --- a/src/simix/popping_bodies.c +++ b/src/simix/popping_bodies.c @@ -923,19 +923,19 @@ inline static void simcall_BODY_vm_restore(smx_host_t ind_vm) { } -inline static void simcall_BODY_vm_migratefrom_resumeto(smx_host_t ind_vm, smx_host_t ind_src_pm, smx_host_t ind_dst_pm) { +inline static void simcall_BODY_vm_migratefrom_resumeto(smx_host_t vm, smx_host_t src_pm, smx_host_t dst_pm) { smx_process_t self = SIMIX_process_self(); /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_vm_migratefrom_resumeto(ind_vm, ind_src_pm, ind_dst_pm); + if (0) SIMIX_vm_migratefrom_resumeto(vm, src_pm, dst_pm); /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ self->simcall.call = SIMCALL_VM_MIGRATEFROM_RESUMETO; memset(&self->simcall.result, 0, sizeof(self->simcall.result)); memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) ind_vm; - self->simcall.args[1].dp = (void*) ind_src_pm; - self->simcall.args[2].dp = (void*) ind_dst_pm; + self->simcall.args[0].dp = (void*) vm; + self->simcall.args[1].dp = (void*) src_pm; + self->simcall.args[2].dp = (void*) dst_pm; if (self != simix_global->maestro_process) { XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index e8faeb107d..d3986bb36e 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -84,7 +84,7 @@ Proc H vm_resume (void) (ind_vm, void*, smx_host_t) Proc H vm_shutdown (void) (ind_vm, void*, smx_host_t) Proc H vm_save (void) (ind_vm, void*, smx_host_t) Proc H vm_restore (void) (ind_vm, void*, smx_host_t) -Proc - vm_migratefrom_resumeto (void) (ind_vm, void*, smx_host_t)(ind_src_pm, void*, smx_host_t) (ind_dst_pm, void*, smx_host_t) +Proc - vm_migratefrom_resumeto (void) (vm, void*, smx_host_t)(src_pm, void*, smx_host_t) (dst_pm, void*, smx_host_t) Proc H process_create (void) (process, void*, smx_process_t*) (name, const char*) (code, FPtr, xbt_main_func_t) (data, void*) (hostname, const char*) (kill_time, double) (argc, int) (argv, void*, char**) (properties, void*, xbt_dict_t) (auto_restart, int) Proc H process_kill (void) (process, void*, smx_process_t) Proc H process_killall (void) (reset_pid, int) diff --git a/src/simix/smx_vm.c b/src/simix/smx_vm.c index d2eab043aa..9bf0d6ba01 100644 --- a/src/simix/smx_vm.c +++ b/src/simix/smx_vm.c @@ -116,6 +116,31 @@ void SIMIX_vm_migrate(smx_host_t ind_vm, smx_host_t ind_dst_pm) surf_vm_workstation_migrate(ind_vm, ind_dst_pm); } +/** + * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration + * The simcall actually invokes the following calls: + * simcall_vm_set_affinity(vm, src_pm, 0); + * simcall_vm_migrate(vm, dst_pm); + * simcall_vm_resume(vm); + * + * It is called at the end of the migration_rx_fun function from msg/msg_vm.c + * + * \param vm VM to migrate + * \param src_pm Source physical host + * \param dst_pmt Destination physical host + */ +void SIMIX_vm_migratefrom_resumeto(smx_host_t vm, smx_host_t src_pm, smx_host_t dst_pm) +{ + /* deinstall the current affinity setting for the CPU */ + SIMIX _vm_set_affinity(vm, src_pm, 0); + + /* Update the vm location */ + SIMIX_vm_migrate(vm, dst_pm); + + /* Resume the VM */ + SIMIX_vm_resume(vm); +} + /** * \brief Function to get the physical host of the given SIMIX VM host. * -- 2.20.1