Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions tools/testing/selftests/bpf/prog_tests/perf_link.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2021 Facebook */
#define _GNU_SOURCE
#include <pthread.h>
#include <sched.h>
#include <linux/compiler.h>
#include <test_progs.h>
#include "testing_helpers.h"
#include "test_perf_link.skel.h"
Expand All @@ -12,23 +11,14 @@

static void burn_cpu(void)
{
volatile int j = 0;
cpu_set_t cpu_set;
int i, err;

/* generate some branches on cpu 0 */
CPU_ZERO(&cpu_set);
CPU_SET(0, &cpu_set);
err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set), &cpu_set);
ASSERT_OK(err, "set_thread_affinity");
int i;

/* spin the loop for a while (random high number) */
for (i = 0; i < 1000000; ++i)
++j;
barrier();
}

/* TODO: often fails in concurrent mode */
void serial_test_perf_link(void)
void test_perf_link(void)
{
struct test_perf_link *skel = NULL;
struct perf_event_attr attr;
Expand All @@ -45,7 +35,7 @@ void serial_test_perf_link(void)
attr.config = PERF_COUNT_SW_CPU_CLOCK;
attr.freq = 1;
attr.sample_freq = 1000;
pfd = syscall(__NR_perf_event_open, &attr, -1, 0, -1, PERF_FLAG_FD_CLOEXEC);
pfd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, PERF_FLAG_FD_CLOEXEC);
if (!ASSERT_GE(pfd, 0, "perf_fd"))
goto cleanup;

Expand Down
Loading