Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/testing/selftests/powerpc/tm/tm-signal-stack.c
int tm_signal_stack() { int pid; SKIP_IF(!have_htm()); SKIP_IF(htm_is_synthetic()); pid = fork(); if (pid < 0) exit(1); if (pid) { /* * It's likely the whole machine will crash here so if * the child ever exits, we are good. */ wait(NULL); return 0; } /* * The flow ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/tm/tm-sigreturn.c
int main(void) { return test_harness(tm_sigreturn, "tm_sigreturn"); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/tm/tm-syscall.c
int tm_syscall(void) { unsigned count = 0; struct timeval end, now; SKIP_IF(!have_htm_nosc()); SKIP_IF(htm_is_synthetic()); setbuf(stdout, NULL); printf("Testing transactional syscalls for %d seconds...\n", TEST_DURATION); gettimeofday(&end, NULL); now.tv_sec = TEST_DURATION; now.tv_usec = 0; ti...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/tm/tm-tar.c
int main(int argc, char *argv[]) { if (argc > 1) { if (strcmp(argv[1], "-h") == 0) { printf("Syntax:\n\t%s [<num loops>]\n", argv[0]); return 1; } else { num_loops = atoi(argv[1]); } } printf("Starting, %d loops\n", num_loops); return test_harness(test_tar, "tm_tar"); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/tm/tm-tmspr.c
int test_tmspr() { pthread_t *thread; int thread_num; unsigned long i; SKIP_IF(!have_htm()); SKIP_IF(htm_is_synthetic()); thread_num = 10 * sysconf(_SC_NPROCESSORS_ONLN); thread = malloc(thread_num * sizeof(pthread_t)); if (thread == NULL) return EXIT_FAILURE; /* Test TFIAR and TFHAR */ for ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/tm/tm.h
static inline bool failure_is_nesting(void) { return (__builtin_get_texasru() & 0x400000); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/utils.c
int pick_online_cpu(void) { int ncpus, cpu = -1; cpu_set_t *mask; size_t size; ncpus = get_nprocs_conf(); size = CPU_ALLOC_SIZE(ncpus); mask = CPU_ALLOC(ncpus); if (!mask) { perror("malloc"); return -1; } CPU_ZERO_S(size, mask); if (sched_getaffinity(0, size, mask)) { perror("sched_ge...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/utils.c
bool is_ppc64le(void) { struct utsname uts; int rc; errno = 0; rc = uname(&uts); if (rc) { perror("uname"); return false; } return strcmp(uts.machine, "ppc64le") == 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/utils.c
int read_sysfs_file(char *fpath, char *result, size_t result_size) { char path[PATH_MAX] = "/sys/"; int rc = -1, fd; strncat(path, fpath, PATH_MAX - strlen(path) - 1); if ((fd = open(path, O_RDONLY)) < 0) return rc; rc = read(fd, result, result_size); close(fd); if (rc < 0) return rc; ret...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/powerpc/vphn/test-vphn.c
static int test_vphn(void) { static struct test *test; for (test = all_tests; test->descr; test++) { int ret; ret = test_one(test); test_finish(test->descr, ret); if (ret) return ret; } return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c
static void sigsegv_fail(int sig) { fprintf(stderr, "FATAL ERROR, rdtsc() failed while enabled\n"); exit(0); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/prctl/disable-tsc-on-off-stress-test.c
static uint64_t rdtsc(void) { uint32_t lo, hi; __asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); return (uint64_t)hi << 32 | lo; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/prctl/disable-tsc-test.c
static uint64_t rdtsc(void) { uint32_t lo, hi; __asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); return (uint64_t)hi << 32 | lo; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/fd-001-lookup.c
static void test_lookup_pass(const char *pathname) { struct stat st; ssize_t rv; memset(&st, 0, sizeof(struct stat)); rv = lstat(pathname, &st); assert(rv == 0); assert(S_ISLNK(st.st_mode)); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/fd-001-lookup.c
static void test_lookup_fail(const char *pathname) { struct stat st; ssize_t rv; rv = lstat(pathname, &st); assert(rv == -1 && errno == ENOENT); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/fd-002-posix-eq.c
int main(void) { int fd0, fd1, fd2; struct stat st0, st1, st2; char buf[64]; int rv; fd0 = open("/", O_DIRECTORY | O_RDONLY); assert(fd0 >= 0); snprintf(buf, sizeof(buf), "/proc/self/fd/%u", fd0); fd1 = open(buf, O_RDONLY); assert(fd1 >= 0); snprintf(buf, sizeof(buf), "/proc/thread-self/fd/%u", ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/fd-003-kthread.c
static void test_readdir(int fd) { DIR *d; struct dirent *de; d = fdopendir(fd); assert(d); de = xreaddir(d); assert(streq(de->d_name, ".")); assert(de->d_type == DT_DIR); de = xreaddir(d); assert(streq(de->d_name, "..")); assert(de->d_type == DT_DIR); de = xreaddir(d); assert(!de); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-empty-vm.c
static int test_proc_pid_maps(pid_t pid) { char buf[4096]; snprintf(buf, sizeof(buf), "/proc/%u/maps", pid); int fd = open(buf, O_RDONLY); if (fd == -1) { perror("open /proc/${pid}/maps"); return EXIT_FAILURE; } else { ssize_t rv = read(fd, buf, sizeof(buf)); close(fd); if (g_vsyscall == ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-empty-vm.c
static int test_proc_pid_smaps(pid_t pid) { char buf[4096]; snprintf(buf, sizeof(buf), "/proc/%u/smaps", pid); int fd = open(buf, O_RDONLY); if (fd == -1) { if (errno == ENOENT) { return EXIT_SUCCESS; } perror("open /proc/${pid}/smaps"); return EXIT_FAILURE; } else { ssize_t rv = re...
[ 1, 1 ]
Linux Kernel
tools/testing/selftests/proc/proc-fsconfig-hidepid.c
static inline int fsopen(const char *fsname, unsigned int flags) { return syscall(__NR_fsopen, fsname, flags); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-fsconfig-hidepid.c
int main(void) { int fsfd, ret; int hidepid = 2; assert((fsfd = fsopen("proc", 0)) != -1); ret = fsconfig(fsfd, FSCONFIG_SET_BINARY, "hidepid", &hidepid, 0); assert(ret == -1); assert(errno == EINVAL); assert(!fsconfig(fsfd, FSCONFIG_SET_STRING, "hidepid", "2", 0)); assert(!fsconfig(fsfd, FSCONFIG_S...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-pid-vm.c
static inline long sys_execveat(int dirfd, const char *pathname, char **argv, char **envp, int flags) { return syscall(SYS_execveat, dirfd, pathname, argv, envp, flags); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-pid-vm.c
static void make_private_tmp(void) { if (unshare(CLONE_NEWNS) == -1) { if (errno == ENOSYS || errno == EPERM) { exit(4); } exit(1); } if (mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL) == -1) { exit(1); } if (mount(NULL, "/tmp", "tmpfs", 0, NULL) == -1) { exit(1); } }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-pid-vm.c
static void vsyscall(void) { pid_t pid; int wstatus; pid = fork(); if (pid < 0) { fprintf(stderr, "fork, errno %d\n", errno); exit(1); } if (pid == 0) { struct rlimit rlim = {0, 0}; (void)setrlimit(RLIMIT_CORE, &rlim); struct sigaction act; memset(&act, 0, sizeof(struct sigaction))...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-self-map-files-001.c
static void pass(const char *fmt, unsigned long a, unsigned long b) { char name[64]; char buf[64]; snprintf(name, sizeof(name), fmt, a, b); if (readlink(name, buf, sizeof(buf)) == -1) exit(1); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-self-map-files-002.c
int main(void) { const int PAGE_SIZE = sysconf(_SC_PAGESIZE); const unsigned long va_max = 1UL << 20; unsigned long va; void *p; int fd; unsigned long a, b; fd = open("/dev/zero", O_RDONLY); if (fd == -1) return 1; for (va = 0; va < va_max; va += PAGE_SIZE) { p = mmap((void *)va, PAGE_SIZE,...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-self-syscall.c
int main(void) { char buf1[64]; char buf2[64]; int fd; ssize_t rv; fd = open("/proc/self/syscall", O_RDONLY); if (fd == -1) { if (errno == ENOENT) return 4; return 1; } snprintf(buf1, sizeof(buf1), "%ld 0x%lx 0x%lx 0x%lx", (long)SYS_read, (long)fd, (long)buf2, (long)sizeof(buf...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-self-wchan.c
int main(void) { char buf[64]; int fd; fd = open("/proc/self/wchan", O_RDONLY); if (fd == -1) { if (errno == ENOENT) return 4; return 1; } buf[0] = '\0'; if (read(fd, buf, sizeof(buf)) != 1) return 1; if (buf[0] != '0') return 1; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-subset-pid.c
static void make_private_proc(void) { if (unshare(CLONE_NEWNS) == -1) { if (errno == ENOSYS || errno == EPERM) { exit(4); } exit(1); } if (mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL) == -1) { exit(1); } if (mount(NULL, "/proc", "proc", 0, "subset=pid") == -1) { exit(1); } }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-tid0.c
static void atexit_hook(void) { if (pid > 0) { kill(pid, SIGKILL); } }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-tid0.c
int main(void) { pid = fork(); if (pid == 0) { while (1) { pthread_t pth; pthread_create(&pth, NULL, f, NULL); pthread_join(pth, NULL); } } else if (pid > 0) { /* parent */ atexit(atexit_hook); char buf[64]; snprintf(buf, sizeof(buf), "/proc/%u/task", pid); signal(...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-uptime-001.c
int main(void) { uint64_t start, u0, u1, i0, i1; int fd; fd = open("/proc/uptime", O_RDONLY); assert(fd >= 0); proc_uptime(fd, &u0, &i0); start = u0; do { proc_uptime(fd, &u1, &i1); assert(u1 >= u0); assert(i1 >= i0); u0 = u1; i0 = i1; } while (u1 - start < 100); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-uptime-002.c
static inline int sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long *m) { return syscall(SYS_sched_getaffinity, pid, len, m); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-uptime-002.c
static inline int sys_sched_setaffinity(pid_t pid, unsigned int len, unsigned long *m) { return syscall(SYS_sched_setaffinity, pid, len, m); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/proc/proc-uptime.h
static void proc_uptime(int fd, uint64_t *uptime, uint64_t *idle) { uint64_t val1, val2; char buf[64], *p; ssize_t rv; memset(buf, 0, sizeof(buf)); rv = pread(fd, buf, sizeof(buf), 0); assert(0 <= rv && rv <= sizeof(buf)); buf[sizeof(buf) - 1] = '\0'; p = buf; val1 = xstrtoull(p, &p); assert(p[0]...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/proc/read.c
static void f_reg(DIR *d, const char *filename) { char buf[4096]; int fd; ssize_t rv; fd = openat(dirfd(d), filename, O_RDONLY | O_NONBLOCK); if (fd == -1) return; /* struct proc_ops::proc_lseek is mandatory if file is seekable. */ (void)lseek(fd, 0, SEEK_SET); rv = read(fd, buf, sizeof(buf)); as...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/ptp/testptp.c
static void usage(char *progname) { fprintf( stderr, "usage: %s [options]\n" " -c query the ptp clock's capabilities\n" " -d name device to open\n" " -e val read 'val' external time stamp events\n" " -f val adjust the ptp clock frequency by 'val' ppb\n" " ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/ptrace/get_syscall_info.c
static int kill_tracee(pid_t pid) { if (!pid) return 0; int saved_errno = errno; int rc = kill(pid, SIGKILL); errno = saved_errno; return rc; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/ptrace/get_syscall_info.c
static long sys_ptrace(int request, pid_t pid, unsigned long addr, unsigned long data) { return syscall(__NR_ptrace, request, pid, addr, data); } #define LOG_KILL_TRACEE(fmt, ...) \ do { ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/ptrace/peeksiginfo.c
static int sys_rt_sigqueueinfo(pid_t tgid, int sig, siginfo_t *uinfo) { return syscall(SYS_rt_sigqueueinfo, tgid, sig, uinfo); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/ptrace/peeksiginfo.c
static int sys_rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *uinfo) { return syscall(SYS_rt_tgsigqueueinfo, tgid, tid, sig, uinfo); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/ptrace/vmaccess.c
static void *thread(void *arg) { ptrace(PTRACE_TRACEME, 0, 0L, 0L); return NULL; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/locks.h
static inline bool lock_impl_trylock(struct lock_impl *lock) { int err = pthread_mutex_trylock(&lock->mutex); if (!err) return true; else if (err == EBUSY) return false; BUG(); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/locks.h
static inline void lock_impl_init(struct lock_impl *lock) { lock->locked = false; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/locks.h
static inline void spin_lock_init(spinlock_t *lock) { lock_impl_init(&lock->internal_lock); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/locks.h
static inline void complete(struct completion *c) { unsigned int prev_count = __sync_fetch_and_add(&c->count, 1); BUG_ON(prev_count == UINT_MAX); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/misc.h
static inline void local_bh_disable(void) {}
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/percpu.h
static inline void *__alloc_percpu(size_t size, size_t align) { BUG(); return NULL; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/preempt.c
void preempt_disable(void) { BUG_ON(preempt_disable_count < 0 || preempt_disable_count == INT_MAX); if (preempt_disable_count++) return; thread_cpu_id = nondet_int(); assume(thread_cpu_id >= 0); assume(thread_cpu_id < NR_CPUS); lock_impl_lock(&cpu_preemption_locks[thread_cpu_id]); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/preempt.h
static inline bool preemptible(void) { return !preempt_count(); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/preempt.h
static inline void put_cpu(void) { preempt_enable(); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/simple_sync_srcu.c
void synchronize_srcu(struct srcu_struct *sp) { int idx; const int trycount = 1; might_sleep(); /* Ignore the lock, as multiple writers aren't working yet anyway. */ idx = 1 ^ (sp->completed & 1); /* For comments see srcu_advance_batches. */ assume(try_check_zero(sp, idx, trycount)); srcu_flip(sp...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/tests/store_buffering/test.c
void *thread_update(void *arg) { WRITE_ONCE(y, 1); #ifndef FORCE_FAILURE_2 synchronize_srcu(&ss); #endif might_sleep(); __unbuffered_tpr_x = READ_ONCE(x); return NULL; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rcutorture/formal/srcu-cbmc/tests/store_buffering/test.c
int main(int argc, char *argv[]) { pthread_t tu; pthread_t tpr; if (pthread_create(&tu, NULL, thread_update, NULL)) abort(); if (pthread_create(&tpr, NULL, thread_process_reader, NULL)) abort(); if (pthread_join(tu, NULL)) abort(); if (pthread_join(tpr, NULL)) abort(); assert(__unbuffere...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/cache.c
static void initialize_perf_event_attr(void) { pea_llc_miss.type = PERF_TYPE_HARDWARE; pea_llc_miss.size = sizeof(struct perf_event_attr); pea_llc_miss.read_format = PERF_FORMAT_GROUP; pea_llc_miss.exclude_kernel = 1; pea_llc_miss.exclude_hv = 1; pea_llc_miss.exclude_idle = 1; pea_llc_miss.exclude_callch...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/cache.c
static void ioctl_perf_event_ioc_reset_enable(void) { ioctl(fd_lm, PERF_EVENT_IOC_RESET, 0); ioctl(fd_lm, PERF_EVENT_IOC_ENABLE, 0); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/cache.c
int cat_val(struct resctrl_val_param *param) { int malloc_and_init_memory = 1, memflush = 1, operation = 0, ret = 0; char *resctrl_val = param->resctrl_val; pid_t bm_pid; if (strcmp(param->filename, "") == 0) sprintf(param->filename, "stdio"); bm_pid = getpid(); ret = taskset_benchmark(bm_pid, param-...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/cat_test.c
static int check_results(struct resctrl_val_param *param) { char *token_array[8], temp[512]; unsigned long sum_llc_perf_miss = 0; int runs = 0, no_of_bits = 0; FILE *fp; ksft_print_msg("Checking for pass/fail\n"); fp = fopen(param->filename, "r"); if (!fp) { perror("# Cannot open file"); return ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/cat_test.c
void cat_test_cleanup(void) { remove(RESULT_FILE_NAME1); remove(RESULT_FILE_NAME2); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/cmt_test.c
void cmt_test_cleanup(void) { remove(RESULT_FILE_NAME); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/fill_buf.c
static void ctrl_handler(int signo) { free(startptr); printf("\nEnding\n"); sb(); exit(EXIT_SUCCESS); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/fill_buf.c
static void cl_flush(void *p) { #if defined(__i386) || defined(__x86_64) asm volatile("clflush (%0)\n\t" : : "r"(p) : "memory"); #endif }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/fill_buf.c
static int fill_cache_read(unsigned char *start_ptr, unsigned char *end_ptr, char *resctrl_val) { int ret = 0; FILE *fp; while (1) { ret = fill_one_span_read(start_ptr, end_ptr); if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) break; } fp = fopen("/dev/null", "w...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/mba_test.c
static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) { int allocation, runs; bool failed = false; ksft_print_msg("Results are displayed in (MB)\n"); for (allocation = 0; allocation < ALLOCATION_MAX / ALLOCATION_STEP; allocation++) { unsigned long avg_bw_imc, avg_bw_resc; uns...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/mbm_test.c
static int check_results(int span) { unsigned long bw_imc[NUM_OF_RUNS], bw_resc[NUM_OF_RUNS]; char temp[1024], *token_array[8]; char output[] = RESULT_FILE_NAME; int runs, ret; FILE *fp; ksft_print_msg("Checking for pass/fail\n"); fp = fopen(output, "r"); if (!fp) { perror(output); return er...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/mbm_test.c
static int mbm_setup(int num, ...) { struct resctrl_val_param *p; static int num_of_runs; va_list param; int ret = 0; if (num_of_runs++ >= NUM_OF_RUNS) return -1; va_start(param, num); p = va_arg(param, struct resctrl_val_param *); va_end(param); /* Set up shemata with 100% allocation on the fi...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
static int find_resctrl_mount(char *buffer) { FILE *mounts; char line[256], *fs, *mntpoint; mounts = fopen("/proc/mounts", "r"); if (!mounts) { perror("/proc/mounts"); return -ENXIO; } while (!feof(mounts)) { if (!fgets(line, 256, mounts)) break; fs = strtok(line, " \t"); if (!fs...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size) { char cache_path[1024], cache_str[64]; int length, i, cache_num; FILE *fp; if (!strcmp(cache_type, "L3")) { cache_num = 3; } else if (!strcmp(cache_type, "L2")) { cache_num = 2; } else { perror("Invalid cache level"); ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, char *resctrl_val) { char controlgroup[128], monitorgroup[512], monitorgroup_p[256]; char tasks[1024]; int ret = 0; if (strlen(ctrlgrp)) sprintf(controlgroup, "%s/%s", RESCTRL_PATH, ctrlgrp); else sprin...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
bool validate_resctrl_feature_request(const char *resctrl_val) { struct stat statbuf; bool found = false; char *res; FILE *inf; if (!resctrl_val) return false; if (remount_resctrlfs(false)) return false; if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { if (!stat(L3_PATH, &statbuf)) ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
int validate_bw_report_request(char *bw_report) { if (strcmp(bw_report, "reads") == 0) return 0; if (strcmp(bw_report, "writes") == 0) return 0; if (strcmp(bw_report, "nt-writes") == 0) { strcpy(bw_report, "writes"); return 0; } if (strcmp(bw_report, "total") == 0) return 0; fprintf(st...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags) { int ret; ret = syscall(__NR_perf_event_open, hw_event, pid, cpu, group_fd, flags); return ret; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrlfs.c
unsigned int count_bits(unsigned long n) { unsigned int count = 0; while (n) { count += n & 1; n >>= 1; } return count; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_tests.c
static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) { int res; ksft_print_msg("Starting CMT test ...\n"); if (!validate_resctrl_feature_request(CMT_STR)) { ksft_test_result_skip("Hardware does not support CMT or CMT is disabled\n"); return; } if (!has_ben) sprintf(benchmark...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
void get_event_and_umask(char *cas_count_cfg, int count, bool op) { char *token[MAX_TOKENS]; int i = 0; strcat(cas_count_cfg, ","); token[0] = strtok(cas_count_cfg, "=,"); for (i = 1; i < MAX_TOKENS; i++) token[i] = strtok(NULL, "=,"); for (i = 0; i < MAX_TOKENS; i++) { if (!token[i]) break...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
static int open_perf_event(int i, int cpu_no, int j) { imc_counters_config[i][j].fd = perf_event_open( &imc_counters_config[i][j].pe, -1, cpu_no, -1, PERF_FLAG_FD_CLOEXEC); if (imc_counters_config[i][j].fd == -1) { fprintf(stderr, "Error opening leader %llx\n", imc_counters_config[i][j].pe.c...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
static int read_from_imc_dir(char *imc_dir, int count) { char cas_count_cfg[1024], imc_counter_cfg[1024], imc_counter_type[1024]; FILE *fp; sprintf(imc_counter_type, "%s%s", imc_dir, "type"); fp = fopen(imc_counter_type, "r"); if (!fp) { perror("Failed to open imc counter type file"); return -1; }...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
static int num_of_imcs(void) { char imc_dir[512], *temp; unsigned int count = 0; struct dirent *ep; int ret; DIR *dp; dp = opendir(DYN_PMU_PATH); if (dp) { while ((ep = readdir(dp))) { temp = strstr(ep->d_name, UNCORE_IMC); if (!temp) continue; temp = temp + sizeof(UNCORE_I...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
void set_mbm_path(const char *ctrlgrp, const char *mongrp, int resource_id) { if (ctrlgrp && mongrp) sprintf(mbm_total_path, CON_MON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, ctrlgrp, mongrp, resource_id); else if (!ctrlgrp && mongrp) sprintf(mbm_total_path, MON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, mo...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, int cpu_no, char *resctrl_val) { int resource_id; if (get_resource_id(cpu_no, &resource_id) < 0) { perror("# Unable to resource_id"); return; } if (!strncmp(resctrl_val, CMT_STR, si...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/resctrl/resctrl_val.c
static int measure_vals(struct resctrl_val_param *param, unsigned long *bw_resc_start) { unsigned long bw_resc, bw_resc_end; float bw_imc; int ret; ret = get_mem_bw_imc(param->cpu_no, param->bw_report, &bw_imc); if (ret < 0) return ret; ret = get_mem_bw_resctrl(&bw_resc_end); ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rlimits/rlimits-per-userns.c
static void setrlimit_nproc(rlim_t n) { pid_t pid = getpid(); struct rlimit limit = {.rlim_cur = n, .rlim_max = n}; warnx("(pid=%d): Setting RLIMIT_NPROC=%ld", pid, n); if (setrlimit(RLIMIT_NPROC, &limit) < 0) err(EXIT_FAILURE, "(pid=%d): setrlimit(RLIMIT_NPROC)", pid); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/basic_percpu_ops_test.c
void test_percpu_spinlock(void) { const int num_threads = 200; int i; uint64_t sum; pthread_t test_threads[num_threads]; struct spinlock_test_data data; memset(&data, 0, sizeof(data)); data.reps = 5000; for (i = 0; i < num_threads; i++) pthread_create(&test_threads[i], NULL, test_percpu_spinlock_t...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
void test_percpu_spinlock(void) { const int num_threads = opt_threads; int i, ret; uint64_t sum; pthread_t test_threads[num_threads]; struct spinlock_test_data data; struct spinlock_thread_test_data thread_data[num_threads]; memset(&data, 0, sizeof(data)); for (i = 0; i < num_threads; i++) { thread...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
void *test_percpu_list_thread(void *arg) { long long i, reps; struct percpu_list *list = (struct percpu_list *)arg; if (!opt_disable_rseq && rseq_register_current_thread()) abort(); reps = opt_reps; for (i = 0; i < reps; i++) { struct percpu_list_node *node; node = this_cpu_list_pop(list, NULL)...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
bool this_cpu_buffer_push(struct percpu_buffer *buffer, struct percpu_buffer_node *node, int *_cpu) { bool result = false; int cpu; for (;;) { intptr_t *targetptr_spec, newval_spec; intptr_t *targetptr_final, newval_final; intptr_t offset; int ret; cpu = rseq_cpu_st...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
bool __percpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, struct percpu_memcpy_buffer_node *item, int cpu) { intptr_t offset; offset = buffer->c[cpu].offset; if (offset == 0) return false; memcpy(item, &buffer->c[cpu].array[offset -...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
void *test_percpu_memcpy_buffer_thread(void *arg) { long long i, reps; struct percpu_memcpy_buffer *buffer = (struct percpu_memcpy_buffer *)arg; if (!opt_disable_rseq && rseq_register_current_thread()) abort(); reps = opt_reps; for (i = 0; i < reps; i++) { struct percpu_memcpy_buffer_node item; ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
static int set_signal_handler(void) { int ret = 0; struct sigaction sa; sigset_t sigset; ret = sigemptyset(&sigset); if (ret < 0) { perror("sigemptyset"); return ret; } sa.sa_handler = test_signal_interrupt_handler; sa.sa_mask = sigset; sa.sa_flags = 0; ret = sigaction(SIGUSR1, &sa, NULL);...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/param_test.c
void *test_membarrier_worker_thread(void *arg) { struct test_membarrier_thread_args *args = (struct test_membarrier_thread_args *)arg; const int iters = opt_reps; int i; if (rseq_register_current_thread()) { fprintf(stderr, "Error: rseq_register_current_thread(...) failed(%d): %s\n", errn...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/rseq/rseq-riscv.h
inline __always_inline int rseq_cmpnev_storeoffp_load(intptr_t *v, intptr_t expectnot, off_t voffp, intptr_t *load, int cpu) { RSEQ_INJECT_C(9) __...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/rseq-riscv.h
inline __always_inline int rseq_addv(intptr_t *v, intptr_t count, int cpu) { RSEQ_INJECT_C(9) __asm__ __volatile__ goto(RSEQ_ASM_DEFINE_TABLE(1, 2f, 3f, 4f) #ifdef RSEQ_COMPARE_TWICE RSEQ_ASM_DEFINE_EXIT_POINT(2f, "%l[error1]")
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/rseq-riscv.h
inline __always_inline int rseq_offset_deref_addv(intptr_t *ptr, off_t off, intptr_t inc, int cpu) { RSEQ_INJECT_C(9) __asm__ __volatile__ goto(RSEQ_ASM_DEFINE_TABLE(1, 2f, 3f, 4f) #ifdef RSEQ_COMPARE_TWICE RSEQ_ASM_DEFINE_EXIT_POINT(2f, "%l[error1]")
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/rseq.h
static inline int32_t rseq_current_cpu_raw(void) { return RSEQ_ACCESS_ONCE(rseq_get_abi()->cpu_id); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rseq/rseq.h
static inline void rseq_prepare_unload(void) { rseq_clear_rseq_cs(); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rtc/rtctest.c
static time_t rtc_time_to_timestamp(struct rtc_time *rtc_time) { struct tm tm_time = { .tm_sec = rtc_time->tm_sec, .tm_min = rtc_time->tm_min, .tm_hour = rtc_time->tm_hour, .tm_mday = rtc_time->tm_mday, .tm_mon = rtc_time->tm_mon, .tm_year = rtc_time->tm_year, }; return mktim...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/rtc/rtctest.c
static void nanosleep_with_retries(long ns) { struct timespec req = { .tv_sec = 0, .tv_nsec = ns, }; struct timespec rem; while (nanosleep(&req, &rem) != 0) { req.tv_sec = rem.tv_sec; req.tv_nsec = rem.tv_nsec; } }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/safesetid/safesetid-test.c
static bool vmaybe_write_file(bool enoent_ok, char *filename, char *fmt, va_list ap) { char buf[4096]; int fd; ssize_t written; int buf_len; buf_len = vsnprintf(buf, sizeof(buf), fmt, ap); if (buf_len < 0) { printf("vsnprintf failed: %s\n", strerror(errno)); return fa...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/safesetid/safesetid-test.c
static void ensure_user_exists(uid_t uid) { struct passwd p; FILE *fd; char name_str[10]; if (getpwuid(uid) == NULL) { memset(&p, 0x00, sizeof(p)); fd = fopen("/etc/passwd", "a"); if (fd == NULL) die("couldn't open file\n"); if (fseek(fd, 0, SEEK_END)) die("couldn't fseek\n"); ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/safesetid/safesetid-test.c
static void ensure_group_exists(gid_t gid) { struct group g; FILE *fd; char name_str[10]; if (getgrgid(gid) == NULL) { memset(&g, 0x00, sizeof(g)); fd = fopen("/etc/group", "a"); if (fd == NULL) die("couldn't open group file\n"); if (fseek(fd, 0, SEEK_END)) die("couldn't fseek gro...
[ 1, 0 ]