Skip to content

Commit

Permalink
add affinity control with taskset
Browse files Browse the repository at this point in the history
When there are more than 4 cores, or mixed architecture (e.g. big.LITTLE),
then we want to be able to specify which we run on.

This makes `make kvm` produce a shell script that runs taskset on qemu.
By default QEMU is pinned to cores 0-7.
Can specify which cores with e.g.:
> AFFINITY=0xf ./kvm_litmus ...

Or compile a kvm_litmus without affinity control by
> make kvm AFFINITY=
  • Loading branch information
bensimner committed May 16, 2024
1 parent 8e9cfca commit 8cf730d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Options:
Do not perform existence checks of cross-compilation tools.
make kvm [...] HOST="no-gic"
Use KVM with virtualized interrupt controller
make kvm [...] AFFINITY=
Build KVM executable without `taskset` affinity control
make [...] SHOW_PREPROCESSED_OUTPUT=1
For each .o file generate .pp containing pre-processor output
make [...] TEST_DISCOVER=0
Expand Down Expand Up @@ -110,6 +112,17 @@ OBJDUMP = $(PREFIX)objdump
QEMU = qemu-system-aarch64
GDB = $(PREFIX)gdb

# use `taskset` to force QEMU to exist only on some cores
# e.g. for big.LITTLE implementations
#
# Can run e.g. `AFFINITY=0xf ./kvm_litmus` to pin to hardware threads 0-3.
# or `make build AFFINITY=` to turn off affinity-aware kvm_litmus entirely
# (e.g. for systems without `taskset`)
AFFINITY = 0xff
ifneq ($(AFFINITY),)
QEMU := taskset $${AFFINITY:-$(AFFINITY)} $(QEMU)
endif

# set to 1 to do a second CC pass with -E
# this will generate not only bin/**/f.o files but bin/**/f.pp files that are the output
# of the preprocessor.
Expand Down

0 comments on commit 8cf730d

Please sign in to comment.