[lxc-devel] [lxd/master] cpuset: fall back to cpuset.cpus on older kernels
hallyn on Github
lxc-bot at linuxcontainers.org
Tue Apr 26 21:04:27 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 574 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160426/502fff5a/attachment.bin>
-------------- next part --------------
From 9e852bc662a8c612d9fdb28c72d0e4ce4b1bbb11 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Tue, 26 Apr 2016 15:59:05 -0500
Subject: [PATCH] cpuset: fall back to cpuset.cpus on older kernels
cpuset.effective_cpus is better because it does not include cpus which
we cannot use. But it is not available on older kernels. In that
case fall back to using cpuset.cpus and hoping for the best.
Closes #1929
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
lxd/devices.go | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lxd/devices.go b/lxd/devices.go
index f25a02c..6504fb6 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -184,8 +184,13 @@ func deviceTaskBalance(d *Daemon) {
// Get effective cpus list - those are all guaranteed to be online
effectiveCpus, err := cGroupGet("cpuset", "/", "cpuset.effective_cpus")
if err != nil {
- shared.Log.Error("Error reading host's cpuset.effective_cpus")
- return
+ // Older kernel - use cpuset.cpus
+ shared.Log.Warn("Failed reading host's cpuset.effective_cpus, falling back to cpuset.cpus")
+ effectiveCpus, err = cGroupGet("cpuset", "/", "cpuset.cpus")
+ if err != nil {
+ shared.Log.Error("Error reading host's cpuset.cpus")
+ return
+ }
}
err = cGroupSet("cpuset", "/lxc", "cpuset.cpus", effectiveCpus)
if err != nil && shared.PathExists("/sys/fs/cgroup/cpuset/lxc") {
@@ -193,7 +198,7 @@ func deviceTaskBalance(d *Daemon) {
}
cpus, err := parseCpuset(effectiveCpus)
if err != nil {
- shared.Log.Error("Error parsing host's cpuset.effective_cpus", log.Ctx{"cpuset": effectiveCpus, "err": err})
+ shared.Log.Error("Error parsing host's cpu set", log.Ctx{"cpuset": effectiveCpus, "err": err})
return
}
More information about the lxc-devel
mailing list