Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
4 * Copyright (c) 2024 David Vernet <dvernet@meta.com>
5 * Copyright (c) 2024 Tejun Heo <tj@kernel.org>
6 */
7#include <bpf/bpf.h>
8#include <scx/common.h>
9#include <sys/wait.h>
10#include <unistd.h>
11#include "ddsp_bogus_dsq_fail.bpf.skel.h"
12#include "scx_test.h"
13
14static enum scx_test_status setup(void **ctx)
15{
16 struct ddsp_bogus_dsq_fail *skel;
17
18 skel = ddsp_bogus_dsq_fail__open();
19 SCX_FAIL_IF(!skel, "Failed to open");
20 SCX_ENUM_INIT(skel);
21 SCX_FAIL_IF(ddsp_bogus_dsq_fail__load(skel), "Failed to load skel");
22
23 *ctx = skel;
24
25 return SCX_TEST_PASS;
26}
27
28static enum scx_test_status run(void *ctx)
29{
30 struct ddsp_bogus_dsq_fail *skel = ctx;
31 struct bpf_link *link;
32
33 link = bpf_map__attach_struct_ops(skel->maps.ddsp_bogus_dsq_fail_ops);
34 SCX_FAIL_IF(!link, "Failed to attach struct_ops");
35
36 sleep(1);
37
38 SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR));
39 bpf_link__destroy(link);
40
41 return SCX_TEST_PASS;
42}
43
44static void cleanup(void *ctx)
45{
46 struct ddsp_bogus_dsq_fail *skel = ctx;
47
48 ddsp_bogus_dsq_fail__destroy(skel);
49}
50
51struct scx_test ddsp_bogus_dsq_fail = {
52 .name = "ddsp_bogus_dsq_fail",
53 .description = "Verify we gracefully fail, and fall back to using a "
54 "built-in DSQ, if we do a direct dispatch to an invalid"
55 " DSQ in ops.select_cpu()",
56 .setup = setup,
57 .run = run,
58 .cleanup = cleanup,
59};
60REGISTER_SCX_TEST(&ddsp_bogus_dsq_fail)