src/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java

Fri, 24 Jul 2020 14:31:02 +0200

author
sgehwolf
date
Fri, 24 Jul 2020 14:31:02 +0200
changeset 14169
edb84bd2f10f
parent 14148
8310f9fb8d93
child 14174
26c1140d2613
permissions
-rw-r--r--

8250627: Use -XX:+/-UseContainerSupport for enabling/disabling Java container metrics
Reviewed-by: aph, dholmes, bobv, shade

sgehwolf@14148 1 /*
sgehwolf@14148 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
sgehwolf@14148 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sgehwolf@14148 4 *
sgehwolf@14148 5 * This code is free software; you can redistribute it and/or modify it
sgehwolf@14148 6 * under the terms of the GNU General Public License version 2 only, as
sgehwolf@14148 7 * published by the Free Software Foundation. Oracle designates this
sgehwolf@14148 8 * particular file as subject to the "Classpath" exception as provided
sgehwolf@14148 9 * by Oracle in the LICENSE file that accompanied this code.
sgehwolf@14148 10 *
sgehwolf@14148 11 * This code is distributed in the hope that it will be useful, but WITHOUT
sgehwolf@14148 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sgehwolf@14148 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sgehwolf@14148 14 * version 2 for more details (a copy is included in the LICENSE file that
sgehwolf@14148 15 * accompanied this code).
sgehwolf@14148 16 *
sgehwolf@14148 17 * You should have received a copy of the GNU General Public License version
sgehwolf@14148 18 * 2 along with this work; if not, write to the Free Software Foundation,
sgehwolf@14148 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sgehwolf@14148 20 *
sgehwolf@14148 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sgehwolf@14148 22 *
sgehwolf@14148 23 * or visit www.oracle.com if you need additional information or have any
sgehwolf@14148 24 * questions.
sgehwolf@14148 25 */
sgehwolf@14148 26
sgehwolf@14148 27 package jdk.internal.platform.cgroupv1;
sgehwolf@14148 28
sgehwolf@14148 29 import java.io.BufferedReader;
sgehwolf@14148 30 import java.io.IOException;
sgehwolf@14148 31 import java.nio.file.Files;
sgehwolf@14148 32 import java.nio.file.Path;
sgehwolf@14148 33 import java.nio.file.Paths;
sgehwolf@14148 34 import java.util.stream.Stream;
sgehwolf@14148 35
sgehwolf@14148 36 public class Metrics implements jdk.internal.platform.Metrics {
sgehwolf@14148 37 private SubSystem memory;
sgehwolf@14148 38 private SubSystem cpu;
sgehwolf@14148 39 private SubSystem cpuacct;
sgehwolf@14148 40 private SubSystem cpuset;
sgehwolf@14148 41 private SubSystem blkio;
sgehwolf@14148 42 private boolean activeSubSystems;
sgehwolf@14148 43
sgehwolf@14148 44 // Values returned larger than this number are unlimited.
sgehwolf@14148 45 static long unlimited_minimum = 0x7FFFFFFFFF000000L;
sgehwolf@14148 46
sgehwolf@14148 47 private static final Metrics INSTANCE = initContainerSubSystems();
sgehwolf@14148 48
sgehwolf@14148 49 private static final String PROVIDER_NAME = "cgroupv1";
sgehwolf@14148 50
sgehwolf@14148 51 private Metrics() {
sgehwolf@14148 52 activeSubSystems = false;
sgehwolf@14148 53 }
sgehwolf@14148 54
sgehwolf@14148 55 public static Metrics getInstance() {
sgehwolf@14148 56 return INSTANCE;
sgehwolf@14148 57 }
sgehwolf@14148 58
sgehwolf@14148 59 private static Metrics initContainerSubSystems() {
sgehwolf@14169 60 if (!isUseContainerSupport()) {
sgehwolf@14169 61 return null;
sgehwolf@14169 62 }
sgehwolf@14148 63 Metrics metrics = new Metrics();
sgehwolf@14148 64
sgehwolf@14148 65 /**
sgehwolf@14148 66 * Find the cgroup mount points for subsystems
sgehwolf@14148 67 * by reading /proc/self/mountinfo
sgehwolf@14148 68 *
sgehwolf@14148 69 * Example for docker MemorySubSystem subsystem:
sgehwolf@14148 70 * 219 214 0:29 /docker/7208cebd00fa5f2e342b1094f7bed87fa25661471a4637118e65f1c995be8a34 /sys/fs/cgroup/MemorySubSystem ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,MemorySubSystem
sgehwolf@14148 71 *
sgehwolf@14148 72 * Example for host:
sgehwolf@14148 73 * 34 28 0:29 / /sys/fs/cgroup/MemorySubSystem rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,MemorySubSystem
sgehwolf@14148 74 */
sgehwolf@14148 75 try (Stream<String> lines =
sgehwolf@14148 76 Files.lines(Paths.get("/proc/self/mountinfo"))) {
sgehwolf@14148 77
sgehwolf@14148 78 lines.filter(line -> line.contains(" - cgroup "))
sgehwolf@14148 79 .map(line -> line.split(" "))
sgehwolf@14148 80 .forEach(entry -> createSubSystem(metrics, entry));
sgehwolf@14148 81
sgehwolf@14148 82 } catch (IOException e) {
sgehwolf@14148 83 return null;
sgehwolf@14148 84 }
sgehwolf@14148 85
sgehwolf@14148 86 /**
sgehwolf@14148 87 * Read /proc/self/cgroup and map host mount point to
sgehwolf@14148 88 * local one via /proc/self/mountinfo content above
sgehwolf@14148 89 *
sgehwolf@14148 90 * Docker example:
sgehwolf@14148 91 * 5:memory:/docker/6558aed8fc662b194323ceab5b964f69cf36b3e8af877a14b80256e93aecb044
sgehwolf@14148 92 *
sgehwolf@14148 93 * Host example:
sgehwolf@14148 94 * 5:memory:/user.slice
sgehwolf@14148 95 *
sgehwolf@14148 96 * Construct a path to the process specific memory and cpuset
sgehwolf@14148 97 * cgroup directory.
sgehwolf@14148 98 *
sgehwolf@14148 99 * For a container running under Docker from memory example above
sgehwolf@14148 100 * the paths would be:
sgehwolf@14148 101 *
sgehwolf@14148 102 * /sys/fs/cgroup/memory
sgehwolf@14148 103 *
sgehwolf@14148 104 * For a Host from memory example above the path would be:
sgehwolf@14148 105 *
sgehwolf@14148 106 * /sys/fs/cgroup/memory/user.slice
sgehwolf@14148 107 *
sgehwolf@14148 108 */
sgehwolf@14148 109 try (Stream<String> lines =
sgehwolf@14148 110 Files.lines(Paths.get("/proc/self/cgroup"))) {
sgehwolf@14148 111
sgehwolf@14148 112 lines.map(line -> line.split(":"))
sgehwolf@14148 113 .filter(line -> (line.length >= 3))
sgehwolf@14148 114 .forEach(line -> setSubSystemPath(metrics, line));
sgehwolf@14148 115
sgehwolf@14148 116 } catch (IOException e) {
sgehwolf@14148 117 return null;
sgehwolf@14148 118 }
sgehwolf@14148 119
sgehwolf@14148 120 // Return Metrics object if we found any subsystems.
sgehwolf@14148 121 if (metrics.activeSubSystems()) {
sgehwolf@14148 122 return metrics;
sgehwolf@14148 123 }
sgehwolf@14148 124
sgehwolf@14148 125 return null;
sgehwolf@14148 126 }
sgehwolf@14148 127
sgehwolf@14148 128 /**
sgehwolf@14148 129 * createSubSystem objects and initialize mount points
sgehwolf@14148 130 */
sgehwolf@14148 131 private static void createSubSystem(Metrics metric, String [] mountentry) {
sgehwolf@14148 132 if (mountentry.length < 5) return;
sgehwolf@14148 133
sgehwolf@14148 134 Path p = Paths.get(mountentry[4]);
sgehwolf@14148 135 String subsystemName = p.getFileName().toString();
sgehwolf@14148 136
sgehwolf@14148 137 if (subsystemName != null) {
sgehwolf@14148 138 switch (subsystemName) {
sgehwolf@14148 139 case "memory":
sgehwolf@14148 140 metric.setMemorySubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 141 break;
sgehwolf@14148 142 case "cpuset":
sgehwolf@14148 143 metric.setCpuSetSubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 144 break;
sgehwolf@14148 145 case "cpu,cpuacct":
sgehwolf@14148 146 case "cpuacct,cpu":
sgehwolf@14148 147 metric.setCpuSubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 148 metric.setCpuAcctSubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 149 break;
sgehwolf@14148 150 case "cpuacct":
sgehwolf@14148 151 metric.setCpuAcctSubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 152 break;
sgehwolf@14148 153 case "cpu":
sgehwolf@14148 154 metric.setCpuSubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 155 break;
sgehwolf@14148 156 case "blkio":
sgehwolf@14148 157 metric.setBlkIOSubSystem(new SubSystem(mountentry[3], mountentry[4]));
sgehwolf@14148 158 break;
sgehwolf@14148 159 default:
sgehwolf@14148 160 // Ignore subsystems that we don't support
sgehwolf@14148 161 break;
sgehwolf@14148 162 }
sgehwolf@14148 163 }
sgehwolf@14148 164 }
sgehwolf@14148 165
sgehwolf@14148 166 /**
sgehwolf@14148 167 * setSubSystemPath based on the contents of /proc/self/cgroup
sgehwolf@14148 168 */
sgehwolf@14148 169 private static void setSubSystemPath(Metrics metric, String [] entry) {
sgehwolf@14148 170 String controller;
sgehwolf@14148 171 String base;
sgehwolf@14148 172 SubSystem subsystem = null;
sgehwolf@14148 173 SubSystem subsystem2 = null;
sgehwolf@14148 174
sgehwolf@14148 175 controller = entry[1];
sgehwolf@14148 176 base = entry[2];
sgehwolf@14148 177 if (controller != null && base != null) {
sgehwolf@14148 178 switch (controller) {
sgehwolf@14148 179 case "memory":
sgehwolf@14148 180 subsystem = metric.MemorySubSystem();
sgehwolf@14148 181 break;
sgehwolf@14148 182 case "cpuset":
sgehwolf@14148 183 subsystem = metric.CpuSetSubSystem();
sgehwolf@14148 184 break;
sgehwolf@14148 185 case "cpu,cpuacct":
sgehwolf@14148 186 case "cpuacct,cpu":
sgehwolf@14148 187 subsystem = metric.CpuSubSystem();
sgehwolf@14148 188 subsystem2 = metric.CpuAcctSubSystem();
sgehwolf@14148 189 break;
sgehwolf@14148 190 case "cpuacct":
sgehwolf@14148 191 subsystem = metric.CpuAcctSubSystem();
sgehwolf@14148 192 break;
sgehwolf@14148 193 case "cpu":
sgehwolf@14148 194 subsystem = metric.CpuSubSystem();
sgehwolf@14148 195 break;
sgehwolf@14148 196 case "blkio":
sgehwolf@14148 197 subsystem = metric.BlkIOSubSystem();
sgehwolf@14148 198 break;
sgehwolf@14148 199 // Ignore subsystems that we don't support
sgehwolf@14148 200 default:
sgehwolf@14148 201 break;
sgehwolf@14148 202 }
sgehwolf@14148 203 }
sgehwolf@14148 204
sgehwolf@14148 205 if (subsystem != null) {
sgehwolf@14148 206 subsystem.setPath(base);
sgehwolf@14148 207 metric.setActiveSubSystems();
sgehwolf@14148 208 }
sgehwolf@14148 209 if (subsystem2 != null) {
sgehwolf@14148 210 subsystem2.setPath(base);
sgehwolf@14148 211 }
sgehwolf@14148 212 }
sgehwolf@14148 213
sgehwolf@14148 214
sgehwolf@14148 215 private void setActiveSubSystems() {
sgehwolf@14148 216 activeSubSystems = true;
sgehwolf@14148 217 }
sgehwolf@14148 218
sgehwolf@14148 219 private boolean activeSubSystems() {
sgehwolf@14148 220 return activeSubSystems;
sgehwolf@14148 221 }
sgehwolf@14148 222
sgehwolf@14148 223 private void setMemorySubSystem(SubSystem memory) {
sgehwolf@14148 224 this.memory = memory;
sgehwolf@14148 225 }
sgehwolf@14148 226
sgehwolf@14148 227 private void setCpuSubSystem(SubSystem cpu) {
sgehwolf@14148 228 this.cpu = cpu;
sgehwolf@14148 229 }
sgehwolf@14148 230
sgehwolf@14148 231 private void setCpuAcctSubSystem(SubSystem cpuacct) {
sgehwolf@14148 232 this.cpuacct = cpuacct;
sgehwolf@14148 233 }
sgehwolf@14148 234
sgehwolf@14148 235 private void setCpuSetSubSystem(SubSystem cpuset) {
sgehwolf@14148 236 this.cpuset = cpuset;
sgehwolf@14148 237 }
sgehwolf@14148 238
sgehwolf@14148 239 private void setBlkIOSubSystem(SubSystem blkio) {
sgehwolf@14148 240 this.blkio = blkio;
sgehwolf@14148 241 }
sgehwolf@14148 242
sgehwolf@14148 243 private SubSystem MemorySubSystem() {
sgehwolf@14148 244 return memory;
sgehwolf@14148 245 }
sgehwolf@14148 246
sgehwolf@14148 247 private SubSystem CpuSubSystem() {
sgehwolf@14148 248 return cpu;
sgehwolf@14148 249 }
sgehwolf@14148 250
sgehwolf@14148 251 private SubSystem CpuAcctSubSystem() {
sgehwolf@14148 252 return cpuacct;
sgehwolf@14148 253 }
sgehwolf@14148 254
sgehwolf@14148 255 private SubSystem CpuSetSubSystem() {
sgehwolf@14148 256 return cpuset;
sgehwolf@14148 257 }
sgehwolf@14148 258
sgehwolf@14148 259 private SubSystem BlkIOSubSystem() {
sgehwolf@14148 260 return blkio;
sgehwolf@14148 261 }
sgehwolf@14148 262
sgehwolf@14148 263 public String getProvider() {
sgehwolf@14148 264 return PROVIDER_NAME;
sgehwolf@14148 265 }
sgehwolf@14148 266
sgehwolf@14148 267 /*****************************************************************
sgehwolf@14148 268 * CPU Accounting Subsystem
sgehwolf@14148 269 ****************************************************************/
sgehwolf@14148 270
sgehwolf@14148 271
sgehwolf@14148 272 public long getCpuUsage() {
sgehwolf@14148 273 return SubSystem.getLongValue(cpuacct, "cpuacct.usage");
sgehwolf@14148 274 }
sgehwolf@14148 275
sgehwolf@14148 276 public long[] getPerCpuUsage() {
sgehwolf@14148 277 String usagelist = SubSystem.getStringValue(cpuacct, "cpuacct.usage_percpu");
sgehwolf@14148 278 if (usagelist == null) {
sgehwolf@14148 279 return new long[0];
sgehwolf@14148 280 }
sgehwolf@14148 281
sgehwolf@14148 282 String list[] = usagelist.split(" ");
sgehwolf@14148 283 long percpu[] = new long[list.length];
sgehwolf@14148 284 for (int i = 0; i < list.length; i++) {
sgehwolf@14148 285 percpu[i] = Long.parseLong(list[i]);
sgehwolf@14148 286 }
sgehwolf@14148 287 return percpu;
sgehwolf@14148 288 }
sgehwolf@14148 289
sgehwolf@14148 290 public long getCpuUserUsage() {
sgehwolf@14148 291 return SubSystem.getLongEntry(cpuacct, "cpuacct.stat", "user");
sgehwolf@14148 292 }
sgehwolf@14148 293
sgehwolf@14148 294 public long getCpuSystemUsage() {
sgehwolf@14148 295 return SubSystem.getLongEntry(cpuacct, "cpuacct.stat", "system");
sgehwolf@14148 296 }
sgehwolf@14148 297
sgehwolf@14148 298
sgehwolf@14148 299 /*****************************************************************
sgehwolf@14148 300 * CPU Subsystem
sgehwolf@14148 301 ****************************************************************/
sgehwolf@14148 302
sgehwolf@14148 303
sgehwolf@14148 304 public long getCpuPeriod() {
sgehwolf@14148 305 return SubSystem.getLongValue(cpuacct, "cpu.cfs_period_us");
sgehwolf@14148 306 }
sgehwolf@14148 307
sgehwolf@14148 308 public long getCpuQuota() {
sgehwolf@14148 309 return SubSystem.getLongValue(cpuacct, "cpu.cfs_quota_us");
sgehwolf@14148 310 }
sgehwolf@14148 311
sgehwolf@14148 312 public long getCpuShares() {
sgehwolf@14148 313 long retval = SubSystem.getLongValue(cpuacct, "cpu.shares");
sgehwolf@14148 314 if (retval == 0 || retval == 1024)
sgehwolf@14148 315 return -1;
sgehwolf@14148 316 else
sgehwolf@14148 317 return retval;
sgehwolf@14148 318 }
sgehwolf@14148 319
sgehwolf@14148 320 public long getCpuNumPeriods() {
sgehwolf@14148 321 return SubSystem.getLongEntry(cpuacct, "cpu.stat", "nr_periods");
sgehwolf@14148 322 }
sgehwolf@14148 323
sgehwolf@14148 324 public long getCpuNumThrottled() {
sgehwolf@14148 325 return SubSystem.getLongEntry(cpuacct, "cpu.stat", "nr_throttled");
sgehwolf@14148 326 }
sgehwolf@14148 327
sgehwolf@14148 328 public long getCpuThrottledTime() {
sgehwolf@14148 329 return SubSystem.getLongEntry(cpuacct, "cpu.stat", "throttled_time");
sgehwolf@14148 330 }
sgehwolf@14148 331
sgehwolf@14148 332 public long getEffectiveCpuCount() {
sgehwolf@14148 333 return Runtime.getRuntime().availableProcessors();
sgehwolf@14148 334 }
sgehwolf@14148 335
sgehwolf@14148 336
sgehwolf@14148 337 /*****************************************************************
sgehwolf@14148 338 * CPUSet Subsystem
sgehwolf@14148 339 ****************************************************************/
sgehwolf@14148 340
sgehwolf@14148 341 public int[] getCpuSetCpus() {
sgehwolf@14148 342 return SubSystem.StringRangeToIntArray(SubSystem.getStringValue(cpuset, "cpuset.cpus"));
sgehwolf@14148 343 }
sgehwolf@14148 344
sgehwolf@14148 345 public int[] getEffectiveCpuSetCpus() {
sgehwolf@14148 346 return SubSystem.StringRangeToIntArray(SubSystem.getStringValue(cpuset, "cpuset.effective_cpus"));
sgehwolf@14148 347 }
sgehwolf@14148 348
sgehwolf@14148 349 public int[] getCpuSetMems() {
sgehwolf@14148 350 return SubSystem.StringRangeToIntArray(SubSystem.getStringValue(cpuset, "cpuset.mems"));
sgehwolf@14148 351 }
sgehwolf@14148 352
sgehwolf@14148 353 public int[] getEffectiveCpuSetMems() {
sgehwolf@14148 354 return SubSystem.StringRangeToIntArray(SubSystem.getStringValue(cpuset, "cpuset.effective_mems"));
sgehwolf@14148 355 }
sgehwolf@14148 356
sgehwolf@14148 357 public double getCpuSetMemoryPressure() {
sgehwolf@14148 358 return SubSystem.getDoubleValue(cpuset, "cpuset.memory_pressure");
sgehwolf@14148 359 }
sgehwolf@14148 360
sgehwolf@14148 361 public boolean isCpuSetMemoryPressureEnabled() {
sgehwolf@14148 362 long val = SubSystem.getLongValue(cpuset, "cpuset.memory_pressure_enabled");
sgehwolf@14148 363 return (val == 1);
sgehwolf@14148 364 }
sgehwolf@14148 365
sgehwolf@14148 366
sgehwolf@14148 367 /*****************************************************************
sgehwolf@14148 368 * Memory Subsystem
sgehwolf@14148 369 ****************************************************************/
sgehwolf@14148 370
sgehwolf@14148 371
sgehwolf@14148 372 public long getMemoryFailCount() {
sgehwolf@14148 373 return SubSystem.getLongValue(memory, "memory.failcnt");
sgehwolf@14148 374 }
sgehwolf@14148 375
sgehwolf@14148 376 public long getMemoryLimit() {
sgehwolf@14148 377 long retval = SubSystem.getLongValue(memory, "memory.limit_in_bytes");
sgehwolf@14148 378 return retval > unlimited_minimum ? -1L : retval;
sgehwolf@14148 379 }
sgehwolf@14148 380
sgehwolf@14148 381 public long getMemoryMaxUsage() {
sgehwolf@14148 382 return SubSystem.getLongValue(memory, "memory.max_usage_in_bytes");
sgehwolf@14148 383 }
sgehwolf@14148 384
sgehwolf@14148 385 public long getMemoryUsage() {
sgehwolf@14148 386 return SubSystem.getLongValue(memory, "memory.usage_in_bytes");
sgehwolf@14148 387 }
sgehwolf@14148 388
sgehwolf@14148 389 public long getKernelMemoryFailCount() {
sgehwolf@14148 390 return SubSystem.getLongValue(memory, "memory.kmem.failcnt");
sgehwolf@14148 391 }
sgehwolf@14148 392
sgehwolf@14148 393 public long getKernelMemoryLimit() {
sgehwolf@14148 394 long retval = SubSystem.getLongValue(memory, "memory.kmem.limit_in_bytes");
sgehwolf@14148 395 return retval > unlimited_minimum ? -1L : retval;
sgehwolf@14148 396 }
sgehwolf@14148 397
sgehwolf@14148 398 public long getKernelMemoryMaxUsage() {
sgehwolf@14148 399 return SubSystem.getLongValue(memory, "memory.kmem.max_usage_in_bytes");
sgehwolf@14148 400 }
sgehwolf@14148 401
sgehwolf@14148 402 public long getKernelMemoryUsage() {
sgehwolf@14148 403 return SubSystem.getLongValue(memory, "memory.kmem.usage_in_bytes");
sgehwolf@14148 404 }
sgehwolf@14148 405
sgehwolf@14148 406 public long getTcpMemoryFailCount() {
sgehwolf@14148 407 return SubSystem.getLongValue(memory, "memory.kmem.tcp.failcnt");
sgehwolf@14148 408 }
sgehwolf@14148 409
sgehwolf@14148 410 public long getTcpMemoryLimit() {
sgehwolf@14148 411 long retval = SubSystem.getLongValue(memory, "memory.kmem.tcp.limit_in_bytes");
sgehwolf@14148 412 return retval > unlimited_minimum ? -1L : retval;
sgehwolf@14148 413 }
sgehwolf@14148 414
sgehwolf@14148 415 public long getTcpMemoryMaxUsage() {
sgehwolf@14148 416 return SubSystem.getLongValue(memory, "memory.kmem.tcp.max_usage_in_bytes");
sgehwolf@14148 417 }
sgehwolf@14148 418
sgehwolf@14148 419 public long getTcpMemoryUsage() {
sgehwolf@14148 420 return SubSystem.getLongValue(memory, "memory.kmem.tcp.usage_in_bytes");
sgehwolf@14148 421 }
sgehwolf@14148 422
sgehwolf@14148 423 public long getMemoryAndSwapFailCount() {
sgehwolf@14148 424 return SubSystem.getLongValue(memory, "memory.memsw.failcnt");
sgehwolf@14148 425 }
sgehwolf@14148 426
sgehwolf@14148 427 public long getMemoryAndSwapLimit() {
sgehwolf@14148 428 long retval = SubSystem.getLongValue(memory, "memory.memsw.limit_in_bytes");
sgehwolf@14148 429 return retval > unlimited_minimum ? -1L : retval;
sgehwolf@14148 430 }
sgehwolf@14148 431
sgehwolf@14148 432 public long getMemoryAndSwapMaxUsage() {
sgehwolf@14148 433 return SubSystem.getLongValue(memory, "memory.memsw.max_usage_in_bytes");
sgehwolf@14148 434 }
sgehwolf@14148 435
sgehwolf@14148 436 public long getMemoryAndSwapUsage() {
sgehwolf@14148 437 return SubSystem.getLongValue(memory, "memory.memsw.usage_in_bytes");
sgehwolf@14148 438 }
sgehwolf@14148 439
sgehwolf@14148 440 public boolean isMemoryOOMKillEnabled() {
sgehwolf@14148 441 long val = SubSystem.getLongEntry(memory, "memory.oom_control", "oom_kill_disable");
sgehwolf@14148 442 return (val == 0);
sgehwolf@14148 443 }
sgehwolf@14148 444
sgehwolf@14148 445 public long getMemorySoftLimit() {
sgehwolf@14148 446 long retval = SubSystem.getLongValue(memory, "memory.soft_limit_in_bytes");
sgehwolf@14148 447 return retval > unlimited_minimum ? -1L : retval;
sgehwolf@14148 448 }
sgehwolf@14148 449
sgehwolf@14148 450
sgehwolf@14148 451 /*****************************************************************
sgehwolf@14148 452 * BlKIO Subsystem
sgehwolf@14148 453 ****************************************************************/
sgehwolf@14148 454
sgehwolf@14148 455
sgehwolf@14148 456 public long getBlkIOServiceCount() {
sgehwolf@14148 457 return SubSystem.getLongEntry(blkio, "blkio.throttle.io_service_bytes", "Total");
sgehwolf@14148 458 }
sgehwolf@14148 459
sgehwolf@14148 460 public long getBlkIOServiced() {
sgehwolf@14148 461 return SubSystem.getLongEntry(blkio, "blkio.throttle.io_serviced", "Total");
sgehwolf@14148 462 }
sgehwolf@14148 463
sgehwolf@14169 464 private static native boolean isUseContainerSupport();
sgehwolf@14169 465
sgehwolf@14148 466 }

mercurial