Skip to content

Commit 591a6e8

Browse files
Sai Praneeth Prakhyashuahkh
authored andcommitted
selftests/resctrl: Add basic resctrl file system operations and data
The basic resctrl file system operations and data are added for future usage by resctrl selftest tool. Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com> Co-developed-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Babu Moger <babu.moger@amd.com> Co-developed-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 034c767 commit 591a6e8

File tree

3 files changed

+524
-0
lines changed

3 files changed

+524
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CC = $(CROSS_COMPILE)gcc
2+
CFLAGS = -g -Wall
3+
SRCS=$(wildcard *.c)
4+
OBJS=$(SRCS:.c=.o)
5+
6+
$(OBJS): $(SRCS)
7+
$(CC) $(CFLAGS) -c $(SRCS)
8+
9+
.PHONY: clean
10+
11+
clean:
12+
$(RM) $(OBJS)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#define _GNU_SOURCE
3+
#ifndef RESCTRL_H
4+
#define RESCTRL_H
5+
#include <stdio.h>
6+
#include <errno.h>
7+
#include <sched.h>
8+
#include <stdlib.h>
9+
#include <unistd.h>
10+
#include <string.h>
11+
#include <signal.h>
12+
#include <dirent.h>
13+
#include <stdbool.h>
14+
#include <sys/stat.h>
15+
#include <sys/ioctl.h>
16+
#include <sys/mount.h>
17+
#include <sys/types.h>
18+
#include <sys/wait.h>
19+
#include <asm/unistd.h>
20+
#include <linux/perf_event.h>
21+
22+
#define RESCTRL_PATH "/sys/fs/resctrl"
23+
#define PHYS_ID_PATH "/sys/devices/system/cpu/cpu"
24+
25+
#define PARENT_EXIT(err_msg) \
26+
do { \
27+
perror(err_msg); \
28+
kill(ppid, SIGKILL); \
29+
exit(EXIT_FAILURE); \
30+
} while (0)
31+
32+
pid_t bm_pid, ppid;
33+
34+
int remount_resctrlfs(bool mum_resctrlfs);
35+
int get_resource_id(int cpu_no, int *resource_id);
36+
int validate_bw_report_request(char *bw_report);
37+
bool validate_resctrl_feature_request(char *resctrl_val);
38+
char *fgrep(FILE *inf, const char *str);
39+
int taskset_benchmark(pid_t bm_pid, int cpu_no);
40+
void run_benchmark(int signum, siginfo_t *info, void *ucontext);
41+
int write_schemata(char *ctrlgrp, char *schemata, int cpu_no,
42+
char *resctrl_val);
43+
int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,
44+
char *resctrl_val);
45+
int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
46+
int group_fd, unsigned long flags);
47+
int run_fill_buf(unsigned long span, int malloc_and_init_memory, int memflush,
48+
int op, char *resctrl_va);
49+
50+
#endif /* RESCTRL_H */

0 commit comments

Comments
 (0)