diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/compat.c | 59 | ||||
-rw-r--r-- | kernel/fork.c | 2 | ||||
-rw-r--r-- | kernel/hrtimer.c | 193 | ||||
-rw-r--r-- | kernel/irq/manage.c | 1 | ||||
-rw-r--r-- | kernel/itimer.c | 14 | ||||
-rw-r--r-- | kernel/kprobes.c | 10 | ||||
-rw-r--r-- | kernel/posix-timers.c | 67 | ||||
-rw-r--r-- | kernel/power/swap.c | 7 | ||||
-rw-r--r-- | kernel/sched.c | 9 | ||||
-rw-r--r-- | kernel/time.c | 4 |
10 files changed, 220 insertions, 146 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index 8c9cd88b6785..b9bdd1271f44 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/syscalls.h> | 21 | #include <linux/syscalls.h> |
22 | #include <linux/unistd.h> | 22 | #include <linux/unistd.h> |
23 | #include <linux/security.h> | 23 | #include <linux/security.h> |
24 | #include <linux/timex.h> | ||
24 | 25 | ||
25 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
26 | 27 | ||
@@ -898,3 +899,61 @@ asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, compat | |||
898 | return -ERESTARTNOHAND; | 899 | return -ERESTARTNOHAND; |
899 | } | 900 | } |
900 | #endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */ | 901 | #endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */ |
902 | |||
903 | asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp) | ||
904 | { | ||
905 | struct timex txc; | ||
906 | int ret; | ||
907 | |||
908 | memset(&txc, 0, sizeof(struct timex)); | ||
909 | |||
910 | if (!access_ok(VERIFY_READ, utp, sizeof(struct compat_timex)) || | ||
911 | __get_user(txc.modes, &utp->modes) || | ||
912 | __get_user(txc.offset, &utp->offset) || | ||
913 | __get_user(txc.freq, &utp->freq) || | ||
914 | __get_user(txc.maxerror, &utp->maxerror) || | ||
915 | __get_user(txc.esterror, &utp->esterror) || | ||
916 | __get_user(txc.status, &utp->status) || | ||
917 | __get_user(txc.constant, &utp->constant) || | ||
918 | __get_user(txc.precision, &utp->precision) || | ||
919 | __get_user(txc.tolerance, &utp->tolerance) || | ||
920 | __get_user(txc.time.tv_sec, &utp->time.tv_sec) || | ||
921 | __get_user(txc.time.tv_usec, &utp->time.tv_usec) || | ||
922 | __get_user(txc.tick, &utp->tick) || | ||
923 | __get_user(txc.ppsfreq, &utp->ppsfreq) || | ||
924 | __get_user(txc.jitter, &utp->jitter) || | ||
925 | __get_user(txc.shift, &utp->shift) || | ||
926 | __get_user(txc.stabil, &utp->stabil) || | ||
927 | __get_user(txc.jitcnt, &utp->jitcnt) || | ||
928 | __get_user(txc.calcnt, &utp->calcnt) || | ||
929 | __get_user(txc.errcnt, &utp->errcnt) || | ||
930 | __get_user(txc.stbcnt, &utp->stbcnt)) | ||
931 | return -EFAULT; | ||
932 | |||
933 | ret = do_adjtimex(&txc); | ||
934 | |||
935 | if (!access_ok(VERIFY_WRITE, utp, sizeof(struct compat_timex)) || | ||
936 | __put_user(txc.modes, &utp->modes) || | ||
937 | __put_user(txc.offset, &utp->offset) || | ||
938 | __put_user(txc.freq, &utp->freq) || | ||
939 | __put_user(txc.maxerror, &utp->maxerror) || | ||
940 | __put_user(txc.esterror, &utp->esterror) || | ||
941 | __put_user(txc.status, &utp->status) || | ||
942 | __put_user(txc.constant, &utp->constant) || | ||
943 | __put_user(txc.precision, &utp->precision) || | ||
944 | __put_user(txc.tolerance, &utp->tolerance) || | ||
945 | __put_user(txc.time.tv_sec, &utp->time.tv_sec) || | ||
946 | __put_user(txc.time.tv_usec, &utp->time.tv_usec) || | ||
947 | __put_user(txc.tick, &utp->tick) || | ||
948 | __put_user(txc.ppsfreq, &utp->ppsfreq) || | ||
949 | __put_user(txc.jitter, &utp->jitter) || | ||
950 | __put_user(txc.shift, &utp->shift) || | ||
951 | __put_user(txc.stabil, &utp->stabil) || | ||
952 | __put_user(txc.jitcnt, &utp->jitcnt) || | ||
953 | __put_user(txc.calcnt, &utp->calcnt) || | ||
954 | __put_user(txc.errcnt, &utp->errcnt) || | ||
955 | __put_user(txc.stbcnt, &utp->stbcnt)) | ||
956 | ret = -EFAULT; | ||
957 | |||
958 | return ret; | ||
959 | } | ||
diff --git a/kernel/fork.c b/kernel/fork.c index d93ab2ba729c..e0a2b449dea6 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -847,7 +847,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts | |||
847 | hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL); | 847 | hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL); |
848 | sig->it_real_incr.tv64 = 0; | 848 | sig->it_real_incr.tv64 = 0; |
849 | sig->real_timer.function = it_real_fn; | 849 | sig->real_timer.function = it_real_fn; |
850 | sig->real_timer.data = tsk; | 850 | sig->tsk = tsk; |
851 | 851 | ||
852 | sig->it_virt_expires = cputime_zero; | 852 | sig->it_virt_expires = cputime_zero; |
853 | sig->it_virt_incr = cputime_zero; | 853 | sig->it_virt_incr = cputime_zero; |
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 14bc9cfa6399..0237a556eb1f 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -123,6 +123,26 @@ void ktime_get_ts(struct timespec *ts) | |||
123 | EXPORT_SYMBOL_GPL(ktime_get_ts); | 123 | EXPORT_SYMBOL_GPL(ktime_get_ts); |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * Get the coarse grained time at the softirq based on xtime and | ||
127 | * wall_to_monotonic. | ||
128 | */ | ||
129 | static void hrtimer_get_softirq_time(struct hrtimer_base *base) | ||
130 | { | ||
131 | ktime_t xtim, tomono; | ||
132 | unsigned long seq; | ||
133 | |||
134 | do { | ||
135 | seq = read_seqbegin(&xtime_lock); | ||
136 | xtim = timespec_to_ktime(xtime); | ||
137 | tomono = timespec_to_ktime(wall_to_monotonic); | ||
138 | |||
139 | } while (read_seqretry(&xtime_lock, seq)); | ||
140 | |||
141 | base[CLOCK_REALTIME].softirq_time = xtim; | ||
142 | base[CLOCK_MONOTONIC].softirq_time = ktime_add(xtim, tomono); | ||
143 | } | ||
144 | |||
145 | /* | ||
126 | * Functions and macros which are different for UP/SMP systems are kept in a | 146 | * Functions and macros which are different for UP/SMP systems are kept in a |
127 | * single place | 147 | * single place |
128 | */ | 148 | */ |
@@ -246,7 +266,7 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec) | |||
246 | /* | 266 | /* |
247 | * Divide a ktime value by a nanosecond value | 267 | * Divide a ktime value by a nanosecond value |
248 | */ | 268 | */ |
249 | static unsigned long ktime_divns(const ktime_t kt, nsec_t div) | 269 | static unsigned long ktime_divns(const ktime_t kt, s64 div) |
250 | { | 270 | { |
251 | u64 dclc, inc, dns; | 271 | u64 dclc, inc, dns; |
252 | int sft = 0; | 272 | int sft = 0; |
@@ -281,18 +301,17 @@ void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) | |||
281 | * hrtimer_forward - forward the timer expiry | 301 | * hrtimer_forward - forward the timer expiry |
282 | * | 302 | * |
283 | * @timer: hrtimer to forward | 303 | * @timer: hrtimer to forward |
304 | * @now: forward past this time | ||
284 | * @interval: the interval to forward | 305 | * @interval: the interval to forward |
285 | * | 306 | * |
286 | * Forward the timer expiry so it will expire in the future. | 307 | * Forward the timer expiry so it will expire in the future. |
287 | * Returns the number of overruns. | 308 | * Returns the number of overruns. |
288 | */ | 309 | */ |
289 | unsigned long | 310 | unsigned long |
290 | hrtimer_forward(struct hrtimer *timer, ktime_t interval) | 311 | hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) |
291 | { | 312 | { |
292 | unsigned long orun = 1; | 313 | unsigned long orun = 1; |
293 | ktime_t delta, now; | 314 | ktime_t delta; |
294 | |||
295 | now = timer->base->get_time(); | ||
296 | 315 | ||
297 | delta = ktime_sub(now, timer->expires); | 316 | delta = ktime_sub(now, timer->expires); |
298 | 317 | ||
@@ -303,7 +322,7 @@ hrtimer_forward(struct hrtimer *timer, ktime_t interval) | |||
303 | interval.tv64 = timer->base->resolution.tv64; | 322 | interval.tv64 = timer->base->resolution.tv64; |
304 | 323 | ||
305 | if (unlikely(delta.tv64 >= interval.tv64)) { | 324 | if (unlikely(delta.tv64 >= interval.tv64)) { |
306 | nsec_t incr = ktime_to_ns(interval); | 325 | s64 incr = ktime_to_ns(interval); |
307 | 326 | ||
308 | orun = ktime_divns(delta, incr); | 327 | orun = ktime_divns(delta, incr); |
309 | timer->expires = ktime_add_ns(timer->expires, incr * orun); | 328 | timer->expires = ktime_add_ns(timer->expires, incr * orun); |
@@ -355,8 +374,6 @@ static void enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) | |||
355 | rb_link_node(&timer->node, parent, link); | 374 | rb_link_node(&timer->node, parent, link); |
356 | rb_insert_color(&timer->node, &base->active); | 375 | rb_insert_color(&timer->node, &base->active); |
357 | 376 | ||
358 | timer->state = HRTIMER_PENDING; | ||
359 | |||
360 | if (!base->first || timer->expires.tv64 < | 377 | if (!base->first || timer->expires.tv64 < |
361 | rb_entry(base->first, struct hrtimer, node)->expires.tv64) | 378 | rb_entry(base->first, struct hrtimer, node)->expires.tv64) |
362 | base->first = &timer->node; | 379 | base->first = &timer->node; |
@@ -376,6 +393,7 @@ static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) | |||
376 | if (base->first == &timer->node) | 393 | if (base->first == &timer->node) |
377 | base->first = rb_next(&timer->node); | 394 | base->first = rb_next(&timer->node); |
378 | rb_erase(&timer->node, &base->active); | 395 | rb_erase(&timer->node, &base->active); |
396 | timer->node.rb_parent = HRTIMER_INACTIVE; | ||
379 | } | 397 | } |
380 | 398 | ||
381 | /* | 399 | /* |
@@ -386,7 +404,6 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) | |||
386 | { | 404 | { |
387 | if (hrtimer_active(timer)) { | 405 | if (hrtimer_active(timer)) { |
388 | __remove_hrtimer(timer, base); | 406 | __remove_hrtimer(timer, base); |
389 | timer->state = HRTIMER_INACTIVE; | ||
390 | return 1; | 407 | return 1; |
391 | } | 408 | } |
392 | return 0; | 409 | return 0; |
@@ -560,6 +577,7 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, | |||
560 | clock_id = CLOCK_MONOTONIC; | 577 | clock_id = CLOCK_MONOTONIC; |
561 | 578 | ||
562 | timer->base = &bases[clock_id]; | 579 | timer->base = &bases[clock_id]; |
580 | timer->node.rb_parent = HRTIMER_INACTIVE; | ||
563 | } | 581 | } |
564 | 582 | ||
565 | /** | 583 | /** |
@@ -586,48 +604,35 @@ int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp) | |||
586 | */ | 604 | */ |
587 | static inline void run_hrtimer_queue(struct hrtimer_base *base) | 605 | static inline void run_hrtimer_queue(struct hrtimer_base *base) |
588 | { | 606 | { |
589 | ktime_t now = base->get_time(); | ||
590 | struct rb_node *node; | 607 | struct rb_node *node; |
591 | 608 | ||
609 | if (base->get_softirq_time) | ||
610 | base->softirq_time = base->get_softirq_time(); | ||
611 | |||
592 | spin_lock_irq(&base->lock); | 612 | spin_lock_irq(&base->lock); |
593 | 613 | ||
594 | while ((node = base->first)) { | 614 | while ((node = base->first)) { |
595 | struct hrtimer *timer; | 615 | struct hrtimer *timer; |
596 | int (*fn)(void *); | 616 | int (*fn)(struct hrtimer *); |
597 | int restart; | 617 | int restart; |
598 | void *data; | ||
599 | 618 | ||
600 | timer = rb_entry(node, struct hrtimer, node); | 619 | timer = rb_entry(node, struct hrtimer, node); |
601 | if (now.tv64 <= timer->expires.tv64) | 620 | if (base->softirq_time.tv64 <= timer->expires.tv64) |
602 | break; | 621 | break; |
603 | 622 | ||
604 | fn = timer->function; | 623 | fn = timer->function; |
605 | data = timer->data; | ||
606 | set_curr_timer(base, timer); | 624 | set_curr_timer(base, timer); |
607 | timer->state = HRTIMER_RUNNING; | ||
608 | __remove_hrtimer(timer, base); | 625 | __remove_hrtimer(timer, base); |
609 | spin_unlock_irq(&base->lock); | 626 | spin_unlock_irq(&base->lock); |
610 | 627 | ||
611 | /* | 628 | restart = fn(timer); |
612 | * fn == NULL is special case for the simplest timer | ||
613 | * variant - wake up process and do not restart: | ||
614 | */ | ||
615 | if (!fn) { | ||
616 | wake_up_process(data); | ||
617 | restart = HRTIMER_NORESTART; | ||
618 | } else | ||
619 | restart = fn(data); | ||
620 | 629 | ||
621 | spin_lock_irq(&base->lock); | 630 | spin_lock_irq(&base->lock); |
622 | 631 | ||
623 | /* Another CPU has added back the timer */ | 632 | if (restart != HRTIMER_NORESTART) { |
624 | if (timer->state != HRTIMER_RUNNING) | 633 | BUG_ON(hrtimer_active(timer)); |
625 | continue; | ||
626 | |||
627 | if (restart == HRTIMER_RESTART) | ||
628 | enqueue_hrtimer(timer, base); | 634 | enqueue_hrtimer(timer, base); |
629 | else | 635 | } |
630 | timer->state = HRTIMER_EXPIRED; | ||
631 | } | 636 | } |
632 | set_curr_timer(base, NULL); | 637 | set_curr_timer(base, NULL); |
633 | spin_unlock_irq(&base->lock); | 638 | spin_unlock_irq(&base->lock); |
@@ -641,6 +646,8 @@ void hrtimer_run_queues(void) | |||
641 | struct hrtimer_base *base = __get_cpu_var(hrtimer_bases); | 646 | struct hrtimer_base *base = __get_cpu_var(hrtimer_bases); |
642 | int i; | 647 | int i; |
643 | 648 | ||
649 | hrtimer_get_softirq_time(base); | ||
650 | |||
644 | for (i = 0; i < MAX_HRTIMER_BASES; i++) | 651 | for (i = 0; i < MAX_HRTIMER_BASES; i++) |
645 | run_hrtimer_queue(&base[i]); | 652 | run_hrtimer_queue(&base[i]); |
646 | } | 653 | } |
@@ -649,79 +656,70 @@ void hrtimer_run_queues(void) | |||
649 | * Sleep related functions: | 656 | * Sleep related functions: |
650 | */ | 657 | */ |
651 | 658 | ||
652 | /** | 659 | struct sleep_hrtimer { |
653 | * schedule_hrtimer - sleep until timeout | 660 | struct hrtimer timer; |
654 | * | 661 | struct task_struct *task; |
655 | * @timer: hrtimer variable initialized with the correct clock base | 662 | int expired; |
656 | * @mode: timeout value is abs/rel | 663 | }; |
657 | * | ||
658 | * Make the current task sleep until @timeout is | ||
659 | * elapsed. | ||
660 | * | ||
661 | * You can set the task state as follows - | ||
662 | * | ||
663 | * %TASK_UNINTERRUPTIBLE - at least @timeout is guaranteed to | ||
664 | * pass before the routine returns. The routine will return 0 | ||
665 | * | ||
666 | * %TASK_INTERRUPTIBLE - the routine may return early if a signal is | ||
667 | * delivered to the current task. In this case the remaining time | ||
668 | * will be returned | ||
669 | * | ||
670 | * The current task state is guaranteed to be TASK_RUNNING when this | ||
671 | * routine returns. | ||
672 | */ | ||
673 | static ktime_t __sched | ||
674 | schedule_hrtimer(struct hrtimer *timer, const enum hrtimer_mode mode) | ||
675 | { | ||
676 | /* fn stays NULL, meaning single-shot wakeup: */ | ||
677 | timer->data = current; | ||
678 | 664 | ||
679 | hrtimer_start(timer, timer->expires, mode); | 665 | static int nanosleep_wakeup(struct hrtimer *timer) |
666 | { | ||
667 | struct sleep_hrtimer *t = | ||
668 | container_of(timer, struct sleep_hrtimer, timer); | ||
680 | 669 | ||
681 | schedule(); | 670 | t->expired = 1; |
682 | hrtimer_cancel(timer); | 671 | wake_up_process(t->task); |
683 | 672 | ||
684 | /* Return the remaining time: */ | 673 | return HRTIMER_NORESTART; |
685 | if (timer->state != HRTIMER_EXPIRED) | ||
686 | return ktime_sub(timer->expires, timer->base->get_time()); | ||
687 | else | ||
688 | return (ktime_t) {.tv64 = 0 }; | ||
689 | } | 674 | } |
690 | 675 | ||
691 | static inline ktime_t __sched | 676 | static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode) |
692 | schedule_hrtimer_interruptible(struct hrtimer *timer, | ||
693 | const enum hrtimer_mode mode) | ||
694 | { | 677 | { |
695 | set_current_state(TASK_INTERRUPTIBLE); | 678 | t->timer.function = nanosleep_wakeup; |
679 | t->task = current; | ||
680 | t->expired = 0; | ||
681 | |||
682 | do { | ||
683 | set_current_state(TASK_INTERRUPTIBLE); | ||
684 | hrtimer_start(&t->timer, t->timer.expires, mode); | ||
685 | |||
686 | schedule(); | ||
687 | |||
688 | if (unlikely(!t->expired)) { | ||
689 | hrtimer_cancel(&t->timer); | ||
690 | mode = HRTIMER_ABS; | ||
691 | } | ||
692 | } while (!t->expired && !signal_pending(current)); | ||
696 | 693 | ||
697 | return schedule_hrtimer(timer, mode); | 694 | return t->expired; |
698 | } | 695 | } |
699 | 696 | ||
700 | static long __sched nanosleep_restart(struct restart_block *restart) | 697 | static long __sched nanosleep_restart(struct restart_block *restart) |
701 | { | 698 | { |
699 | struct sleep_hrtimer t; | ||
702 | struct timespec __user *rmtp; | 700 | struct timespec __user *rmtp; |
703 | struct timespec tu; | 701 | struct timespec tu; |
704 | void *rfn_save = restart->fn; | 702 | ktime_t time; |
705 | struct hrtimer timer; | ||
706 | ktime_t rem; | ||
707 | 703 | ||
708 | restart->fn = do_no_restart_syscall; | 704 | restart->fn = do_no_restart_syscall; |
709 | 705 | ||
710 | hrtimer_init(&timer, (clockid_t) restart->arg3, HRTIMER_ABS); | 706 | hrtimer_init(&t.timer, restart->arg3, HRTIMER_ABS); |
711 | 707 | t.timer.expires.tv64 = ((u64)restart->arg1 << 32) | (u64) restart->arg0; | |
712 | timer.expires.tv64 = ((u64)restart->arg1 << 32) | (u64) restart->arg0; | ||
713 | |||
714 | rem = schedule_hrtimer_interruptible(&timer, HRTIMER_ABS); | ||
715 | 708 | ||
716 | if (rem.tv64 <= 0) | 709 | if (do_nanosleep(&t, HRTIMER_ABS)) |
717 | return 0; | 710 | return 0; |
718 | 711 | ||
719 | rmtp = (struct timespec __user *) restart->arg2; | 712 | rmtp = (struct timespec __user *) restart->arg2; |
720 | tu = ktime_to_timespec(rem); | 713 | if (rmtp) { |
721 | if (rmtp && copy_to_user(rmtp, &tu, sizeof(tu))) | 714 | time = ktime_sub(t.timer.expires, t.timer.base->get_time()); |
722 | return -EFAULT; | 715 | if (time.tv64 <= 0) |
716 | return 0; | ||
717 | tu = ktime_to_timespec(time); | ||
718 | if (copy_to_user(rmtp, &tu, sizeof(tu))) | ||
719 | return -EFAULT; | ||
720 | } | ||
723 | 721 | ||
724 | restart->fn = rfn_save; | 722 | restart->fn = nanosleep_restart; |
725 | 723 | ||
726 | /* The other values in restart are already filled in */ | 724 | /* The other values in restart are already filled in */ |
727 | return -ERESTART_RESTARTBLOCK; | 725 | return -ERESTART_RESTARTBLOCK; |
@@ -731,33 +729,34 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, | |||
731 | const enum hrtimer_mode mode, const clockid_t clockid) | 729 | const enum hrtimer_mode mode, const clockid_t clockid) |
732 | { | 730 | { |
733 | struct restart_block *restart; | 731 | struct restart_block *restart; |
734 | struct hrtimer timer; | 732 | struct sleep_hrtimer t; |
735 | struct timespec tu; | 733 | struct timespec tu; |
736 | ktime_t rem; | 734 | ktime_t rem; |
737 | 735 | ||
738 | hrtimer_init(&timer, clockid, mode); | 736 | hrtimer_init(&t.timer, clockid, mode); |
739 | 737 | t.timer.expires = timespec_to_ktime(*rqtp); | |
740 | timer.expires = timespec_to_ktime(*rqtp); | 738 | if (do_nanosleep(&t, mode)) |
741 | |||
742 | rem = schedule_hrtimer_interruptible(&timer, mode); | ||
743 | if (rem.tv64 <= 0) | ||
744 | return 0; | 739 | return 0; |
745 | 740 | ||
746 | /* Absolute timers do not update the rmtp value and restart: */ | 741 | /* Absolute timers do not update the rmtp value and restart: */ |
747 | if (mode == HRTIMER_ABS) | 742 | if (mode == HRTIMER_ABS) |
748 | return -ERESTARTNOHAND; | 743 | return -ERESTARTNOHAND; |
749 | 744 | ||
750 | tu = ktime_to_timespec(rem); | 745 | if (rmtp) { |
751 | 746 | rem = ktime_sub(t.timer.expires, t.timer.base->get_time()); | |
752 | if (rmtp && copy_to_user(rmtp, &tu, sizeof(tu))) | 747 | if (rem.tv64 <= 0) |
753 | return -EFAULT; | 748 | return 0; |
749 | tu = ktime_to_timespec(rem); | ||
750 | if (copy_to_user(rmtp, &tu, sizeof(tu))) | ||
751 | return -EFAULT; | ||
752 | } | ||
754 | 753 | ||
755 | restart = ¤t_thread_info()->restart_block; | 754 | restart = ¤t_thread_info()->restart_block; |
756 | restart->fn = nanosleep_restart; | 755 | restart->fn = nanosleep_restart; |
757 | restart->arg0 = timer.expires.tv64 & 0xFFFFFFFF; | 756 | restart->arg0 = t.timer.expires.tv64 & 0xFFFFFFFF; |
758 | restart->arg1 = timer.expires.tv64 >> 32; | 757 | restart->arg1 = t.timer.expires.tv64 >> 32; |
759 | restart->arg2 = (unsigned long) rmtp; | 758 | restart->arg2 = (unsigned long) rmtp; |
760 | restart->arg3 = (unsigned long) timer.base->index; | 759 | restart->arg3 = (unsigned long) t.timer.base->index; |
761 | 760 | ||
762 | return -ERESTART_RESTARTBLOCK; | 761 | return -ERESTART_RESTARTBLOCK; |
763 | } | 762 | } |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 6edfcef291e8..ac766ad573e8 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -271,6 +271,7 @@ void free_irq(unsigned int irq, void *dev_id) | |||
271 | struct irqaction **p; | 271 | struct irqaction **p; |
272 | unsigned long flags; | 272 | unsigned long flags; |
273 | 273 | ||
274 | WARN_ON(in_interrupt()); | ||
274 | if (irq >= NR_IRQS) | 275 | if (irq >= NR_IRQS) |
275 | return; | 276 | return; |
276 | 277 | ||
diff --git a/kernel/itimer.c b/kernel/itimer.c index 680e6b70c872..204ed7939e75 100644 --- a/kernel/itimer.c +++ b/kernel/itimer.c | |||
@@ -128,16 +128,16 @@ asmlinkage long sys_getitimer(int which, struct itimerval __user *value) | |||
128 | /* | 128 | /* |
129 | * The timer is automagically restarted, when interval != 0 | 129 | * The timer is automagically restarted, when interval != 0 |
130 | */ | 130 | */ |
131 | int it_real_fn(void *data) | 131 | int it_real_fn(struct hrtimer *timer) |
132 | { | 132 | { |
133 | struct task_struct *tsk = (struct task_struct *) data; | 133 | struct signal_struct *sig = |
134 | container_of(timer, struct signal_struct, real_timer); | ||
134 | 135 | ||
135 | send_group_sig_info(SIGALRM, SEND_SIG_PRIV, tsk); | 136 | send_group_sig_info(SIGALRM, SEND_SIG_PRIV, sig->tsk); |
136 | |||
137 | if (tsk->signal->it_real_incr.tv64 != 0) { | ||
138 | hrtimer_forward(&tsk->signal->real_timer, | ||
139 | tsk->signal->it_real_incr); | ||
140 | 137 | ||
138 | if (sig->it_real_incr.tv64 != 0) { | ||
139 | hrtimer_forward(timer, timer->base->softirq_time, | ||
140 | sig->it_real_incr); | ||
141 | return HRTIMER_RESTART; | 141 | return HRTIMER_RESTART; |
142 | } | 142 | } |
143 | return HRTIMER_NORESTART; | 143 | return HRTIMER_NORESTART; |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 1fb9f753ef60..1156eb0977d0 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -323,10 +323,10 @@ struct hlist_head __kprobes *kretprobe_inst_table_head(struct task_struct *tsk) | |||
323 | } | 323 | } |
324 | 324 | ||
325 | /* | 325 | /* |
326 | * This function is called from exit_thread or flush_thread when task tk's | 326 | * This function is called from finish_task_switch when task tk becomes dead, |
327 | * stack is being recycled so that we can recycle any function-return probe | 327 | * so that we can recycle any function-return probe instances associated |
328 | * instances associated with this task. These left over instances represent | 328 | * with this task. These left over instances represent probed functions |
329 | * probed functions that have been called but will never return. | 329 | * that have been called but will never return. |
330 | */ | 330 | */ |
331 | void __kprobes kprobe_flush_task(struct task_struct *tk) | 331 | void __kprobes kprobe_flush_task(struct task_struct *tk) |
332 | { | 332 | { |
@@ -336,7 +336,7 @@ void __kprobes kprobe_flush_task(struct task_struct *tk) | |||
336 | unsigned long flags = 0; | 336 | unsigned long flags = 0; |
337 | 337 | ||
338 | spin_lock_irqsave(&kretprobe_lock, flags); | 338 | spin_lock_irqsave(&kretprobe_lock, flags); |
339 | head = kretprobe_inst_table_head(current); | 339 | head = kretprobe_inst_table_head(tk); |
340 | hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { | 340 | hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { |
341 | if (ri->task == tk) | 341 | if (ri->task == tk) |
342 | recycle_rp_inst(ri); | 342 | recycle_rp_inst(ri); |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 9944379360b5..ac6dc8744429 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -145,7 +145,7 @@ static int common_timer_set(struct k_itimer *, int, | |||
145 | struct itimerspec *, struct itimerspec *); | 145 | struct itimerspec *, struct itimerspec *); |
146 | static int common_timer_del(struct k_itimer *timer); | 146 | static int common_timer_del(struct k_itimer *timer); |
147 | 147 | ||
148 | static int posix_timer_fn(void *data); | 148 | static int posix_timer_fn(struct hrtimer *data); |
149 | 149 | ||
150 | static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); | 150 | static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); |
151 | 151 | ||
@@ -251,15 +251,18 @@ __initcall(init_posix_timers); | |||
251 | 251 | ||
252 | static void schedule_next_timer(struct k_itimer *timr) | 252 | static void schedule_next_timer(struct k_itimer *timr) |
253 | { | 253 | { |
254 | struct hrtimer *timer = &timr->it.real.timer; | ||
255 | |||
254 | if (timr->it.real.interval.tv64 == 0) | 256 | if (timr->it.real.interval.tv64 == 0) |
255 | return; | 257 | return; |
256 | 258 | ||
257 | timr->it_overrun += hrtimer_forward(&timr->it.real.timer, | 259 | timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(), |
258 | timr->it.real.interval); | 260 | timr->it.real.interval); |
261 | |||
259 | timr->it_overrun_last = timr->it_overrun; | 262 | timr->it_overrun_last = timr->it_overrun; |
260 | timr->it_overrun = -1; | 263 | timr->it_overrun = -1; |
261 | ++timr->it_requeue_pending; | 264 | ++timr->it_requeue_pending; |
262 | hrtimer_restart(&timr->it.real.timer); | 265 | hrtimer_restart(timer); |
263 | } | 266 | } |
264 | 267 | ||
265 | /* | 268 | /* |
@@ -331,13 +334,14 @@ EXPORT_SYMBOL_GPL(posix_timer_event); | |||
331 | 334 | ||
332 | * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers. | 335 | * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers. |
333 | */ | 336 | */ |
334 | static int posix_timer_fn(void *data) | 337 | static int posix_timer_fn(struct hrtimer *timer) |
335 | { | 338 | { |
336 | struct k_itimer *timr = data; | 339 | struct k_itimer *timr; |
337 | unsigned long flags; | 340 | unsigned long flags; |
338 | int si_private = 0; | 341 | int si_private = 0; |
339 | int ret = HRTIMER_NORESTART; | 342 | int ret = HRTIMER_NORESTART; |
340 | 343 | ||
344 | timr = container_of(timer, struct k_itimer, it.real.timer); | ||
341 | spin_lock_irqsave(&timr->it_lock, flags); | 345 | spin_lock_irqsave(&timr->it_lock, flags); |
342 | 346 | ||
343 | if (timr->it.real.interval.tv64 != 0) | 347 | if (timr->it.real.interval.tv64 != 0) |
@@ -351,7 +355,8 @@ static int posix_timer_fn(void *data) | |||
351 | */ | 355 | */ |
352 | if (timr->it.real.interval.tv64 != 0) { | 356 | if (timr->it.real.interval.tv64 != 0) { |
353 | timr->it_overrun += | 357 | timr->it_overrun += |
354 | hrtimer_forward(&timr->it.real.timer, | 358 | hrtimer_forward(timer, |
359 | timer->base->softirq_time, | ||
355 | timr->it.real.interval); | 360 | timr->it.real.interval); |
356 | ret = HRTIMER_RESTART; | 361 | ret = HRTIMER_RESTART; |
357 | ++timr->it_requeue_pending; | 362 | ++timr->it_requeue_pending; |
@@ -603,38 +608,41 @@ static struct k_itimer * lock_timer(timer_t timer_id, unsigned long *flags) | |||
603 | static void | 608 | static void |
604 | common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) | 609 | common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) |
605 | { | 610 | { |
606 | ktime_t remaining; | 611 | ktime_t now, remaining, iv; |
607 | struct hrtimer *timer = &timr->it.real.timer; | 612 | struct hrtimer *timer = &timr->it.real.timer; |
608 | 613 | ||
609 | memset(cur_setting, 0, sizeof(struct itimerspec)); | 614 | memset(cur_setting, 0, sizeof(struct itimerspec)); |
610 | remaining = hrtimer_get_remaining(timer); | ||
611 | 615 | ||
612 | /* Time left ? or timer pending */ | 616 | iv = timr->it.real.interval; |
613 | if (remaining.tv64 > 0 || hrtimer_active(timer)) | 617 | |
614 | goto calci; | ||
615 | /* interval timer ? */ | 618 | /* interval timer ? */ |
616 | if (timr->it.real.interval.tv64 == 0) | 619 | if (iv.tv64) |
620 | cur_setting->it_interval = ktime_to_timespec(iv); | ||
621 | else if (!hrtimer_active(timer) && | ||
622 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) | ||
617 | return; | 623 | return; |
624 | |||
625 | now = timer->base->get_time(); | ||
626 | |||
618 | /* | 627 | /* |
619 | * When a requeue is pending or this is a SIGEV_NONE timer | 628 | * When a requeue is pending or this is a SIGEV_NONE |
620 | * move the expiry time forward by intervals, so expiry is > | 629 | * timer move the expiry time forward by intervals, so |
621 | * now. | 630 | * expiry is > now. |
622 | */ | 631 | */ |
623 | if (timr->it_requeue_pending & REQUEUE_PENDING || | 632 | if (iv.tv64 && (timr->it_requeue_pending & REQUEUE_PENDING || |
624 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) { | 633 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) |
625 | timr->it_overrun += | 634 | timr->it_overrun += hrtimer_forward(timer, now, iv); |
626 | hrtimer_forward(timer, timr->it.real.interval); | 635 | |
627 | remaining = hrtimer_get_remaining(timer); | 636 | remaining = ktime_sub(timer->expires, now); |
628 | } | ||
629 | calci: | ||
630 | /* interval timer ? */ | ||
631 | if (timr->it.real.interval.tv64 != 0) | ||
632 | cur_setting->it_interval = | ||
633 | ktime_to_timespec(timr->it.real.interval); | ||
634 | /* Return 0 only, when the timer is expired and not pending */ | 637 | /* Return 0 only, when the timer is expired and not pending */ |
635 | if (remaining.tv64 <= 0) | 638 | if (remaining.tv64 <= 0) { |
636 | cur_setting->it_value.tv_nsec = 1; | 639 | /* |
637 | else | 640 | * A single shot SIGEV_NONE timer must return 0, when |
641 | * it is expired ! | ||
642 | */ | ||
643 | if ((timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) | ||
644 | cur_setting->it_value.tv_nsec = 1; | ||
645 | } else | ||
638 | cur_setting->it_value = ktime_to_timespec(remaining); | 646 | cur_setting->it_value = ktime_to_timespec(remaining); |
639 | } | 647 | } |
640 | 648 | ||
@@ -717,7 +725,6 @@ common_timer_set(struct k_itimer *timr, int flags, | |||
717 | 725 | ||
718 | mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; | 726 | mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; |
719 | hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); | 727 | hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); |
720 | timr->it.real.timer.data = timr; | ||
721 | timr->it.real.timer.function = posix_timer_fn; | 728 | timr->it.real.timer.function = posix_timer_fn; |
722 | 729 | ||
723 | timer->expires = timespec_to_ktime(new_setting->it_value); | 730 | timer->expires = timespec_to_ktime(new_setting->it_value); |
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 9177f3f73a6c..044b8e0c1025 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
@@ -454,10 +454,11 @@ static int load_image(struct swap_map_handle *handle, | |||
454 | nr_pages++; | 454 | nr_pages++; |
455 | } | 455 | } |
456 | } while (ret > 0); | 456 | } while (ret > 0); |
457 | if (!error) | 457 | if (!error) { |
458 | printk("\b\b\b\bdone\n"); | 458 | printk("\b\b\b\bdone\n"); |
459 | if (!snapshot_image_loaded(snapshot)) | 459 | if (!snapshot_image_loaded(snapshot)) |
460 | error = -ENODATA; | 460 | error = -ENODATA; |
461 | } | ||
461 | return error; | 462 | return error; |
462 | } | 463 | } |
463 | 464 | ||
diff --git a/kernel/sched.c b/kernel/sched.c index 7ffaabd64f89..78acdefeccca 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/syscalls.h> | 49 | #include <linux/syscalls.h> |
50 | #include <linux/times.h> | 50 | #include <linux/times.h> |
51 | #include <linux/acct.h> | 51 | #include <linux/acct.h> |
52 | #include <linux/kprobes.h> | ||
52 | #include <asm/tlb.h> | 53 | #include <asm/tlb.h> |
53 | 54 | ||
54 | #include <asm/unistd.h> | 55 | #include <asm/unistd.h> |
@@ -1546,8 +1547,14 @@ static inline void finish_task_switch(runqueue_t *rq, task_t *prev) | |||
1546 | finish_lock_switch(rq, prev); | 1547 | finish_lock_switch(rq, prev); |
1547 | if (mm) | 1548 | if (mm) |
1548 | mmdrop(mm); | 1549 | mmdrop(mm); |
1549 | if (unlikely(prev_task_flags & PF_DEAD)) | 1550 | if (unlikely(prev_task_flags & PF_DEAD)) { |
1551 | /* | ||
1552 | * Remove function-return probe instances associated with this | ||
1553 | * task and put them back on the free list. | ||
1554 | */ | ||
1555 | kprobe_flush_task(prev); | ||
1550 | put_task_struct(prev); | 1556 | put_task_struct(prev); |
1557 | } | ||
1551 | } | 1558 | } |
1552 | 1559 | ||
1553 | /** | 1560 | /** |
diff --git a/kernel/time.c b/kernel/time.c index e00a97b77241..ff8e7019c4c4 100644 --- a/kernel/time.c +++ b/kernel/time.c | |||
@@ -610,7 +610,7 @@ void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec) | |||
610 | * | 610 | * |
611 | * Returns the timespec representation of the nsec parameter. | 611 | * Returns the timespec representation of the nsec parameter. |
612 | */ | 612 | */ |
613 | struct timespec ns_to_timespec(const nsec_t nsec) | 613 | struct timespec ns_to_timespec(const s64 nsec) |
614 | { | 614 | { |
615 | struct timespec ts; | 615 | struct timespec ts; |
616 | 616 | ||
@@ -630,7 +630,7 @@ struct timespec ns_to_timespec(const nsec_t nsec) | |||
630 | * | 630 | * |
631 | * Returns the timeval representation of the nsec parameter. | 631 | * Returns the timeval representation of the nsec parameter. |
632 | */ | 632 | */ |
633 | struct timeval ns_to_timeval(const nsec_t nsec) | 633 | struct timeval ns_to_timeval(const s64 nsec) |
634 | { | 634 | { |
635 | struct timespec ts = ns_to_timespec(nsec); | 635 | struct timespec ts = ns_to_timespec(nsec); |
636 | struct timeval tv; | 636 | struct timeval tv; |