Implement sched_getattr and sched_setattr syscalls decoding
* xlat/sched_flags.in: New file. * sched.c: Include "xlat/sched_flags.h". (print_sched_attr, sys_sched_setattr, sys_sched_getattr): New functions. * linux/dummy.h (sys_sched_getattr, sys_sched_setattr): Remove. * tests/sched_xetattr.c: New file. * tests/sched_xetattr.test: New test. * tests/Makefile.am (check_PROGRAMS): Add sched_xetattr. (TESTS): Add sched_xetattr.test. * tests/.gitignore: Add sched_xetattr.
This commit is contained in:
parent
95b84ea641
commit
3456bcca67
@ -39,8 +39,6 @@
|
||||
#define sys_lookup_dcookie printargs
|
||||
#define sys_name_to_handle_at printargs
|
||||
#define sys_open_by_handle_at printargs
|
||||
#define sys_sched_getattr printargs
|
||||
#define sys_sched_setattr printargs
|
||||
#define sys_sysfs printargs
|
||||
#define sys_vm86 printargs
|
||||
#define sys_vm86old printargs
|
||||
|
54
sched.c
54
sched.c
@ -3,6 +3,7 @@
|
||||
#include <sched.h>
|
||||
|
||||
#include "xlat/schedulers.h"
|
||||
#include "xlat/sched_flags.h"
|
||||
|
||||
SYS_FUNC(sched_getscheduler)
|
||||
{
|
||||
@ -62,3 +63,56 @@ SYS_FUNC(sched_rr_get_interval)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
print_sched_attr(struct tcb *tcp, const long addr, unsigned int size)
|
||||
{
|
||||
struct {
|
||||
uint32_t size;
|
||||
uint32_t sched_policy;
|
||||
uint64_t sched_flags;
|
||||
uint32_t sched_nice;
|
||||
uint32_t sched_priority;
|
||||
uint64_t sched_runtime;
|
||||
uint64_t sched_deadline;
|
||||
uint64_t sched_period;
|
||||
} attr = {};
|
||||
|
||||
if (size > sizeof(attr))
|
||||
size = sizeof(attr);
|
||||
if (umoven_or_printaddr(tcp, addr, size, &attr))
|
||||
return;
|
||||
|
||||
tprintf("{size=%u, sched_policy=", attr.size);
|
||||
printxval(schedulers, attr.sched_policy, "SCHED_???");
|
||||
tprints(", sched_flags=");
|
||||
printflags(sched_flags, attr.sched_flags, "SCHED_FLAG_???");
|
||||
tprintf(", sched_nice=%d", attr.sched_nice);
|
||||
tprintf(", sched_priority=%u", attr.sched_priority);
|
||||
tprintf(", sched_runtime=%" PRIu64, attr.sched_runtime);
|
||||
tprintf(", sched_deadline=%" PRIu64, attr.sched_deadline);
|
||||
tprintf(", sched_period=%" PRIu64 "}", attr.sched_period);
|
||||
}
|
||||
|
||||
SYS_FUNC(sched_setattr)
|
||||
{
|
||||
tprintf("%d, ", (int) tcp->u_arg[0]);
|
||||
print_sched_attr(tcp, tcp->u_arg[1], 0x100);
|
||||
tprintf(", %u", (unsigned int) tcp->u_arg[2]);
|
||||
|
||||
return RVAL_DECODED;
|
||||
}
|
||||
|
||||
SYS_FUNC(sched_getattr)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
tprintf("%d, ", (int) tcp->u_arg[0]);
|
||||
} else {
|
||||
print_sched_attr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
|
||||
tprintf(", %u, %u",
|
||||
(unsigned int) tcp->u_arg[2],
|
||||
(unsigned int) tcp->u_arg[3]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -20,6 +20,7 @@ netlink_inet_diag
|
||||
netlink_unix_diag
|
||||
pc
|
||||
pipe
|
||||
sched_xetattr
|
||||
scm_rights
|
||||
seccomp
|
||||
select
|
||||
|
@ -31,6 +31,7 @@ check_PROGRAMS = \
|
||||
netlink_unix_diag \
|
||||
pc \
|
||||
pipe \
|
||||
sched_xetattr \
|
||||
scm_rights \
|
||||
seccomp \
|
||||
select \
|
||||
@ -79,6 +80,7 @@ TESTS = \
|
||||
ipc_msg.test \
|
||||
ipc_shm.test \
|
||||
ipc_sem.test \
|
||||
sched_xetattr.test \
|
||||
scm_rights-fd.test \
|
||||
seccomp.test \
|
||||
select.test \
|
||||
|
65
tests/sched_xetattr.c
Normal file
65
tests/sched_xetattr.c
Normal file
@ -0,0 +1,65 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#if defined __NR_sched_getattr && defined __NR_sched_setattr
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static union {
|
||||
struct {
|
||||
uint32_t size;
|
||||
uint32_t sched_policy;
|
||||
uint64_t sched_flags;
|
||||
uint32_t sched_nice;
|
||||
uint32_t sched_priority;
|
||||
uint64_t sched_runtime;
|
||||
uint64_t sched_deadline;
|
||||
uint64_t sched_period;
|
||||
} attr;
|
||||
char buf[256];
|
||||
} sched;
|
||||
|
||||
if (syscall(__NR_sched_getattr, 0, &sched, sizeof(sched), 0))
|
||||
return 77;
|
||||
|
||||
printf("sched_getattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, sched_flags=%s, sched_nice=%u, sched_priority=%u, sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", sched_period=%" PRIu64 "\\}, 256, 0\\) += 0\n",
|
||||
sched.attr.size,
|
||||
sched.attr.sched_flags ? "SCHED_FLAG_RESET_ON_FORK" : "0",
|
||||
sched.attr.sched_nice,
|
||||
sched.attr.sched_priority,
|
||||
sched.attr.sched_runtime,
|
||||
sched.attr.sched_deadline,
|
||||
sched.attr.sched_period);
|
||||
|
||||
sched.attr.sched_flags |= 1;
|
||||
if (syscall(__NR_sched_setattr, 0, &sched, 0))
|
||||
return 77;
|
||||
|
||||
printf("sched_setattr\\(0, \\{size=%u, sched_policy=SCHED_[A-Z]+, sched_flags=%s, sched_nice=%u, sched_priority=%u, sched_runtime=%" PRIu64 ", sched_deadline=%" PRIu64 ", sched_period=%" PRIu64 "\\}, 0\\) += 0\n",
|
||||
sched.attr.size,
|
||||
"SCHED_FLAG_RESET_ON_FORK",
|
||||
sched.attr.sched_nice,
|
||||
sched.attr.sched_priority,
|
||||
sched.attr.sched_runtime,
|
||||
sched.attr.sched_deadline,
|
||||
sched.attr.sched_period);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
return 77;
|
||||
}
|
||||
|
||||
#endif
|
13
tests/sched_xetattr.test
Executable file
13
tests/sched_xetattr.test
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check sched_getattr and sched_setattr syscalls decoding.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
run_prog > /dev/null
|
||||
OUT="$LOG.out"
|
||||
run_strace -e sched_getattr,sched_setattr $args > "$OUT"
|
||||
match_grep "$LOG" "$OUT"
|
||||
rm -f "$OUT"
|
||||
|
||||
exit 0
|
1
xlat/sched_flags.in
Normal file
1
xlat/sched_flags.in
Normal file
@ -0,0 +1 @@
|
||||
SCHED_FLAG_RESET_ON_FORK 1
|
Loading…
x
Reference in New Issue
Block a user