forge
Clone
https://git.tahinli.com/Tahinli/forge.git
0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits
| 1 | //! Out-of-memory kills inside a job's cgroup. The sandbox helper reads the cgroup's `memory.events` |
| 2 | //! when the job's init exits, before it deletes the cgroup, and prints one line on stderr. The |
| 3 | //! runner reads that line back and reports it when it finishes the job. |
| 4 | //! |
| 5 | //! Why the cgroup and not the exit code: when rustc is killed, cargo prints `(signal: 9, SIGKILL: |
| 6 | //! kill)` in the log and itself exits 101, so neither the job's exit code nor its message shows it. |
| 7 | //! |
| 8 | //! Kernel semantics (`Documentation/admin-guide/cgroup-v2.rst`): in `memory.events`, `oom` counts |
| 9 | //! how often the cgroup reached its limit and the OOM killer was invoked for it, and `oom_kill` |
| 10 | //! counts the processes of this cgroup that were killed by any kind of OOM killer. The victim's |
| 11 | //! cgroup is charged in `oom_kill_process`, so a victim of a host-wide OOM (global OOM killer, |
| 12 | //! nothing hit its own `memory.max`) is still counted in `oom_kill` of the cgroup it lived in, on |
| 13 | //! kernels since 4.13 that have the counter. `oom` stays 0 in that case, which is why both are |
| 14 | //! read and `oom_kill` is the one to trust. Both are hierarchical in `memory.events`, so a |
| 15 | //! process in a child cgroup counts too. A victim that was not in the job's cgroup at all (the |
| 16 | //! runner itself) is not counted, and nothing here can see it. |
| 17 | |
| 18 | use Arc; |
| 19 | use ; |
| 20 | |
| 21 | /// The line the helper prints. It starts with the sandbox prefix, see `SANDBOX_PREFIX`. |
| 22 | pub const LINE_PREFIX: &str = "forge-sandbox: oom-events "; |
| 23 | |
| 24 | /// The `oom` and `oom_kill` counters of a job cgroup. |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | /// Where an executor leaves the OOM kills it saw for a job. Cheap to clone and share. |
| 83 | |
| 84 | ; |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 |