/[packages]/updates/5/java-1.8.0-openjdk/current/SOURCES/8170888-pr3314-rh1390708.patch
ViewVC logotype

Contents of /updates/5/java-1.8.0-openjdk/current/SOURCES/8170888-pr3314-rh1390708.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1088712 - (show annotations) (download)
Sat Mar 4 17:16:38 2017 UTC (7 years, 1 month ago) by luigiwalser
File size: 4043 byte(s)
sync with fedora as of 2017-02-28
1 # HG changeset patch
2 # User dholmes
3 # Date 1483660520 18000
4 # Thu Jan 05 18:55:20 2017 -0500
5 # Node ID 652fe741b8f2bfdacba66d772cc89fe7ec6dea66
6 # Parent 9e43b1c17a3ad5b26d64499c72db61a1dc1649f0
7 8170888, PR3314: [linux] Experimental support for cgroup memory limits in container (ie Docker) environments
8 Summary: Set apparent physical memory to cgroup memory limit when UseCGroupMemoryLimitForHeap is true
9 Reviewed-by: acorn, gtriantafill
10 Contributed-by: Christine Flood <chf@redhat.com>
11
12 diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
13 --- openjdk/hotspot/src/share/vm/runtime/arguments.cpp
14 +++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp
15 @@ -1,5 +1,5 @@
16 /*
17 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
18 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
19 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20 *
21 * This code is free software; you can redistribute it and/or modify it
22 @@ -1768,10 +1768,39 @@
23 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
24 }
25
26 - const julong phys_mem =
27 + julong phys_mem =
28 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
29 : (julong)MaxRAM;
30
31 + // Experimental support for CGroup memory limits
32 + if (UseCGroupMemoryLimitForHeap) {
33 + // This is a rough indicator that a CGroup limit may be in force
34 + // for this process
35 + const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
36 + FILE *fp = fopen(lim_file, "r");
37 + if (fp != NULL) {
38 + julong cgroup_max = 0;
39 + int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
40 + if (ret == 1 && cgroup_max > 0) {
41 + // If unlimited, cgroup_max will be a very large, but unspecified
42 + // value, so use initial phys_mem as a limit
43 + if (PrintGCDetails && Verbose) {
44 + // Cannot use gclog_or_tty yet.
45 + tty->print_cr("Setting phys_mem to the min of cgroup limit ("
46 + JULONG_FORMAT "MB) and initial phys_mem ("
47 + JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
48 + }
49 + phys_mem = MIN2(cgroup_max, phys_mem);
50 + } else {
51 + warning("Unable to read/parse cgroup memory limit from %s: %s",
52 + lim_file, errno != 0 ? strerror(errno) : "unknown error");
53 + }
54 + fclose(fp);
55 + } else {
56 + warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
57 + }
58 + }
59 +
60 // If the maximum heap size has not been set with -Xmx,
61 // then set it as fraction of the size of physical memory,
62 // respecting the maximum and minimum sizes of the heap.
63 diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
64 --- openjdk/hotspot/src/share/vm/runtime/globals.hpp
65 +++ openjdk/hotspot/src/share/vm/runtime/globals.hpp
66 @@ -1,5 +1,5 @@
67 /*
68 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
69 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
70 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
71 *
72 * This code is free software; you can redistribute it and/or modify it
73 @@ -2080,6 +2080,10 @@
74 "Maximum ergonomically set heap size (in bytes); zero means use " \
75 "MaxRAM / MaxRAMFraction") \
76 \
77 + experimental(bool, UseCGroupMemoryLimitForHeap, false, \
78 + "Use CGroup memory limit as physical memory limit for heap " \
79 + "sizing") \
80 + \
81 product(uintx, MaxRAMFraction, 4, \
82 "Maximum fraction (1/n) of real memory used for maximum heap " \
83 "size") \

  ViewVC Help
Powered by ViewVC 1.1.30