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 14 static enum scx_test_status setup(void **ctx) 15 { 16 struct ddsp_bogus_dsq_fail *skel; 17 18 skel = ddsp_bogus_dsq_fail__open_and_load(); 19 SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 *ctx = skel; 21 22 return SCX_TEST_PASS; 23 } 24 25 static enum scx_test_status run(void *ctx) 26 { 27 struct ddsp_bogus_dsq_fail *skel = ctx; 28 struct bpf_link *link; 29 30 link = bpf_map__attach_struct_ops(skel->maps.ddsp_bogus_dsq_fail_ops); 31 SCX_FAIL_IF(!link, "Failed to attach struct_ops"); 32 33 sleep(1); 34 35 SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR)); 36 bpf_link__destroy(link); 37 38 return SCX_TEST_PASS; 39 } 40 41 static void cleanup(void *ctx) 42 { 43 struct ddsp_bogus_dsq_fail *skel = ctx; 44 45 ddsp_bogus_dsq_fail__destroy(skel); 46 } 47 48 struct scx_test ddsp_bogus_dsq_fail = { 49 .name = "ddsp_bogus_dsq_fail", 50 .description = "Verify we gracefully fail, and fall back to using a " 51 "built-in DSQ, if we do a direct dispatch to an invalid" 52 " DSQ in ops.select_cpu()", 53 .setup = setup, 54 .run = run, 55 .cleanup = cleanup, 56 }; 57 REGISTER_SCX_TEST(&ddsp_bogus_dsq_fail) 58
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.