Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
[GR-28211] Merge in tag jdk8u282-b05.
Browse files Browse the repository at this point in the history
PullRequest: graal-jvmci-8/341
  • Loading branch information
marwan-hallaoui committed Dec 15, 2020
2 parents 5148bec + bd1fdee commit 2301fd7
Show file tree
Hide file tree
Showing 27 changed files with 522 additions and 558 deletions.
2 changes: 2 additions & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -1398,3 +1398,5 @@ a0eb08e2db5a40956a9c2d6b7dea76a894559033 jdk8u272-b08
b36c3f635d937798abe5e7c5a40a868705fed15e jdk8u275-b01
b36c3f635d937798abe5e7c5a40a868705fed15e jdk8u275-ga
312e9cb580c5c3f8f6ebf660b1f78ff060590ac4 jdk8u282-b02
83661fdee9f08747a1d7a98123c00732b6a3a43d jdk8u282-b03
d7c102fe9c4736bca65b25da69093d84da141e65 jdk8u282-b04
6 changes: 3 additions & 3 deletions THIRD_PARTY_README
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------

%% This notice is provided with respect to CUP Parser Generator for
Java 0.10k, which may be included with JRE 8, JDK 8, and OpenJDK 8.
Java 0.10b, which may be included with JRE 8, JDK 8, and OpenJDK 8.

--- begin of LICENSE ---

Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian
Copyright 1996-2015 by Scott Hudson, Frank Flannery, C. Scott Ananian, Michael Petter

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
Expand Down Expand Up @@ -3028,7 +3028,7 @@ included with JRE 8, JDK 8, and OpenJDK 8.
Apache Commons Math 3.2
Apache Derby 10.11.1.2
Apache Jakarta BCEL 5.1
Apache Santuario XML Security for Java 2.1.1
Apache Santuario XML Security for Java 2.1.3
Apache Xalan-Java 2.7.2
Apache Xerces Java 2.10.0
Apache XML Resolver 1.1
Expand Down
175 changes: 63 additions & 112 deletions src/os/linux/vm/osContainer_linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,12 +34,15 @@

bool OSContainer::_is_initialized = false;
bool OSContainer::_is_containerized = false;
int OSContainer::_active_processor_count = 1;
julong _unlimited_memory;

