Re: [PATCH v13] high_freq_hwp_cap_cppc.c: new test

Cyril Hrubis <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
Hi!
> +#include "tst_test.h"
> +#include "tst_safe_prw.h"
> +
> +#define MSR_HWP_CAPABILITIES	0x771
> +#define HIGHEST_PERF_MASK	0xFF
> +
> +static int nproc;
> +static int fd = -1;
> +static int *mismatch;
> +
> +static void setup(void)
> +{
> +	if (access("/dev/cpu/0/msr", F_OK) == -1)
> +		tst_brk(TCONF | TERRNO, "msr driver not loaded");
> +
> +	if (access("/sys/devices/system/cpu/cpu0/acpi_cppc/highest_perf", F_OK) == -1)
> +		tst_brk(TCONF | TERRNO, "CPPC sysfs not available");
> +
> +	nproc = tst_ncpus_conf();
> +	mismatch = SAFE_MALLOC(nproc * sizeof(int));
> +}
> +
> +static void cleanup(void)
> +{
> +	if (fd != -1)
> +		SAFE_CLOSE(fd);
> +
> +	free(mismatch);
> +}
> +
> +static void run(void)
> +{
> +	bool status = true;
> +	char path[PATH_MAX];
> +
> +	memset(mismatch, 0, nproc * sizeof(*mismatch));
> +
> +	for (int i = 0; i < nproc; i++) {
> +		int online = 1;
> +		unsigned long long msr_highest_perf = 0, sysfs_highest_perf = 0;
> +
> +		if (i) {
> +			snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/online", i);
> +			SAFE_FILE_SCANF(path, "%d", &online);
> +		}
> +
> +		if (!online) {
> +			tst_res(TINFO, "CPU%d offline, skipping", i);
> +			continue;
> +		}
> +
> +		snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/acpi_cppc/highest_perf", i);
> +		SAFE_FILE_SCANF(path, "%llu", &sysfs_highest_perf);
> +		tst_res(TDEBUG, "%s: %llu", path, sysfs_highest_perf);
> +
> +		snprintf(path, sizeof(path), "/dev/cpu/%d/msr", i);
> +		fd = SAFE_OPEN(path, O_RDONLY);
> +
> +		SAFE_PREAD(1, fd, &msr_highest_perf, sizeof(msr_highest_perf), MSR_HWP_CAPABILITIES);

If I run the test on AMD Ryzen I get EIO here. I suppose that we need to
limit this test to a family of CPUs that match the MSR format we expect.

-- 
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.