Skip to content

Commit

Permalink
selftests/powerpc: Run EBB tests only on POWER8
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Denis Kirjanov authored and Michael Ellerman committed Oct 19, 2015
1 parent 20d0992 commit 39fcfb9
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ int back_to_back_ebbs(void)
{
struct event event;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ int close_clears_pmcc(void)
{
struct event event;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ int cpu_event_pinned_vs_ebb(void)
int cpu, rc;
pid_t pid;

SKIP_IF(!ebb_is_supported());

cpu = pick_online_cpu();
FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int cpu_event_vs_ebb(void)
int cpu, rc;
pid_t pid;

SKIP_IF(!ebb_is_supported());

cpu = pick_online_cpu();
FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu));
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ int cycles(void)
{
struct event event;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ int cycles_with_freeze(void)
uint64_t val;
bool fc_cleared;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ int cycles_with_mmcr2(void)
int i;
bool bad_mmcr2;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
11 changes: 11 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/ebb.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/auxvec.h>

#include "trace.h"
#include "reg.h"
Expand Down Expand Up @@ -319,6 +320,16 @@ void ebb_global_disable(void)
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)
{
e->attr.config |= (1ull << 63);
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/ebb.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void standard_ebb_callee(void);
int ebb_event_enable(struct event *e);
void ebb_global_enable(void);
void ebb_global_disable(void);
bool ebb_is_supported(void);
void ebb_freeze_pmcs(void);
void ebb_unfreeze_pmcs(void);
void event_ebb_init(struct event *e);
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/ebb_on_child_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ int ebb_on_child(void)
struct event event;
pid_t pid;

SKIP_IF(!ebb_is_supported());

FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ int ebb_on_willing_child(void)
struct event event;
pid_t pid;

SKIP_IF(!ebb_is_supported());

FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int ebb_vs_cpu_event(void)
int cpu, rc;
pid_t pid;

SKIP_IF(!ebb_is_supported());

cpu = pick_online_cpu();
FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ int event_attributes(void)
{
struct event event, leader;

SKIP_IF(!ebb_is_supported());

event_init(&event, 0x1001e);
event_leader_ebb_init(&event);
/* Expected to succeed */
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/fork_cleanup_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ int fork_cleanup(void)
{
pid_t pid;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ int instruction_count(void)
struct event event;
uint64_t overhead;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x400FA, "PM_RUN_INST_CMPL");
event_leader_ebb_init(&event);
event.attr.exclude_kernel = 1;
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ static int test_body(void)
int i, orig_period, max_period;
struct event event;

SKIP_IF(!ebb_is_supported());

/* We use PMC4 to make sure the kernel switches all counters correctly */
event_init_named(&event, 0x40002, "instructions");
event_leader_ebb_init(&event);
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ int multi_counter(void)
struct event events[6];
int i, group_fd;

SKIP_IF(!ebb_is_supported());

event_init_named(&events[0], 0x1001C, "PM_CMPLU_STALL_THRD");
event_init_named(&events[1], 0x2D016, "PM_CMPLU_STALL_FXU");
event_init_named(&events[2], 0x30006, "PM_CMPLU_STALL_OTHER_CMPL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ int multi_ebb_procs(void)
pid_t pids[NR_CHILDREN];
int cpu, rc, i;

SKIP_IF(!ebb_is_supported());

cpu = pick_online_cpu();
FAIL_IF(cpu < 0);
FAIL_IF(bind_to_cpu(cpu));
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ static int no_handler_test(void)
u64 val;
int i;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ static int test_body(void)
{
struct event event;

SKIP_IF(!ebb_is_supported());

event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);

Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ int pmc56_overflow(void)
{
struct event event;

SKIP_IF(!ebb_is_supported());

/* Use PMC2 so we set PMCjCE, which enables PMC5/6 */
event_init(&event, 0x2001e);
event_leader_ebb_init(&event);
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/ebb/reg_access_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ int reg_access(void)
{
uint64_t val, expected;

SKIP_IF(!ebb_is_supported());

expected = 0x8000000100000000ull;
mtspr(SPRN_BESCR, expected);
val = mfspr(SPRN_BESCR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ int task_event_pinned_vs_ebb(void)
pid_t pid;
int rc;

SKIP_IF(!ebb_is_supported());

FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ int task_event_vs_ebb(void)
pid_t pid;
int rc;

SKIP_IF(!ebb_is_supported());

FAIL_IF(pipe(read_pipe.fds) == -1);
FAIL_IF(pipe(write_pipe.fds) == -1);

Expand Down

0 comments on commit 39fcfb9

Please sign in to comment.