Skip to contentSkip to conversation

selftests/resctrl: Add resctrl selftest

PATCH New Moger, Babu 1 participant 14 messages Jan 18, 2019

Subsystems (2)
lore
Share & tools
lore

Moger, Babu

author reviewer
#0 lore raw

v5 cover selftests/resctrl: Add resctrl selftest

With more and more resctrl features are being added by Intel, AMD and ARM, a test tool is becoming more and more useful to validate that both hardware and software functionalities work as expected.

We introduce resctrl selftest to cover resctrl features on both X86 and ARM architectures. It first implements MBM (Memory Bandwidth Monitoring) and MBA (Memory Bandwidth Allocation) tests. We can enhance the selftest tool to include more functionality tests in future.

There is an existing resctrl test suite 'intel_cmt_cat'. But the major purpose of the tool is to test Intel(R) RDT hardware via writing and reading MSR registers. It does access resctrl file system; but the functionalities are very limited. And it doesn't support automatic test and a lot of manual verifications are involved.

So the selftest tool we are introducing here provides a convenient tool which does automatic resctrl testing, is easily available in kernel tree, and will be extended to AMD QoS and ARM MPAM.

The selftest tool is in tools/testing/selftests/resctrl in order to have generic test code for all architectures.

Changelog:
v5:
- Based the v4 patches submitted by Fenghua Yu and added changes to support AMD.
- Changed the function name get_sock_num to get_resource_id. Intel uses socket number for schemata and AMD uses l3 index id. To generalize changed the function name to get_resource_id.
- Added the code to detect vendor.
- Disabled the few tests for AMD where the test results are not clear.
Also AMD does not have IMC.
- Fixed few compile issues.
- Some cleanup to make each patch independent.
- Tested the patches on AMD system. Fenghua, Need your help to test on Intel box. Please feel free to change and resubmit if something
broken.
- Here is the link for previous version.
https://lore.kernel.org/lkml/1545438038-75107-1-git-send-email-fenghua.yu at intel.com/

v4:
- address comments from Balu and Randy
- Add CAT and CQM tests

v3:
- Change code based on comments from Babu Moger
- Remove some unnessary code and use pipe to communicate b/w processes

v2:
- Change code based on comments from Babu Moger
- Clean up other places.

Arshiya Hayatkhan Pathan (4):
selftests/resctrl: Add MBM test
selftests/resctrl: Add MBA test
selftests/resctrl Add Cache QoS Monitoring (CQM) selftest selftests/resctrl: Add Cache Allocation Technology (CAT) selftest

Babu Moger (3):
selftests/resctrl: Add vendor detection mechanism selftests/resctrl: Use cache index3 id for AMD schemata masks selftests/resctrl: Disable MBA and MBM tests for AMD

Fenghua Yu (2):
selftests/resctrl: Add README for resctrl tests
selftests/resctrl: Add the test in MAINTAINERS

Sai Praneeth Prakhya (4):
selftests/resctrl: Add basic resctrl file system operations and data selftests/resctrl: Read memory bandwidth from perf IMC counter and
from resctrl file system
selftests/resctrl: Add callback to start a benchmark selftests/resctrl: Add built in benchmark

 MAINTAINERS                                     |   1 +
 tools/testing/selftests/resctrl/Makefile        |  16 +
 tools/testing/selftests/resctrl/README          |  53 ++
 tools/testing/selftests/resctrl/cache.c         | 275 +++++++++
 tools/testing/selftests/resctrl/cat_test.c      | 243 ++++++++
 tools/testing/selftests/resctrl/cqm_test.c      | 169 ++++++
 tools/testing/selftests/resctrl/fill_buf.c      | 198 +++++++
 tools/testing/selftests/resctrl/mba_test.c      | 174 ++++++
 tools/testing/selftests/resctrl/mbm_test.c      | 146 +++++
 tools/testing/selftests/resctrl/resctrl.h       | 117 ++++
 tools/testing/selftests/resctrl/resctrl_tests.c | 243 ++++++++
 tools/testing/selftests/resctrl/resctrl_val.c   | 727 ++++++++++++++++++++++++
 tools/testing/selftests/resctrl/resctrlfs.c     | 649 +++++++++++++++++++++
 13 files changed, 3011 insertions(+)
 create mode 100644 tools/testing/selftests/resctrl/Makefile
 create mode 100644 tools/testing/selftests/resctrl/README
 create mode 100644 tools/testing/selftests/resctrl/cache.c
 create mode 100644 tools/testing/selftests/resctrl/cat_test.c
 create mode 100644 tools/testing/selftests/resctrl/cqm_test.c
 create mode 100644 tools/testing/selftests/resctrl/fill_buf.c
 create mode 100644 tools/testing/selftests/resctrl/mba_test.c
 create mode 100644 tools/testing/selftests/resctrl/mbm_test.c
 create mode 100644 tools/testing/selftests/resctrl/resctrl.h
 create mode 100644 tools/testing/selftests/resctrl/resctrl_tests.c
 create mode 100644 tools/testing/selftests/resctrl/resctrl_val.c
 create mode 100644 tools/testing/selftests/resctrl/resctrlfs.c
Signature · 1 line
1.8.3.1
author reviewer
#1 lore raw

PATCH v5 1/13 selftests/resctrl: Add README for resctrl tests

From: Fenghua Yu <[email protected]>

