sched_policy.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <sched.h>
  2. /*
  3. * Not defined anywhere else, probably, just to make sure we
  4. * catch future flags
  5. */
  6. #define SCHED_POLICY_MASK 0xff
  7. #ifndef SCHED_DEADLINE
  8. #define SCHED_DEADLINE 6
  9. #endif
  10. #ifndef SCHED_RESET_ON_FORK
  11. #define SCHED_RESET_ON_FORK 0x40000000
  12. #endif
  13. static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size,
  14. struct syscall_arg *arg)
  15. {
  16. const char *policies[] = {
  17. "NORMAL", "FIFO", "RR", "BATCH", "ISO", "IDLE", "DEADLINE",
  18. };
  19. size_t printed;
  20. int policy = arg->val,
  21. flags = policy & ~SCHED_POLICY_MASK;
  22. policy &= SCHED_POLICY_MASK;
  23. if (policy <= SCHED_DEADLINE)
  24. printed = scnprintf(bf, size, "%s", policies[policy]);
  25. else
  26. printed = scnprintf(bf, size, "%#x", policy);
  27. #define P_POLICY_FLAG(n) \
  28. if (flags & SCHED_##n) { \
  29. printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
  30. flags &= ~SCHED_##n; \
  31. }
  32. P_POLICY_FLAG(RESET_ON_FORK);
  33. #undef P_POLICY_FLAG
  34. if (flags)
  35. printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
  36. return printed;
  37. }
  38. #define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy