From: Anju T Sudhakar <anju@linux.vnet.ibm.com>
To: mpe@ellerman.id.au
Cc: nasastry@in.ibm.com, maddy@linux.vnet.ibm.com,
linuxppc-dev@lists.ozlabs.org, anju@linux.vnet.ibm.com
Subject: [PATCH v2 5/5] selftest/powerpc/pmu: Testcase for imc global lock mechanism
Date: Tue, 21 Jan 2020 15:47:28 +0530 [thread overview]
Message-ID: <20200121101728.14858-6-anju@linux.vnet.ibm.com> (raw)
In-Reply-To: <20200121101728.14858-1-anju@linux.vnet.ibm.com>
From: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
---
.../pmu/mem_counters/imc_global_lock_test.c | 49 ++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/powerpc/pmu/mem_counters/imc_global_lock_test.c b/tools/testing/selftests/powerpc/pmu/mem_counters/imc_global_lock_test.c
index ea687ffc1990..f643dba8ecc0 100644
--- a/tools/testing/selftests/powerpc/pmu/mem_counters/imc_global_lock_test.c
+++ b/tools/testing/selftests/powerpc/pmu/mem_counters/imc_global_lock_test.c
@@ -5,9 +5,56 @@
#include "mem_counters.h"
+static bool check_imc_interface_glob_lck(void)
+{
+ if (!access("/sys/devices/thread_imc/interface/glob_lck", F_OK))
+ return true;
+
+ return false;
+}
+
static int testcase(void)
{
- return 0;
+ struct event events[2];
+
+ if (!check_imc_interface_glob_lck()) {
+ printf("Test not supported\n");
+ return MAGIC_SKIP_RETURN_VALUE;
+ }
+
+ if (!is_mem_counters_device_enabled(CORE) || !is_mem_counters_device_enabled(THREAD)) {
+ printf("%s: IMC device not found. So exiting the test\n", __FUNCTION__);
+ return -1;
+ }
+
+ if (setup_mem_counters_event(THREAD, &events[0], 0xe0, "thread_imc/cycles")) {
+ printf("%s setup_mem_counters_event for thread_imc failed\n", __FUNCTION__);
+ return -1;
+ }
+
+ if (setup_mem_counters_event(CORE, &events[1], 0xe0, "core_imc/cycles")) {
+ printf("%s setup_mem_counters_event for core_imc failed\n", __FUNCTION__);
+ return -1;
+ }
+
+ if (event_open(&events[0])) {
+ perror("thread_imc: perf_event_open");
+ return -1;
+ }
+
+ /*
+ * If we have the Global lock patchset applied to kernel
+ * event_open for events[1] should fail with resource busy
+ */
+ if (event_open_with_cpu(&events[1], 0)) {
+ /*
+ * Check for the errno to certify the test result
+ */
+ if (errno == 16) // Resource busy (EBUSY)
+ return 0;
+ }
+
+ return -1;
}
static int imc_global_lock_test(void)
--
2.20.1
prev parent reply other threads:[~2020-01-21 10:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 10:17 [PATCH v2 0/5] Re-enable IMC trace-mode Anju T Sudhakar
2020-01-21 10:17 ` [PATCH v2 1/5] powerpc/powernv: Re-enable imc trace-mode in kernel Anju T Sudhakar
2020-02-06 9:03 ` maddy
2020-01-21 10:17 ` [PATCH v2 2/5] powerpc/perf: Implement a global lock to avoid races between trace, core and thread imc events Anju T Sudhakar
2020-02-06 9:04 ` maddy
2020-01-21 10:17 ` [PATCH v2 3/5] powerpc/perf: Add an interface sub-folder to imc pmu Anju T Sudhakar
2020-01-21 10:17 ` [PATCH v2 4/5] selftest/powerpc/pmc: Support to include interface test for Memory Counter PMUs Anju T Sudhakar
2020-01-21 10:17 ` Anju T Sudhakar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200121101728.14858-6-anju@linux.vnet.ibm.com \
--to=anju@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.vnet.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=nasastry@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).