Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004 Ulrich Drepper <drepper@redhat.com> |
| 3 | * Copyright (c) 2005 Roland McGrath <roland@redhat.com> |
| 4 | * Copyright (c) 2012-2015 Dmitry V. Levin <ldv@altlinux.org> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 30 | #include "defs.h" |
| 31 | |
| 32 | #include <sched.h> |
| 33 | |
| 34 | #include "xlat/schedulers.h" |
Dmitry V. Levin | 3456bcc | 2015-07-29 07:59:56 +0000 | [diff] [blame] | 35 | #include "xlat/sched_flags.h" |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 36 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 37 | SYS_FUNC(sched_getscheduler) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 38 | { |
| 39 | if (entering(tcp)) { |
| 40 | tprintf("%d", (int) tcp->u_arg[0]); |
| 41 | } else if (!syserror(tcp)) { |
Dmitry V. Levin | 9134aab | 2016-05-14 21:46:05 +0000 | [diff] [blame] | 42 | tcp->auxstr = xlookup(schedulers, (unsigned long) tcp->u_rval); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 43 | if (tcp->auxstr != NULL) |
| 44 | return RVAL_STR; |
| 45 | } |
| 46 | return 0; |
| 47 | } |
| 48 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 49 | SYS_FUNC(sched_setscheduler) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 50 | { |
Dmitry V. Levin | 10c408a | 2015-07-17 16:16:24 +0000 | [diff] [blame] | 51 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 52 | printxval(schedulers, tcp->u_arg[1], "SCHED_???"); |
| 53 | tprints(", "); |
| 54 | printnum_int(tcp, tcp->u_arg[2], "%d"); |
| 55 | |
| 56 | return RVAL_DECODED; |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 59 | SYS_FUNC(sched_getparam) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 60 | { |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 61 | if (entering(tcp)) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 62 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 63 | else |
| 64 | printnum_int(tcp, tcp->u_arg[1], "%d"); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 65 | return 0; |
| 66 | } |
| 67 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 68 | SYS_FUNC(sched_setparam) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 69 | { |
Dmitry V. Levin | 10c408a | 2015-07-17 16:16:24 +0000 | [diff] [blame] | 70 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 71 | printnum_int(tcp, tcp->u_arg[1], "%d"); |
| 72 | |
| 73 | return RVAL_DECODED; |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 76 | SYS_FUNC(sched_get_priority_min) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 77 | { |
Dmitry V. Levin | 10c408a | 2015-07-17 16:16:24 +0000 | [diff] [blame] | 78 | printxval(schedulers, tcp->u_arg[0], "SCHED_???"); |
| 79 | |
| 80 | return RVAL_DECODED; |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 83 | SYS_FUNC(sched_rr_get_interval) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 84 | { |
| 85 | if (entering(tcp)) { |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 86 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 87 | } else { |
| 88 | if (syserror(tcp)) |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 89 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 90 | else |
| 91 | print_timespec(tcp, tcp->u_arg[1]); |
| 92 | } |
| 93 | return 0; |
| 94 | } |
Dmitry V. Levin | 3456bcc | 2015-07-29 07:59:56 +0000 | [diff] [blame] | 95 | |
| 96 | static void |
| 97 | print_sched_attr(struct tcb *tcp, const long addr, unsigned int size) |
| 98 | { |
| 99 | struct { |
| 100 | uint32_t size; |
| 101 | uint32_t sched_policy; |
| 102 | uint64_t sched_flags; |
| 103 | uint32_t sched_nice; |
| 104 | uint32_t sched_priority; |
| 105 | uint64_t sched_runtime; |
| 106 | uint64_t sched_deadline; |
| 107 | uint64_t sched_period; |
| 108 | } attr = {}; |
| 109 | |
| 110 | if (size > sizeof(attr)) |
| 111 | size = sizeof(attr); |
| 112 | if (umoven_or_printaddr(tcp, addr, size, &attr)) |
| 113 | return; |
| 114 | |
| 115 | tprintf("{size=%u, sched_policy=", attr.size); |
| 116 | printxval(schedulers, attr.sched_policy, "SCHED_???"); |
| 117 | tprints(", sched_flags="); |
| 118 | printflags(sched_flags, attr.sched_flags, "SCHED_FLAG_???"); |
| 119 | tprintf(", sched_nice=%d", attr.sched_nice); |
| 120 | tprintf(", sched_priority=%u", attr.sched_priority); |
| 121 | tprintf(", sched_runtime=%" PRIu64, attr.sched_runtime); |
| 122 | tprintf(", sched_deadline=%" PRIu64, attr.sched_deadline); |
| 123 | tprintf(", sched_period=%" PRIu64 "}", attr.sched_period); |
| 124 | } |
| 125 | |
| 126 | SYS_FUNC(sched_setattr) |
| 127 | { |
| 128 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 129 | print_sched_attr(tcp, tcp->u_arg[1], 0x100); |
| 130 | tprintf(", %u", (unsigned int) tcp->u_arg[2]); |
| 131 | |
| 132 | return RVAL_DECODED; |
| 133 | } |
| 134 | |
| 135 | SYS_FUNC(sched_getattr) |
| 136 | { |
| 137 | if (entering(tcp)) { |
| 138 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 139 | } else { |
| 140 | print_sched_attr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 141 | tprintf(", %u, %u", |
| 142 | (unsigned int) tcp->u_arg[2], |
| 143 | (unsigned int) tcp->u_arg[3]); |
| 144 | } |
| 145 | |
| 146 | return 0; |
| 147 | } |