dsp_local_on.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. */
  6. #include <bpf/bpf.h>
  7. #include <scx/common.h>
  8. #include <unistd.h>
  9. #include "dsp_local_on.bpf.skel.h"
  10. #include "scx_test.h"
  11. static enum scx_test_status setup(void **ctx)
  12. {
  13. struct dsp_local_on *skel;
  14. skel = dsp_local_on__open();
  15. SCX_FAIL_IF(!skel, "Failed to open");
  16. SCX_ENUM_INIT(skel);
  17. skel->rodata->nr_cpus = libbpf_num_possible_cpus();
  18. SCX_FAIL_IF(dsp_local_on__load(skel), "Failed to load skel");
  19. *ctx = skel;
  20. return SCX_TEST_PASS;
  21. }
  22. static enum scx_test_status run(void *ctx)
  23. {
  24. struct dsp_local_on *skel = ctx;
  25. struct bpf_link *link;
  26. link = bpf_map__attach_struct_ops(skel->maps.dsp_local_on_ops);
  27. SCX_FAIL_IF(!link, "Failed to attach struct_ops");
  28. /* Just sleeping is fine, plenty of scheduling events happening */
  29. sleep(1);
  30. bpf_link__destroy(link);
  31. SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_UNREG));
  32. return SCX_TEST_PASS;
  33. }
  34. static void cleanup(void *ctx)
  35. {
  36. struct dsp_local_on *skel = ctx;
  37. dsp_local_on__destroy(skel);
  38. }
  39. struct scx_test dsp_local_on = {
  40. .name = "dsp_local_on",
  41. .description = "Verify we can directly dispatch tasks to a local DSQs "
  42. "from ops.dispatch()",
  43. .setup = setup,
  44. .run = run,
  45. .cleanup = cleanup,
  46. };
  47. REGISTER_SCX_TEST(&dsp_local_on)