1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2025 Andrea Righi <arighi@nvidia.com> 4 */ 5 #include <bpf/bpf.h> 6 #include <scx/common.h> 7 #include <sys/wait.h> 8 #include <unistd.h> 9 #include "numa.bpf.skel.h" 10 #include "scx_test.h" 11 12 static enum scx_test_status setup(void **ctx) 13 { 14 struct numa *skel; 15 16 skel = numa__open(); 17 SCX_FAIL_IF(!skel, "Failed to open"); 18 SCX_ENUM_INIT(skel); 19 skel->rodata->__COMPAT_SCX_PICK_IDLE_IN_NODE = SCX_PICK_IDLE_IN_NODE; 20 skel->struct_ops.numa_ops->flags = SCX_OPS_BUILTIN_IDLE_PER_NODE; 21 SCX_FAIL_IF(numa__load(skel), "Failed to load skel"); 22 23 *ctx = skel; 24 25 return SCX_TEST_PASS; 26 } 27 28 static enum scx_test_status run(void *ctx) 29 { 30 struct numa *skel = ctx; 31 struct bpf_link *link; 32 33 link = bpf_map__attach_struct_ops(skel->maps.numa_ops); 34 SCX_FAIL_IF(!link, "Failed to attach scheduler"); 35 36 /* Just sleeping is fine, plenty of scheduling events happening */ 37 sleep(1); 38 39 SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_NONE)); 40 bpf_link__destroy(link); 41 42 return SCX_TEST_PASS; 43 } 44 45 static void cleanup(void *ctx) 46 { 47 struct numa *skel = ctx; 48 49 numa__destroy(skel); 50 } 51 52 struct scx_test numa = { 53 .name = "numa", 54 .description = "Verify NUMA-aware functionalities", 55 .setup = setup, 56 .run = run, 57 .cleanup = cleanup, 58 }; 59 REGISTER_SCX_TEST(&numa) 60