1 #include <sched.h> 2 3 /* 4 * Not defined anywhere else, probably, just to make sure we 5 * catch future flags 6 */ 7 #define SCHED_POLICY_MASK 0xff 8 9 #ifndef SCHED_DEADLINE 10 #define SCHED_DEADLINE 6 11 #endif 12 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 23 policy &= SCHED_POLICY_MASK; 24 if (policy <= SCHED_DEADLINE) 25 printed = scnprintf(bf, size, "%s", policies[policy]); 26 else 27 printed = scnprintf(bf, size, "%#x", policy); 28 29 #define P_POLICY_FLAG(n) \ 30 if (flags & SCHED_##n) { \ 31 printed += scnprintf(bf + printed, size - printed, "|%s", #n); \ 32 flags &= ~SCHED_##n; \ 33 } 34 35 P_POLICY_FLAG(RESET_ON_FORK); 36 #undef P_POLICY_FLAG 37 38 if (flags) 39 printed += scnprintf(bf + printed, size - printed, "|%#x", flags); 40 41 return printed; 42 } 43 44 #define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy 45