2017-01-20 20:37 GMT-03:00 Guillermo: > > [...] I'll do more testing during the weekend.
And here are the results: > 1) Programs from at least util-linux get confused by the way > system-manager(8) mounts some of the filesystems from > source/api_mounts.cpp. The problem seems to be those whose > corresponding array of iovecs doesn't have a 'from' element, which > IIUC results in a mount(2) call for them with an empty string as the > 'source' argument in source/nmount.cpp. It's definitely that. To see what happens, I added lines of the form: FROM, MAKE_IOVEC("Some non-empty source, even if it is meaningless for this filesystem's type"), to each array of iovecs in source/api_mounts.cpp that didn't have one (inside the #if defined(__LINUX__) || defined(__linux__) ... #else block), and that does make the other programs happy: $ mount /dev/sda4 on / type ext4 (rw,relatime,data=ordered) proc on /proc type proc (rw,nosuid,nodev,relatime) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,name=systemd) dev on /dev type devtmpfs (rw,nosuid,size=10240k,nr_inodes=128775,mode=755) devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620,ptmxmode=666) tmpfs on /run type tmpfs (rw,nosuid,nodev,size=206124k,mode=755) tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,size=515312k) [...] $ findmnt --list TARGET SOURCE FSTYPE OPTIONS / /dev/sda4 ext4 rw,relatime,data=ordered /proc proc proc rw,nosuid,nodev,relatime /sys sysfs sysfs rw,nosuid,nodev,noexec,relatime /sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755 /sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,name=systemd /dev dev devtmpfs rw,nosuid,size=10240k,nr_inodes=128775,mode=755 /dev/pts devpts devpts rw,nosuid,noexec,gid=5,mode=620,ptmxmode=666 /run tmpfs tmpfs rw,nosuid,nodev,size=206124k,mode=755 /run/shm tmpfs tmpfs rw,nosuid,nodev,noexec,size=515312k [...] > 2) [...] > /sys/fs/cgroup shows up empty even though the kernel has cgroups v1 > support compiled in. And the catch-all logger reports this: > > $ tai64nlocal /run/system-manager/log/current > 2017-01-19 21:36:21.771835085 system-manager: INFO: cg1: Not required > by this kernel. > 2017-01-19 21:36:21.771907685 system-manager: INFO: sc1: Not required > by this kernel. > [...] > The lines about cg1 and sc1, the arrays of iovecs corresponding to > /sys/fs/cgroup (fstype=tmpfs) and /sys/fs/cgroup/systemd > (fstype=cgroup), shouldn't be there, since there is a 'cgroup' line in > /proc/filesystems that query_control_group_level() in > source/common-manager.cpp should have seen: Well, it turns out the explanation wasn't that complicated: query_control_group_level() tries to read /proc/filesystems, which is only available after mounting /proc... and /proc is mounted in setup_kernel_api_volumes_and_devices(), by the code that loops over the api_mounts vector, *after* calling query_control_group_level(), so that function unconditionally returns 0 because it can't read the file. For testing purposes I modified the code to do the dirty trick of triggering the query_control_group_level() call when an api_mount object with a 'cgl' field of 3 shows up (and some std::fprintf() calls to make system-manager more verbose so I could check the results) to get past this and see what I really wanted to check out in the first place: system-manager's cgroups v1 setup and its interaction with set-control-group-knob(1) :) $ tai64nlocal /run/system-manager/log/current 2017-01-21 22:11:17.709571254 system-manager: INFO: proc: has cgl = 0 2017-01-21 22:11:17.709633263 system-manager: INFO: sys: has cgl = 3 2017-01-21 22:11:17.709637174 system-manager: INFO: query_control_group_level() returned 1 2017-01-21 22:11:17.709641144 system-manager: INFO: cg1: has cgl = 1 2017-01-21 22:11:17.709644536 system-manager: INFO: sc1: has cgl = 1 2017-01-21 22:11:17.709647934 system-manager: INFO: cg2: has cgl = 2 2017-01-21 22:11:17.709651209 system-manager: INFO: cg2: Not required by this kernel. 2017-01-21 22:11:17.709654884 system-manager: INFO: sc2: has cgl = 2 2017-01-21 22:11:17.709658104 system-manager: INFO: sc2: Not required by this kernel. 2017-01-21 22:11:17.709661871 system-manager: INFO: dev: has cgl = 0 2017-01-21 22:11:17.709665114 system-manager: INFO: pts: has cgl = 0 2017-01-21 22:11:17.709668389 system-manager: INFO: run: has cgl = 0 2017-01-21 22:11:17.709671634 system-manager: INFO: shm: has cgl = 0 2017-01-21 22:11:17.709674891 system-manager: ERROR: symlink: /dev/ptmx: File exists 2017-01-21 22:11:17.709678664 system-manager: ERROR: /sys/fs/cgroup/systemd//cgroup.subtree_control: No such file or directory 2017-01-21 22:11:17.709683364 system-manager: ERROR: /sys/fs/cgroup/systemd//service-manager.slice/cgroup.subtree_control: No such file or directory 2017-01-21 22:11:17.709688663 system-manager: INFO: system-control (pid 61) started (init ) 2017-01-21 22:11:17.709692514 system-manager: INFO: cyclog (pid 62) started 2017-01-21 22:11:17.709695970 system-manager: INFO: service-manager (pid 63) started 2017-01-21 22:11:17.735193005 system-manager: INFO: system-control (pid 61) ended status 0 2017-01-21 22:11:17.735941678 system-manager: INFO: system-control (pid 64) started (start sysinit) [...] $ ps -e -o pid,ppid,comm,cgroup PID PPID COMMAND CGROUP 1 0 system-manager 1:name=systemd:/me.slice [...] 62 1 cyclog 1:name=systemd:/system-manager-log.slice 63 1 service-manager 1:name=systemd:/service-manager.slice/me.slice 73 63 udevd 1:name=systemd:/service-manager.slice/eudev.service 113 63 login 1:name=systemd:/service-manager.slice/agetty@.service/agetty@tty1.service 115 113 bash 1:name=systemd:/service-manager.slice/agetty@.service/agetty@tty1.service 131 115 ps 1:name=systemd:/service-manager.slice/agetty@.service/agetty@tty1.service $ ls /sys/fs/cgroup/systemd/* /sys/fs/cgroup/systemd/cgroup.clone_children /sys/fs/cgroup/systemd/cgroup.procs /sys/fs/cgroup/systemd/cgroup.sane_behavior /sys/fs/cgroup/systemd/notify_on_release /sys/fs/cgroup/systemd/release_agent /sys/fs/cgroup/systemd/tasks /sys/fs/cgroup/systemd/me.slice: cgroup.clone_children cgroup.procs notify_on_release tasks /sys/fs/cgroup/systemd/service-manager.slice: agetty@.service basic.target cgroup.clone_children cgroup.procs eudev.service frame-buffer.target fs-servers.target local-fs-pre.target local-fs.target local-syslog.target me.slice multi-user-pre.target multi-user.target normal.target notify_on_release remote-fs-pre.target remote-fs.target server.target static-networking.target swapauto.target swaplate.target sysinit.target tasks uhidd.target workstation.target /sys/fs/cgroup/systemd/system-control.slice: cgroup.clone_children cgroup.procs notify_on_release tasks /sys/fs/cgroup/systemd/system-manager-log.slice: cgroup.clone_children cgroup.procs notify_on_release tasks G.