Bug#824779: container getty-static.service causes lxcfs high cpu usage
Wang Jian
larkwang at gmail.com
Wed Jul 20 16:37:12 BST 2016
2016-07-19 19:29 GMT+08:00 Michael Biebl <biebl at debian.org>:
> On Sat, 16 Jul 2016 15:34:20 +0200 Martin Pitt <mpitt at debian.org> wrote:
>> Control: tag -1 pending
>>
>> Wang Jian [2016-05-19 23:59 +0800]:
>> > getty-static.service starts getty on tty2-6, but container has only 4
>> > ttys (1-4) at default. getty will exit and be respawned for tty5-tty6.
>> > This leads to high cpu usage on host's lxcfs daemon.
>> >
>
> That's interesting. Shouldn't the rate liming of systemd kick in here?
>
> Can you show us the output of systemctl status getty at tty5.service and/or
> getty at tty6.service
>
It's long time ago, I can't remember clearly what I did.
# find /etc/systemd /lib/systemd /run/systemd -name "*getty*"
/etc/systemd/system/getty.target.wants
/etc/systemd/system/getty.target.wants/getty at tty1.service
/etc/systemd/system/getty.target.wants/getty at tty4.service
/etc/systemd/system/getty.target.wants/getty at tty2.service
/etc/systemd/system/getty.target.wants/getty at tty3.service
/etc/systemd/system/.getty at .service.swp
/etc/systemd/system/getty at .service
/lib/systemd/system-generators/systemd-getty-generator
/lib/systemd/system/getty.target.wants
/lib/systemd/system/getty.target.wants/getty-static.service
/lib/systemd/system/multi-user.target.wants/getty.target
/lib/systemd/system/getty at .service
/lib/systemd/system/getty.target
/lib/systemd/system/getty-static.service
/lib/systemd/system/console-getty.service
/lib/systemd/system/serial-getty at .service
/lib/systemd/system/container-getty at .service
/run/systemd/generator/getty.target.wants
/run/systemd/generator/getty.target.wants/container-getty at 5.service
/run/systemd/generator/getty.target.wants/container-getty at 4.service
/run/systemd/generator/getty.target.wants/container-getty at 3.service
/run/systemd/generator/getty.target.wants/container-getty at 2.service
/run/systemd/generator/getty.target.wants/container-getty at 1.service
/run/systemd/generator/getty.target.wants/container-getty at 0.service
/run/systemd/generator/getty.target.wants/console-getty.service
I may override it to disable the respawning the day I submitted this bug report
# ls -l /etc/systemd/system/.getty at .service.swp
-rw-r--r-- 1 root root 12288 May 19 23:25
/etc/systemd/system/.getty at .service.swp
# diff -u /lib/systemd/system/getty at .service /etc/systemd/system/getty at .service
--- /lib/systemd/system/getty at .service 2016-04-25 17:32:15.000000000 +0800
+++ /etc/systemd/system/getty at .service 2015-05-17 20:28:50.253964583 +0800
@@ -21,7 +21,7 @@
# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty at .service, not this
# unit.
-ConditionPathExists=/dev/tty0
+# ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
# cat /lib/systemd/system/getty-static.service
[Unit]
Description=getty on tty2-tty6 if dbus and logind are not available
ConditionPathExists=/dev/tty2
ConditionPathExists=!/lib/systemd/system/dbus.service
[Service]
Type=oneshot
ExecStart=/bin/systemctl --no-block start getty at tty2.service
getty at tty3.service getty at tty4.service getty at tty5.service
getty at tty6.service
RemainAfterExit=true
# systemctl status getty at tty5.service getty at tty6.service
● getty at tty5.service - Getty on tty5
Loaded: loaded (/etc/systemd/system/getty at .service; enabled; vendor
preset: enabled)
Active: active (running) since Fri 2016-06-24 00:28:55 CST; 3 weeks
5 days ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 152 (agetty)
Tasks: 1 (limit: 512)
CGroup: /system.slice/system-getty.slice/getty at tty5.service
└─152 /sbin/agetty --noclear tty5 linux
Warning: Journal has been rotated since unit was started. Log output
is incomplete or unavailable.
● getty at tty6.service - Getty on tty6
Loaded: loaded (/etc/systemd/system/getty at .service; enabled; vendor
preset: enabled)
Active: active (running) since Fri 2016-06-24 00:28:55 CST; 3 weeks
5 days ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 148 (agetty)
Tasks: 1 (limit: 512)
CGroup: /system.slice/system-getty.slice/getty at tty6.service
└─148 /sbin/agetty --noclear tty6 linux
The host was rebooted at 2016-06-24 00:28:55 CST.
# ls -l /dev/tty*
crw-rw-rw- 1 root root 5, 0 Jun 24 00:28 /dev/tty
crw--w---- 1 root tty 136, 0 Jun 24 00:29 /dev/tty1
crw--w---- 1 root tty 136, 1 Jun 24 00:29 /dev/tty2
crw--w---- 1 root tty 136, 2 Jun 24 00:29 /dev/tty3
crw--w---- 1 root tty 136, 3 Jun 24 00:29 /dev/tty4
crw--w---- 1 root tty 136, 4 Jun 24 00:29 /dev/tty5
crw--w---- 1 root tty 136, 5 Jun 24 00:29 /dev/tty6
# ps auxf|grep linux
root 145 0.0 0.0 12688 1684 ? Ss Jun24 0:00
/sbin/agetty --noclear tty3 linux
root 148 0.0 0.0 12688 1688 ? Ss Jun24 0:00
/sbin/agetty --noclear tty6 linux
root 151 0.0 0.0 12688 1612 tty2 Ss+ Jun24 0:00
/sbin/agetty --noclear tty2 linux
root 152 0.0 0.0 12688 1572 tty5 Ss+ Jun24 0:00
/sbin/agetty --noclear tty5 linux
root 153 0.0 0.0 12688 1748 ? Ss Jun24 0:00
/sbin/agetty --noclear tty1 linux
root 154 0.0 0.0 12688 1544 ? Ss Jun24 0:00
/sbin/agetty --noclear tty4 linux
>> There is no point in even wasting four getty processes on tty1-4 in
>> LXC -- containers are not meant to have gettys on ttys in the first
>> place. I committed a fix to git for that.
>> (ConditionVirtualization=!container)
>
> getty-static.service is really simplistic. Maybe we should replace it by
> a tiny generator which runs in case dbus is not installed and creates
> symlink in /run/systemd/generator/getty.target.wants/
> for actually available ttys. We could even make it respect it NAutoVTs=
> from logind.conf then.
>
> Michael
> --
> Why is it that all of the instruments seeking intelligent life in the
> universe are pointed away from Earth?
>
More information about the Pkg-systemd-maintainers
mailing list