resctrl tests will be implemented. README is added for the tool first.

Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/README | 53 ++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 tools/testing/selftests/resctrl/README
tools/testing/selftests/resctrl/README new file +53 -0
new file mode 100644
index 0000000..f9621d6
@@ -0,0 +1,53 @@
+resctrl_tests - resctrl file system test suit
+
+Authors:
+	Fenghua Yu <fenghua.yu at intel.com>
+	Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>,
+	Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
+
+resctrl_tests tests various resctrl functionalities and interfaces including
+both software and hardware.
+
+Currently it supports Memory Bandwidth Monitoring test and Memory Bandwidth
+Allocation test on Intel RDT hardware. More tests will be added in the future.
+And the test suit can be extended to cover AMD QoS and ARM MPAM hardware
+as well.
+
+BUILD
+-----
+
+Run "make" to build executable file "resctrl_tests".
+
+RUN
+---
+
+To use resctrl_tests, root or sudoer privileges are required. This is because
+the test needs to mount resctrl file system and change contents in the file
+system.
+
+Executing the test without any parameter will run all supported tests:
+
+	sudo ./resctrl_tests
+
+OVERVIEW OF EXECUTION
+---------------------
+
+A test case has four stages:
+
+  - setup: mount resctrl file system, create group, setup schemata, move test
+    process pids to tasks, start benchmark.
+  - execute: let benchmark run
+  - verify: get resctrl data and verify the data with another source, e.g.
+    perf event.
+  - teardown: umount resctrl and clear temporary files.
+
+ARGUMENTS
+---------
+
+Parameter '-h' shows usage information.
+
+usage: resctrl_tests [-h] [-b "benchmark_cmd [options]"] [-t test list] [-n no_of_bits]
+        -b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CQM default benchmark is builtin fill_buf
+        -t test list: run tests specified in the test list, e.g. -t mbm, mba, cqm, cat
+        -n no_of_bits: run cache tests using specified no of bits in cache bit mask
+        -h: help
Signature · 1 line
1.8.3.1
author reviewer
#2 lore raw

PATCH v5 2/13 selftests/resctrl: Add basic resctrl file system operations and data

In reply to Moger, Babu

From: Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>

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 at intel.com>
Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/Makefile    |  10 +
 tools/testing/selftests/resctrl/resctrl.h   |  47 +++
 tools/testing/selftests/resctrl/resctrlfs.c | 457 ++++++++++++++++++++++++++++
 3 files changed, 514 insertions(+)
 create mode 100644 tools/testing/selftests/resctrl/Makefile
 create mode 100644 tools/testing/selftests/resctrl/resctrl.h
 create mode 100644 tools/testing/selftests/resctrl/resctrlfs.c
tools/testing/selftests/resctrl/Makefile new file +10 -0
new file mode 100644
index 0000000..bd5c541
@@ -0,0 +1,10 @@
+CC = gcc
+CFLAGS = -g -Wall
+
+*.o: *.c
+	$(CC) $(CFLAGS) -c *.c
+
+.PHONY: clean
+
+clean:
+	$(RM) *.o *~
tools/testing/selftests/resctrl/resctrl.h new file +47 -0

47 lines not on this page · raw message

tools/testing/selftests/resctrl/resctrlfs.c new file +457 -0

457 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author reviewer
#3 lore raw

PATCH v5 3/13 selftests/resctrl: Read memory bandwidth from perf IMC counter and from resctrl file system

In reply to Moger, Babu

From: Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>

Total memory bandwidth can be monitored from perf IMC counter and from resctrl file system. Later the two will be compared to verify the total memory bandwidth read from resctrl is correct.

Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>
Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/resctrl_val.c | 118 ++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)
 create mode 100644 tools/testing/selftests/resctrl/resctrl_val.c
tools/testing/selftests/resctrl/resctrl_val.c new file +118 -0
new file mode 100644
index 0000000..12301ac
@@ -0,0 +1,118 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Memory bandwidth monitoring and allocation library
+ *
+ * Copyright (C) 2018 Intel Corporation
+ *
+ * Authors:
+ *    Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
+ *    Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>,
+ *    Fenghua Yu <fenghua.yu at intel.com>
+ */
+#include "resctrl.h"
+
+#define UNCORE_IMC		"uncore_imc"
+#define READ_FILE_NAME		"events/cas_count_read"
+#define WRITE_FILE_NAME		"events/cas_count_write"
+#define DYN_PMU_PATH		"/sys/bus/event_source/devices"
+#define SCALE			0.00006103515625
+#define MAX_IMCS		20
+#define MAX_TOKENS		5
+#define READ			0
+#define WRITE			1
+#define CON_MON_MBM_LOCAL_BYTES_PATH				\
+	"%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
+
+#define CON_MBM_LOCAL_BYTES_PATH		\
+	"%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
+
+#define MON_MBM_LOCAL_BYTES_PATH		\
+	"%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
+
+#define MBM_LOCAL_BYTES_PATH			\
+	"%s/mon_data/mon_L3_%02d/mbm_local_bytes"
+
+struct membw_read_format {
+	__u64 value;         /* The value of the event */
+	__u64 time_enabled;  /* if PERF_FORMAT_TOTAL_TIME_ENABLED */
+	__u64 time_running;  /* if PERF_FORMAT_TOTAL_TIME_RUNNING */
+	__u64 id;            /* if PERF_FORMAT_ID */
+};
+
+struct imc_counter_config {
+	__u32 type;
+	__u64 event;
+	__u64 umask;
+	struct perf_event_attr pe;
+	struct membw_read_format return_value;
+	int fd;
+};
+static struct imc_counter_config imc_counters_config[MAX_IMCS][2];
+
+void membw_initialize_perf_event_attr(int i, int j)
+{
+	memset(&imc_counters_config[i][j].pe, 0,
+	       sizeof(struct perf_event_attr));
+	imc_counters_config[i][j].pe.type = imc_counters_config[i][j].type;
+	imc_counters_config[i][j].pe.size = sizeof(struct perf_event_attr);
+	imc_counters_config[i][j].pe.disabled = 1;
+	imc_counters_config[i][j].pe.inherit = 1;
+	imc_counters_config[i][j].pe.exclude_guest = 1;
+	imc_counters_config[i][j].pe.config =
+		imc_counters_config[i][j].umask << 8 |
+		imc_counters_config[i][j].event;
+	imc_counters_config[i][j].pe.sample_type = PERF_SAMPLE_IDENTIFIER;
+	imc_counters_config[i][j].pe.read_format =
+		PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING;
+}
+
+void membw_ioctl_perf_event_ioc_reset_enable(int i, int j)
+{
+	ioctl(imc_counters_config[i][j].fd, PERF_EVENT_IOC_RESET, 0);
+	ioctl(imc_counters_config[i][j].fd, PERF_EVENT_IOC_ENABLE, 0);
+}
+
+void membw_ioctl_perf_event_ioc_disable(int i, int j)
+{
+	ioctl(imc_counters_config[i][j].fd, PERF_EVENT_IOC_DISABLE, 0);
+}
+
+/*
+ * get_event_and_umask:	Parse config into event and umask
+ * @cas_count_cfg:	Config
+ * @count:		iMC number
+ * @op:			Operation (read/write)
+ */
+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;
+		if (strcmp(token[i], "event") == 0) {
+			if (op == READ)
+				imc_counters_config[count][READ].event =
+				strtol(token[i + 1], NULL, 16);
+			else
+				imc_counters_config[count][WRITE].event =
+				strtol(token[i + 1], NULL, 16);
+		}
+		if (strcmp(token[i], "umask") == 0) {
+			if (op == READ)
+				imc_counters_config[count][READ].umask =
+				strtol(token[i + 1], NULL, 16);
+			else
+				imc_counters_config[count][WRITE].umask =
+				strtol(token[i + 1], NULL, 16);
+		}
+	}
+}
+
Signature · 1 line
1.8.3.1
author reviewer
#4 lore raw

PATCH v5 4/13 selftests/resctrl: Add callback to start a benchmark

In reply to Moger, Babu

From: Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>

The callback starts a child process and puts the child pid in created resctrl group with specified memory bandwidth in schemata. The child starts running benchmark.

Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>
Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/resctrl.h     |  27 ++
 tools/testing/selftests/resctrl/resctrl_val.c | 586 ++++++++++++++++++++++++++
 2 files changed, 613 insertions(+)
tools/testing/selftests/resctrl/resctrl.h +27 -0
index 17fcb5e..f30a2dc 100644
@@ -3,6 +3,7 @@
 #ifndef RESCTRL_H
 #define RESCTRL_H
 #include <stdio.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <sched.h>
 #include <stdlib.h>
@@ -28,10 +29,35 @@
 		exit(EXIT_FAILURE);		\
 	} while (0)
 
+/*
+ * resctrl_val_param:	resctrl test parameters
+ * @resctrl_val:	Resctrl feature (Eg: mbm, mba.. etc)
+ * @ctrlgrp:		Name of the control monitor group (con_mon grp)
+ * @mongrp:		Name of the monitor group (mon grp)
+ * @cpu_no:		CPU number to which the benchmark would be binded
+ * @span:		Memory bytes accessed in each benchmark iteration
+ * @mum_resctrlfs:	Should the resctrl FS be remounted?
+ * @filename:		Name of file to which the o/p should be written
+ * @bw_report:		Bandwidth report type (reads vs writes)
+ * @setup:		Call back function to setup test environment
+ */
+struct resctrl_val_param {
+	char	*resctrl_val;
+	char	ctrlgrp[64];
+	char	mongrp[64];
+	int	cpu_no;
+	int	span;
+	int	mum_resctrlfs;
+	char	filename[64];
+	char	*bw_report;
+	int	(*setup)(int num, ...);
+};
+
 pid_t bm_pid, ppid;
 
 int remount_resctrlfs(bool mum_resctrlfs);
 int get_resource_id(int cpu_no, int *resource_id);
+int umount_resctrlfs(void);
 int validate_bw_report_request(char *bw_report);
 int validate_resctrl_feature_request(char *resctrl_val);
 int taskset_benchmark(pid_t bm_pid, int cpu_no);
@@ -43,5 +69,6 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,
 int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
 		    int group_fd, unsigned long flags);
 int run_fill_buf(int span, int malloc_and_init_memory, int memflush, int op);
+int membw_val(char **benchmark_cmd, struct resctrl_val_param *param);
 
 #endif /* RESCTRL_H */
tools/testing/selftests/resctrl/resctrl_val.c +586 -0

601 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author reviewer
#5 lore raw

PATCH v5 5/13 selftests/resctrl: Add built in benchmark

In reply to Moger, Babu

From: Sai Praneeth Prakhya <[email protected]>

Built-in benchmark fill_buf generates stressful memory bandwidth and cache traffic.

Later it will be used as a default benchmark by various resctrl tests such as MBA (Memory Bandwidth Allocation) and MBM (Memory Bandwidth Monitoring) tests.

Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>
Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/fill_buf.c | 175 +++++++++++++++++++++++++++++
 1 file changed, 175 insertions(+)
 create mode 100644 tools/testing/selftests/resctrl/fill_buf.c
