![]() |
MySQL 9.5.0
Source Code Documentation
|
Functions to retrieve total physical memory and total number of logical CPUs available to the server by reading the limits set by cgroups. More...
#include <cassert>#include <climits>#include <cstdint>#include <fstream>#include <optional>#include <string_view>#include "my_config.h"#include "my_system_api.h"#include <unistd.h>Namespaces | |
| namespace | anonymous_namespace{my_system_api_cgroup.cc} |
Functions | |
| template<typename... Args> | |
| bool | anonymous_namespace{my_system_api_cgroup.cc}::read_line_from_file (const std::string_view &path, Args &...args) |
| Utility: Read the first line from the file specified in path and copy its contents into the arguments passed. More... | |
| std::optional< uint32_t > | anonymous_namespace{my_system_api_cgroup.cc}::cgroup_v1_cpu () |
| Read CPU limits as if it were set by cgroup v1. More... | |
| std::optional< uint64_t > | anonymous_namespace{my_system_api_cgroup.cc}::cgroup_v1_memory () |
| Read memory limits as if it were set by cgroup v1. More... | |
| std::optional< uint32_t > | anonymous_namespace{my_system_api_cgroup.cc}::cgroup_v2_cpu () |
| Read CPU limits as if it were set by cgroup v2. More... | |
| std::optional< uint64_t > | anonymous_namespace{my_system_api_cgroup.cc}::cgroup_v2_memory () |
| Read Memory limits as if it were set by cgroup v2. More... | |
| uint64_t | my_cgroup_mem_limit () |
| Read the memory limit set by the container. More... | |
| uint32_t | my_cgroup_vcpu_limit () |
| Read the CPU limit set by the container. More... | |
Variables | |
| constexpr std::string_view | anonymous_namespace{my_system_api_cgroup.cc}::quota_path {"/sys/fs/cgroup/cpu/cpu.cfs_quota_us"} |
| cgroup v1 path to file containing CPU quota More... | |
| constexpr std::string_view | anonymous_namespace{my_system_api_cgroup.cc}::period_path {"/sys/fs/cgroup/cpu/cpu.cfs_period_us"} |
| cgroup v1 path to file containing CPU period More... | |
| constexpr std::string_view | anonymous_namespace{my_system_api_cgroup.cc}::mem_path_v1 |
| cgroup v1 path to file containing Memory limits More... | |
| constexpr std::string_view | anonymous_namespace{my_system_api_cgroup.cc}::cpu_path_v2 {"/sys/fs/cgroup/cpu.max"} |
| cgroup v2 path to file containing CPU limts More... | |
| constexpr std::string_view | anonymous_namespace{my_system_api_cgroup.cc}::mem_path_v2 {"/sys/fs/cgroup/memory.max"} |
| cgroup v2 path to file containing Memory limits More... | |
Functions to retrieve total physical memory and total number of logical CPUs available to the server by reading the limits set by cgroups.
| uint64_t my_cgroup_mem_limit | ( | ) |
Read the memory limit set by the container.
Try cgroup v2, and then cgroup v1
| uint32_t my_cgroup_vcpu_limit | ( | ) |
Read the CPU limit set by the container.
Try cgroup v2, and then cgroup v1