core: always enable CPU accounting; cgtop: drop cgv1 handling (#37448)
This commit is contained in:
@@ -2181,57 +2181,6 @@ static const char *const cgroup_controller_table[_CGROUP_CONTROLLER_MAX] = {
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(cgroup_controller, CGroupController);
|
||||
|
||||
CGroupMask get_cpu_accounting_mask(void) {
|
||||
static CGroupMask needed_mask = (CGroupMask) -1;
|
||||
|
||||
/* On kernel ≥4.15 with unified hierarchy, cpu.stat's usage_usec is
|
||||
* provided externally from the CPU controller, which means we don't
|
||||
* need to enable the CPU controller just to get metrics. This is good,
|
||||
* because enabling the CPU controller comes at a minor performance
|
||||
* hit, especially when it's propagated deep into large hierarchies.
|
||||
* There's also no separate CPU accounting controller available within
|
||||
* a unified hierarchy.
|
||||
*
|
||||
* This combination of factors results in the desired cgroup mask to
|
||||
* enable for CPU accounting varying as follows:
|
||||
*
|
||||
* ╔═════════════════════╤═════════════════════╗
|
||||
* ║ Linux ≥4.15 │ Linux <4.15 ║
|
||||
* ╔═══════════════╬═════════════════════╪═════════════════════╣
|
||||
* ║ Unified ║ nothing │ CGROUP_MASK_CPU ║
|
||||
* ╟───────────────╫─────────────────────┼─────────────────────╢
|
||||
* ║ Hybrid/Legacy ║ CGROUP_MASK_CPUACCT │ CGROUP_MASK_CPUACCT ║
|
||||
* ╚═══════════════╩═════════════════════╧═════════════════════╝
|
||||
*
|
||||
* We check kernel version here instead of manually checking whether
|
||||
* cpu.stat is present for every cgroup, as that check in itself would
|
||||
* already be fairly expensive.
|
||||
*
|
||||
* Kernels where this patch has been backported will therefore have the
|
||||
* CPU controller enabled unnecessarily. This is more expensive than
|
||||
* necessary, but harmless. ☺️
|
||||
*/
|
||||
|
||||
if (needed_mask == (CGroupMask) -1) {
|
||||
if (cg_all_unified()) {
|
||||
struct utsname u;
|
||||
assert_se(uname(&u) >= 0);
|
||||
|
||||
if (strverscmp_improved(u.release, "4.15") < 0)
|
||||
needed_mask = CGROUP_MASK_CPU;
|
||||
else
|
||||
needed_mask = 0;
|
||||
} else
|
||||
needed_mask = CGROUP_MASK_CPUACCT;
|
||||
}
|
||||
|
||||
return needed_mask;
|
||||
}
|
||||
|
||||
bool cpu_accounting_is_cheap(void) {
|
||||
return get_cpu_accounting_mask() == 0;
|
||||
}
|
||||
|
||||
static const char* const managed_oom_mode_table[_MANAGED_OOM_MODE_MAX] = {
|
||||
[MANAGED_OOM_AUTO] = "auto",
|
||||
[MANAGED_OOM_KILL] = "kill",
|
||||
|
||||
@@ -86,9 +86,6 @@ static inline CGroupMask CGROUP_MASK_EXTEND_JOINED(CGroupMask mask) {
|
||||
return mask;
|
||||
}
|
||||
|
||||
CGroupMask get_cpu_accounting_mask(void);
|
||||
bool cpu_accounting_is_cheap(void);
|
||||
|
||||
/* Special values for all weight knobs on unified hierarchy */
|
||||
#define CGROUP_WEIGHT_INVALID UINT64_MAX
|
||||
#define CGROUP_WEIGHT_IDLE UINT64_C(0)
|
||||
|
||||
Reference in New Issue
Block a user