Loading arch/x86/include/uapi/asm/kvm.h +1 −0 Original line number Diff line number Diff line Loading @@ -845,6 +845,7 @@ struct kvm_sev_snp_launch_start { }; /* Kept in sync with firmware values for simplicity. */ #define KVM_SEV_PAGE_TYPE_INVALID 0x0 #define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1 #define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3 #define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4 Loading tools/arch/x86/include/uapi/asm/kvm.h +1 −0 Original line number Diff line number Diff line Loading @@ -844,6 +844,7 @@ struct kvm_sev_snp_launch_start { }; /* Kept in sync with firmware values for simplicity. */ #define KVM_SEV_PAGE_TYPE_INVALID 0x0 #define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1 #define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3 #define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4 Loading tools/testing/selftests/cgroup/Makefile +11 −10 Original line number Diff line number Diff line Loading @@ -21,14 +21,15 @@ TEST_GEN_PROGS += test_zswap LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h include ../lib.mk include lib/libcgroup.mk $(OUTPUT)/test_core: cgroup_util.c $(OUTPUT)/test_cpu: cgroup_util.c $(OUTPUT)/test_cpuset: cgroup_util.c $(OUTPUT)/test_freezer: cgroup_util.c $(OUTPUT)/test_hugetlb_memcg: cgroup_util.c $(OUTPUT)/test_kill: cgroup_util.c $(OUTPUT)/test_kmem: cgroup_util.c $(OUTPUT)/test_memcontrol: cgroup_util.c $(OUTPUT)/test_pids: cgroup_util.c $(OUTPUT)/test_zswap: cgroup_util.c $(OUTPUT)/test_core: $(LIBCGROUP_O) $(OUTPUT)/test_cpu: $(LIBCGROUP_O) $(OUTPUT)/test_cpuset: $(LIBCGROUP_O) $(OUTPUT)/test_freezer: $(LIBCGROUP_O) $(OUTPUT)/test_hugetlb_memcg: $(LIBCGROUP_O) $(OUTPUT)/test_kill: $(LIBCGROUP_O) $(OUTPUT)/test_kmem: $(LIBCGROUP_O) $(OUTPUT)/test_memcontrol: $(LIBCGROUP_O) $(OUTPUT)/test_pids: $(LIBCGROUP_O) $(OUTPUT)/test_zswap: $(LIBCGROUP_O) tools/testing/selftests/cgroup/cgroup_util.c→tools/testing/selftests/cgroup/lib/cgroup_util.c +30 −88 Original line number Diff line number Diff line Loading @@ -17,10 +17,10 @@ #include <unistd.h> #include "cgroup_util.h" #include "../clone3/clone3_selftests.h" #include "../../clone3/clone3_selftests.h" /* Returns read len on success, or -errno on failure. */ static ssize_t read_text(const char *path, char *buf, size_t max_len) ssize_t read_text(const char *path, char *buf, size_t max_len) { ssize_t len; int fd; Loading @@ -39,7 +39,7 @@ static ssize_t read_text(const char *path, char *buf, size_t max_len) } /* Returns written len on success, or -errno on failure. */ static ssize_t write_text(const char *path, char *buf, ssize_t len) ssize_t write_text(const char *path, char *buf, ssize_t len) { int fd; Loading Loading @@ -217,7 +217,8 @@ int cg_write_numeric(const char *cgroup, const char *control, long value) return cg_write(cgroup, control, buf); } int cg_find_unified_root(char *root, size_t len, bool *nsdelegate) static int cg_find_root(char *root, size_t len, const char *controller, bool *nsdelegate) { char buf[10 * PAGE_SIZE]; char *fs, *mount, *type, *options; Loading @@ -236,18 +237,37 @@ int cg_find_unified_root(char *root, size_t len, bool *nsdelegate) options = strtok(NULL, delim); strtok(NULL, delim); strtok(NULL, delim); if (strcmp(type, "cgroup2") == 0) { if (strcmp(type, "cgroup") == 0) { if (!controller || !strstr(options, controller)) continue; } else if (strcmp(type, "cgroup2") == 0) { if (controller && cg_read_strstr(mount, "cgroup.controllers", controller)) continue; } else { continue; } strncpy(root, mount, len); if (nsdelegate) *nsdelegate = !!strstr(options, "nsdelegate"); return 0; } } return -1; } int cg_find_controller_root(char *root, size_t len, const char *controller) { return cg_find_root(root, len, controller, NULL); } int cg_find_unified_root(char *root, size_t len, bool *nsdelegate) { return cg_find_root(root, len, NULL, nsdelegate); } int cg_create(const char *cgroup) { return mkdir(cgroup, 0755); Loading Loading @@ -488,84 +508,6 @@ int cg_run_nowait(const char *cgroup, return pid; } int get_temp_fd(void) { return open(".", O_TMPFILE | O_RDWR | O_EXCL); } int alloc_pagecache(int fd, size_t size) { char buf[PAGE_SIZE]; struct stat st; int i; if (fstat(fd, &st)) goto cleanup; size += st.st_size; if (ftruncate(fd, size)) goto cleanup; for (i = 0; i < size; i += sizeof(buf)) read(fd, buf, sizeof(buf)); return 0; cleanup: return -1; } int alloc_anon(const char *cgroup, void *arg) { size_t size = (unsigned long)arg; char *buf, *ptr; buf = malloc(size); for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE) *ptr = 0; free(buf); return 0; } int is_swap_enabled(void) { char buf[PAGE_SIZE]; const char delim[] = "\n"; int cnt = 0; char *line; if (read_text("/proc/swaps", buf, sizeof(buf)) <= 0) return -1; for (line = strtok(buf, delim); line; line = strtok(NULL, delim)) cnt++; return cnt > 1; } int set_oom_adj_score(int pid, int score) { char path[PATH_MAX]; int fd, len; sprintf(path, "/proc/%d/oom_score_adj", pid); fd = open(path, O_WRONLY | O_APPEND); if (fd < 0) return fd; len = dprintf(fd, "%d", score); if (len < 0) { close(fd); return len; } close(fd); return 0; } int proc_mount_contains(const char *option) { char buf[4 * PAGE_SIZE]; Loading tools/testing/selftests/cgroup/cgroup_util.h→tools/testing/selftests/cgroup/lib/include/cgroup_util.h +6 −7 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ #include <stdbool.h> #include <stdlib.h> #include "../kselftest.h" #ifndef PAGE_SIZE #define PAGE_SIZE 4096 #endif #define MB(x) (x << 20) Loading @@ -21,6 +21,10 @@ static inline int values_close(long a, long b, int err) return labs(a - b) <= (a + b) / 100 * err; } extern ssize_t read_text(const char *path, char *buf, size_t max_len); extern ssize_t write_text(const char *path, char *buf, ssize_t len); extern int cg_find_controller_root(char *root, size_t len, const char *controller); extern int cg_find_unified_root(char *root, size_t len, bool *nsdelegate); extern char *cg_name(const char *root, const char *name); extern char *cg_name_indexed(const char *root, const char *name, int index); Loading Loading @@ -49,11 +53,6 @@ extern int cg_enter_current_thread(const char *cgroup); extern int cg_run_nowait(const char *cgroup, int (*fn)(const char *cgroup, void *arg), void *arg); extern int get_temp_fd(void); extern int alloc_pagecache(int fd, size_t size); extern int alloc_anon(const char *cgroup, void *arg); extern int is_swap_enabled(void); extern int set_oom_adj_score(int pid, int score); extern int cg_wait_for_proc_count(const char *cgroup, int count); extern int cg_killall(const char *cgroup); int proc_mount_contains(const char *option); Loading Loading
arch/x86/include/uapi/asm/kvm.h +1 −0 Original line number Diff line number Diff line Loading @@ -845,6 +845,7 @@ struct kvm_sev_snp_launch_start { }; /* Kept in sync with firmware values for simplicity. */ #define KVM_SEV_PAGE_TYPE_INVALID 0x0 #define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1 #define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3 #define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4 Loading
tools/arch/x86/include/uapi/asm/kvm.h +1 −0 Original line number Diff line number Diff line Loading @@ -844,6 +844,7 @@ struct kvm_sev_snp_launch_start { }; /* Kept in sync with firmware values for simplicity. */ #define KVM_SEV_PAGE_TYPE_INVALID 0x0 #define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1 #define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3 #define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4 Loading
tools/testing/selftests/cgroup/Makefile +11 −10 Original line number Diff line number Diff line Loading @@ -21,14 +21,15 @@ TEST_GEN_PROGS += test_zswap LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h include ../lib.mk include lib/libcgroup.mk $(OUTPUT)/test_core: cgroup_util.c $(OUTPUT)/test_cpu: cgroup_util.c $(OUTPUT)/test_cpuset: cgroup_util.c $(OUTPUT)/test_freezer: cgroup_util.c $(OUTPUT)/test_hugetlb_memcg: cgroup_util.c $(OUTPUT)/test_kill: cgroup_util.c $(OUTPUT)/test_kmem: cgroup_util.c $(OUTPUT)/test_memcontrol: cgroup_util.c $(OUTPUT)/test_pids: cgroup_util.c $(OUTPUT)/test_zswap: cgroup_util.c $(OUTPUT)/test_core: $(LIBCGROUP_O) $(OUTPUT)/test_cpu: $(LIBCGROUP_O) $(OUTPUT)/test_cpuset: $(LIBCGROUP_O) $(OUTPUT)/test_freezer: $(LIBCGROUP_O) $(OUTPUT)/test_hugetlb_memcg: $(LIBCGROUP_O) $(OUTPUT)/test_kill: $(LIBCGROUP_O) $(OUTPUT)/test_kmem: $(LIBCGROUP_O) $(OUTPUT)/test_memcontrol: $(LIBCGROUP_O) $(OUTPUT)/test_pids: $(LIBCGROUP_O) $(OUTPUT)/test_zswap: $(LIBCGROUP_O)
tools/testing/selftests/cgroup/cgroup_util.c→tools/testing/selftests/cgroup/lib/cgroup_util.c +30 −88 Original line number Diff line number Diff line Loading @@ -17,10 +17,10 @@ #include <unistd.h> #include "cgroup_util.h" #include "../clone3/clone3_selftests.h" #include "../../clone3/clone3_selftests.h" /* Returns read len on success, or -errno on failure. */ static ssize_t read_text(const char *path, char *buf, size_t max_len) ssize_t read_text(const char *path, char *buf, size_t max_len) { ssize_t len; int fd; Loading @@ -39,7 +39,7 @@ static ssize_t read_text(const char *path, char *buf, size_t max_len) } /* Returns written len on success, or -errno on failure. */ static ssize_t write_text(const char *path, char *buf, ssize_t len) ssize_t write_text(const char *path, char *buf, ssize_t len) { int fd; Loading Loading @@ -217,7 +217,8 @@ int cg_write_numeric(const char *cgroup, const char *control, long value) return cg_write(cgroup, control, buf); } int cg_find_unified_root(char *root, size_t len, bool *nsdelegate) static int cg_find_root(char *root, size_t len, const char *controller, bool *nsdelegate) { char buf[10 * PAGE_SIZE]; char *fs, *mount, *type, *options; Loading @@ -236,18 +237,37 @@ int cg_find_unified_root(char *root, size_t len, bool *nsdelegate) options = strtok(NULL, delim); strtok(NULL, delim); strtok(NULL, delim); if (strcmp(type, "cgroup2") == 0) { if (strcmp(type, "cgroup") == 0) { if (!controller || !strstr(options, controller)) continue; } else if (strcmp(type, "cgroup2") == 0) { if (controller && cg_read_strstr(mount, "cgroup.controllers", controller)) continue; } else { continue; } strncpy(root, mount, len); if (nsdelegate) *nsdelegate = !!strstr(options, "nsdelegate"); return 0; } } return -1; } int cg_find_controller_root(char *root, size_t len, const char *controller) { return cg_find_root(root, len, controller, NULL); } int cg_find_unified_root(char *root, size_t len, bool *nsdelegate) { return cg_find_root(root, len, NULL, nsdelegate); } int cg_create(const char *cgroup) { return mkdir(cgroup, 0755); Loading Loading @@ -488,84 +508,6 @@ int cg_run_nowait(const char *cgroup, return pid; } int get_temp_fd(void) { return open(".", O_TMPFILE | O_RDWR | O_EXCL); } int alloc_pagecache(int fd, size_t size) { char buf[PAGE_SIZE]; struct stat st; int i; if (fstat(fd, &st)) goto cleanup; size += st.st_size; if (ftruncate(fd, size)) goto cleanup; for (i = 0; i < size; i += sizeof(buf)) read(fd, buf, sizeof(buf)); return 0; cleanup: return -1; } int alloc_anon(const char *cgroup, void *arg) { size_t size = (unsigned long)arg; char *buf, *ptr; buf = malloc(size); for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE) *ptr = 0; free(buf); return 0; } int is_swap_enabled(void) { char buf[PAGE_SIZE]; const char delim[] = "\n"; int cnt = 0; char *line; if (read_text("/proc/swaps", buf, sizeof(buf)) <= 0) return -1; for (line = strtok(buf, delim); line; line = strtok(NULL, delim)) cnt++; return cnt > 1; } int set_oom_adj_score(int pid, int score) { char path[PATH_MAX]; int fd, len; sprintf(path, "/proc/%d/oom_score_adj", pid); fd = open(path, O_WRONLY | O_APPEND); if (fd < 0) return fd; len = dprintf(fd, "%d", score); if (len < 0) { close(fd); return len; } close(fd); return 0; } int proc_mount_contains(const char *option) { char buf[4 * PAGE_SIZE]; Loading
tools/testing/selftests/cgroup/cgroup_util.h→tools/testing/selftests/cgroup/lib/include/cgroup_util.h +6 −7 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ #include <stdbool.h> #include <stdlib.h> #include "../kselftest.h" #ifndef PAGE_SIZE #define PAGE_SIZE 4096 #endif #define MB(x) (x << 20) Loading @@ -21,6 +21,10 @@ static inline int values_close(long a, long b, int err) return labs(a - b) <= (a + b) / 100 * err; } extern ssize_t read_text(const char *path, char *buf, size_t max_len); extern ssize_t write_text(const char *path, char *buf, ssize_t len); extern int cg_find_controller_root(char *root, size_t len, const char *controller); extern int cg_find_unified_root(char *root, size_t len, bool *nsdelegate); extern char *cg_name(const char *root, const char *name); extern char *cg_name_indexed(const char *root, const char *name, int index); Loading Loading @@ -49,11 +53,6 @@ extern int cg_enter_current_thread(const char *cgroup); extern int cg_run_nowait(const char *cgroup, int (*fn)(const char *cgroup, void *arg), void *arg); extern int get_temp_fd(void); extern int alloc_pagecache(int fd, size_t size); extern int alloc_anon(const char *cgroup, void *arg); extern int is_swap_enabled(void); extern int set_oom_adj_score(int pid, int score); extern int cg_wait_for_proc_count(const char *cgroup, int count); extern int cg_killall(const char *cgroup); int proc_mount_contains(const char *option); Loading