Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp
40951 views
1
/*
2
* Copyright (c) 2020, Red Hat Inc.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef CGROUP_V2_SUBSYSTEM_LINUX_HPP
26
#define CGROUP_V2_SUBSYSTEM_LINUX_HPP
27
28
#include "cgroupSubsystem_linux.hpp"
29
30
class CgroupV2Controller: public CgroupController {
31
private:
32
/* the mount path of the cgroup v2 hierarchy */
33
char *_mount_path;
34
/* The cgroup path for the controller */
35
char *_cgroup_path;
36
37
/* Constructed full path to the subsystem directory */
38
char *_path;
39
static char* construct_path(char* mount_path, char *cgroup_path);
40
41
public:
42
CgroupV2Controller(char * mount_path, char *cgroup_path) {
43
_mount_path = mount_path;
44
_cgroup_path = os::strdup(cgroup_path);
45
_path = construct_path(mount_path, cgroup_path);
46
}
47
48
char *subsystem_path() { return _path; }
49
};
50
51
class CgroupV2Subsystem: public CgroupSubsystem {
52
private:
53
/* One unified controller */
54
CgroupController* _unified = NULL;
55
/* Caching wrappers for cpu/memory metrics */
56
CachingCgroupController* _memory = NULL;
57
CachingCgroupController* _cpu = NULL;
58
59
char *mem_limit_val();
60
char *mem_swp_limit_val();
61
char *mem_soft_limit_val();
62
char *cpu_quota_val();
63
jlong limit_from_str(char* limit_str);
64
65
public:
66
CgroupV2Subsystem(CgroupController * unified) {
67
_unified = unified;
68
_memory = new CachingCgroupController(unified);
69
_cpu = new CachingCgroupController(unified);
70
}
71
72
jlong read_memory_limit_in_bytes();
73
int cpu_quota();
74
int cpu_period();
75
int cpu_shares();
76
jlong memory_and_swap_limit_in_bytes();
77
jlong memory_soft_limit_in_bytes();
78
jlong memory_usage_in_bytes();
79
jlong memory_max_usage_in_bytes();
80
char * cpu_cpuset_cpus();
81
char * cpu_cpuset_memory_nodes();
82
const char * container_type() {
83
return "cgroupv2";
84
}
85
CachingCgroupController * memory_controller() { return _memory; }
86
CachingCgroupController * cpu_controller() { return _cpu; }
87
};
88
89
#endif // CGROUP_V2_SUBSYSTEM_LINUX_HPP
90
91