diff --git a/src/share/vm/classfile/vmSymbols.hpp b/src/share/vm/classfile/vmSymbols.hpp index c69898f24fe8331bd11fe97f780008dc7cd90575..b6a7e0d6c491ce019bd60635d47472d5d11386d4 100644 --- a/src/share/vm/classfile/vmSymbols.hpp +++ b/src/share/vm/classfile/vmSymbols.hpp @@ -351,6 +351,7 @@ template(type_name, "type") \ template(findNative_name, "findNative") \ template(initializeTenantContainerClass_name, "initializeTenantContainerClass") \ + template(initializeJGroupClass_name, "initializeJGroupClass") \ template(deadChild_name, "deadChild") \ template(addClass_name, "addClass") \ template(throwIllegalAccessError_name, "throwIllegalAccessError") \ diff --git a/src/share/vm/prims/tenantenv.cpp b/src/share/vm/prims/tenantenv.cpp index ffa7802f15ca8f3c8a1b59ffc002331a9349b215..fa8b10ce2d860ae7ce3128f44bbc32ab89c62a1c 100644 --- a/src/share/vm/prims/tenantenv.cpp +++ b/src/share/vm/prims/tenantenv.cpp @@ -29,6 +29,8 @@ #define TENANT_FLAG_MULTI_TENANT_ENABLED (0x1) // bit 0 to indicate if the tenant feature is enabled. #define TENANT_FLAG_HEAP_THROTTLING_ENABLED (0x2) // bit 1 to indicate if heap throttling feature is enabled. +#define TENANT_FLAG_CPU_THROTTLING_ENABLED (0x4) // bit 2 to indicate if cpu throttling feature is enabled. +#define TENANT_FLAG_CPU_ACCOUNTING_ENABLED (0x40) // bit 6 to indicate if cpu accounting feature is enabled. #define TENANT_FLAG_HEAP_ISOLATION_ENABLED (0x80) // bit 7 to indicate if heap isolation feature is enabled. static jint tenant_GetTenantFlags(TenantEnv *env, jclass cls); @@ -59,5 +61,13 @@ tenant_GetTenantFlags(TenantEnv *env, jclass cls) result |= TENANT_FLAG_HEAP_ISOLATION_ENABLED; } + if (TenantCpuThrottling) { + result |= TENANT_FLAG_CPU_THROTTLING_ENABLED; + } + + if (TenantCpuAccounting) { + result |= TENANT_FLAG_CPU_ACCOUNTING_ENABLED; + } + return result; } diff --git a/src/share/vm/runtime/globals_ext.hpp b/src/share/vm/runtime/globals_ext.hpp index 6d49fd6283d1db886e0f57f0e87d02256b9e72a4..a9deb712ae27febfba3eadfa502767569a5bd61a 100644 --- a/src/share/vm/runtime/globals_ext.hpp +++ b/src/share/vm/runtime/globals_ext.hpp @@ -104,7 +104,13 @@ "Mutator may maintain multiple TLABs for each of the tenants") \ \ product(bool, TenantHeapThrottling, false, \ - "Enable heap throttling per tenant") \ + "Enable heap throttling per tenant") \ + \ + product(bool, TenantCpuThrottling, false, \ + "Enable cpu throttling per tenant") \ + \ + product(bool, TenantCpuAccounting, false, \ + "Enable cpu accounting per tenant") \ //add new AJVM specific flags here diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp index 5a3389475ce0405db9eed51d4e5c98bede690aa1..1b5f4473b140b11cf02032d7f1ad939b96c41f11 100644 --- a/src/share/vm/runtime/thread.cpp +++ b/src/share/vm/runtime/thread.cpp @@ -1078,6 +1078,16 @@ static void call_initializeTenantContainerClass(TRAPS) { vmSymbols::void_method_signature(), CHECK); } +static void call_initializeJGroupClass(TRAPS) { + assert(TenantCpuThrottling || TenantCpuAccounting, "TenantCpuThrottling or TenantCpuAccounting disabled"); + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::com_alibaba_tenant_JGroup(), true, CHECK); + instanceKlassHandle klass (THREAD, k); + + JavaValue result(T_VOID); + JavaCalls::call_static(&result, klass, vmSymbols::initializeJGroupClass_name(), + vmSymbols::void_method_signature(), CHECK); +} + char java_runtime_name[128] = ""; char java_runtime_version[128] = ""; @@ -3964,6 +3974,12 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { } } + if (MultiTenant && (TenantCpuThrottling || TenantCpuAccounting)) { + // JGroup initialization may involve complex steps + // have to do that after full JVM initialization + call_initializeJGroupClass(CHECK_0); + } + create_vm_timer.end(); #ifdef ASSERT _vm_complete = true;