mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-26 04:25:27 +08:00
2a42461a88
Add remove_cgroup() to remove a cgroup which doesn't have any children or live processes. It will be used by the following patch to test cgroup iterator on a dead cgroup. Signed-off-by: Hou Tao <houtao1@huawei.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20221121073440.1828292-3-houtao@huaweicloud.com
38 lines
1.2 KiB
C
38 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __CGROUP_HELPERS_H
|
|
#define __CGROUP_HELPERS_H
|
|
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
#define clean_errno() (errno == 0 ? "None" : strerror(errno))
|
|
#define log_err(MSG, ...) fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \
|
|
__FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
|
|
|
|
/* cgroupv2 related */
|
|
int enable_controllers(const char *relative_path, const char *controllers);
|
|
int write_cgroup_file(const char *relative_path, const char *file,
|
|
const char *buf);
|
|
int write_cgroup_file_parent(const char *relative_path, const char *file,
|
|
const char *buf);
|
|
int cgroup_setup_and_join(const char *relative_path);
|
|
int get_root_cgroup(void);
|
|
int create_and_get_cgroup(const char *relative_path);
|
|
void remove_cgroup(const char *relative_path);
|
|
unsigned long long get_cgroup_id(const char *relative_path);
|
|
|
|
int join_cgroup(const char *relative_path);
|
|
int join_parent_cgroup(const char *relative_path);
|
|
|
|
int setup_cgroup_environment(void);
|
|
void cleanup_cgroup_environment(void);
|
|
|
|
/* cgroupv1 related */
|
|
int set_classid(unsigned int id);
|
|
int join_classid(void);
|
|
|
|
int setup_classid_environment(void);
|
|
void cleanup_classid_environment(void);
|
|
|
|
#endif /* __CGROUP_HELPERS_H */
|