Skip to content

Conversation

@bnoordhuis
Copy link
Member

It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.

Fixes: #2249

The second commit DRYs the code in exchange for what might be considered a little more magic. Majority rule; I don't feel strongly about what approach is better.

CI: https://ci.nodejs.org/job/libuv-test-commit/1364/

@bnoordhuis
Copy link
Member Author

@bnoordhuis
Copy link
Member Author

Okay, the clever approach gets defeated by the absence of __kernel_ulong_t on some systems. Back to the more verbose way: https://ci.nodejs.org/job/libuv-test-commit/1372/

It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.

Fixes: libuv#2249
PR-URL: libuv#2258
Reviewed-By: Colin Ihrig <[email protected]>
@bnoordhuis bnoordhuis closed this Apr 23, 2019
@bnoordhuis bnoordhuis deleted the fix2249 branch April 23, 2019 09:51
@bnoordhuis bnoordhuis merged commit 3a1be72 into libuv:v1.x Apr 23, 2019
@bnoordhuis bnoordhuis mentioned this pull request May 17, 2019
liujinye-sys pushed a commit to open-vela/apps_system_libuv that referenced this pull request Jul 23, 2025
It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.

Fixes: libuv/libuv#2249
PR-URL: libuv/libuv#2258
Reviewed-By: Colin Ihrig <[email protected]>
liujinye-sys pushed a commit to open-vela/apps_system_libuv that referenced this pull request Dec 16, 2025
It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.

Fixes: libuv/libuv#2249
PR-URL: libuv/libuv#2258
Reviewed-By: Colin Ihrig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linux: read /proc/meminfo in uv_get_total_memory()

3 participants