linux_dsm_epyc7002/tools/perf/trace/beauty/sched_policy.c
Arnaldo Carvalho de Melo 794f594e0c perf beauty: Switch from GPL v2.0 to LGPL v2.1
The intention is to have this as a library, since it is not perf
specific at all.

I did the switch for the files where I'm the only contributor, with the
exception of a few lines changed by Jiri Olsa.

Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-a04q6chdyjknm1hr305ulx8h@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-10-30 11:46:23 -03:00

49 lines
1.1 KiB
C

// SPDX-License-Identifier: LGPL-2.1
#include <sched.h>
/*
* Not defined anywhere else, probably, just to make sure we
* catch future flags
*/
#define SCHED_POLICY_MASK 0xff
#ifndef SCHED_DEADLINE
#define SCHED_DEADLINE 6
#endif
#ifndef SCHED_RESET_ON_FORK
#define SCHED_RESET_ON_FORK 0x40000000
#endif
static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size,
struct syscall_arg *arg)
{
const char *policies[] = {
"NORMAL", "FIFO", "RR", "BATCH", "ISO", "IDLE", "DEADLINE",
};
size_t printed;
int policy = arg->val,
flags = policy & ~SCHED_POLICY_MASK;
policy &= SCHED_POLICY_MASK;
if (policy <= SCHED_DEADLINE)
printed = scnprintf(bf, size, "%s", policies[policy]);
else
printed = scnprintf(bf, size, "%#x", policy);
#define P_POLICY_FLAG(n) \
if (flags & SCHED_##n) { \
printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
flags &= ~SCHED_##n; \
}
P_POLICY_FLAG(RESET_ON_FORK);
#undef P_POLICY_FLAG
if (flags)
printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
return printed;
}
#define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy