libuv icon indicating copy to clipboard operation
libuv copied to clipboard

linux: support hierarchies and cgroup2 for mem constraint lookup (rebase)

Open maleadt opened this issue 3 years ago • 4 comments

Rebase of https://github.com/libuv/libuv/pull/2323, which I'm hoping to help push over the line.

As far as I could see, here were only a couple of remaining review comments by @bnoordhuis:

You parse /proc/self/mountinfo to determine if the system uses cgroups v1 or v2? Is that necessary? Doesn't the format of the memory field in /proc/self/cgroups tell you that?

Would open("/sys/fs/cgroup/unified", O_DIRECTORY|O_CLOEXEC) work? It's a v2 system when it's there, it seems reasonable to assume v1 when it's not. (Related subject: I prefer openat() over path munging.)

I don't know whether the cgroupv2 controller is guaranteed to be mounted at /sys/fs/cgroup/unified. The cgroups man pages only state that modern systemd auto-mounts the cgroup2 filesystem there, nothing more general. So for now, I've left the mountinfo parsing in, but happy to change that.

I think it should fall back to /sys/fs/cgroup/memory/memory.limit_in_bytes if procfs isn't mounted. Right now it seems to default to 0, no limit.

Done.

cc @vtjnash @kjin

maleadt avatar Aug 02 '22 12:08 maleadt

On an Alpine Linux (OpenRC, not systemd) system, the cgroup2 mount also appears at /sys/fs/cgroup/unified, if that's helpful at all.

jpsamaroo avatar Aug 02 '22 14:08 jpsamaroo

I'll review this when I get back from vacation, around the 25th. Thanks for the PR, @maleadt.

bnoordhuis avatar Aug 13 '22 11:08 bnoordhuis

@bnoordhuis Friendly bump; have you had the time to review this yet? Thanks!

maleadt avatar Sep 01 '22 06:09 maleadt

I had this on my list of PRs to review this week but looks like I'm not going to get around to it due to time constraints.

bnoordhuis avatar Sep 02 '22 10:09 bnoordhuis

Superseded by https://github.com/libuv/libuv/pull/3744

maleadt avatar Oct 12 '22 09:10 maleadt