tools/testing/selftests/resctrl/fill_buf.c new file +175 -0
new file mode 100644
index 0000000..d9950b5
@@ -0,0 +1,175 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * fill_buf benchmark
+ *
+ * Copyright (C) 2018 Intel Corporation
+ *
+ * Authors:
+ *    Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
+ *    Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>,
+ *    Fenghua Yu <fenghua.yu at intel.com>
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <inttypes.h>
+#include <malloc.h>
+#include <string.h>
+
+#include "resctrl.h"
+
+#define CL_SIZE			(64)
+#define PAGE_SIZE		(4 * 1024)
+#define MB			(1024 * 1024)
+
+static unsigned char *startptr;
+
+static void sb(void)
+{
+	asm volatile("sfence\n\t"
+		     : : : "memory");
+}
+
+static void ctrl_handler(int signo)
+{
+	free(startptr);
+	printf("\nEnding\n");
+	sb();
+	exit(EXIT_SUCCESS);
+}
+
+static void cl_flush(void *p)
+{
+	asm volatile("clflush (%0)\n\t"
+		     : : "r"(p) : "memory");
+}
+
+static void mem_flush(void *p, size_t s)
+{
+	char *cp = (char *)p;
+	size_t i = 0;
+
+	s = s / CL_SIZE; /* mem size in cache llines */
+
+	for (i = 0; i < s; i++)
+		cl_flush(&cp[i * CL_SIZE]);
+
+	sb();
+}
+
+static void *malloc_and_init_memory(size_t s)
+{
+	uint64_t *p64;
+	size_t s64;
+
+	void *p = memalign(PAGE_SIZE, s);
+
+	p64 = (uint64_t *)p;
+	s64 = s / sizeof(uint64_t);
+
+	while (s64 > 0) {
+		*p64 = (uint64_t)rand();
+		p64 += (CL_SIZE / sizeof(uint64_t));
+		s64 -= (CL_SIZE / sizeof(uint64_t));
+	}
+
+	return p;
+}
+
+static void fill_cache_read(unsigned char *start_ptr, unsigned char *end_ptr)
+{
+	while (1) {
+		unsigned char sum, *p;
+
+		p = start_ptr;
+		/* Read two chars in each cache line to stress cache */
+		while (p < (end_ptr - 1024)) {
+			sum += p[0] + p[32] + p[64] + p[96] + p[128] +
+			       p[160] + p[192] + p[224] + p[256] + p[288] +
+			       p[320] + p[352] + p[384] + p[416] + p[448] +
+			       p[480] + p[512] + p[544] + p[576] + p[608] +
+			       p[640] + p[672] + p[704] + p[736] + p[768] +
+			       p[800] + p[832] + p[864] + p[896] + p[928] +
+			       p[960] + p[992];
+			p += 1024;
+		}
+	}
+}
+
+static void fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr)
+{
+	while (1) {
+		while (start_ptr < end_ptr) {
+			*start_ptr = '1';
+			start_ptr += (CL_SIZE / 2);
+		}
+		start_ptr = startptr;
+	}
+}
+
+static void
+fill_cache(unsigned long long buf_size, int malloc_and_init,
+	   int memflush, int op)
+{
+	unsigned char *start_ptr, *end_ptr;
+	unsigned long long i;
+
+	if (malloc_and_init) {
+		start_ptr = malloc_and_init_memory(buf_size);
+		printf("Started benchmark with memalign\n");
+	} else {
+		start_ptr = malloc(buf_size);
+		printf("Started benchmark with malloc\n");
+	}
+
+	if (!start_ptr)
+		return;
+
+	startptr = start_ptr;
+	end_ptr = start_ptr + buf_size;
+
+	/*
+	 * It's better to touch the memory once to avoid any compiler
+	 * optimizations
+	 */
+	if (!malloc_and_init) {
+		for (i = 0; i < buf_size; i++)
+			*start_ptr++ = (unsigned char)rand();
+	}
+
+	start_ptr = startptr;
+
+	/* Flush the memory before using to avoid "cache hot pages" effect */
+	if (memflush) {
+		mem_flush(start_ptr, buf_size);
+		printf("Started benchmark with memflush\n");
+	} else {
+		printf("Started benchmark *without* memflush\n");
+	}
+
+	if (op == 0)
+		fill_cache_read(start_ptr, end_ptr);
+	else
+		fill_cache_write(start_ptr, end_ptr);
+
+	free(startptr);
+}
+
+int run_fill_buf(int span, int malloc_and_init_memory, int memflush, int op)
+{
+	unsigned long long cache_size = span * MB;
+
+	/* set up ctrl-c handler */
+	if (signal(SIGINT, ctrl_handler) == SIG_ERR)
+		printf("Failed to catch SIGINT!\n");
+	if (signal(SIGHUP, ctrl_handler) == SIG_ERR)
+		printf("Failed to catch SIGHUP!\n");
+
+	printf("Cache size in Bytes = %llu\n", cache_size);
+
+	fill_cache(cache_size, malloc_and_init_memory, memflush, op);
+
+	return -1;
+}
Signature · 1 line
1.8.3.1
author reviewer
#6 lore raw

PATCH v5 6/13 selftests/resctrl: Add MBM test

In reply to Moger, Babu

From: Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>

MBM (Memory Bandwidth Monitoring) test is the first implemented selftest. It starts a stressful memory bandwidth benchmark and assigns the bandwidth pid in a resctrl monitoring group. Read and compare perf IMC counter and MBM total bytes for the benchmark. The numbers should be close enough to pass the test.

Default benchmark is built-in fill_buf. But users can specify their own benchmark by option "-b".

We can add memory bandwidth monitoring for multiple processes in the future.

Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>,
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/Makefile        |   8 +-
 tools/testing/selftests/resctrl/mbm_test.c      | 145 ++++++++++++++++++++++++
 tools/testing/selftests/resctrl/resctrl.h       |   3 +
 tools/testing/selftests/resctrl/resctrl_tests.c | 123 ++++++++++++++++++++
 tools/testing/selftests/resctrl/resctrl_val.c   |   2 +
 5 files changed, 280 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/resctrl/mbm_test.c
 create mode 100644 tools/testing/selftests/resctrl/resctrl_tests.c
tools/testing/selftests/resctrl/Makefile +7 -1
index bd5c541..eaa8b45 100644
@@ -1,10 +1,16 @@
 CC = gcc
 CFLAGS = -g -Wall
 
+all: resctrl_tests
+
 *.o: *.c
 	$(CC) $(CFLAGS) -c *.c
 
+resctrl_tests: *.o
+	$(CC) $(CFLAGS) -o resctrl_tests resctrl_tests.o resctrlfs.o \
+		 resctrl_val.o fill_buf.o mbm_test.o
+
 .PHONY: clean
 
 clean:
-	$(RM) *.o *~
+	$(RM) *.o *~ resctrl_tests
tools/testing/selftests/resctrl/mbm_test.c new file +145 -0

145 lines not on this page · raw message

tools/testing/selftests/resctrl/resctrl.h +3 -0
index f30a2dc..90d1fd1 100644
@@ -70,5 +70,8 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
 		    int group_fd, unsigned long flags);
 int run_fill_buf(int span, int malloc_and_init_memory, int memflush, int op);
 int membw_val(char **benchmark_cmd, struct resctrl_val_param *param);
+int mbm_bw_change(int span, int core_id, char *bw_report, char **benchmark_cmd);
+void tests_cleanup(void);
+void mbm_test_cleanup(void);
 
 #endif /* RESCTRL_H */
tools/testing/selftests/resctrl/resctrl_tests.c new file +123 -0

123 lines not on this page · raw message

