-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf trace: Beautify sched_setscheduler 'policy' argument
$ trace -e sched_setscheduler chrt -f 1 usleep 1 chrt: failed to set pid 0's policy: Operation not permitted 0.005 ( 0.005 ms): chrt/19189 sched_setscheduler(policy: FIFO, param: 0x7ffec5273d70) = -1 EPERM Operation not permitted $ Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-i5vlo5n5jv0amt8bkyicmdxh@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
- Loading branch information
Arnaldo Carvalho de Melo
committed
Apr 6, 2016
1 parent
85f8f96
commit a3bca91
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#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 | ||
|
||
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 |