ddsp_vtimelocal_fail.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <unistd.h>
  10. #include "ddsp_vtimelocal_fail.bpf.skel.h"
  11. #include "scx_test.h"
  12. static enum scx_test_status setup(void **ctx)
  13. {
  14. struct ddsp_vtimelocal_fail *skel;
  15. skel = ddsp_vtimelocal_fail__open_and_load();
  16. SCX_FAIL_IF(!skel, "Failed to open and load skel");
  17. *ctx = skel;
  18. return SCX_TEST_PASS;
  19. }
  20. static enum scx_test_status run(void *ctx)
  21. {
  22. struct ddsp_vtimelocal_fail *skel = ctx;
  23. struct bpf_link *link;
  24. link = bpf_map__attach_struct_ops(skel->maps.ddsp_vtimelocal_fail_ops);
  25. SCX_FAIL_IF(!link, "Failed to attach struct_ops");
  26. sleep(1);
  27. SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR));
  28. bpf_link__destroy(link);
  29. return SCX_TEST_PASS;
  30. }
  31. static void cleanup(void *ctx)
  32. {
  33. struct ddsp_vtimelocal_fail *skel = ctx;
  34. ddsp_vtimelocal_fail__destroy(skel);
  35. }
  36. struct scx_test ddsp_vtimelocal_fail = {
  37. .name = "ddsp_vtimelocal_fail",
  38. .description = "Verify we gracefully fail, and fall back to using a "
  39. "built-in DSQ, if we do a direct vtime dispatch to a "
  40. "built-in DSQ from DSQ in ops.select_cpu()",
  41. .setup = setup,
  42. .run = run,
  43. .cleanup = cleanup,
  44. };
  45. REGISTER_SCX_TEST(&ddsp_vtimelocal_fail)