| 166 | } |
| 167 | |
| 168 | uint64_t meminfo_bytes(const std::string& meminfo_text, const std::string& key) { |
| 169 | std::istringstream in(meminfo_text); |
| 170 | std::string line; |
| 171 | const std::string want = key + ":"; |
| 172 | while (std::getline(in, line)) { |
| 173 | std::istringstream fields(line); |
| 174 | std::string k, unit; |
| 175 | uint64_t value = 0; |
| 176 | if (fields >> k >> value && k == want) { |
| 177 | fields >> unit; |
| 178 | return unit == "kB" ? value * 1024 : value; |
| 179 | } |
| 180 | } |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | uint64_t numa_pin_free(uint64_t global_free, const std::vector<uint64_t>& node_free) { |
| 185 | if (node_free.size() < 2) return global_free; |
no outgoing calls