| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: linux_sched.c,v 1.65 2011/08/18 02:26:38 christos Exp $ */ | | 1 | /* $NetBSD: linux_sched.c,v 1.66 2014/01/23 19:18:08 njoly Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center; by Matthias Scheler. | | 9 | * NASA Ames Research Center; by Matthias Scheler. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * Linux compatibility module. Try to deal with scheduler related syscalls. | | 34 | * Linux compatibility module. Try to deal with scheduler related syscalls. |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #include <sys/cdefs.h> | | 37 | #include <sys/cdefs.h> |
38 | __KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.65 2011/08/18 02:26:38 christos Exp $"); | | 38 | __KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.66 2014/01/23 19:18:08 njoly Exp $"); |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/mount.h> | | 41 | #include <sys/mount.h> |
42 | #include <sys/proc.h> | | 42 | #include <sys/proc.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | #include <sys/sysctl.h> | | 44 | #include <sys/sysctl.h> |
45 | #include <sys/malloc.h> | | 45 | #include <sys/malloc.h> |
46 | #include <sys/syscallargs.h> | | 46 | #include <sys/syscallargs.h> |
47 | #include <sys/wait.h> | | 47 | #include <sys/wait.h> |
48 | #include <sys/kauth.h> | | 48 | #include <sys/kauth.h> |
49 | #include <sys/ptrace.h> | | 49 | #include <sys/ptrace.h> |
50 | #include <sys/atomic.h> | | 50 | #include <sys/atomic.h> |
51 | | | 51 | |
| @@ -408,62 +408,62 @@ linux_sys_sched_setparam(struct lwp *l, | | | @@ -408,62 +408,62 @@ linux_sys_sched_setparam(struct lwp *l, |
408 | struct linux_sched_param lp; | | 408 | struct linux_sched_param lp; |
409 | struct sched_param sp; | | 409 | struct sched_param sp; |
410 | | | 410 | |
411 | if (SCARG(uap, pid) < 0 || SCARG(uap, sp) == NULL) { | | 411 | if (SCARG(uap, pid) < 0 || SCARG(uap, sp) == NULL) { |
412 | error = EINVAL; | | 412 | error = EINVAL; |
413 | goto out; | | 413 | goto out; |
414 | } | | 414 | } |
415 | | | 415 | |
416 | error = copyin(SCARG(uap, sp), &lp, sizeof(lp)); | | 416 | error = copyin(SCARG(uap, sp), &lp, sizeof(lp)); |
417 | if (error) | | 417 | if (error) |
418 | goto out; | | 418 | goto out; |
419 | | | 419 | |
420 | /* We need the current policy in Linux terms. */ | | 420 | /* We need the current policy in Linux terms. */ |
421 | error = do_sched_getparam(0, SCARG(uap, pid), &policy, NULL); | | 421 | error = do_sched_getparam(SCARG(uap, pid), 0, &policy, NULL); |
422 | if (error) | | 422 | if (error) |
423 | goto out; | | 423 | goto out; |
424 | error = sched_native2linux(policy, NULL, &policy, NULL); | | 424 | error = sched_native2linux(policy, NULL, &policy, NULL); |
425 | if (error) | | 425 | if (error) |
426 | goto out; | | 426 | goto out; |
427 | | | 427 | |
428 | error = sched_linux2native(policy, &lp, &policy, &sp); | | 428 | error = sched_linux2native(policy, &lp, &policy, &sp); |
429 | if (error) | | 429 | if (error) |
430 | goto out; | | 430 | goto out; |
431 | | | 431 | |
432 | error = do_sched_setparam(0, SCARG(uap, pid), policy, &sp); | | 432 | error = do_sched_setparam(SCARG(uap, pid), 0, policy, &sp); |
433 | if (error) | | 433 | if (error) |
434 | goto out; | | 434 | goto out; |
435 | | | 435 | |
436 | out: | | 436 | out: |
437 | return error; | | 437 | return error; |
438 | } | | 438 | } |
439 | | | 439 | |
440 | int | | 440 | int |
441 | linux_sys_sched_getparam(struct lwp *l, const struct linux_sys_sched_getparam_args *uap, register_t *retval) | | 441 | linux_sys_sched_getparam(struct lwp *l, const struct linux_sys_sched_getparam_args *uap, register_t *retval) |
442 | { | | 442 | { |
443 | /* { | | 443 | /* { |
444 | syscallarg(linux_pid_t) pid; | | 444 | syscallarg(linux_pid_t) pid; |
445 | syscallarg(struct linux_sched_param *) sp; | | 445 | syscallarg(struct linux_sched_param *) sp; |
446 | } */ | | 446 | } */ |
447 | struct linux_sched_param lp; | | 447 | struct linux_sched_param lp; |
448 | struct sched_param sp; | | 448 | struct sched_param sp; |
449 | int error, policy; | | 449 | int error, policy; |
450 | | | 450 | |
451 | if (SCARG(uap, pid) < 0 || SCARG(uap, sp) == NULL) { | | 451 | if (SCARG(uap, pid) < 0 || SCARG(uap, sp) == NULL) { |
452 | error = EINVAL; | | 452 | error = EINVAL; |
453 | goto out; | | 453 | goto out; |
454 | } | | 454 | } |
455 | | | 455 | |
456 | error = do_sched_getparam(0, SCARG(uap, pid), &policy, &sp); | | 456 | error = do_sched_getparam(SCARG(uap, pid), 0, &policy, &sp); |
457 | if (error) | | 457 | if (error) |
458 | goto out; | | 458 | goto out; |
459 | DPRINTF(("%s: native: policy %d, priority %d\n", | | 459 | DPRINTF(("%s: native: policy %d, priority %d\n", |
460 | __func__, policy, sp.sched_priority)); | | 460 | __func__, policy, sp.sched_priority)); |
461 | | | 461 | |
462 | error = sched_native2linux(policy, &sp, NULL, &lp); | | 462 | error = sched_native2linux(policy, &sp, NULL, &lp); |
463 | if (error) | | 463 | if (error) |
464 | goto out; | | 464 | goto out; |
465 | DPRINTF(("%s: linux: policy %d, priority %d\n", | | 465 | DPRINTF(("%s: linux: policy %d, priority %d\n", |
466 | __func__, policy, lp.sched_priority)); | | 466 | __func__, policy, lp.sched_priority)); |
467 | | | 467 | |
468 | error = copyout(&lp, SCARG(uap, sp), sizeof(lp)); | | 468 | error = copyout(&lp, SCARG(uap, sp), sizeof(lp)); |
469 | if (error) | | 469 | if (error) |
| @@ -492,45 +492,45 @@ linux_sys_sched_setscheduler(struct lwp | | | @@ -492,45 +492,45 @@ linux_sys_sched_setscheduler(struct lwp |
492 | | | 492 | |
493 | error = copyin(SCARG(uap, sp), &lp, sizeof(lp)); | | 493 | error = copyin(SCARG(uap, sp), &lp, sizeof(lp)); |
494 | if (error) | | 494 | if (error) |
495 | goto out; | | 495 | goto out; |
496 | DPRINTF(("%s: linux: policy %d, priority %d\n", | | 496 | DPRINTF(("%s: linux: policy %d, priority %d\n", |
497 | __func__, SCARG(uap, policy), lp.sched_priority)); | | 497 | __func__, SCARG(uap, policy), lp.sched_priority)); |
498 | | | 498 | |
499 | error = sched_linux2native(SCARG(uap, policy), &lp, &policy, &sp); | | 499 | error = sched_linux2native(SCARG(uap, policy), &lp, &policy, &sp); |
500 | if (error) | | 500 | if (error) |
501 | goto out; | | 501 | goto out; |
502 | DPRINTF(("%s: native: policy %d, priority %d\n", | | 502 | DPRINTF(("%s: native: policy %d, priority %d\n", |
503 | __func__, policy, sp.sched_priority)); | | 503 | __func__, policy, sp.sched_priority)); |
504 | | | 504 | |
505 | error = do_sched_setparam(0, SCARG(uap, pid), policy, &sp); | | 505 | error = do_sched_setparam(SCARG(uap, pid), 0, policy, &sp); |
506 | if (error) | | 506 | if (error) |
507 | goto out; | | 507 | goto out; |
508 | | | 508 | |
509 | out: | | 509 | out: |
510 | return error; | | 510 | return error; |
511 | } | | 511 | } |
512 | | | 512 | |
513 | int | | 513 | int |
514 | linux_sys_sched_getscheduler(struct lwp *l, const struct linux_sys_sched_getscheduler_args *uap, register_t *retval) | | 514 | linux_sys_sched_getscheduler(struct lwp *l, const struct linux_sys_sched_getscheduler_args *uap, register_t *retval) |
515 | { | | 515 | { |
516 | /* { | | 516 | /* { |
517 | syscallarg(linux_pid_t) pid; | | 517 | syscallarg(linux_pid_t) pid; |
518 | } */ | | 518 | } */ |
519 | int error, policy; | | 519 | int error, policy; |
520 | | | 520 | |
521 | *retval = -1; | | 521 | *retval = -1; |
522 | | | 522 | |
523 | error = do_sched_getparam(0, SCARG(uap, pid), &policy, NULL); | | 523 | error = do_sched_getparam(SCARG(uap, pid), 0, &policy, NULL); |
524 | if (error) | | 524 | if (error) |
525 | goto out; | | 525 | goto out; |
526 | | | 526 | |
527 | error = sched_native2linux(policy, NULL, &policy, NULL); | | 527 | error = sched_native2linux(policy, NULL, &policy, NULL); |
528 | if (error) | | 528 | if (error) |
529 | goto out; | | 529 | goto out; |
530 | | | 530 | |
531 | *retval = policy; | | 531 | *retval = policy; |
532 | | | 532 | |
533 | out: | | 533 | out: |
534 | return error; | | 534 | return error; |
535 | } | | 535 | } |
536 | | | 536 | |