selftests/powerpc: Run EBB tests only on POWER8

EBB (Event Based Branches) are currently only available on POWER8, so we
should skip them on other CPUs.

I've found that at least one test loops forever on 970MP (cycles_with_freeze_test).

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
[mpe: Minor change log editing, add skip to cpu_event_vs_ebb_test]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
Denis Kirjanov 2015-10-18 13:23:53 +03:00 committed by Michael Ellerman
parent 20d09927e6
commit 39fcfb911c
24 changed files with 56 additions and 0 deletions

View file

@ -63,6 +63,8 @@ int back_to_back_ebbs(void)
{ {
struct event event; struct event event;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -20,6 +20,8 @@ int close_clears_pmcc(void)
{ {
struct event event; struct event event;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -43,6 +43,8 @@ int cpu_event_pinned_vs_ebb(void)
int cpu, rc; int cpu, rc;
pid_t pid; pid_t pid;
SKIP_IF(!ebb_is_supported());
cpu = pick_online_cpu(); cpu = pick_online_cpu();
FAIL_IF(cpu < 0); FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu)); FAIL_IF(bind_to_cpu(cpu));

View file

@ -41,6 +41,8 @@ int cpu_event_vs_ebb(void)
int cpu, rc; int cpu, rc;
pid_t pid; pid_t pid;
SKIP_IF(!ebb_is_supported());
cpu = pick_online_cpu(); cpu = pick_online_cpu();
FAIL_IF(cpu < 0); FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu)); FAIL_IF(bind_to_cpu(cpu));

View file

@ -16,6 +16,8 @@ int cycles(void)
{ {
struct event event; struct event event;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -56,6 +56,8 @@ int cycles_with_freeze(void)
uint64_t val; uint64_t val;
bool fc_cleared; bool fc_cleared;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -26,6 +26,8 @@ int cycles_with_mmcr2(void)
int i; int i;
bool bad_mmcr2; bool bad_mmcr2;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -13,6 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/auxvec.h>
#include "trace.h" #include "trace.h"
#include "reg.h" #include "reg.h"
@ -319,6 +320,16 @@ void ebb_global_disable(void)
mb(); mb();
} }
bool ebb_is_supported(void)
{
#ifdef PPC_FEATURE2_EBB
/* EBB requires at least POWER8 */
return ((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_EBB);
#else
return false;
#endif
}
void event_ebb_init(struct event *e) void event_ebb_init(struct event *e)
{ {
e->attr.config |= (1ull << 63); e->attr.config |= (1ull << 63);

View file

@ -52,6 +52,7 @@ void standard_ebb_callee(void);
int ebb_event_enable(struct event *e); int ebb_event_enable(struct event *e);
void ebb_global_enable(void); void ebb_global_enable(void);
void ebb_global_disable(void); void ebb_global_disable(void);
bool ebb_is_supported(void);
void ebb_freeze_pmcs(void); void ebb_freeze_pmcs(void);
void ebb_unfreeze_pmcs(void); void ebb_unfreeze_pmcs(void);
void event_ebb_init(struct event *e); void event_ebb_init(struct event *e);

View file

@ -47,6 +47,8 @@ int ebb_on_child(void)
struct event event; struct event event;
pid_t pid; pid_t pid;
SKIP_IF(!ebb_is_supported());
FAIL_IF(pipe(read_pipe.fds) == -1); FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1); FAIL_IF(pipe(write_pipe.fds) == -1);

View file

@ -54,6 +54,8 @@ int ebb_on_willing_child(void)
struct event event; struct event event;
pid_t pid; pid_t pid;
SKIP_IF(!ebb_is_supported());
FAIL_IF(pipe(read_pipe.fds) == -1); FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1); FAIL_IF(pipe(write_pipe.fds) == -1);

View file

@ -41,6 +41,8 @@ int ebb_vs_cpu_event(void)
int cpu, rc; int cpu, rc;
pid_t pid; pid_t pid;
SKIP_IF(!ebb_is_supported());
cpu = pick_online_cpu(); cpu = pick_online_cpu();
FAIL_IF(cpu < 0); FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu)); FAIL_IF(bind_to_cpu(cpu));

View file

@ -16,6 +16,8 @@ int event_attributes(void)
{ {
struct event event, leader; struct event event, leader;
SKIP_IF(!ebb_is_supported());
event_init(&event, 0x1001e); event_init(&event, 0x1001e);
event_leader_ebb_init(&event); event_leader_ebb_init(&event);
/* Expected to succeed */ /* Expected to succeed */

View file

@ -44,6 +44,8 @@ int fork_cleanup(void)
{ {
pid_t pid; pid_t pid;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -111,6 +111,8 @@ int instruction_count(void)
struct event event; struct event event;
uint64_t overhead; uint64_t overhead;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x400FA, "PM_RUN_INST_CMPL"); event_init_named(&event, 0x400FA, "PM_RUN_INST_CMPL");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);
event.attr.exclude_kernel = 1; event.attr.exclude_kernel = 1;

View file

@ -23,6 +23,8 @@ static int test_body(void)
int i, orig_period, max_period; int i, orig_period, max_period;
struct event event; struct event event;
SKIP_IF(!ebb_is_supported());
/* We use PMC4 to make sure the kernel switches all counters correctly */ /* We use PMC4 to make sure the kernel switches all counters correctly */
event_init_named(&event, 0x40002, "instructions"); event_init_named(&event, 0x40002, "instructions");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -18,6 +18,8 @@ int multi_counter(void)
struct event events[6]; struct event events[6];
int i, group_fd; int i, group_fd;
SKIP_IF(!ebb_is_supported());
event_init_named(&events[0], 0x1001C, "PM_CMPLU_STALL_THRD"); event_init_named(&events[0], 0x1001C, "PM_CMPLU_STALL_THRD");
event_init_named(&events[1], 0x2D016, "PM_CMPLU_STALL_FXU"); event_init_named(&events[1], 0x2D016, "PM_CMPLU_STALL_FXU");
event_init_named(&events[2], 0x30006, "PM_CMPLU_STALL_OTHER_CMPL"); event_init_named(&events[2], 0x30006, "PM_CMPLU_STALL_OTHER_CMPL");

View file

@ -79,6 +79,8 @@ int multi_ebb_procs(void)
pid_t pids[NR_CHILDREN]; pid_t pids[NR_CHILDREN];
int cpu, rc, i; int cpu, rc, i;
SKIP_IF(!ebb_is_supported());
cpu = pick_online_cpu(); cpu = pick_online_cpu();
FAIL_IF(cpu < 0); FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu)); FAIL_IF(bind_to_cpu(cpu));

View file

@ -19,6 +19,8 @@ static int no_handler_test(void)
u64 val; u64 val;
int i; int i;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -58,6 +58,8 @@ static int test_body(void)
{ {
struct event event; struct event event;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles"); event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -49,6 +49,8 @@ int pmc56_overflow(void)
{ {
struct event event; struct event event;
SKIP_IF(!ebb_is_supported());
/* Use PMC2 so we set PMCjCE, which enables PMC5/6 */ /* Use PMC2 so we set PMCjCE, which enables PMC5/6 */
event_init(&event, 0x2001e); event_init(&event, 0x2001e);
event_leader_ebb_init(&event); event_leader_ebb_init(&event);

View file

@ -18,6 +18,8 @@ int reg_access(void)
{ {
uint64_t val, expected; uint64_t val, expected;
SKIP_IF(!ebb_is_supported());
expected = 0x8000000100000000ull; expected = 0x8000000100000000ull;
mtspr(SPRN_BESCR, expected); mtspr(SPRN_BESCR, expected);
val = mfspr(SPRN_BESCR); val = mfspr(SPRN_BESCR);

View file

@ -42,6 +42,8 @@ int task_event_pinned_vs_ebb(void)
pid_t pid; pid_t pid;
int rc; int rc;
SKIP_IF(!ebb_is_supported());
FAIL_IF(pipe(read_pipe.fds) == -1); FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1); FAIL_IF(pipe(write_pipe.fds) == -1);

View file

@ -40,6 +40,8 @@ int task_event_vs_ebb(void)
pid_t pid; pid_t pid;
int rc; int rc;
SKIP_IF(!ebb_is_supported());
FAIL_IF(pipe(read_pipe.fds) == -1); FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1); FAIL_IF(pipe(write_pipe.fds) == -1);