]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/perf/trace/beauty/sched_policy.c
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / tools / perf / trace / beauty / sched_policy.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
a3bca91f
ACM
2#include <sched.h>
3
4/*
5 * Not defined anywhere else, probably, just to make sure we
6 * catch future flags
7 */
8#define SCHED_POLICY_MASK 0xff
9
10#ifndef SCHED_DEADLINE
11#define SCHED_DEADLINE 6
12#endif
a41af25b
ACM
13#ifndef SCHED_RESET_ON_FORK
14#define SCHED_RESET_ON_FORK 0x40000000
15#endif
a3bca91f
ACM
16
17static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size,
18 struct syscall_arg *arg)
19{
20 const char *policies[] = {
21 "NORMAL", "FIFO", "RR", "BATCH", "ISO", "IDLE", "DEADLINE",
22 };
23 size_t printed;
24 int policy = arg->val,
25 flags = policy & ~SCHED_POLICY_MASK;
26
27 policy &= SCHED_POLICY_MASK;
28 if (policy <= SCHED_DEADLINE)
29 printed = scnprintf(bf, size, "%s", policies[policy]);
30 else
31 printed = scnprintf(bf, size, "%#x", policy);
32
33#define P_POLICY_FLAG(n) \
34 if (flags & SCHED_##n) { \
35 printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
36 flags &= ~SCHED_##n; \
37 }
38
39 P_POLICY_FLAG(RESET_ON_FORK);
40#undef P_POLICY_FLAG
41
42 if (flags)
43 printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
44
45 return printed;
46}
47
48#define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy