staticvoid check_good_sample(struct test_perf_branches *skel)
{ int written_global = skel->bss->written_global_out; int required_size = skel->bss->required_size_out; int written_stack = skel->bss->written_stack_out; int pbe_size = sizeof(struct perf_branch_entry); int duration = 0;
if (CHECK(!skel->bss->valid, "output not valid", "no valid sample from prog")) return;
/* * It's hard to validate the contents of the branch entries b/c it * would require some kind of disassembler and also encoding the * valid jump instructions for supported architectures. So just check * the easy stuff for now.
*/
CHECK(required_size <= 0, "read_branches_size", "err %d\n", required_size);
CHECK(written_stack < 0, "read_branches_stack", "err %d\n", written_stack);
CHECK(written_stack % pbe_size != 0, "read_branches_stack", "stack bytes written=%d not multiple of struct size=%d\n",
written_stack, pbe_size);
CHECK(written_global < 0, "read_branches_global", "err %d\n", written_global);
CHECK(written_global % pbe_size != 0, "read_branches_global", "global bytes written=%d not multiple of struct size=%d\n",
written_global, pbe_size);
CHECK(written_global < written_stack, "read_branches_size", "written_global=%d < written_stack=%d\n", written_global, written_stack);
}
staticvoid check_bad_sample(struct test_perf_branches *skel)
{ int written_global = skel->bss->written_global_out; int required_size = skel->bss->required_size_out; int written_stack = skel->bss->written_stack_out; int duration = 0;
if (CHECK(!skel->bss->valid, "output not valid", "no valid sample from prog")) return;
skel = test_perf_branches__open_and_load(); if (CHECK(!skel, "test_perf_branches_load", "perf_branches skeleton failed\n")) return;
/* attach perf_event */
link = bpf_program__attach_perf_event(skel->progs.perf_branches, perf_fd); if (!ASSERT_OK_PTR(link, "attach_perf_event")) goto out_destroy_skel;
/* 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); if (CHECK(err, "set_affinity", "cpu #0, err %d\n", err)) goto out_destroy; /* spin the loop for a while (random high number) */ for (i = 0; i < 1000000; ++i)
++j;
void test_perf_branches(void)
{ if (test__start_subtest("perf_branches_hw"))
test_perf_branches_hw(); if (test__start_subtest("perf_branches_no_hw"))
test_perf_branches_no_hw();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.