^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <stdint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include "resctrl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) struct read_format {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) __u64 nr; /* The number of events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) __u64 value; /* The value of the event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) } values[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static struct perf_event_attr pea_llc_miss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static struct read_format rf_cqm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int fd_lm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) char llc_occup_path[1024];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static void initialize_perf_event_attr(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) pea_llc_miss.type = PERF_TYPE_HARDWARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) pea_llc_miss.size = sizeof(struct perf_event_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) pea_llc_miss.read_format = PERF_FORMAT_GROUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) pea_llc_miss.exclude_kernel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) pea_llc_miss.exclude_hv = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) pea_llc_miss.exclude_idle = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) pea_llc_miss.exclude_callchain_kernel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) pea_llc_miss.inherit = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) pea_llc_miss.exclude_guest = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) pea_llc_miss.disabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static void ioctl_perf_event_ioc_reset_enable(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ioctl(fd_lm, PERF_EVENT_IOC_RESET, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) ioctl(fd_lm, PERF_EVENT_IOC_ENABLE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static int perf_event_open_llc_miss(pid_t pid, int cpu_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) fd_lm = perf_event_open(&pea_llc_miss, pid, cpu_no, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) PERF_FLAG_FD_CLOEXEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (fd_lm == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) perror("Error opening leader");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ctrlc_handler(0, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int initialize_llc_perf(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) memset(&pea_llc_miss, 0, sizeof(struct perf_event_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) memset(&rf_cqm, 0, sizeof(struct read_format));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* Initialize perf_event_attr structures for HW_CACHE_MISSES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) initialize_perf_event_attr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) pea_llc_miss.config = PERF_COUNT_HW_CACHE_MISSES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) rf_cqm.nr = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static int reset_enable_llc_perf(pid_t pid, int cpu_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ret = perf_event_open_llc_miss(pid, cpu_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Start counters to log values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ioctl_perf_event_ioc_reset_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * get_llc_perf: llc cache miss through perf events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @cpu_no: CPU number that the benchmark PID is binded to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Perf events like HW_CACHE_MISSES could be used to validate number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * cache lines allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * Return: =0 on success. <0 on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static int get_llc_perf(unsigned long *llc_perf_miss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) __u64 total_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* Stop counters after one span to get miss rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ioctl(fd_lm, PERF_EVENT_IOC_DISABLE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (read(fd_lm, &rf_cqm, sizeof(struct read_format)) == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) perror("Could not get llc misses through perf");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) total_misses = rf_cqm.values[0].value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) close(fd_lm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) *llc_perf_miss = total_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * Get LLC Occupancy as reported by RESCTRL FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * For CQM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * 1. If con_mon grp and mon grp given, then read from mon grp in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * con_mon grp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * 2. If only con_mon grp given, then read from con_mon grp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * 3. If both not given, then read from root con_mon grp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * For CAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * 1. If con_mon grp given, then read from it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * 2. If con_mon grp not given, then read from root con_mon grp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * Return: =0 on success. <0 on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static int get_llc_occu_resctrl(unsigned long *llc_occupancy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) FILE *fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) fp = fopen(llc_occup_path, "r");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (!fp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) perror("Failed to open results file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) return errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (fscanf(fp, "%lu", llc_occupancy) <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) perror("Could not get llc occupancy");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) fclose(fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) fclose(fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * print_results_cache: the cache results are stored in a file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * @filename: file that stores the results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * @bm_pid: child pid that runs benchmark
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * @llc_value: perf miss value /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * llc occupancy value reported by resctrl FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * Return: 0 on success. non-zero on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static int print_results_cache(char *filename, int bm_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) unsigned long llc_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) FILE *fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (strcmp(filename, "stdio") == 0 || strcmp(filename, "stderr") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) printf("Pid: %d \t LLC_value: %lu\n", bm_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) llc_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) fp = fopen(filename, "a");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (!fp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) perror("Cannot open results file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) fprintf(fp, "Pid: %d \t llc_value: %lu\n", bm_pid, llc_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) fclose(fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int measure_cache_vals(struct resctrl_val_param *param, int bm_pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) unsigned long llc_perf_miss = 0, llc_occu_resc = 0, llc_value = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * Measure cache miss from perf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (!strncmp(param->resctrl_val, CAT_STR, sizeof(CAT_STR))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ret = get_llc_perf(&llc_perf_miss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) llc_value = llc_perf_miss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * Measure llc occupancy from resctrl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (!strncmp(param->resctrl_val, CQM_STR, sizeof(CQM_STR))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ret = get_llc_occu_resctrl(&llc_occu_resc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) llc_value = llc_occu_resc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ret = print_results_cache(param->filename, bm_pid, llc_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * cache_val: execute benchmark and measure LLC occupancy resctrl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * and perf cache miss for the benchmark
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * @param: parameters passed to cache_val()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * Return: 0 on success. non-zero on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int cat_val(struct resctrl_val_param *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int malloc_and_init_memory = 1, memflush = 1, operation = 0, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) char *resctrl_val = param->resctrl_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) pid_t bm_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (strcmp(param->filename, "") == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) sprintf(param->filename, "stdio");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) bm_pid = getpid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /* Taskset benchmark to specified cpu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ret = taskset_benchmark(bm_pid, param->cpu_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) resctrl_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ret = initialize_llc_perf();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /* Test runs until the callback setup() tells the test to stop. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ret = param->setup(1, param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) ret = reset_enable_llc_perf(bm_pid, param->cpu_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (run_fill_buf(param->span, malloc_and_init_memory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) memflush, operation, resctrl_val)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) fprintf(stderr, "Error-running fill buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) sleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ret = measure_cache_vals(param, bm_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }