changeset 57888:5d49b846aef7

8235681: Remove unnecessary workarounds in UnixOperatingSystem.c Reviewed-by: cjplummer, amenkov
author dtitov
date Mon, 27 Jan 2020 09:39:44 -0800
parents 4b2d33292638
children e7c4199e4d32
files src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c	Mon Jan 27 14:30:57 2020 +0100
+++ b/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c	Mon Jan 27 09:39:44 2020 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2020, 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
@@ -38,6 +38,8 @@
 #include <inttypes.h>
 #include "com_sun_management_internal_OperatingSystemImpl.h"
 
+#include <assert.h>
+
 struct ticks {
     uint64_t  used;
     uint64_t  usedKernel;
@@ -250,7 +252,7 @@
 
     pthread_mutex_lock(&lock);
 
-    if(perfInit() == 0) {
+    if (perfInit() == 0) {
 
         if (target == CPU_LOAD_VM_ONLY) {
             pticks = &counters.jvmTicks;
@@ -270,14 +272,10 @@
             failed = 1;
         }
 
-        if(!failed) {
-            // seems like we sometimes end up with less kernel ticks when
-            // reading /proc/self/stat a second time, timing issue between cpus?
-            if (pticks->usedKernel < tmp.usedKernel) {
-                kdiff = 0;
-            } else {
-                kdiff = pticks->usedKernel - tmp.usedKernel;
-            }
+        if (!failed) {
+
+            assert(pticks->usedKernel >= tmp.usedKernel);
+            kdiff = pticks->usedKernel - tmp.usedKernel;
             tdiff = pticks->total - tmp.total;
             udiff = pticks->used - tmp.used;