Knobs: Modify the behaviour of the Mlock knob.

The Mlock knob is unfortunately tied to realtime.
Allow Mlock knob to implicitly enable realtime to get the
desired swapping behavior when swapping is desired.

Note: Realtime as implemented today can only be used to enable
swap, and as such does not really control realtime behaviour.
The knob is redundant but retained here just to ensure that
when more capabilities are added in future QEMU iterations
we can take advantage of the same.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
This commit is contained in:
Manohar Castelino 2017-09-15 09:44:23 -07:00
parent ddee41d553
commit 0c206170c4
2 changed files with 14 additions and 3 deletions

11
qemu.go
View File

@ -1015,11 +1015,22 @@ func (config *Config) appendKnobs() {
if config.Knobs.Realtime == true {
config.qemuParams = append(config.qemuParams, "-realtime")
// This path is redundant as the default behaviour is locked memory
// Realtime today does not control any other feature even though
// other features may be added in the future
// https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg03330.html
if config.Knobs.Mlock == true {
config.qemuParams = append(config.qemuParams, "mlock=on")
} else {
config.qemuParams = append(config.qemuParams, "mlock=off")
}
} else {
// In order to turn mlock off we need the -realtime option as well
if config.Knobs.Mlock == false {
//Enable realtime anyway just to get the right swapping behaviour
config.qemuParams = append(config.qemuParams, "-realtime")
config.qemuParams = append(config.qemuParams, "mlock=off")
}
}
}

View File

@ -223,9 +223,8 @@ func TestAppendEmptyDevice(t *testing.T) {
testAppend(device, "", t)
}
var knobsString = "-no-user-config -nodefaults -nographic -daemonize -realtime mlock=on"
func TestAppendKnobsAllTrue(t *testing.T) {
var knobsString = "-no-user-config -nodefaults -nographic -daemonize -realtime mlock=on"
knobs := Knobs{
NoUserConfig: true,
NoDefaults: true,
@ -240,6 +239,7 @@ func TestAppendKnobsAllTrue(t *testing.T) {
}
func TestAppendKnobsAllFalse(t *testing.T) {
var knobsString = "-realtime mlock=off"
knobs := Knobs{
NoUserConfig: false,
NoDefaults: false,
@ -249,7 +249,7 @@ func TestAppendKnobsAllFalse(t *testing.T) {
Mlock: false,
}
testAppend(knobs, "", t)
testAppend(knobs, knobsString, t)
}
var kernelString = "-kernel /opt/vmlinux.container -append root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable"