8262491: AArch64: CPU description should contain compatible board list

Reviewed-by: akozlov, aph
This commit is contained in:
Yasumasa Suenaga 2021-03-13 09:40:40 +00:00
parent 86e4c755f9
commit a528771064
4 changed files with 40 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -130,6 +130,8 @@ public:
static bool supports_fast_class_init_checks() { return true; }
constexpr static bool supports_stack_watermark_barrier() { return true; }
static void get_compatible_board(char *buf, int buflen);
};
#endif // CPU_AARCH64_VM_VERSION_AARCH64_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, 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
@ -51,7 +51,12 @@ void VM_Version_Ext::initialize_cpu_information(void) {
_no_of_threads = _no_of_cores;
_no_of_sockets = _no_of_cores;
snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE - 1, "AArch64");
snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "AArch64 %s", _features_string);
int desc_len = snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "AArch64 ");
VM_Version::get_compatible_board(_cpu_desc + desc_len, CPU_DETAILED_DESC_BUF_SIZE - desc_len);
desc_len = (int)strlen(_cpu_desc);
snprintf(_cpu_desc + desc_len, CPU_DETAILED_DESC_BUF_SIZE - desc_len, " %s", _features_string);
_initialized = true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -167,3 +167,25 @@ void VM_Version::get_os_cpu_info() {
fclose(f);
}
}
void VM_Version::get_compatible_board(char *buf, int buflen) {
assert(buf != NULL, "invalid argument");
assert(buflen >= 1, "invalid argument");
*buf = '\0';
int fd = open("/proc/device-tree/compatible", O_RDONLY);
if (fd != -1) {
ssize_t read_sz = read(fd, buf, buflen - 1);
if (read_sz > 0) {
buf[read_sz] = '\0';
// Replace '\0' to ' '
for (char *ch = buf; ch < buf + read_sz; ch++) {
if (*ch == '\0') {
*ch = ' ';
}
}
} else {
*buf = '\0';
}
close(fd);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Microsoft Corporation. All rights reserved.
* Copyright (c) 2020, 2021, Microsoft Corporation. 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
@ -97,3 +97,9 @@ void VM_Version::get_os_cpu_info() {
}
}
}
void VM_Version::get_compatible_board(char *buf, int buflen) {
assert(buf != NULL, "invalid argument");
assert(buflen >= 1, "invalid argument");
*buf = '\0';
}