/srv/irclogs.ubuntu.com/2022/04/28/#ubuntu-devel.txt

ahasenackddstreet: cjwatson wrt uring, mariadb and memlock, check "ulimit settings" in this doc: https://git.kernel.dk/cgit/liburing/tree/README#n1913:31
ahasenackthis is not mariadb calling mlock specifically, it's just a side effect of using uring13:32
ahasenackwhat we can tweak maybe is the size of the ring13:32
ddstreetah that's interesting, i should have realized it from the name of the lib 'uring', makes sense. if the rlimit can't be increased then does seem like no other choice than to limit the uring size13:41
cjwatsonThe rlimit can be increased, I just advocate doing it in the distro rather than specifically for buildds13:44
cjwatsonIf that's thought to be the right thing to do13:45
ahasenackit's not even clear to me how the default memlock limit is calculated or set13:45
cjwatsonLimiting the ring size doesn't seem silly if it's possible though13:45
ahasenacksystemd manpages say one thing, but experiments show another13:45
ahasenackddstreet: and fyi, the way things are currently, a focal host cannot run a jammy mariadb lxd without tweaking this on the host13:47
ahasenackthe mariadb install will fail in the jammy lxd13:47
ahasenackmysql seems fine. I haven't checked if it's even using uring, but it installs fine in the same lxd at least13:48
ddstreetahasenack there were some significant problems before around the rlimit size inside a container, as it was varying between host releases13:48
ahasenack/ io_uring instance queue depth13:51
ahasenackconst unsigned int kIoUringDepth = 256;13:51
ahasenackI guess I know where the 256 magic number comes from13:51
* ahasenack runs some experiments13:52
ahasenackhm, don't the units here seem odd: https://pastebin.ubuntu.com/p/94dhcWvcBj/14:12
ahasenackI either get 65536 kbytes14:12
ahasenackor 64 kbytes14:12
ahasenacksame host14:12
ahasenackit's a big difference14:12
ahasenackand I can't raise it inside the lxd, as expected14:12
ahasenackroot@j-mysql:~# ulimit -l 6553614:12
ahasenack-bash: ulimit: max locked memory: cannot modify limit: Operation not permitted14:12
ahasenackI wonder if there is some confusion about the unit, whether it's bytes or kbytes14:18
ahasenackok, each ring entry costs 128 bytes14:26
ahasenackmariadb is setting it up with 2048 entries14:26
ddstreetahasenack if i'm reading it correctly, it looks like lxd is defaulting to 64 for RLIMIT_MEMLOCK in containers... https://github.com/lxc/lxd/blob/master/lxd/main_forklimits.go#L10314:30
ahasenackin /proc/<pid>/limits, the unit is bytes14:31
ahasenackin the ulimit tool, the unit is kbytes14:31
ahasenackddstreet: but above that line, there is14:31
ahasenackif limit.name == "memlock" {14:31
ahasenackresource = unix.RLIMIT_MEMLOCK14:31
ahasenackah, n/m14:32
ddstreetah the '64' there isn't the default sorry14:32
ddstreetit's the 'bitsize'14:32
ddstreeti'm not very familiar with golang :)14:32
stgraberlimits.kernel.memlock can likely be set to bump that14:33
stgraberhttps://linuxcontainers.org/lxd/docs/latest/instances/#resource-limits-via-limits-kernel-limit-name14:34
ahasenackstgraber: was wondering if there isn't a 1024 error somewhere14:34
stgraberahasenack: LXD doesn't set any limits by default14:35
stgraberahasenack: so you get what the kernel gets you14:35
ahasenackor if you really intended to have 64kbytes for the container, when the host has 64Mb14:35
ahasenackhttps://pastebin.ubuntu.com/p/94dhcWvcBj/14:35
ahasenackanyway, that's a different issue14:37
stgraberahasenack: that 64k is what the LXD snap is given14:38
stgraberahasenack: we don't set it ourselves14:38
ddstreetahasenack stgraber not sure if you noticed but all lxd containers (maybe all containers in general?) seem to be getting the reduced limit, e.g. https://pastebin.ubuntu.com/p/FfChSRxbrR/14:39
stgraberstgraber@dakara:~$ cat /proc/$(cat /var/snap/lxd/common/lxd.pid)/limits | grep -i locked14:39
stgraberMax locked memory         65536                65536                bytes14:39
ddstreetmaybe a snap or apparmor limit?14:39
stgraberddstreet, ahasenack: yes, that's normal. The LXD snap is started with 64k apparently, don't know if it's a snapd, snap-confine or systemd thing and so everything that it spawns itself will have that limit applied too.14:39
ahasenackok14:40
stgraberlooks like it's the default for systemd units14:41
stgraberstgraber@dakara:~$ sudo cat /proc/$(pgrep sshd)/limits | grep -i locked14:42
stgraberMax locked memory         65536                65536                bytes14:42
ahasenackyeah, just checked another daemon, also that value14:42
cjwatsonfwiw builders use chroots rather than lxd containers for .deb builds, so lxd wouldn't be the sole solution here14:42
cjwatson(I haven't been following in detail though)14:43
ahasenackright, I used lxd just because it was easier to use than a chroot14:43
ahasenackI needed something to have jammy on a focal kernel14:43
ahasenackit's good enough to test what I can tweak to get mariadb running14:44
ahasenackcjwatson: the default ulimit -l I get in a focal with 8Gb of RAM  is 64Mb, can you check what you get in a focal builder host? `ulimit -a | grep locked` is best because it prints out the unit, so there is no confusion between 64kb and 64Mb15:00
ahasenack64Mb would be more than enough for mariadb, it just needs 256kb15:00
ahasenackstgraber: > looks like it's the default for systemd units15:11
ahasenackone consequence is that mariadb in a jammy lxd container won't start15:11
ahasenackunsure yet how to address that15:11
ahasenackan unsuspecting user would have quite an investigation to find out what to tweak15:12
ddstreetmaybe lxd should ask snapd to set a higher memlock limit for the lxd process?15:15
ddstreet64k might be ok for general system services that don't typically need to lock memory, but containers probably should have a higher limit15:15
ahasenackwe can also drop uring support in mariadb for the time being, go back to linux aio15:17
ahasenackor rather, the former. I think they mix aio with uring and aio with something-else15:17
ahasenackI'm not too versed in that15:18
cjwatsonahasenack: max locked memory       (kbytes, -l) 6553615:43
ahasenack64Mb then15:55
* ahasenack scratches head15:55
ahasenackcjwatson: https://launchpadlibrarian.net/596606723/buildlog_ubuntu-jammy-amd64.mariadb-10.6_1%3A10.6.7-3_BUILDING.txt.gz shows 65536 bytes15:56
ahasenacksearch for "locked memory", there is a `ulimit -a` output at the end of the build15:56
ddstreetahasenack i think this commit probably should be sru'ed for systemd https://github.com/systemd/systemd/commit/852b62507b216:02
ubottuCommit 852b625 in systemd/systemd "pid1,nspawn: raise default RLIMIT_MEMLOCK to 8M"16:02
cjwatsonahasenack: I don't know, sorry.  Maybe schroot is doing something odd?16:02
ahasenackcjwatson: did you run it as your user, root, or something else?16:03
cjwatsonubuntu@16:04
ddstreetahasenack the LWN article linked from the commit is especially interesting and relevant to what you're looking at ;-)16:04
cjwatsonI didn't set up a chroot though16:04
cjwatsonubuntu@dogfood-lcy02-amd64-004:~$ sudo cat /proc/$(pgrep -f launchpad-buildd)/limits | grep -i locked16:04
cjwatsonMax locked memory         65536                65536                bytes16:04
cjwatsonMaybe more relevant ...16:05
cjwatsonThat's launched directly from a systemd service16:05
cjwatsonSo maybe a systemd default?16:05
ddstreetcjwatson see the commit i referenced above16:05
ahasenackah, ok, that's the missing piece then16:06
ahasenacklaunched by systemd, 64k is the default for systemd services16:06
ddstreetno16:06
ddstreetit's the kernel default16:06
cjwatsonah yes, looks plausible16:06
ddstreetsigh16:06
ahasenackmy local user has a much higher limit16:07
ahasenackso something raised it, if it's the kernel default16:07
cjwatsonSRUing that to focal would filter through to Launchpad with no intervention needed from us16:08
cjwatson(via cloud images)16:08
ahasenackah, I'm on impish, forgot that16:12
ahasenackbut focal, brand new 1Gb VM, got 65536 kbytes16:12
ahasenack$ ulimit -a|grep locked16:12
ahasenackmax locked memory       (kbytes, -l) 6553616:12
ahasenack$ cat /proc/$$/limits|grep locked16:12
ahasenackMax locked memory         67108864             67108864             bytes16:12
* ahasenack reached the part in the article where it says "The big new consumer of locked memory, though, is io_uring"16:19
ahasenackcjwatson: is it unreasonable to add LimitMEMLOCK=524288 to the launchpad-buildd systemd service? Or even half that? DOes it come from a deb?18:23
ahasenacka systemd sru is scary18:24
=== bdmurray changed the topic of #ubuntu-devel to: Archive: Kinetic open! | Devel of Ubuntu (not support) | Build failures: http://qa.ubuntuwire.com/ftbfs/ | #ubuntu for support and discussion of Bionic-Jammy | If you can't send messages here, authenticate to NickServ first | Patch Pilots:
ahasenackbdmurray: what about these packages? https://launchpad.net/ubuntu/kinetic/+queue?queue_state=1&queue_text=20:24
ahasenacknmap, in my case20:25
vorlonahasenack: part of the opening process will be batch-accepting these from unapproved20:44
ahasenackk20:44

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!