You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ad0e137
Browse filesBrowse the repository at this point in the historyBrowse files
<p>Before creating the cgroup namespace, Droidspaces moves the monitor process into the container's own cgroup. When <code>unshare(CLONE_NEWCGROUP)</code> is then called, the root of the new namespace maps to the container's subtree.</p>
445
+
<p>A cgroup namespace is rooted wherever the process sits when it is created. So for every boot, the short-lived process that forks the container's init first joins the container's own cgroup and only then calls <code>unshare(CLONE_NEWCGROUP)</code>, and the root of the new namespace maps to the container's subtree.</p>
446
+
<p>The supervising monitor never enters that cgroup. The cgroup is created fresh for each boot, including a restart and a reboot from inside the container, and removed when the container stops, so limits always match the current configuration.</p>
446
447
<h3id="cgroup-v1-and-v2-support">Cgroup v1 and v2 support <aclass="header-anchor" href="#cgroup-v1-and-v2-support">#</a></h3>
<p>If an option is missing, the limit is skipped at start with a warning that names it. See <ahref="kernel-configuration.html">Kernel Configuration</a> to add them.</p>
487
+
<p><code>--pids-limit</code> has a floor of 16. The limit counts every task in the container's cgroup, including the two the runtime keeps there and the three each <code>enter</code> or <code>run</code> session starts with. A systemd distribution needs far more, typically a few hundred.</p>
486
488
<p><code>--memory</code> limits RAM only. A container that goes over it is pushed into swap (zram on Android) before anything is killed.</p>
487
489
<h4id="where-a-limit-is-applied">Where a limit is applied <aclass="header-anchor" href="#where-a-limit-is-applied">#</a></h4>
488
490
<p>For each limit Droidspaces looks for the controller in the container's cgroup v2 directory first. If it is not there, it finds the v1 hierarchy that owns the controller, wherever the host mounted it, and puts the container in <code>droidspaces/<name></code> inside it. On a typical Android phone that means memory at <code>/dev/memcg/droidspaces/<name></code>, while the container's own view, the one systemd manages, stays cgroup v2. <code>enter</code> and <code>run</code> sessions join the same cgroups, so they are held to the same limits.</p>
<p>The same block, without the usage figures, is printed after <code>start</code> and <code>restart</code>.</p>
497
499
<p><code>info --format</code> adds <code>memory_limit</code> (bytes), <code>cpu_quota</code>, <code>cpu_period</code> (microseconds) and <code>pids_limit</code>. <code>show --format</code> and <code>info --format</code> add <code>ram_limit_kb</code> and <code>cpu_limit_permill</code> per container, on the same scale as <code>ram_used_kb</code> and <code>cpu_permill</code>. All are 0 when unlimited.</p>
498
500
<p>Memory use means one thing everywhere for a container with a memory cgroup: what the cgroup is charged, minus its file cache, which the kernel reclaims on its own. <code>info</code>, <code>show --format</code> and <code>free</code> or fastfetch inside the container all report that figure. The limit itself still counts the cache, so a container can be pushed to reclaim before "used" reaches the limit.</p>
501
+
<p>One gap: a program that asks the kernel through the <code>sysinfo()</code> system call, and not through <code>/proc</code>, still sees the host's memory, load and uptime. OpenWRT's LuCI is the common case. The limit is enforced regardless, see <ahref="troubleshooting.html#sysinfo-host-values">Troubleshooting</a>.</p>
499
502
<h4id="in-the-android-app">In the Android app <aclass="header-anchor" href="#in-the-android-app">#</a></h4>
500
503
<p>The container settings have a <strong>Resource Limits</strong> section with a switch per limit. Memory and CPU open a slider bounded by the device's real RAM and core count, the process limit a number field. A limit the kernel cannot enforce is greyed out with the missing option named. The limits also show on the container's card and in the installation summary, and the Panel tab shows usage against the limit, for example <code>94/512 MB (18%)</code>.</p>
<li><ahref="#nuke-wifi-powersave">Wi-Fi <code>Power save: on</code> makes networking sluggish on Android</a></li>
96
+
<li><ahref="#sysinfo-host-values">LuCI, or another tool, shows the host's RAM and load despite a limit</a></li>
96
97
<li><ahref="#getting-help">Getting help</a></li>
97
98
</ul>
98
99
<hr/>
@@ -341,6 +342,14 @@ <h3 id="3-wire-up-the-init-service">3. Wire up the init service <a class="header
341
342
</code></pre></div>
342
343
<divclass="callout callout-note"><strongclass="callout-title">Note</strong><p>This workaround <strong>requires host networking mode</strong> (<code>--net=host</code>). The script needs direct access to Android's <code>wlan0</code> interface, which is not visible in <code>NAT</code> or <code>None</code> modes. We recommend a small "burner" container used only for this watchdog.</p></div>
343
344
<hr/>
345
+
<p><aid="sysinfo-host-values"></a></p>
346
+
<h2id="luci-or-another-tool-shows-the-hosts-ram-and-load-despite-a-limit">LuCI, or another tool, shows the host's RAM and load despite a limit <aclass="header-anchor" href="#luci-or-another-tool-shows-the-hosts-ram-and-load-despite-a-limit">#</a></h2>
347
+
<p><strong>Symptom:</strong> a container has a memory or CPU limit, and <code>free</code>, <code>nproc</code> and fastfetch inside it show the limited values, but OpenWRT's LuCI overview still shows the device's full RAM and its real load average.</p>
348
+
<p><strong>Cause:</strong> there are two ways for a program to ask how much memory the machine has. Most read <code>/proc/meminfo</code>, which Droidspaces replaces with the container's own figures. Some call the kernel's <code>sysinfo()</code> system call instead, and a system call cannot be replaced by a file. OpenWRT's <code>procd</code> is one of them: <code>ubus call system info</code> takes total, free, shared and buffered memory, swap, load and uptime from <code>sysinfo()</code>, and LuCI displays what <code>procd</code> reports. Some Java runtimes and a few Alpine tools do the same.</p>
349
+
<p><strong>What still holds:</strong> the limit is enforced either way. The container cannot use more than it was given. Only the number these tools display is wrong.</p>
350
+
<p><strong>Checking a limit yourself:</strong> run <code>droidspaces -n <name> info</code> on the host, or <code>cat /proc/meminfo</code> inside the container.</p>
351
+
<p>There is no fix for this at the moment. Intercepting <code>sysinfo()</code> needs seccomp user notifications, which only exist on kernel 5.0 and later.</p>
352
+
<hr/>
344
353
<h2id="getting-help">Getting help <aclass="header-anchor" href="#getting-help">#</a></h2>
345
354
<p>If your problem is not listed here:</p>
346
355
<ol>
@@ -356,7 +365,7 @@ <h2 id="getting-help">Getting help <a class="header-anchor" href="#getting-help"
356
365
<navclass="doc-nav" aria-label="Pages"><ahref="cool-things-you-can-do.html" class="doc-nav-prev"><small>Previous</small>Cool things you can do</a><ahref="community-supported-devices.html" class="doc-nav-next"><small>Next</small>Community-supported devices</a></nav>
357
366
</main>
358
367
<asideclass="toc-column">
359
-
<navclass="toc" aria-label="On this page"><pclass="toc-title">On this page</p><ul><liclass="toc-h3"><ahref="#quick-navigation">Quick navigation</a></li><liclass="toc-h2"><ahref="#modern-distros-arch-fedora-etc-failure-on-legacy-kernels">Modern distros (Arch, Fedora, etc.) failure on legacy kernels</a></li><liclass="toc-h2"><ahref="#required-key-not-available">"Required key not available"</a></li><liclass="toc-h2"><ahref="#mount-errors-on-kernel-414">Mount errors on kernel 4.14</a></li><liclass="toc-h2"><ahref="#overlayfs-not-supported-f2fs">OverlayFS not supported (f2fs)</a></li><liclass="toc-h2"><ahref="#container-name-conflicts">Container name conflicts</a></li><liclass="toc-h2"><ahref="#systemd-hangs-on-older-kernels">systemd hangs on older kernels</a></li><liclass="toc-h2"><ahref="#container-wont-stop">Container won't stop</a></li><liclass="toc-h2"><ahref="#rootfs-image-io-errors-on-android">Rootfs image I/O errors on Android</a></li><liclass="toc-h2"><ahref="#networking-is-completely-dead---ping-fails-with-socket-permission-denied">Networking is completely dead - ping fails with "socket: permission denied"</a></li><liclass="toc-h2"><ahref="#dns--name-resolution-issues">DNS / name resolution issues</a></li><liclass="toc-h2"><ahref="#wifimobile-data-disconnects">WiFi/mobile data disconnects</a></li><liclass="toc-h2"><ahref="#selinux-induced-rootfs-corruption-directory-mode">SELinux-induced rootfs corruption (directory mode)</a></li><liclass="toc-h2"><ahref="#reclaiming-storage-sparse-image">Reclaiming storage (sparse image)</a></li><liclass="toc-h2"><ahref="#wi-fi-power-save-on-causing-sluggish-networking-on-android">Wi-Fi Power save: on causing sluggish networking on Android</a></li><liclass="toc-h3"><ahref="#1-install-required-utilities">1. Install required utilities</a></li><liclass="toc-h3"><ahref="#2-create-the-watchdog-script">2. Create the watchdog script</a></li><liclass="toc-h3"><ahref="#3-wire-up-the-init-service">3. Wire up the init service</a></li><liclass="toc-h2"><ahref="#getting-help">Getting help</a></li></ul></nav>
368
+
<navclass="toc" aria-label="On this page"><pclass="toc-title">On this page</p><ul><liclass="toc-h3"><ahref="#quick-navigation">Quick navigation</a></li><liclass="toc-h2"><ahref="#modern-distros-arch-fedora-etc-failure-on-legacy-kernels">Modern distros (Arch, Fedora, etc.) failure on legacy kernels</a></li><liclass="toc-h2"><ahref="#required-key-not-available">"Required key not available"</a></li><liclass="toc-h2"><ahref="#mount-errors-on-kernel-414">Mount errors on kernel 4.14</a></li><liclass="toc-h2"><ahref="#overlayfs-not-supported-f2fs">OverlayFS not supported (f2fs)</a></li><liclass="toc-h2"><ahref="#container-name-conflicts">Container name conflicts</a></li><liclass="toc-h2"><ahref="#systemd-hangs-on-older-kernels">systemd hangs on older kernels</a></li><liclass="toc-h2"><ahref="#container-wont-stop">Container won't stop</a></li><liclass="toc-h2"><ahref="#rootfs-image-io-errors-on-android">Rootfs image I/O errors on Android</a></li><liclass="toc-h2"><ahref="#networking-is-completely-dead---ping-fails-with-socket-permission-denied">Networking is completely dead - ping fails with "socket: permission denied"</a></li><liclass="toc-h2"><ahref="#dns--name-resolution-issues">DNS / name resolution issues</a></li><liclass="toc-h2"><ahref="#wifimobile-data-disconnects">WiFi/mobile data disconnects</a></li><liclass="toc-h2"><ahref="#selinux-induced-rootfs-corruption-directory-mode">SELinux-induced rootfs corruption (directory mode)</a></li><liclass="toc-h2"><ahref="#reclaiming-storage-sparse-image">Reclaiming storage (sparse image)</a></li><liclass="toc-h2"><ahref="#wi-fi-power-save-on-causing-sluggish-networking-on-android">Wi-Fi Power save: on causing sluggish networking on Android</a></li><liclass="toc-h3"><ahref="#1-install-required-utilities">1. Install required utilities</a></li><liclass="toc-h3"><ahref="#2-create-the-watchdog-script">2. Create the watchdog script</a></li><liclass="toc-h3"><ahref="#3-wire-up-the-init-service">3. Wire up the init service</a></li><liclass="toc-h2"><ahref="#luci-or-another-tool-shows-the-hosts-ram-and-load-despite-a-limit">LuCI, or another tool, shows the host's RAM and load despite a limit</a></li><liclass="toc-h2"><ahref="#getting-help">Getting help</a></li></ul></nav>
<p>In NAT mode, the <strong>Port Forwarding</strong> section maps host ports to container ports (for example <code>22:22</code>). It also takes <strong>port ranges</strong> (for example <code>1000-2000:1000-2000</code>) for services that need several contiguous ports.</p>
0 commit comments