tools/testing/selftests/resctrl/resctrl_val.c +2 -0
index 8b32595..86a513e 100644
@@ -437,6 +437,8 @@ static unsigned long get_mem_bw_resctrl(void)
 static void ctrlc_handler(int signum, siginfo_t *info, void *ptr)
 {
 	kill(bm_pid, SIGKILL);
+	umount_resctrlfs();
+	tests_cleanup();
 	printf("Ending\n\n");
 
 	exit(EXIT_SUCCESS);
Signature · 1 line
1.8.3.1
author reviewer
#7 lore raw

PATCH v5 7/13 selftests/resctrl: Add MBA test

In reply to Moger, Babu

From: Arshiya Hayatkhan Pathan <[email protected]>

MBA (Memory Bandwidth Allocation) test starts a stressful memory bandwidth benchmark and allocates memory bandwidth from 100% down to 10% for the benchmark process. For each allocation, compare perf IMC counter and mbm total bytes from resctrl. The difference between the two values should be within a threshold to pass the test.

Default benchmark is built-in fill_buf. But users can specify their own benchmark by option "-b".

We can add memory bandwidth allocation for multiple processes in the future.

Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>,
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/Makefile        |   2 +-
 tools/testing/selftests/resctrl/mba_test.c      | 173 ++++++++++++++++++++++++
 tools/testing/selftests/resctrl/resctrl.h       |   2 +
 tools/testing/selftests/resctrl/resctrl_tests.c |  15 +-
 4 files changed, 190 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/resctrl/mba_test.c
tools/testing/selftests/resctrl/Makefile +1 -1
index eaa8b45..141cbdb 100644
@@ -8,7 +8,7 @@ all: resctrl_tests
 
 resctrl_tests: *.o
 	$(CC) $(CFLAGS) -o resctrl_tests resctrl_tests.o resctrlfs.o \
-		 resctrl_val.o fill_buf.o mbm_test.o
+		 resctrl_val.o fill_buf.o mbm_test.o mba_test.o
 
 .PHONY: clean
 
tools/testing/selftests/resctrl/mba_test.c new file +173 -0

173 lines not on this page · raw message

tools/testing/selftests/resctrl/resctrl.h +2 -0
index 90d1fd1..f54a034 100644
@@ -73,5 +73,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
 int mbm_bw_change(int span, int core_id, char *bw_report, char **benchmark_cmd);
 void tests_cleanup(void);
 void mbm_test_cleanup(void);
+int mba_schemata_change(int core_id, char *bw_report, char **benchmark_cmd);
+void mba_test_cleanup(void);
 
 #endif /* RESCTRL_H */
tools/testing/selftests/resctrl/resctrl_tests.c +14 -1
index 8a33809..e4d00fb 100644
@@ -29,13 +29,14 @@ static void cmd_help(void)
 void tests_cleanup(void)
 {
 	mbm_test_cleanup();
+	mba_test_cleanup();
 }
 
 int main(int argc, char **argv)
 {
 	char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE];
 	int res, c, core_id = 0, span = 250, argc_new = argc, i;
-	bool has_ben = false, mbm_test = true;
+	bool has_ben = false, mbm_test = true, mba_test = true;
 	char *benchmark_cmd[BENCHMARK_ARGS];
 	char bw_report[64], bm_type[64];
 
@@ -47,9 +48,12 @@ int main(int argc, char **argv)
 			token = strtok(optarg, ",");
 
 			mbm_test = false;
+			mba_test = false;
 			while (token) {
 				if (!strcmp(token, "mbm")) {
 					mbm_test = true;
+				} else if (!strcmp(token, "mba")) {
+					mba_test = true;
 				} else {
 					printf("invalid argument\n");
 
@@ -119,5 +123,14 @@ int main(int argc, char **argv)
 			printf("Error in running tests for mbm bw change!\n");
 	}
 
+	if (mba_test) {
+		printf("\nMBA Schemata Change Starting..\n");
+		if (!has_ben)
+			sprintf(benchmark_cmd[1], "%d", span);
+		res = mba_schemata_change(core_id, bw_report, benchmark_cmd);
+		if (res)
+			printf("Error in tests for mba-change-schemata!\n");
+	}
+
 	return 0;
 }
Signature · 1 line
1.8.3.1
author reviewer
#8 lore raw

PATCH v5 8/13 selftests/resctrl Add Cache QoS Monitoring (CQM) selftest

In reply to Moger, Babu

From: Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>

Cache QoS Monitoring (CQM) selftest starts stressful cache benchmark with specified size of memory to access the cache. Last Level cache occupancy reported by CQM should be close to the size of the memory.

Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/Makefile        |   2 +-
 tools/testing/selftests/resctrl/cache.c         | 102 +++++++++++
 tools/testing/selftests/resctrl/cqm_test.c      | 169 ++++++++++++++++++
 tools/testing/selftests/resctrl/fill_buf.c      | 107 +++++++-----
 tools/testing/selftests/resctrl/mba_test.c      |   3 +-
 tools/testing/selftests/resctrl/mbm_test.c      |   3 +-
 tools/testing/selftests/resctrl/resctrl.h       |  28 ++-
 tools/testing/selftests/resctrl/resctrl_tests.c |  82 ++++++---
 tools/testing/selftests/resctrl/resctrl_val.c   | 101 ++++++-----
 tools/testing/selftests/resctrl/resctrlfs.c     | 217 ++++++++++++++++++++++--
 10 files changed, 679 insertions(+), 135 deletions(-)
 create mode 100644 tools/testing/selftests/resctrl/cache.c
 create mode 100644 tools/testing/selftests/resctrl/cqm_test.c
tools/testing/selftests/resctrl/Makefile +1 -1
index 141cbdb..664561c 100644
@@ -8,7 +8,7 @@ all: resctrl_tests
 
 resctrl_tests: *.o
 	$(CC) $(CFLAGS) -o resctrl_tests resctrl_tests.o resctrlfs.o \
-		 resctrl_val.o fill_buf.o mbm_test.o mba_test.o
+		 resctrl_val.o fill_buf.o mbm_test.o mba_test.o cache.o cqm_test.o
 
 .PHONY: clean
 
tools/testing/selftests/resctrl/cache.c new file +102 -0

102 lines not on this page · raw message

tools/testing/selftests/resctrl/cqm_test.c new file +169 -0

169 lines not on this page · raw message

tools/testing/selftests/resctrl/fill_buf.c +62 -45

149 lines not on this page · raw message

tools/testing/selftests/resctrl/mba_test.c +2 -1
index 7a5d869..66be852 100644
@@ -57,6 +57,7 @@ static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc)
 {
 	int allocation, failed = 0, runs;
 
+	printf("\nResults are displayed in (MB)\n");
 	/* Memory bandwidth from 100% down to 10% */
 	for (allocation = 0; allocation < ALLOCATION_MAX / ALLOCATION_STEP;
 	     allocation++) {
@@ -159,7 +160,7 @@ int mba_schemata_change(int core_id, char *bw_report, char **benchmark_cmd)
 
 	remove(RESULT_FILE_NAME);
 
-	ret = membw_val(benchmark_cmd, &param);
+	ret = resctrl_val(benchmark_cmd, &param);
 	if (ret)
 		return ret;
 
tools/testing/selftests/resctrl/mbm_test.c +2 -1
index fc1b8ba..ce3eab1 100644
@@ -36,6 +36,7 @@
 	avg_bw_resc = sum_bw_resc / 4;
 	avg_diff = avg_bw_resc - avg_bw_imc;
 
+	printf("\nResults are displayed in (MB)\n");
 	printf("\nSpan (MB): %d \t", span);
 	printf("avg_bw_imc: %lu\t", avg_bw_imc);
 	printf("avg_bw_resc: %lu\t", avg_bw_resc);
@@ -131,7 +132,7 @@ int mbm_bw_change(int span, int core_id, char *bw_report, char **benchmark_cmd)
 
 	remove(RESULT_FILE_NAME);
 
-	ret = membw_val(benchmark_cmd, &param);
+	ret = resctrl_val(benchmark_cmd, &param);
 	if (ret)
 		return ret;
 
tools/testing/selftests/resctrl/resctrl.h +25 -3
index f54a034..a4f8040 100644
@@ -16,11 +16,18 @@
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/types.h>
+#include <sys/select.h>
 #include <asm/unistd.h>
 #include <linux/perf_event.h>
+#include <sys/time.h>
+#include <math.h>
+#include <sys/wait.h>
+#include <sys/eventfd.h>
 
+#define MB			(1024 * 1024)
 #define RESCTRL_PATH		"/sys/fs/resctrl"
 #define PHYS_ID_PATH		"/sys/devices/system/cpu/cpu"
+#define CBM_MASK_PATH		"/sys/fs/resctrl/info"
 
 #define PARENT_EXIT(err_msg)			\
 	do {					\
@@ -46,14 +53,20 @@ struct resctrl_val_param {
 	char	ctrlgrp[64];
 	char	mongrp[64];
 	int	cpu_no;
-	int	span;
+	unsigned long long span;
 	int	mum_resctrlfs;
 	char	filename[64];
 	char	*bw_report;
+	unsigned long mask;
+	int	num_of_runs;
 	int	(*setup)(int num, ...);
+
 };
 
 pid_t bm_pid, ppid;
+extern char cbm_mask[256];
+extern unsigned long long_mask;
+extern char llc_occup_path[1024];
 
 int remount_resctrlfs(bool mum_resctrlfs);
 int get_resource_id(int cpu_no, int *resource_id);
@@ -68,12 +81,21 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,
 			    char *resctrl_val);
 int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
 		    int group_fd, unsigned long flags);
-int run_fill_buf(int span, int malloc_and_init_memory, int memflush, int op);
-int membw_val(char **benchmark_cmd, struct resctrl_val_param *param);
+int run_fill_buf(unsigned long long span, int malloc_and_init_memory,
+		 int memflush, int op, char *resctrl_val);
+int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param);
 int mbm_bw_change(int span, int core_id, char *bw_report, char **benchmark_cmd);
 void tests_cleanup(void);
 void mbm_test_cleanup(void);
 int mba_schemata_change(int core_id, char *bw_report, char **benchmark_cmd);
 void mba_test_cleanup(void);
