Hello all,
I'm forwarding a patch for the loopback setup from Stéphane. I already
pushed one part of it as
http://cgit.freedesktop.org/systemd/systemd/commit/?id=58a489c
which is trivial and obvious, but the other part isn't.
Thanks,
Martin
- Forwarded message from Stéphane Graber stgra...@ubuntu.com -
Date: Thu, 25 Dec 2014 22:17:52 +0100
From: Stéphane Graber stgra...@ubuntu.com
To: martin.p...@ubuntu.com
Subject: systemd patch for unprivileged containers
X-Spam-Status: No, score=-1.9 required=3.4 tests=BAYES_00 autolearn=no
version=3.3.2
Hey Martin,
Attached is a pretty simple patch/workaround to fix the massive CPU
usage of systemd in unprivileged containers.
LXC provides each containers with an already-UP loopback device. systemd
will attempt to bring it up regardless of its current state and doing so
gets it into a broken codepath somewhere deep in the netlink handling
code of systemd.
The fix is to always check whether the loopback is ready to use before
doing anything.
I then noticed that this code path in systemd was broken too due to it
checking against 1.0.0.127 rather than 127.0.0.1 so I added the missing
htonl and now it all works as expected and systemd fails on the next
problem about a minute faster than it used to :)
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
- End forwarded message -
--
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From af71697dcc084b81f4c585c4b0c9dd6ac51b77d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= stgra...@ubuntu.com
Date: Sat, 27 Dec 2014 19:22:58 +0100
Subject: [PATCH] core: Optimize loopback setup
Check if the loopback device is already set up (like with LXC) before doing any
setup ourselves.
---
src/core/loopback-setup.c | 8
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c
index ab6335c..e46b70a 100644
--- a/src/core/loopback-setup.c
+++ b/src/core/loopback-setup.c
@@ -86,15 +86,15 @@ int loopback_setup(void) {
_cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
int r;
+if (check_loopback())
+return 0;
+
r = sd_rtnl_open(rtnl, 0);
if (r 0)
return r;
r = start_loopback(rtnl);
-if (r == -EPERM) {
-if (check_loopback() 0)
-return log_warning_errno(EPERM, Failed to configure loopback device: %m);
-} else if (r 0)
+if (r 0)
return log_warning_errno(r, Failed to configure loopback device: %m);
--
2.1.3
signature.asc
Description: Digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel