Skip to content

Stack Shuffle

Jaidev Shastri edited this page Dec 13, 2022 · 1 revision

This page shows how to stack-shuffle a checkpointed process once the entire setup is in place. The steps demonstrated here are the same for both emulated as well as bare-metal environments. Stack-shuffling and migrating are not dependent on each other and as such can be invoked either order (migration followed by stack-shuffling or vice versa).

Directory Structure

It is recommended to follow the same directory structure as that of process migration shown here. The directory below shows the structure of bt benchmark from SNU_NPB:

.
├── bin
│   ├── bt_aarch64
│   └── bt_x86-64
└── bt

As part of stack-shuffling, the binary image outside bin folder (shown above as bt) along with criu images are modified. The binary image needs to be copied and replaced inside the bin folder based on the ISA of the binary.

SNU-NPB benchmarks

In order to create this directory structure:

  1. Navigate to Transproc directory with the command
cd /path/to/TransProc/test/SNU_NPB_SER_C

2a) If on a x86-64 host, run the script setup_x86.sh by simply running

./setup_x86.sh

2b) If on a aarch64 host, run the script setup_arm.sh by simply running

./setup_arm.sh

This will create the aforementioned directory structure in your home folder.

There are 4 main steps for stack shuffling:

  • Spawn : Spawn a process and suspend it at a migration point
  • Dump : Criu dump the process
  • Stack-shuffle : Shuffle the stack allocations of the checkpointed process
  • Restore : Criu restore the process on destination

Spawn

This example uses bt as the benchmark that gets live migrated, bt can be replaced with any SNU-NPB benchmarks. After executing the setup_{ISA}.sh script, navigate to the bt directory in your home directory.

cd ~/bt/

This directory should contain a Makefile with recipes that will help in both stack-shuffling and live migration of the process. To launch bt with the TransProc monitor run:

make spawn

Dump

Once the process is spawned under the TransProc monitor, it will be suspended at a migration point. To dump it we have another Makefile target it place. You will need another terminal to run the following command from the process' directory context:

make dump

This command will dump the process.

Stack-shuffle

Run the following command to shuffle the stack allocations of the checkpointed process:

make shuffle

Copy (Optional)

This step is optional and needs to be invoked only if stack-shuffling is carried out with migration in either order. Copy binary to the bin folder based on the ISA of the stack-shuffled binary:

cp bt ./bin/bt_{ISA}

Restore

Run the following command to restore the process:

make restore

Redis

For redis, first create the redis directory structure by navigating to /path/to/TransProc/test/redis and running either ./setup-x86.sh or ./setup-arm.sh based on the ISA of the binary being transformed (stack-shuffled).

After executing the setup_{ISA}.sh script, navigate to the redis-server directory in your home directory with

cd ~/redis-server

Next, run redis binary within:

./redis-server

Dump

Once the process is able to accept key-value pairs dump it:

make dump

or, invoke the following command manually:

sudo /Path-to-TransProc/criu-3.15/criu/criu dump -o dump.log -t $(pidof redis-server) --shell-job

Stack-shuffle

Run the following command to shuffle the stack allocations of the checkpointed process:

make shuffle

or, invoke the following command manually:

sudo /Path-to-TransProc/criu-3.15/crit/crit ss $(pwd) $(pwd)/redis-server

Copy (Optional)

This step is optional and needs to be invoked only if stack-shuffling is carried out with migration in either order. Copy binary to the bin folder based on the ISA of the stack-shuffled binary:

cp redis-server ./bin/redis-server_{ISA}

Restore

Run the following command to restore the process:

make restore

or, invoke the following command manually:

sudo /Path-to-TransProc/criu-3.15/criu/criu restore -o restore.log --shell-job

This will spawn the stack-shuffled process.

NOTE:

  • Please note that the Makefiles contain variable TRANSPROC which need to be updated to point to the root of the project repository.