From 6bd71ad6a4b3f8f858788c153ad273ea16bb4d89 Mon Sep 17 00:00:00 2001 From: Zefan Li Date: Tue, 14 Jul 2015 10:28:21 +0800 Subject: [PATCH] Add memory swappiness support - Initialize swappiness to -1 for the default config.json - Pass swappiness from config.json to libcontainer config Signed-off-by: Zefan Li --- README.md | 3 ++- spec.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ccf28458..f6050606b 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,8 @@ user named `daemon` defined within that file-system. "limit": 0, "reservation": 0, "swap": 0, - "kernel": 0 + "kernel": 0, + "swappiness": -1 }, "cpu": { "shares": 0, diff --git a/spec.go b/spec.go index 2bdf8ac70..a99415b99 100644 --- a/spec.go +++ b/spec.go @@ -116,6 +116,11 @@ var specCommand = cli.Command{ "zero", "urandom", }, + Resources: specs.Resources{ + Memory: specs.Memory{ + Swappiness: -1, + }, + }, }, } data, err := json.MarshalIndent(&spec, "", "\t") @@ -247,6 +252,7 @@ func createCgroupConfig(spec *specs.LinuxSpec, devices []*configs.Device) (*conf c.MemoryReservation = r.Memory.Reservation c.MemorySwap = r.Memory.Swap c.KernelMemory = r.Memory.Kernel + c.MemorySwappiness = r.Memory.Swappiness c.CpuShares = r.CPU.Shares c.CpuQuota = r.CPU.Quota c.CpuPeriod = r.CPU.Period