46 #include "runtime/arguments.hpp"
47 #include "runtime/atomic.hpp"
48 #include "runtime/extendedPC.hpp"
49 #include "runtime/globals.hpp"
50 #include "runtime/interfaceSupport.inline.hpp"
51 #include "runtime/init.hpp"
52 #include "runtime/java.hpp"
53 #include "runtime/javaCalls.hpp"
54 #include "runtime/mutexLocker.hpp"
55 #include "runtime/objectMonitor.hpp"
56 #include "runtime/orderAccess.hpp"
57 #include "runtime/osThread.hpp"
58 #include "runtime/perfMemory.hpp"
59 #include "runtime/sharedRuntime.hpp"
60 #include "runtime/statSampler.hpp"
61 #include "runtime/stubRoutines.hpp"
62 #include "runtime/thread.inline.hpp"
63 #include "runtime/threadCritical.hpp"
64 #include "runtime/threadSMR.hpp"
65 #include "runtime/timer.hpp"
66 #include "runtime/vm_version.hpp"
67 #include "semaphore_posix.hpp"
68 #include "services/attachListener.hpp"
69 #include "services/memTracker.hpp"
70 #include "services/runtimeService.hpp"
71 #include "utilities/align.hpp"
72 #include "utilities/decoder.hpp"
73 #include "utilities/defaultStream.hpp"
74 #include "utilities/events.hpp"
75 #include "utilities/elfFile.hpp"
76 #include "utilities/growableArray.hpp"
77 #include "utilities/macros.hpp"
78 #include "utilities/vmError.hpp"
79
80 // put OS-includes here
81 # include <sys/types.h>
82 # include <sys/mman.h>
83 # include <sys/stat.h>
84 # include <sys/select.h>
85 # include <pthread.h>
86 # include <signal.h>
1923 if (fd == -1) {
1924 return false;
1925 }
1926
1927 if (hdr != NULL) {
1928 st->print_cr("%s", hdr);
1929 }
1930
1931 char buf[33];
1932 int bytes;
1933 buf[32] = '\0';
1934 while ((bytes = ::read(fd, buf, sizeof(buf)-1)) > 0) {
1935 st->print_raw(buf, bytes);
1936 }
1937
1938 ::close(fd);
1939
1940 return true;
1941 }
1942
1943 void os::print_dll_info(outputStream *st) {
1944 st->print_cr("Dynamic libraries:");
1945
1946 char fname[32];
1947 pid_t pid = os::Linux::gettid();
1948
1949 jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
1950
1951 if (!_print_ascii_file(fname, st)) {
1952 st->print("Can not get library information for pid = %d\n", pid);
1953 }
1954 }
1955
1956 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
1957 FILE *procmapsFile = NULL;
1958
1959 // Open the procfs maps file for the current process
1960 if ((procmapsFile = fopen("/proc/self/maps", "r")) != NULL) {
1961 // Allocate PATH_MAX for file name plus a reasonable size for other fields.
1962 char line[PATH_MAX + 100];
2007 // Print warning if unsafe chroot environment detected
2008 if (unsafe_chroot_detected) {
2009 st->print("WARNING!! ");
2010 st->print_cr("%s", unstable_chroot_error);
2011 }
2012
2013 os::Linux::print_libversion_info(st);
2014
2015 os::Posix::print_rlimit_info(st);
2016
2017 os::Posix::print_load_average(st);
2018
2019 os::Linux::print_full_memory_info(st);
2020
2021 os::Linux::print_proc_sys_info(st);
2022
2023 os::Linux::print_ld_preload_file(st);
2024
2025 os::Linux::print_container_info(st);
2026
2027 VM_Version::print_platform_virtualization_info(st);
2028
2029 os::Linux::print_steal_info(st);
2030 }
2031
2032 // Try to identify popular distros.
2033 // Most Linux distributions have a /etc/XXX-release file, which contains
2034 // the OS version string. Newer Linux distributions have a /etc/lsb-release
2035 // file that also contains the OS version string. Some have more than one
2036 // /etc/XXX-release file (e.g. Mandrake has both /etc/mandrake-release and
2037 // /etc/redhat-release.), so the order is important.
2038 // Any Linux that is based on Redhat (i.e. Oracle, Mandrake, Sun JDS...) have
2039 // their own specific XXX-release file as well as a redhat-release file.
2040 // Because of this the XXX-release file needs to be searched for before the
2041 // redhat-release file.
2042 // Since Red Hat and SuSE have an lsb-release file that is not very descriptive the
2043 // search for redhat-release / SuSE-release needs to be before lsb-release.
2044 // Since the lsb-release file is the new standard it needs to be searched
2045 // before the older style release files.
2046 // Searching system-release (Red Hat) and os-release (other Linuxes) are a
2047 // next to last resort. The os-release file is a new standard that contains
2262 } else {
2263 st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
2264 }
2265
2266 j = OSContainer::OSContainer::memory_usage_in_bytes();
2267 st->print("memory_usage_in_bytes: ");
2268 if (j > 0) {
2269 st->print(JLONG_FORMAT "\n", j);
2270 } else {
2271 st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
2272 }
2273
2274 j = OSContainer::OSContainer::memory_max_usage_in_bytes();
2275 st->print("memory_max_usage_in_bytes: ");
2276 if (j > 0) {
2277 st->print(JLONG_FORMAT "\n", j);
2278 } else {
2279 st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
2280 }
2281 st->cr();
2282 }
2283
2284 void os::Linux::print_steal_info(outputStream* st) {
2285 if (has_initial_tick_info) {
2286 CPUPerfTicks pticks;
2287 bool res = os::Linux::get_tick_information(&pticks, -1);
2288
2289 if (res && pticks.has_steal_ticks) {
2290 uint64_t steal_ticks_difference = pticks.steal - initial_steal_ticks;
2291 uint64_t total_ticks_difference = pticks.total - initial_total_ticks;
2292 double steal_ticks_perc = 0.0;
2293 if (total_ticks_difference != 0) {
2294 steal_ticks_perc = (double) steal_ticks_difference / total_ticks_difference;
2295 }
2296 st->print_cr("Steal ticks since vm start: " UINT64_FORMAT, steal_ticks_difference);
2297 st->print_cr("Steal ticks percentage since vm start:%7.3f", steal_ticks_perc);
2298 }
2299 }
2300 }
2301
|
46 #include "runtime/arguments.hpp"
47 #include "runtime/atomic.hpp"
48 #include "runtime/extendedPC.hpp"
49 #include "runtime/globals.hpp"
50 #include "runtime/interfaceSupport.inline.hpp"
51 #include "runtime/init.hpp"
52 #include "runtime/java.hpp"
53 #include "runtime/javaCalls.hpp"
54 #include "runtime/mutexLocker.hpp"
55 #include "runtime/objectMonitor.hpp"
56 #include "runtime/orderAccess.hpp"
57 #include "runtime/osThread.hpp"
58 #include "runtime/perfMemory.hpp"
59 #include "runtime/sharedRuntime.hpp"
60 #include "runtime/statSampler.hpp"
61 #include "runtime/stubRoutines.hpp"
62 #include "runtime/thread.inline.hpp"
63 #include "runtime/threadCritical.hpp"
64 #include "runtime/threadSMR.hpp"
65 #include "runtime/timer.hpp"
66 #include "semaphore_posix.hpp"
67 #include "services/attachListener.hpp"
68 #include "services/memTracker.hpp"
69 #include "services/runtimeService.hpp"
70 #include "utilities/align.hpp"
71 #include "utilities/decoder.hpp"
72 #include "utilities/defaultStream.hpp"
73 #include "utilities/events.hpp"
74 #include "utilities/elfFile.hpp"
75 #include "utilities/growableArray.hpp"
76 #include "utilities/macros.hpp"
77 #include "utilities/vmError.hpp"
78
79 // put OS-includes here
80 # include <sys/types.h>
81 # include <sys/mman.h>
82 # include <sys/stat.h>
83 # include <sys/select.h>
84 # include <pthread.h>
85 # include <signal.h>
1922 if (fd == -1) {
1923 return false;
1924 }
1925
1926 if (hdr != NULL) {
1927 st->print_cr("%s", hdr);
1928 }
1929
1930 char buf[33];
1931 int bytes;
1932 buf[32] = '\0';
1933 while ((bytes = ::read(fd, buf, sizeof(buf)-1)) > 0) {
1934 st->print_raw(buf, bytes);
1935 }
1936
1937 ::close(fd);
1938
1939 return true;
1940 }
1941
1942 #if defined(S390) || defined(PPC64)
1943 // keywords_to_match - NULL terminated array of keywords
1944 static bool print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) {
1945 char* line = NULL;
1946 size_t length = 0;
1947 FILE* fp = fopen(filename, "r");
1948 if (fp == NULL) {
1949 return false;
1950 }
1951
1952 st->print_cr("Virtualization information:");
1953 while (getline(&line, &length, fp) != -1) {
1954 int i = 0;
1955 while (keywords_to_match[i] != NULL) {
1956 if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) {
1957 st->print("%s", line);
1958 break;
1959 }
1960 i++;
1961 }
1962 }
1963
1964 free(line);
1965 fclose(fp);
1966
1967 return true;
1968 }
1969 #endif
1970
1971 void os::print_dll_info(outputStream *st) {
1972 st->print_cr("Dynamic libraries:");
1973
1974 char fname[32];
1975 pid_t pid = os::Linux::gettid();
1976
1977 jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
1978
1979 if (!_print_ascii_file(fname, st)) {
1980 st->print("Can not get library information for pid = %d\n", pid);
1981 }
1982 }
1983
1984 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
1985 FILE *procmapsFile = NULL;
1986
1987 // Open the procfs maps file for the current process
1988 if ((procmapsFile = fopen("/proc/self/maps", "r")) != NULL) {
1989 // Allocate PATH_MAX for file name plus a reasonable size for other fields.
1990 char line[PATH_MAX + 100];
2035 // Print warning if unsafe chroot environment detected
2036 if (unsafe_chroot_detected) {
2037 st->print("WARNING!! ");
2038 st->print_cr("%s", unstable_chroot_error);
2039 }
2040
2041 os::Linux::print_libversion_info(st);
2042
2043 os::Posix::print_rlimit_info(st);
2044
2045 os::Posix::print_load_average(st);
2046
2047 os::Linux::print_full_memory_info(st);
2048
2049 os::Linux::print_proc_sys_info(st);
2050
2051 os::Linux::print_ld_preload_file(st);
2052
2053 os::Linux::print_container_info(st);
2054
2055 os::Linux::print_virtualization_info(st);
2056
2057 os::Linux::print_steal_info(st);
2058 }
2059
2060 // Try to identify popular distros.
2061 // Most Linux distributions have a /etc/XXX-release file, which contains
2062 // the OS version string. Newer Linux distributions have a /etc/lsb-release
2063 // file that also contains the OS version string. Some have more than one
2064 // /etc/XXX-release file (e.g. Mandrake has both /etc/mandrake-release and
2065 // /etc/redhat-release.), so the order is important.
2066 // Any Linux that is based on Redhat (i.e. Oracle, Mandrake, Sun JDS...) have
2067 // their own specific XXX-release file as well as a redhat-release file.
2068 // Because of this the XXX-release file needs to be searched for before the
2069 // redhat-release file.
2070 // Since Red Hat and SuSE have an lsb-release file that is not very descriptive the
2071 // search for redhat-release / SuSE-release needs to be before lsb-release.
2072 // Since the lsb-release file is the new standard it needs to be searched
2073 // before the older style release files.
2074 // Searching system-release (Red Hat) and os-release (other Linuxes) are a
2075 // next to last resort. The os-release file is a new standard that contains
2290 } else {
2291 st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
2292 }
2293
2294 j = OSContainer::OSContainer::memory_usage_in_bytes();
2295 st->print("memory_usage_in_bytes: ");
2296 if (j > 0) {
2297 st->print(JLONG_FORMAT "\n", j);
2298 } else {
2299 st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
2300 }
2301
2302 j = OSContainer::OSContainer::memory_max_usage_in_bytes();
2303 st->print("memory_max_usage_in_bytes: ");
2304 if (j > 0) {
2305 st->print(JLONG_FORMAT "\n", j);
2306 } else {
2307 st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
2308 }
2309 st->cr();
2310 }
2311
2312 void os::Linux::print_virtualization_info(outputStream* st) {
2313 #if defined(S390)
2314 // /proc/sysinfo contains interesting information about
2315 // - LPAR
2316 // - whole "Box" (CPUs )
2317 // - z/VM / KVM (VM<nn>); this is not available in an LPAR-only setup
2318 const char* kw[] = { "LPAR", "CPUs", "VM", NULL };
2319 const char* info_file = "/proc/sysinfo";
2320
2321 if (!print_matching_lines_from_file(info_file, st, kw)) {
2322 st->print_cr(" <%s Not Available>", info_file);
2323 }
2324 #elif defined(PPC64)
2325 const char* info_file = "/proc/ppc64/lparcfg";
2326 const char* kw[] = { "system_type=", // qemu indicates PowerKVM
2327 "partition_entitled_capacity=", // entitled processor capacity percentage
2328 "partition_max_entitled_capacity=",
2329 "capacity_weight=", // partition CPU weight
2330 "partition_active_processors=",
2331 "partition_potential_processors=",
2332 "entitled_proc_capacity_available=",
2333 "capped=", // 0 - uncapped, 1 - vcpus capped at entitled processor capacity percentage
2334 "shared_processor_mode=", // (non)dedicated partition
2335 "system_potential_processors=",
2336 "pool=", // CPU-pool number
2337 "pool_capacity=",
2338 "NumLpars=", // on non-KVM machines, NumLpars is not found for full partition mode machines
2339 NULL };
2340 if (!print_matching_lines_from_file(info_file, st, kw)) {
2341 st->print_cr(" <%s Not Available>", info_file);
2342 }
2343 #endif
2344 }
2345
2346 void os::Linux::print_steal_info(outputStream* st) {
2347 if (has_initial_tick_info) {
2348 CPUPerfTicks pticks;
2349 bool res = os::Linux::get_tick_information(&pticks, -1);
2350
2351 if (res && pticks.has_steal_ticks) {
2352 uint64_t steal_ticks_difference = pticks.steal - initial_steal_ticks;
2353 uint64_t total_ticks_difference = pticks.total - initial_total_ticks;
2354 double steal_ticks_perc = 0.0;
2355 if (total_ticks_difference != 0) {
2356 steal_ticks_perc = (double) steal_ticks_difference / total_ticks_difference;
2357 }
2358 st->print_cr("Steal ticks since vm start: " UINT64_FORMAT, steal_ticks_difference);
2359 st->print_cr("Steal ticks percentage since vm start:%7.3f", steal_ticks_perc);
2360 }
2361 }
2362 }
2363
|