/* * Get LLC Occupancy as reported by RESCTRL FS * For CMT, * 1. If con_mon grp and mon grp given, then read from mon grp in * con_mon grp * 2. If only con_mon grp given, then read from con_mon grp * 3. If both not given, then read from root con_mon grp * For CAT, * 1. If con_mon grp given, then read from it * 2. If con_mon grp not given, then read from root con_mon grp * * Return: =0 on success. <0 on failure.
*/ staticint get_llc_occu_resctrl(unsignedlong *llc_occupancy)
{
FILE *fp;
fp = fopen(llc_occup_path, "r"); if (!fp) {
ksft_perror("Failed to open results file");
return -1;
} if (fscanf(fp, "%lu", llc_occupancy) <= 0) {
ksft_perror("Could not get llc occupancy");
fclose(fp);
return -1;
}
fclose(fp);
return 0;
}
/* * print_results_cache: the cache results are stored in a file * @filename: file that stores the results * @bm_pid: child pid that runs benchmark * @llc_value: perf miss value / * llc occupancy value reported by resctrl FS * * Return: 0 on success, < 0 on error.
*/ staticint print_results_cache(constchar *filename, pid_t bm_pid, __u64 llc_value)
{
FILE *fp;
/* * perf_event_measure - Measure perf events * @filename: Filename for writing the results * @bm_pid: PID that runs the benchmark * * Measures perf events (e.g., cache misses) and writes the results into * @filename. @bm_pid is written to the results file along with the measured * value. * * Return: =0 on success. <0 on failure.
*/ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, constchar *filename, pid_t bm_pid)
{ int ret;
/* Stop counters after one span to get miss rate */
ret = ioctl(pe_fd, PERF_EVENT_IOC_DISABLE, 0); if (ret < 0) return ret;
ret = read(pe_fd, pe_read, sizeof(*pe_read)); if (ret == -1) {
ksft_perror("Could not get perf value"); return -1;
}
/* * measure_llc_resctrl - Measure resctrl LLC value from resctrl * @filename: Filename for writing the results * @bm_pid: PID that runs the benchmark * * Measures LLC occupancy from resctrl and writes the results into @filename. * @bm_pid is written to the results file along with the measured value. * * Return: =0 on success. <0 on failure.
*/ int measure_llc_resctrl(constchar *filename, pid_t bm_pid)
{ unsignedlong llc_occu_resc = 0; int ret;
ret = get_llc_occu_resctrl(&llc_occu_resc); if (ret < 0) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.