class CgroupSubsystem: CHeapObj<mtInternal> {
friend class OSContainer;

private:
volatile jlong _next_check_counter;

/* mountinfo contents */
char *_root;
char *_mount_point;
Expand All @@ -52,6 +55,7 @@ class CgroupSubsystem: CHeapObj<mtInternal> {
_root = os::strdup(root);
_mount_point = os::strdup(mountpoint);
_path = NULL;
_next_check_counter = min_jlong;
}

/*
Expand Down Expand Up @@ -80,14 +84,14 @@ class CgroupSubsystem: CHeapObj<mtInternal> {
buf[MAXPATHLEN-1] = '\0';
_path = os::strdup(buf);
} else {
char *p = strstr(_root, cgroup_path);
char *p = strstr(cgroup_path, _root);
if (p != NULL && p == _root) {
if (strlen(cgroup_path) > strlen(_root)) {
int buflen;
strncpy(buf, _mount_point, MAXPATHLEN);
buf[MAXPATHLEN-1] = '\0';
buflen = strlen(buf);
if ((buflen + strlen(cgroup_path)) > (MAXPATHLEN-1)) {
if ((buflen + strlen(cgroup_path) - strlen(_root)) > (MAXPATHLEN-1)) {
return;
}
strncat(buf, cgroup_path + strlen(_root), MAXPATHLEN-buflen);
Expand All @@ -101,6 +105,14 @@ class CgroupSubsystem: CHeapObj<mtInternal> {
}

char *subsystem_path() { return _path; }

bool cache_has_expired() {
return os::elapsed_counter() > _next_check_counter;
}

void set_cache_expiry_time(jlong timeout) {
_next_check_counter = os::elapsed_counter() + timeout;
}
};

CgroupSubsystem* memory = NULL;
Expand Down Expand Up @@ -214,16 +226,11 @@ PRAGMA_DIAG_POP
* we are running under cgroup control.
*/
void OSContainer::init() {
int mountid;
int parentid;
int major;
int minor;
FILE *mntinfo = NULL;
FILE *cgroup = NULL;
char buf[MAXPATHLEN+1];
char tmproot[MAXPATHLEN+1];
char tmpmount[MAXPATHLEN+1];
char tmpbase[MAXPATHLEN+1];
char *p;
jlong mem_limit;

Expand Down Expand Up @@ -263,99 +270,27 @@ void OSContainer::init() {
return;
}

while ( (p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
// Look for the filesystem type and see if it's cgroup
char fstype[MAXPATHLEN+1];
fstype[0] = '\0';
char *s = strstr(p, " - ");
if (s != NULL &&
sscanf(s, " - %s", fstype) == 1 &&
strcmp(fstype, "cgroup") == 0) {

if (strstr(p, "memory") != NULL) {
int matched = sscanf(p, "%d %d %d:%d %s %s",
&mountid,
&parentid,
&major,
&minor,
tmproot,
tmpmount);
if (matched == 6) {
memory = new CgroupSubsystem(tmproot, tmpmount);
}
else
if (PrintContainerInfo) {
tty->print_cr("Incompatible str containing cgroup and memory: %s", p);
}
} else if (strstr(p, "cpuset") != NULL) {
int matched = sscanf(p, "%d %d %d:%d %s %s",
&mountid,
&parentid,
&major,
&minor,
tmproot,
tmpmount);
if (matched == 6) {
cpuset = new CgroupSubsystem(tmproot, tmpmount);
}
else {
if (PrintContainerInfo) {
tty->print_cr("Incompatible str containing cgroup and cpuset: %s", p);
}
}
} else if (strstr(p, "cpu,cpuacct") != NULL || strstr(p, "cpuacct,cpu") != NULL) {
int matched = sscanf(p, "%d %d %d:%d %s %s",
&mountid,
&parentid,
&major,
&minor,
tmproot,
tmpmount);
if (matched == 6) {
cpu = new CgroupSubsystem(tmproot, tmpmount);
cpuacct = new CgroupSubsystem(tmproot, tmpmount);
}
else {
if (PrintContainerInfo) {
tty->print_cr("Incompatible str containing cgroup and cpu,cpuacct: %s", p);
}
}
} else if (strstr(p, "cpuacct") != NULL) {
int matched = sscanf(p, "%d %d %d:%d %s %s",
&mountid,
&parentid,
&major,
&minor,
tmproot,
tmpmount);
if (matched == 6) {
cpuacct = new CgroupSubsystem(tmproot, tmpmount);
}
else {
if (PrintContainerInfo) {
tty->print_cr("Incompatible str containing cgroup and cpuacct: %s", p);
}
}
} else if (strstr(p, "cpu") != NULL) {
int matched = sscanf(p, "%d %d %d:%d %s %s",
&mountid,
&parentid,
&major,
&minor,
tmproot,
tmpmount);
if (matched == 6) {
cpu = new CgroupSubsystem(tmproot, tmpmount);
}
else {
if (PrintContainerInfo) {
tty->print_cr("Incompatible str containing cgroup and cpu: %s", p);
}
}
while ((p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
char tmpcgroups[MAXPATHLEN+1];
char *cptr = tmpcgroups;
char *token;

// mountinfo format is documented at https://www.kernel.org/doc/Documentation/filesystems/proc.txt
if (sscanf(p, "%*d %*d %*d:%*d %s %s %*[^-]- cgroup %*s %s", tmproot, tmpmount, tmpcgroups) != 3) {
continue;
}
while ((token = strsep(&cptr, ",")) != NULL) {
if (strcmp(token, "memory") == 0) {
memory = new CgroupSubsystem(tmproot, tmpmount);
} else if (strcmp(token, "cpuset") == 0) {
cpuset = new CgroupSubsystem(tmproot, tmpmount);
} else if (strcmp(token, "cpu") == 0) {
cpu = new CgroupSubsystem(tmproot, tmpmount);
} else if (strcmp(token, "cpuacct") == 0) {
cpuacct= new CgroupSubsystem(tmproot, tmpmount);
}
}
}

fclose(mntinfo);

if (memory == NULL) {
Expand Down Expand Up @@ -415,30 +350,30 @@ void OSContainer::init() {
return;
}

while ( (p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
int cgno;
int matched;
char *controller;
while ((p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
char *controllers;
char *token;
char *base;

/* Skip cgroup number */
strsep(&p, ":");
/* Get controller and base */
controller = strsep(&p, ":");
/* Get controllers and base */
controllers = strsep(&p, ":");
base = strsep(&p, "\n");

if (controller != NULL) {
if (strstr(controller, "memory") != NULL) {
if (controllers == NULL) {
continue;
}

while ((token = strsep(&controllers, ",")) != NULL) {
if (strcmp(token, "memory") == 0) {
memory->set_subsystem_path(base);
} else if (strstr(controller, "cpuset") != NULL) {
} else if (strcmp(token, "cpuset") == 0) {
cpuset->set_subsystem_path(base);
} else if (strstr(controller, "cpu,cpuacct") != NULL || strstr(controller, "cpuacct,cpu") != NULL) {
} else if (strcmp(token, "cpu") == 0) {
cpu->set_subsystem_path(base);
} else if (strcmp(token, "cpuacct") == 0) {
cpuacct->set_subsystem_path(base);
} else if (strstr(controller, "cpuacct") != NULL) {
cpuacct->set_subsystem_path(base);
} else if (strstr(controller, "cpu") != NULL) {
cpu->set_subsystem_path(base);
}
}
}
Expand Down Expand Up @@ -584,6 +519,17 @@ int OSContainer::active_processor_count() {
int cpu_count, limit_count;
int result;

// We use a cache with a timeout to avoid performing expensive
// computations in the event this function is called frequently.
// [See 8227006].
if (!cpu->cache_has_expired()) {
if (PrintContainerInfo) {
tty->print_cr("OSContainer::active_processor_count (cached): %d", OSContainer::_active_processor_count);
}

return OSContainer::_active_processor_count;
}

cpu_count = limit_count = os::Linux::active_processor_count();
int quota = cpu_quota();
int period = cpu_period();
Expand Down Expand Up @@ -622,6 +568,11 @@ int OSContainer::active_processor_count() {
if (PrintContainerInfo) {
tty->print_cr("OSContainer::active_processor_count: %d", result);
}

// Update the value and reset the cache timeout
OSContainer::_active_processor_count = result;
cpu->set_cache_expiry_time(OSCONTAINER_CACHE_TIMEOUT);

return result;
}

Expand Down
4 changes: 4 additions & 0 deletions src/os/linux/vm/osContainer_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@

#define OSCONTAINER_ERROR (-2)

// 20ms timeout between re-reads of _active_processor_count.
#define OSCONTAINER_CACHE_TIMEOUT (NANOSECS_PER_SEC/50)

class OSContainer: AllStatic {

private:
static bool _is_initialized;
static bool _is_containerized;
static int _active_processor_count;

public:
static void init();
Expand Down
2 changes: 1 addition & 1 deletion src/os/linux/vm/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5179,7 +5179,7 @@ jint os::init_2(void)

Linux::capture_initial_stack(JavaThread::stack_size_at_create());

#if defined(IA32)
#if defined(IA32) && !defined(ZERO)
workaround_expand_exec_shield_cs_limit();
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -998,18 +998,13 @@ size_t CompactibleFreeListSpace::block_size(const HeapWord* p) const {
// and the klass read.
OrderAccess::loadload();

// must read from what 'p' points to in each loop.
Klass* k = ((volatile oopDesc*)p)->klass_or_null();
// Ensure klass read before size.
Klass* k = oop(p)->klass_or_null_acquire();
if (k != NULL) {
assert(k->is_klass(), "Should really be klass oop.");
oop o = (oop)p;
assert(o->is_oop(true /* ignore mark word */), "Should be an oop.");

// Bugfix for systems with weak memory model (PPC64/IA64).
// The object o may be an array. Acquire to make sure that the array
// size (third word) is consistent.
OrderAccess::acquire();

size_t res = o->size_given_klass(k);
res = adjustObjectSize(res);
assert(res != 0, "Block size should not be 0");
Expand Down Expand Up @@ -1057,21 +1052,13 @@ const {
// and the klass read.
OrderAccess::loadload();

// must read from what 'p' points to in each loop.
Klass* k = ((volatile oopDesc*)p)->klass_or_null();
// We trust the size of any object that has a non-NULL
// klass and (for those in the perm gen) is parsable
// -- irrespective of its conc_safe-ty.
// Ensure klass read before size.
Klass* k = oop(p)->klass_or_null_acquire();
if (k != NULL) {
assert(k->is_klass(), "Should really be klass oop.");
oop o = (oop)p;
assert(o->is_oop(), "Should be an oop");

// Bugfix for systems with weak memory model (PPC64/IA64).
// The object o may be an array. Acquire to make sure that the array
// size (third word) is consistent.
OrderAccess::acquire();

size_t res = o->size_given_klass(k);
res = adjustObjectSize(res);
assert(res != 0, "Block size should not be 0");
Expand Down Expand Up @@ -1124,7 +1111,7 @@ bool CompactibleFreeListSpace::block_is_obj(const HeapWord* p) const {
// and the klass read.
OrderAccess::loadload();

Klass* k = oop(p)->klass_or_null();
Klass* k = oop(p)->klass_or_null_acquire();
if (k != NULL) {
// Ignore mark word because it may have been used to
// chain together promoted objects (the last one
Expand Down
Loading

0 comments on commit 2301fd7

Please sign in to comment.