cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

cgroup_util.h (2637B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#include <stdbool.h>
      3#include <stdlib.h>
      4
      5#include "../kselftest.h"
      6
      7#define PAGE_SIZE 4096
      8
      9#define MB(x) (x << 20)
     10
     11#define USEC_PER_SEC	1000000L
     12#define NSEC_PER_SEC	1000000000L
     13
     14/*
     15 * Checks if two given values differ by less than err% of their sum.
     16 */
     17static inline int values_close(long a, long b, int err)
     18{
     19	return abs(a - b) <= (a + b) / 100 * err;
     20}
     21
     22extern int cg_find_unified_root(char *root, size_t len);
     23extern char *cg_name(const char *root, const char *name);
     24extern char *cg_name_indexed(const char *root, const char *name, int index);
     25extern char *cg_control(const char *cgroup, const char *control);
     26extern int cg_create(const char *cgroup);
     27extern int cg_destroy(const char *cgroup);
     28extern int cg_read(const char *cgroup, const char *control,
     29		   char *buf, size_t len);
     30extern int cg_read_strcmp(const char *cgroup, const char *control,
     31			  const char *expected);
     32extern int cg_read_strstr(const char *cgroup, const char *control,
     33			  const char *needle);
     34extern long cg_read_long(const char *cgroup, const char *control);
     35long cg_read_key_long(const char *cgroup, const char *control, const char *key);
     36extern long cg_read_lc(const char *cgroup, const char *control);
     37extern int cg_write(const char *cgroup, const char *control, char *buf);
     38int cg_write_numeric(const char *cgroup, const char *control, long value);
     39extern int cg_run(const char *cgroup,
     40		  int (*fn)(const char *cgroup, void *arg),
     41		  void *arg);
     42extern int cg_enter(const char *cgroup, int pid);
     43extern int cg_enter_current(const char *cgroup);
     44extern int cg_enter_current_thread(const char *cgroup);
     45extern int cg_run_nowait(const char *cgroup,
     46			 int (*fn)(const char *cgroup, void *arg),
     47			 void *arg);
     48extern int get_temp_fd(void);
     49extern int alloc_pagecache(int fd, size_t size);
     50extern int alloc_anon(const char *cgroup, void *arg);
     51extern int is_swap_enabled(void);
     52extern int set_oom_adj_score(int pid, int score);
     53extern int cg_wait_for_proc_count(const char *cgroup, int count);
     54extern int cg_killall(const char *cgroup);
     55int proc_mount_contains(const char *option);
     56extern ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size);
     57extern int proc_read_strstr(int pid, bool thread, const char *item, const char *needle);
     58extern pid_t clone_into_cgroup(int cgroup_fd);
     59extern int clone_reap(pid_t pid, int options);
     60extern int clone_into_cgroup_run_wait(const char *cgroup);
     61extern int dirfd_open_opath(const char *dir);
     62extern int cg_prepare_for_wait(const char *cgroup);
     63extern int memcg_prepare_for_wait(const char *cgroup);
     64extern int cg_wait_for(int fd);