The ident level is starting to be annoying. More white space than actual code. Split out the timer function call into its own function.
Unified · Split
| @@ -953,6 +953,41 @@ static int cascade(struct tvec_base *base, struct tvec *tv, int index) · 952 unmodified lines | ||
| 953 | 953 | return index; |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | +static void call_timer_fn(struct timer_list *timer, void (*fn)(unsigned long), | |
| 957 | + unsigned long data) | |
| 958 | +{ | |
| 959 | + int preempt_count = preempt_count(); | |
| 960 | + | |
| 961 | +#ifdef CONFIG_LOCKDEP | |
| 962 | + /* | |
| 963 | + * It is permissible to free the timer from inside the | |
| 964 | + * function that is called from it, this we need to take into | |
| 965 | + * account for lockdep too. To avoid bogus "held lock freed" | |
| 966 | + * warnings as well as problems when looking into | |
| 967 | + * timer->lockdep_map, make a copy and use that here. | |
| 968 | + */ | |
| 969 | + struct lockdep_map lockdep_map = timer->lockdep_map; | |
| 970 | +#endif | |
| 971 | + /* | |
| 972 | + * Couple the lock chain with the lock chain at | |
| 973 | + * del_timer_sync() by acquiring the lock_map around the fn() | |
| 974 | + * call here and in del_timer_sync(). | |
| 975 | + */ | |
| 976 | + lock_map_acquire(&lockdep_map); | |
| 977 | + | |
| 978 | + trace_timer_expire_entry(timer); | |
| 979 | + fn(data); | |
| 980 | + trace_timer_expire_exit(timer); | |
| 981 | + | |
| 982 | + lock_map_release(&lockdep_map); | |
| 983 | + | |
| 984 | + if (preempt_count != preempt_count()) { | |
| 985 | + printk(KERN_ERR "timer: %pF preempt leak: %08x -> %08x\n", | |
| 986 | + fn, preempt_count, preempt_count()); | |
| 987 | + BUG(); | |
| 988 | + } | |
| 989 | +} | |
| 990 | + | |
| 956 | 991 | #define INDEX(N) ((base->timer_jiffies >> (TVR_BITS + (N) * TVN_BITS)) & TVN_MASK) |
| 957 | 992 | |
| 958 | 993 | /** |
| @@ -996,42 +1031,7 @@ static inline void __run_timers(struct tvec_base *base) · 37 unmodified lines | ||
| 996 | 1031 | detach_timer(timer, 1); |
| 997 | 1032 | |
| 998 | 1033 | spin_unlock_irq(&base->lock); |
| 999 | − { | |
| 1000 | − int preempt_count = preempt_count(); | |
| 1001 | − | |
| 1002 | −#ifdef CONFIG_LOCKDEP | |
| 1003 | − /* | |
| 1004 | − * It is permissible to free the timer from | |
| 1005 | − * inside the function that is called from | |
| 1006 | − * it, this we need to take into account for | |
| 1007 | − * lockdep too. To avoid bogus "held lock | |
| 1008 | − * freed" warnings as well as problems when | |
| 1009 | − * looking into timer->lockdep_map, make a | |
| 1010 | − * copy and use that here. | |
| 1011 | − */ | |
| 1012 | − struct lockdep_map lockdep_map = | |
| 1013 | − timer->lockdep_map; | |
| 1014 | −#endif | |
| 1015 | − /* | |
| 1016 | − * Couple the lock chain with the lock chain at | |
| 1017 | − * del_timer_sync() by acquiring the lock_map | |
| 1018 | − * around the fn() call here and in | |
| 1019 | − * del_timer_sync(). | |
| 1020 | − */ | |
| 1021 | − lock_map_acquire(&lockdep_map); | |
| 1022 | − | |
| 1023 | − trace_timer_expire_entry(timer); | |
| 1024 | − fn(data); | |
| 1025 | − trace_timer_expire_exit(timer); | |
| 1026 | − | |
| 1027 | − lock_map_release(&lockdep_map); | |
| 1028 | − | |
| 1029 | − if (preempt_count != preempt_count()) { | |
| 1030 | − printk(KERN_ERR "timer: %pF preempt leak: %08x -> %08x\n", | |
| 1031 | − fn, preempt_count, preempt_count()); | |
| 1032 | − BUG(); | |
| 1033 | − } | |
| 1034 | − } | |
| 1034 | + call_timer_fn(timer, fn, data); | |
| 1035 | 1035 | spin_lock_irq(&base->lock); |
| 1036 | 1036 | } |
| 1037 | 1037 | } |