+int get_cbm_mask(char *cache_type);
+int get_cache_size(int cpu_no, int cache_num, unsigned long *cache_size);
+void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
+int cqm_resctrl_val(int core_id, int n, char **benchmark_cmd);
+unsigned int count_bits(unsigned long n);
+void cqm_test_cleanup(void);
+int get_core_sibling(int cpu_no);
+int measure_cache_vals(struct resctrl_val_param *param, int bm_pid);
 
 #endif /* RESCTRL_H */
tools/testing/selftests/resctrl/resctrl_tests.c +55 -27

154 lines not on this page · raw message

tools/testing/selftests/resctrl/resctrl_val.c +61 -40

185 lines not on this page · raw message

tools/testing/selftests/resctrl/resctrlfs.c +200 -17

313 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author reviewer
#9 lore raw

PATCH v5 9/13 selftests/resctrl: Add Cache Allocation Technology (CAT) selftest

In reply to Moger, Babu

From: Arshiya Hayatkhan Pathan <[email protected]>

Cache Allocation Technology (CAT) selftest allocates a portion of last level cache and starts a benchmark to read each cache line in this portion of cache. Measure the cache misses in perf and the misses should be equal to the number of cache lines in this portion of cache.

We don't use CQM to calculate cache usage because some CAT enabled platforms don't have CQM.

Signed-off-by Arshiya Hayatkhan Pathan <arshiya.hayatkhan.pathan at intel.com>
Signed-off-by Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>
Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/Makefile        |   2 +-
 tools/testing/selftests/resctrl/cache.c         | 175 ++++++++++++++++-
 tools/testing/selftests/resctrl/cat_test.c      | 243 ++++++++++++++++++++++++
 tools/testing/selftests/resctrl/fill_buf.c      |  10 +-
 tools/testing/selftests/resctrl/resctrl.h       |   3 +
 tools/testing/selftests/resctrl/resctrl_tests.c |  15 +-
 tools/testing/selftests/resctrl/resctrlfs.c     |   8 +-
 7 files changed, 448 insertions(+), 8 deletions(-)
 create mode 100644 tools/testing/selftests/resctrl/cat_test.c
tools/testing/selftests/resctrl/Makefile +1 -1
index 664561c..0282222 100644
@@ -8,7 +8,7 @@ all: resctrl_tests
 
 resctrl_tests: *.o
 	$(CC) $(CFLAGS) -o resctrl_tests resctrl_tests.o resctrlfs.o \
