Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v6.16-rc7 59 lines 1.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (c) 2023 Meta Platforms, Inc. and affiliates. 4 * Copyright (c) 2023 David Vernet <dvernet@meta.com> 5 * Copyright (c) 2023 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 "select_cpu_dispatch_dbl_dsp.bpf.skel.h" 12#include "scx_test.h" 13 14static enum scx_test_status setup(void **ctx) 15{ 16 struct select_cpu_dispatch_dbl_dsp *skel; 17 18 skel = select_cpu_dispatch_dbl_dsp__open(); 19 SCX_FAIL_IF(!skel, "Failed to open"); 20 SCX_ENUM_INIT(skel); 21 SCX_FAIL_IF(select_cpu_dispatch_dbl_dsp__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 select_cpu_dispatch_dbl_dsp *skel = ctx; 31 struct bpf_link *link; 32 33 link = bpf_map__attach_struct_ops(skel->maps.select_cpu_dispatch_dbl_dsp_ops); 34 SCX_FAIL_IF(!link, "Failed to attach scheduler"); 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 select_cpu_dispatch_dbl_dsp *skel = ctx; 47 48 select_cpu_dispatch_dbl_dsp__destroy(skel); 49} 50 51struct scx_test select_cpu_dispatch_dbl_dsp = { 52 .name = "select_cpu_dispatch_dbl_dsp", 53 .description = "Verify graceful failure if we dispatch twice to a " 54 "DSQ in ops.select_cpu()", 55 .setup = setup, 56 .run = run, 57 .cleanup = cleanup, 58}; 59REGISTER_SCX_TEST(&select_cpu_dispatch_dbl_dsp)