diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 16:19:56 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 16:19:56 -0400 |
| commit | 99ebcf8285df28f32fd2d1c19a7166e70f00309c (patch) | |
| tree | caf45f39a77026b2fae2413c145067a1e5164701 /kernel/sys.c | |
| parent | 72558dde738b06cc01e16b3247a9659ca739e22d (diff) | |
| parent | c465a76af658b443075d6efee1c3131257643020 (diff) | |
Merge branch 'v28-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'v28-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (36 commits)
fix documentation of sysrq-q really
Fix documentation of sysrq-q
timer_list: add base address to clock base
timer_list: print cpu number of clockevents device
timer_list: print real timer address
NOHZ: restart tick device from irq_enter()
NOHZ: split tick_nohz_restart_sched_tick()
NOHZ: unify the nohz function calls in irq_enter()
timers: fix itimer/many thread hang, fix
timers: fix itimer/many thread hang, v3
ntp: improve adjtimex frequency rounding
timekeeping: fix rounding problem during clock update
ntp: let update_persistent_clock() sleep
hrtimer: reorder struct hrtimer to save 8 bytes on 64bit builds
posix-timers: lock_timer: make it readable
posix-timers: lock_timer: kill the bogus ->it_id check
posix-timers: kill ->it_sigev_signo and ->it_sigev_value
posix-timers: sys_timer_create: cleanup the error handling
posix-timers: move the initialization of timer->sigq from send to create path
posix-timers: sys_timer_create: simplify and s/tasklist/rcu/
...
Fix trivial conflicts due to sysrq-q description clahes in
Documentation/sysrq.txt and drivers/char/sysrq.c
Diffstat (limited to 'kernel/sys.c')
| -rw-r--r-- | kernel/sys.c | 75 |
1 files changed, 26 insertions, 49 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 0bc8fa3c2288..53879cdae483 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -853,38 +853,28 @@ asmlinkage long sys_setfsgid(gid_t gid) | |||
| 853 | return old_fsgid; | 853 | return old_fsgid; |
| 854 | } | 854 | } |
| 855 | 855 | ||
| 856 | void do_sys_times(struct tms *tms) | ||
| 857 | { | ||
| 858 | struct task_cputime cputime; | ||
| 859 | cputime_t cutime, cstime; | ||
| 860 | |||
| 861 | spin_lock_irq(¤t->sighand->siglock); | ||
| 862 | thread_group_cputime(current, &cputime); | ||
| 863 | cutime = current->signal->cutime; | ||
| 864 | cstime = current->signal->cstime; | ||
| 865 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 866 | tms->tms_utime = cputime_to_clock_t(cputime.utime); | ||
| 867 | tms->tms_stime = cputime_to_clock_t(cputime.stime); | ||
| 868 | tms->tms_cutime = cputime_to_clock_t(cutime); | ||
| 869 | tms->tms_cstime = cputime_to_clock_t(cstime); | ||
| 870 | } | ||
| 871 | |||
| 856 | asmlinkage long sys_times(struct tms __user * tbuf) | 872 | asmlinkage long sys_times(struct tms __user * tbuf) |
| 857 | { | 873 | { |
| 858 | /* | ||
| 859 | * In the SMP world we might just be unlucky and have one of | ||
| 860 | * the times increment as we use it. Since the value is an | ||
| 861 | * atomically safe type this is just fine. Conceptually its | ||
| 862 | * as if the syscall took an instant longer to occur. | ||
| 863 | */ | ||
| 864 | if (tbuf) { | 874 | if (tbuf) { |
| 865 | struct tms tmp; | 875 | struct tms tmp; |
| 866 | struct task_struct *tsk = current; | 876 | |
| 867 | struct task_struct *t; | 877 | do_sys_times(&tmp); |
| 868 | cputime_t utime, stime, cutime, cstime; | ||
| 869 | |||
| 870 | spin_lock_irq(&tsk->sighand->siglock); | ||
| 871 | utime = tsk->signal->utime; | ||
| 872 | stime = tsk->signal->stime; | ||
| 873 | t = tsk; | ||
| 874 | do { | ||
| 875 | utime = cputime_add(utime, t->utime); | ||
| 876 | stime = cputime_add(stime, t->stime); | ||
| 877 | t = next_thread(t); | ||
| 878 | } while (t != tsk); | ||
| 879 | |||
| 880 | cutime = tsk->signal->cutime; | ||
| 881 | cstime = tsk->signal->cstime; | ||
| 882 | spin_unlock_irq(&tsk->sighand->siglock); | ||
| 883 | |||
| 884 | tmp.tms_utime = cputime_to_clock_t(utime); | ||
| 885 | tmp.tms_stime = cputime_to_clock_t(stime); | ||
| 886 | tmp.tms_cutime = cputime_to_clock_t(cutime); | ||
| 887 | tmp.tms_cstime = cputime_to_clock_t(cstime); | ||
| 888 | if (copy_to_user(tbuf, &tmp, sizeof(struct tms))) | 878 | if (copy_to_user(tbuf, &tmp, sizeof(struct tms))) |
| 889 | return -EFAULT; | 879 | return -EFAULT; |
| 890 | } | 880 | } |
| @@ -1449,7 +1439,6 @@ asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *r | |||
| 1449 | asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) | 1439 | asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) |
| 1450 | { | 1440 | { |
| 1451 | struct rlimit new_rlim, *old_rlim; | 1441 | struct rlimit new_rlim, *old_rlim; |
| 1452 | unsigned long it_prof_secs; | ||
| 1453 | int retval; | 1442 | int retval; |
| 1454 | 1443 | ||
| 1455 | if (resource >= RLIM_NLIMITS) | 1444 | if (resource >= RLIM_NLIMITS) |
| @@ -1503,18 +1492,7 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) | |||
| 1503 | if (new_rlim.rlim_cur == RLIM_INFINITY) | 1492 | if (new_rlim.rlim_cur == RLIM_INFINITY) |
| 1504 | goto out; | 1493 | goto out; |
| 1505 | 1494 | ||
| 1506 | it_prof_secs = cputime_to_secs(current->signal->it_prof_expires); | 1495 | update_rlimit_cpu(new_rlim.rlim_cur); |
| 1507 | if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) { | ||
| 1508 | unsigned long rlim_cur = new_rlim.rlim_cur; | ||
| 1509 | cputime_t cputime; | ||
| 1510 | |||
| 1511 | cputime = secs_to_cputime(rlim_cur); | ||
| 1512 | read_lock(&tasklist_lock); | ||
| 1513 | spin_lock_irq(¤t->sighand->siglock); | ||
| 1514 | set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); | ||
| 1515 | spin_unlock_irq(¤t->sighand->siglock); | ||
| 1516 | read_unlock(&tasklist_lock); | ||
| 1517 | } | ||
| 1518 | out: | 1496 | out: |
| 1519 | return 0; | 1497 | return 0; |
| 1520 | } | 1498 | } |
| @@ -1552,11 +1530,8 @@ out: | |||
| 1552 | * | 1530 | * |
| 1553 | */ | 1531 | */ |
| 1554 | 1532 | ||
| 1555 | static void accumulate_thread_rusage(struct task_struct *t, struct rusage *r, | 1533 | static void accumulate_thread_rusage(struct task_struct *t, struct rusage *r) |
| 1556 | cputime_t *utimep, cputime_t *stimep) | ||
| 1557 | { | 1534 | { |
| 1558 | *utimep = cputime_add(*utimep, t->utime); | ||
| 1559 | *stimep = cputime_add(*stimep, t->stime); | ||
| 1560 | r->ru_nvcsw += t->nvcsw; | 1535 | r->ru_nvcsw += t->nvcsw; |
| 1561 | r->ru_nivcsw += t->nivcsw; | 1536 | r->ru_nivcsw += t->nivcsw; |
| 1562 | r->ru_minflt += t->min_flt; | 1537 | r->ru_minflt += t->min_flt; |
| @@ -1570,12 +1545,13 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
| 1570 | struct task_struct *t; | 1545 | struct task_struct *t; |
| 1571 | unsigned long flags; | 1546 | unsigned long flags; |
| 1572 | cputime_t utime, stime; | 1547 | cputime_t utime, stime; |
| 1548 | struct task_cputime cputime; | ||
| 1573 | 1549 | ||
| 1574 | memset((char *) r, 0, sizeof *r); | 1550 | memset((char *) r, 0, sizeof *r); |
| 1575 | utime = stime = cputime_zero; | 1551 | utime = stime = cputime_zero; |
| 1576 | 1552 | ||
| 1577 | if (who == RUSAGE_THREAD) { | 1553 | if (who == RUSAGE_THREAD) { |
| 1578 | accumulate_thread_rusage(p, r, &utime, &stime); | 1554 | accumulate_thread_rusage(p, r); |
| 1579 | goto out; | 1555 | goto out; |
| 1580 | } | 1556 | } |
| 1581 | 1557 | ||
| @@ -1598,8 +1574,9 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
| 1598 | break; | 1574 | break; |
| 1599 | 1575 | ||
| 1600 | case RUSAGE_SELF: | 1576 | case RUSAGE_SELF: |
| 1601 | utime = cputime_add(utime, p->signal->utime); | 1577 | thread_group_cputime(p, &cputime); |
| 1602 | stime = cputime_add(stime, p->signal->stime); | 1578 | utime = cputime_add(utime, cputime.utime); |
| 1579 | stime = cputime_add(stime, cputime.stime); | ||
| 1603 | r->ru_nvcsw += p->signal->nvcsw; | 1580 | r->ru_nvcsw += p->signal->nvcsw; |
| 1604 | r->ru_nivcsw += p->signal->nivcsw; | 1581 | r->ru_nivcsw += p->signal->nivcsw; |
| 1605 | r->ru_minflt += p->signal->min_flt; | 1582 | r->ru_minflt += p->signal->min_flt; |
| @@ -1608,7 +1585,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
| 1608 | r->ru_oublock += p->signal->oublock; | 1585 | r->ru_oublock += p->signal->oublock; |
| 1609 | t = p; | 1586 | t = p; |
| 1610 | do { | 1587 | do { |
| 1611 | accumulate_thread_rusage(t, r, &utime, &stime); | 1588 | accumulate_thread_rusage(t, r); |
| 1612 | t = next_thread(t); | 1589 | t = next_thread(t); |
| 1613 | } while (t != p); | 1590 | } while (t != p); |
| 1614 | break; | 1591 | break; |