-		 resctrl_val.o fill_buf.o mbm_test.o mba_test.o cache.o cqm_test.o
+		 resctrl_val.o fill_buf.o mbm_test.o mba_test.o cache.o cqm_test.o cat_test.o
 
 .PHONY: clean
 
tools/testing/selftests/resctrl/cache.c +174 -1

197 lines not on this page · raw message

tools/testing/selftests/resctrl/cat_test.c new file +243 -0

243 lines not on this page · raw message

tools/testing/selftests/resctrl/fill_buf.c +8 -2
index 7c3579a..671d801 100644
@@ -105,8 +105,11 @@ void fill_one_span_write(unsigned char *start_ptr, unsigned char *end_ptr)
 static int fill_cache_read(unsigned char *start_ptr, unsigned char *end_ptr,
 			   char *resctrl_val)
 {
-	while (1)
+	while (1) {
 		fill_one_span_read(start_ptr, end_ptr);
+		if (!strcmp(resctrl_val, "cat"))
+			break;
+	}
 
 	return 0;
 }
@@ -114,8 +117,11 @@ static int fill_cache_read(unsigned char *start_ptr, unsigned char *end_ptr,
 static int fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr,
 			    char *resctrl_val)
 {
-	while (1)
+	while (1) {
 		fill_one_span_write(start_ptr, end_ptr);
+		if (!strcmp(resctrl_val, "cat"))
+			break;
+	}
 
 	return 0;
 }
tools/testing/selftests/resctrl/resctrl.h +3 -0
index a4f8040..3da2afe 100644
@@ -91,7 +91,10 @@ int run_fill_buf(unsigned long long span, int malloc_and_init_memory,
 void mba_test_cleanup(void);
 int get_cbm_mask(char *cache_type);
 int get_cache_size(int cpu_no, int cache_num, unsigned long *cache_size);
+int cat_val(struct resctrl_val_param *param);
+void cat_test_cleanup(void);
 void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
+int cat_perf_miss_val(int core_id, int no_of_bits);
 int cqm_resctrl_val(int core_id, int n, char **benchmark_cmd);
 unsigned int count_bits(unsigned long n);
 void cqm_test_cleanup(void);
tools/testing/selftests/resctrl/resctrl_tests.c +13 -2
index 6d4a1cf..2397c3b 100644
@@ -20,7 +20,7 @@ static void cmd_help(void)
 	printf("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CQM");
 	printf("\t default benchmark is builtin fill_buf\n");
 	printf("\t-t test list: run tests specified in the test list, ");
-	printf("e.g. -t mbm, mba, cqm\n");
+	printf("e.g. -t mbm, mba, cqm, cat\n");
 	printf("\t-n no_of_bits: run cache tests using specified no of bits in cache bit mask\n");
 	printf("\t-h: help\n");
 }
@@ -30,6 +30,7 @@ void tests_cleanup(void)
 	mbm_test_cleanup();
 	mba_test_cleanup();
 	cqm_test_cleanup();
+	cat_test_cleanup();
 }
 
 int main(int argc, char **argv)
@@ -38,7 +39,7 @@ int main(int argc, char **argv)
 	int res, c, core_id = 1, span = 250, argc_new = argc, i, no_of_bits = 5;
 	int ben_count, ben_ind;
 	bool has_ben = false, mbm_test = true, mba_test = true;
-	bool cqm_test = true;
+	bool cqm_test = true, cat_test = true;
 	char *benchmark_cmd[BENCHMARK_ARGS];
 	char bw_report[64], bm_type[64];
 
@@ -62,6 +63,7 @@ int main(int argc, char **argv)
 			mbm_test = false;
 			mba_test = false;
 			cqm_test = false;
+			cat_test = false;
 			while (token) {
 				if (!strcmp(token, "mbm")) {
 					mbm_test = true;
@@ -69,6 +71,8 @@ int main(int argc, char **argv)
 					mba_test = true;
 				} else if (!strcmp(token, "cqm")) {
 					cqm_test = true;
+				} else if (!strcmp(token, "cat")) {
+					cat_test = true;
 				} else {
 					printf("invalid argument\n");
 
@@ -159,6 +163,13 @@ int main(int argc, char **argv)
 			printf("Error in CQM test!\n");
 		cqm_test_cleanup();
 	}
+	if (cat_test) {
+		printf("\nCAT Test Starting..\n");
+		res = cat_perf_miss_val(core_id, no_of_bits);
+		if (res)
+			printf("Error in CAT test!\n");
+		cat_test_cleanup();
+	}
 
 	return 0;
 }
tools/testing/selftests/resctrl/resctrlfs.c +6 -2
index 3c88afa..146a10e 100644
@@ -14,6 +14,7 @@
 #define RESCTRL_MBM		"L3 monitoring detected"
 #define RESCTRL_MBA		"MB allocation detected"
 #define RESCTRL_CQM		"L3 monitoring detected"
+#define RESCTRL_L3_CAT		"L3 allocation detected"
 #define MAX_RESCTRL_FEATURES	4
 #define CORE_SIBLINGS_PATH	"/sys/bus/cpu/devices/cpu"
 
@@ -475,6 +476,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val)
 	FILE *fp;
 
 	if ((strcmp(resctrl_val, "mba") == 0) ||
+	    (strcmp(resctrl_val, "cat") == 0) ||
 	    (strcmp(resctrl_val, "cqm") == 0)) {
 		if (!schemata) {
 			printf("Schemata empty, so not updating\n");
@@ -492,7 +494,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val)
 		else
 			sprintf(controlgroup, "%s/schemata", RESCTRL_PATH);
 
-		if (!strcmp(resctrl_val, "cqm"))
+		if (!strcmp(resctrl_val, "cat") || !strcmp(resctrl_val, "cqm"))
 			sprintf(schema, "%s%d%c%s", "L3:", resource_id, '=',
 				schemata);
 		if (strcmp(resctrl_val, "mba") == 0)
@@ -530,7 +532,7 @@ int validate_resctrl_feature_request(char *resctrl_val)
 {
 	int resctrl_features_supported[MAX_RESCTRL_FEATURES] = {0, 0, 0, 0};
 	const char *resctrl_features_list[MAX_RESCTRL_FEATURES] = {
-			"mbm", "mba", "cqm"};
+			"mbm", "mba", "cat", "cqm"};
 	int i, valid_resctrl_feature = -1;
 	char line[1024];
 	FILE *fp;
@@ -571,6 +573,8 @@ int validate_resctrl_feature_request(char *resctrl_val)
 			resctrl_features_supported[0] = 1;
 		if ((strstr(line, RESCTRL_MBA)) != NULL)
 			resctrl_features_supported[1] = 1;
+		if ((strstr(line, RESCTRL_L3_CAT)) != NULL)
+			resctrl_features_supported[2] = 1;
 		if ((strstr(line, RESCTRL_CQM)) != NULL)
 			resctrl_features_supported[3] = 1;
 	}
