[PATCH] perf test: Delete unused Intel CQM test

Howard Chu posted 1 patch 1 month, 2 weeks ago
tools/perf/arch/x86/tests/intel-cqm.c | 128 --------------------------
1 file changed, 128 deletions(-)
delete mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
[PATCH] perf test: Delete unused Intel CQM test
Posted by Howard Chu 1 month, 2 weeks ago
As Ian Rogers <irogers@google.com> pointed out, intel-cqm.c is neither
used nor built. It was deleted in the following commit:

commit b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")

However, it resurfaced soon after in the following commit:

commit 5c9295bfe6f5 ("perf tests: Remove Intel CQM perf test")

It should be deleted once and for all.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Howard Chu <howardchu95@gmail.com>
---
 tools/perf/arch/x86/tests/intel-cqm.c | 128 --------------------------
 1 file changed, 128 deletions(-)
 delete mode 100644 tools/perf/arch/x86/tests/intel-cqm.c

diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c
deleted file mode 100644
index 360a082fc928..000000000000
--- a/tools/perf/arch/x86/tests/intel-cqm.c
+++ /dev/null
@@ -1,128 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include "tests/tests.h"
-#include "cloexec.h"
-#include "debug.h"
-#include "evlist.h"
-#include "evsel.h"
-#include "arch-tests.h"
-#include <internal/lib.h> // page_size
-
-#include <signal.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <string.h>
-
-static pid_t spawn(void)
-{
-	pid_t pid;
-
-	pid = fork();
-	if (pid)
-		return pid;
-
-	while(1)
-		sleep(5);
-	return 0;
-}
-
-/*
- * Create an event group that contains both a sampled hardware
- * (cpu-cycles) and software (intel_cqm/llc_occupancy/) event. We then
- * wait for the hardware perf counter to overflow and generate a PMI,
- * which triggers an event read for both of the events in the group.
- *
- * Since reading Intel CQM event counters requires sending SMP IPIs, the
- * CQM pmu needs to handle the above situation gracefully, and return
- * the last read counter value to avoid triggering a WARN_ON_ONCE() in
- * smp_call_function_many() caused by sending IPIs from NMI context.
- */
-int test__intel_cqm_count_nmi_context(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
-{
-	struct evlist *evlist = NULL;
-	struct evsel *evsel = NULL;
-	struct perf_event_attr pe;
-	int i, fd[2], flag, ret;
-	size_t mmap_len;
-	void *event;
-	pid_t pid;
-	int err = TEST_FAIL;
-
-	flag = perf_event_open_cloexec_flag();
-
-	evlist = evlist__new();
-	if (!evlist) {
-		pr_debug("evlist__new failed\n");
-		return TEST_FAIL;
-	}
-
-	ret = parse_event(evlist, "intel_cqm/llc_occupancy/");
-	if (ret) {
-		pr_debug("parse_events failed, is \"intel_cqm/llc_occupancy/\" available?\n");
-		err = TEST_SKIP;
-		goto out;
-	}
-
-	evsel = evlist__first(evlist);
-	if (!evsel) {
-		pr_debug("evlist__first failed\n");
-		goto out;
-	}
-
-	memset(&pe, 0, sizeof(pe));
-	pe.size = sizeof(pe);
-
-	pe.type = PERF_TYPE_HARDWARE;
-	pe.config = PERF_COUNT_HW_CPU_CYCLES;
-	pe.read_format = PERF_FORMAT_GROUP;
-
-	pe.sample_period = 128;
-	pe.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_READ;
-
-	pid = spawn();
-
-	fd[0] = sys_perf_event_open(&pe, pid, -1, -1, flag);
-	if (fd[0] < 0) {
-		pr_debug("failed to open event\n");
-		goto out;
-	}
-
-	memset(&pe, 0, sizeof(pe));
-	pe.size = sizeof(pe);
-
-	pe.type = evsel->attr.type;
-	pe.config = evsel->attr.config;
-
-	fd[1] = sys_perf_event_open(&pe, pid, -1, fd[0], flag);
-	if (fd[1] < 0) {
-		pr_debug("failed to open event\n");
-		goto out;
-	}
-
-	/*
-	 * Pick a power-of-two number of pages + 1 for the meta-data
-	 * page (struct perf_event_mmap_page). See tools/perf/design.txt.
-	 */
-	mmap_len = page_size * 65;
-
-	event = mmap(NULL, mmap_len, PROT_READ, MAP_SHARED, fd[0], 0);
-	if (event == (void *)(-1)) {
-		pr_debug("failed to mmap %d\n", errno);
-		goto out;
-	}
-
-	sleep(1);
-
-	err = TEST_OK;
-
-	munmap(event, mmap_len);
-
-	for (i = 0; i < 2; i++)
-		close(fd[i]);
-
-	kill(pid, SIGKILL);
-	wait(NULL);
-out:
-	evlist__delete(evlist);
-	return err;
-}
-- 
2.43.0
Re: [PATCH] perf test: Delete unused Intel CQM test
Posted by Namhyung Kim 1 month, 1 week ago
On Thu, 10 Oct 2024 22:57:00 -0700, Howard Chu wrote:

> As Ian Rogers <irogers@google.com> pointed out, intel-cqm.c is neither
> used nor built. It was deleted in the following commit:
> 
> commit b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
> 
> However, it resurfaced soon after in the following commit:
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung
Re: [PATCH] perf test: Delete unused Intel CQM test
Posted by Matt Fleming 1 month, 2 weeks ago
On Fri, Oct 11, 2024 at 6:57 AM Howard Chu <howardchu95@gmail.com> wrote:
>
> As Ian Rogers <irogers@google.com> pointed out, intel-cqm.c is neither
> used nor built. It was deleted in the following commit:
>
> commit b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
>
> However, it resurfaced soon after in the following commit:
>
> commit 5c9295bfe6f5 ("perf tests: Remove Intel CQM perf test")
>
> It should be deleted once and for all.
>
> Suggested-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Howard Chu <howardchu95@gmail.com>
> ---
>  tools/perf/arch/x86/tests/intel-cqm.c | 128 --------------------------
>  1 file changed, 128 deletions(-)
>  delete mode 100644 tools/perf/arch/x86/tests/intel-cqm.c

Reviewed-by: Matt Fleming <mfleming@cloudflare.com>
Re: [PATCH] perf test: Delete unused Intel CQM test
Posted by Ian Rogers 1 month, 2 weeks ago
On Thu, Oct 10, 2024 at 10:57 PM Howard Chu <howardchu95@gmail.com> wrote:
>
> As Ian Rogers <irogers@google.com> pointed out, intel-cqm.c is neither
> used nor built. It was deleted in the following commit:
>
> commit b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
>
> However, it resurfaced soon after in the following commit:
>
> commit 5c9295bfe6f5 ("perf tests: Remove Intel CQM perf test")

I think the two commits are swapped, but otherwise lgtm.

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> It should be deleted once and for all.
>
> Suggested-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Howard Chu <howardchu95@gmail.com>
> ---
>  tools/perf/arch/x86/tests/intel-cqm.c | 128 --------------------------
>  1 file changed, 128 deletions(-)
>  delete mode 100644 tools/perf/arch/x86/tests/intel-cqm.c
>
> diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c
> deleted file mode 100644
> index 360a082fc928..000000000000
> --- a/tools/perf/arch/x86/tests/intel-cqm.c
> +++ /dev/null
> @@ -1,128 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include "tests/tests.h"
> -#include "cloexec.h"
> -#include "debug.h"
> -#include "evlist.h"
> -#include "evsel.h"
> -#include "arch-tests.h"
> -#include <internal/lib.h> // page_size
> -
> -#include <signal.h>
> -#include <sys/mman.h>
> -#include <sys/wait.h>
> -#include <errno.h>
> -#include <string.h>
> -
> -static pid_t spawn(void)
> -{
> -       pid_t pid;
> -
> -       pid = fork();
> -       if (pid)
> -               return pid;
> -
> -       while(1)
> -               sleep(5);
> -       return 0;
> -}
> -
> -/*
> - * Create an event group that contains both a sampled hardware
> - * (cpu-cycles) and software (intel_cqm/llc_occupancy/) event. We then
> - * wait for the hardware perf counter to overflow and generate a PMI,
> - * which triggers an event read for both of the events in the group.
> - *
> - * Since reading Intel CQM event counters requires sending SMP IPIs, the
> - * CQM pmu needs to handle the above situation gracefully, and return
> - * the last read counter value to avoid triggering a WARN_ON_ONCE() in
> - * smp_call_function_many() caused by sending IPIs from NMI context.
> - */
> -int test__intel_cqm_count_nmi_context(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
> -{
> -       struct evlist *evlist = NULL;
> -       struct evsel *evsel = NULL;
> -       struct perf_event_attr pe;
> -       int i, fd[2], flag, ret;
> -       size_t mmap_len;
> -       void *event;
> -       pid_t pid;
> -       int err = TEST_FAIL;
> -
> -       flag = perf_event_open_cloexec_flag();
> -
> -       evlist = evlist__new();
> -       if (!evlist) {
> -               pr_debug("evlist__new failed\n");
> -               return TEST_FAIL;
> -       }
> -
> -       ret = parse_event(evlist, "intel_cqm/llc_occupancy/");
> -       if (ret) {
> -               pr_debug("parse_events failed, is \"intel_cqm/llc_occupancy/\" available?\n");
> -               err = TEST_SKIP;
> -               goto out;
> -       }
> -
> -       evsel = evlist__first(evlist);
> -       if (!evsel) {
> -               pr_debug("evlist__first failed\n");
> -               goto out;
> -       }
> -
> -       memset(&pe, 0, sizeof(pe));
> -       pe.size = sizeof(pe);
> -
> -       pe.type = PERF_TYPE_HARDWARE;
> -       pe.config = PERF_COUNT_HW_CPU_CYCLES;
> -       pe.read_format = PERF_FORMAT_GROUP;
> -
> -       pe.sample_period = 128;
> -       pe.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_READ;
> -
> -       pid = spawn();
> -
> -       fd[0] = sys_perf_event_open(&pe, pid, -1, -1, flag);
> -       if (fd[0] < 0) {
> -               pr_debug("failed to open event\n");
> -               goto out;
> -       }
> -
> -       memset(&pe, 0, sizeof(pe));
> -       pe.size = sizeof(pe);
> -
> -       pe.type = evsel->attr.type;
> -       pe.config = evsel->attr.config;
> -
> -       fd[1] = sys_perf_event_open(&pe, pid, -1, fd[0], flag);
> -       if (fd[1] < 0) {
> -               pr_debug("failed to open event\n");
> -               goto out;
> -       }
> -
> -       /*
> -        * Pick a power-of-two number of pages + 1 for the meta-data
> -        * page (struct perf_event_mmap_page). See tools/perf/design.txt.
> -        */
> -       mmap_len = page_size * 65;
> -
> -       event = mmap(NULL, mmap_len, PROT_READ, MAP_SHARED, fd[0], 0);
> -       if (event == (void *)(-1)) {
> -               pr_debug("failed to mmap %d\n", errno);
> -               goto out;
> -       }
> -
> -       sleep(1);
> -
> -       err = TEST_OK;
> -
> -       munmap(event, mmap_len);
> -
> -       for (i = 0; i < 2; i++)
> -               close(fd[i]);
> -
> -       kill(pid, SIGKILL);
> -       wait(NULL);
> -out:
> -       evlist__delete(evlist);
> -       return err;
> -}
> --
> 2.43.0
>