diff options
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r-- | kernel/posix-timers.c | 52 |
1 files changed, 10 insertions, 42 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index cabb63fc9e16..38798a2ff994 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -89,23 +89,6 @@ static struct idr posix_timers_id; | |||
89 | static DEFINE_SPINLOCK(idr_lock); | 89 | static DEFINE_SPINLOCK(idr_lock); |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * Just because the timer is not in the timer list does NOT mean it is | ||
93 | * inactive. It could be in the "fire" routine getting a new expire time. | ||
94 | */ | ||
95 | #define TIMER_INACTIVE 1 | ||
96 | |||
97 | #ifdef CONFIG_SMP | ||
98 | # define timer_active(tmr) \ | ||
99 | ((tmr)->it.real.timer.entry.prev != (void *)TIMER_INACTIVE) | ||
100 | # define set_timer_inactive(tmr) \ | ||
101 | do { \ | ||
102 | (tmr)->it.real.timer.entry.prev = (void *)TIMER_INACTIVE; \ | ||
103 | } while (0) | ||
104 | #else | ||
105 | # define timer_active(tmr) BARFY // error to use outside of SMP | ||
106 | # define set_timer_inactive(tmr) do { } while (0) | ||
107 | #endif | ||
108 | /* | ||
109 | * we assume that the new SIGEV_THREAD_ID shares no bits with the other | 92 | * we assume that the new SIGEV_THREAD_ID shares no bits with the other |
110 | * SIGEV values. Here we put out an error if this assumption fails. | 93 | * SIGEV values. Here we put out an error if this assumption fails. |
111 | */ | 94 | */ |
@@ -226,7 +209,6 @@ static inline int common_timer_create(struct k_itimer *new_timer) | |||
226 | init_timer(&new_timer->it.real.timer); | 209 | init_timer(&new_timer->it.real.timer); |
227 | new_timer->it.real.timer.data = (unsigned long) new_timer; | 210 | new_timer->it.real.timer.data = (unsigned long) new_timer; |
228 | new_timer->it.real.timer.function = posix_timer_fn; | 211 | new_timer->it.real.timer.function = posix_timer_fn; |
229 | set_timer_inactive(new_timer); | ||
230 | return 0; | 212 | return 0; |
231 | } | 213 | } |
232 | 214 | ||
@@ -480,7 +462,6 @@ static void posix_timer_fn(unsigned long __data) | |||
480 | int do_notify = 1; | 462 | int do_notify = 1; |
481 | 463 | ||
482 | spin_lock_irqsave(&timr->it_lock, flags); | 464 | spin_lock_irqsave(&timr->it_lock, flags); |
483 | set_timer_inactive(timr); | ||
484 | if (!list_empty(&timr->it.real.abs_timer_entry)) { | 465 | if (!list_empty(&timr->it.real.abs_timer_entry)) { |
485 | spin_lock(&abs_list.lock); | 466 | spin_lock(&abs_list.lock); |
486 | do { | 467 | do { |
@@ -915,21 +896,10 @@ static int adjust_abs_time(struct k_clock *clock, struct timespec *tp, | |||
915 | jiffies_64_f = get_jiffies_64(); | 896 | jiffies_64_f = get_jiffies_64(); |
916 | } | 897 | } |
917 | /* | 898 | /* |
918 | * Take away now to get delta | 899 | * Take away now to get delta and normalize |
919 | */ | ||
920 | oc.tv_sec -= now.tv_sec; | ||
921 | oc.tv_nsec -= now.tv_nsec; | ||
922 | /* | ||
923 | * Normalize... | ||
924 | */ | 900 | */ |
925 | while ((oc.tv_nsec - NSEC_PER_SEC) >= 0) { | 901 | set_normalized_timespec(&oc, oc.tv_sec - now.tv_sec, |
926 | oc.tv_nsec -= NSEC_PER_SEC; | 902 | oc.tv_nsec - now.tv_nsec); |
927 | oc.tv_sec++; | ||
928 | } | ||
929 | while ((oc.tv_nsec) < 0) { | ||
930 | oc.tv_nsec += NSEC_PER_SEC; | ||
931 | oc.tv_sec--; | ||
932 | } | ||
933 | }else{ | 903 | }else{ |
934 | jiffies_64_f = get_jiffies_64(); | 904 | jiffies_64_f = get_jiffies_64(); |
935 | } | 905 | } |
@@ -983,8 +953,8 @@ common_timer_set(struct k_itimer *timr, int flags, | |||
983 | * careful here. If smp we could be in the "fire" routine which will | 953 | * careful here. If smp we could be in the "fire" routine which will |
984 | * be spinning as we hold the lock. But this is ONLY an SMP issue. | 954 | * be spinning as we hold the lock. But this is ONLY an SMP issue. |
985 | */ | 955 | */ |
956 | if (try_to_del_timer_sync(&timr->it.real.timer) < 0) { | ||
986 | #ifdef CONFIG_SMP | 957 | #ifdef CONFIG_SMP |
987 | if (timer_active(timr) && !del_timer(&timr->it.real.timer)) | ||
988 | /* | 958 | /* |
989 | * It can only be active if on an other cpu. Since | 959 | * It can only be active if on an other cpu. Since |
990 | * we have cleared the interval stuff above, it should | 960 | * we have cleared the interval stuff above, it should |
@@ -994,11 +964,9 @@ common_timer_set(struct k_itimer *timr, int flags, | |||
994 | * a "retry" exit status. | 964 | * a "retry" exit status. |
995 | */ | 965 | */ |
996 | return TIMER_RETRY; | 966 | return TIMER_RETRY; |
997 | |||
998 | set_timer_inactive(timr); | ||
999 | #else | ||
1000 | del_timer(&timr->it.real.timer); | ||
1001 | #endif | 967 | #endif |
968 | } | ||
969 | |||
1002 | remove_from_abslist(timr); | 970 | remove_from_abslist(timr); |
1003 | 971 | ||
1004 | timr->it_requeue_pending = (timr->it_requeue_pending + 2) & | 972 | timr->it_requeue_pending = (timr->it_requeue_pending + 2) & |
@@ -1083,8 +1051,9 @@ retry: | |||
1083 | static inline int common_timer_del(struct k_itimer *timer) | 1051 | static inline int common_timer_del(struct k_itimer *timer) |
1084 | { | 1052 | { |
1085 | timer->it.real.incr = 0; | 1053 | timer->it.real.incr = 0; |
1054 | |||
1055 | if (try_to_del_timer_sync(&timer->it.real.timer) < 0) { | ||
1086 | #ifdef CONFIG_SMP | 1056 | #ifdef CONFIG_SMP |
1087 | if (timer_active(timer) && !del_timer(&timer->it.real.timer)) | ||
1088 | /* | 1057 | /* |
1089 | * It can only be active if on an other cpu. Since | 1058 | * It can only be active if on an other cpu. Since |
1090 | * we have cleared the interval stuff above, it should | 1059 | * we have cleared the interval stuff above, it should |
@@ -1094,9 +1063,9 @@ static inline int common_timer_del(struct k_itimer *timer) | |||
1094 | * a "retry" exit status. | 1063 | * a "retry" exit status. |
1095 | */ | 1064 | */ |
1096 | return TIMER_RETRY; | 1065 | return TIMER_RETRY; |
1097 | #else | ||
1098 | del_timer(&timer->it.real.timer); | ||
1099 | #endif | 1066 | #endif |
1067 | } | ||
1068 | |||
1100 | remove_from_abslist(timer); | 1069 | remove_from_abslist(timer); |
1101 | 1070 | ||
1102 | return 0; | 1071 | return 0; |
@@ -1197,7 +1166,6 @@ void exit_itimers(struct signal_struct *sig) | |||
1197 | tmr = list_entry(sig->posix_timers.next, struct k_itimer, list); | 1166 | tmr = list_entry(sig->posix_timers.next, struct k_itimer, list); |
1198 | itimer_delete(tmr); | 1167 | itimer_delete(tmr); |
1199 | } | 1168 | } |
1200 | del_timer_sync(&sig->real_timer); | ||
1201 | } | 1169 | } |
1202 | 1170 | ||
1203 | /* | 1171 | /* |