Signature · 1 line
1.8.3.1
author reviewer
#10 lore raw

PATCH v5 10/13 selftests/resctrl: Add the test in MAINTAINERS

In reply to Moger, Babu

From: Fenghua Yu <[email protected]>

The resctrl selftest will be maintained by RDT maintainers.

Signed-off-by Fenghua Yu <fenghua.yu at intel.com>
Signed-off-by Babu Moger <babu.moger at amd.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 32d44447..16359bc 100644
@@ -12815,6 +12815,7 @@ S:	Supported
 F:	arch/x86/kernel/cpu/resctrl/
 F:	arch/x86/include/asm/resctrl_sched.h
 F:	Documentation/x86/resctrl*
+F:	tools/testing/selftests/resctrl/
 
 READ-COPY UPDATE (RCU)
 M:	"Paul E. McKenney" <paulmck at linux.ibm.com>
Signature · 1 line
1.8.3.1
author reviewer
#11 lore raw

PATCH v5 11/13 selftests/resctrl: Add vendor detection mechanism

In reply to Moger, Babu

RESCTRL feature is supported both on Intel and AMD now. Some features are implemented differently. Add vendor detection mechanism. Use the vendor check where there are differences.

Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/resctrl.h       | 13 +++++
 tools/testing/selftests/resctrl/resctrl_tests.c | 68 +++++++++++++++++++++++++
 2 files changed, 81 insertions(+)
tools/testing/selftests/resctrl/resctrl.h +13 -0
index 3da2afe..1ec97d1 100644
@@ -63,10 +63,23 @@ struct resctrl_val_param {
 
 };
 
+/**
+ * Results of CPUID operation are stored in this structure.
+ * It consists of 4x32bits IA registers: EAX, EBX, ECX and EDX.
+ */
+struct cpuid_out {
+        uint32_t eax;
+        uint32_t ebx;
+        uint32_t ecx;
+        uint32_t edx;
+};
+
 pid_t bm_pid, ppid;
 extern char cbm_mask[256];
 extern unsigned long long_mask;
 extern char llc_occup_path[1024];
+extern int genuine_intel;
+extern int authentic_amd;
 
 int remount_resctrlfs(bool mum_resctrlfs);
 int get_resource_id(int cpu_no, int *resource_id);
tools/testing/selftests/resctrl/resctrl_tests.c +68 -0

80 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author reviewer
#12 lore raw

PATCH v5 12/13 selftests/resctrl: Use cache index3 id for AMD schemata masks

In reply to Moger, Babu

AMD uses the cache l3 boundary for schemata masks. Update it accordigly.

Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/resctrlfs.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/resctrlfs.c +7 -2
index 146a10e..15cda1b 100644
@@ -103,8 +103,13 @@ int get_resource_id(int cpu_no, int *resource_id)
 	char phys_pkg_path[1024];
 	FILE *fp;
 
-	sprintf(phys_pkg_path, "%s%d/topology/physical_package_id",
-		PHYS_ID_PATH, cpu_no);
+	if (authentic_amd)
+		sprintf(phys_pkg_path, "%s%d/cache/index3/id",
+                        PHYS_ID_PATH, cpu_no);
+	else
+		sprintf(phys_pkg_path, "%s%d/topology/physical_package_id",
+			PHYS_ID_PATH, cpu_no);
+
 	fp = fopen(phys_pkg_path, "r");
 	if (!fp) {
 		perror("Failed to open physical_package_id");
Signature · 1 line
1.8.3.1
author reviewer
#13 lore raw

PATCH v5 13/13 selftests/resctrl: Disable MBA and MBM tests for AMD

In reply to Moger, Babu

For now, disable MBA and MBM tests for AMD. Deciding test pass/fail is not clear right now. We can enable when we have some clarity.

Signed-off-by Babu Moger <babu.moger at amd.com>
---
 tools/testing/selftests/resctrl/cat_test.c      | 2 +-
 tools/testing/selftests/resctrl/resctrl_tests.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/resctrl/cat_test.c +1 -1
index 57d501d..badf2d1 100644
@@ -69,7 +69,7 @@ static void show_cache_info(unsigned long sum_llc_perf_miss, int no_of_bits,
 	printf("Allocated cache lines: %lu \t", allocated_cache_lines);
 	printf("Percent diff=%d \t", abs((int)diff_percent));
 
-	if (abs((int)diff_percent) > MAX_DIFF_PERCENT)
+	if (genuine_intel && (abs((int)diff_percent) > MAX_DIFF_PERCENT))
 		printf("Failed\n");
 	else
 		printf("Passed\n");
tools/testing/selftests/resctrl/resctrl_tests.c +2 -2
index e8cbcd5..b12f2c5 100644
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
 	sprintf(bw_report, "reads");
 	sprintf(bm_type, "fill_buf");
 
-	if (mbm_test) {
+	if (genuine_intel && mbm_test) {
 		printf("\nMBM BW Change Starting..\n");
 		if (!has_ben)
 			sprintf(benchmark_cmd[5], "%s", "mbm");
@@ -212,7 +212,7 @@ int main(int argc, char **argv)
 		mbm_test_cleanup();
 	}
 
-	if (mba_test) {
+	if (genuine_intel && mba_test) {
 		printf("\nMBA Schemata Change Starting..\n");
 		if (!has_ben)
 			sprintf(benchmark_cmd[5], "%s", "mba");
Signature · 1 line
1.8.3.1