History

Merge branch 'locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (33 commits) lockdep: fix deadlock in lockdep_trace_alloc lockdep: annotate reclaim context (__GFP_NOFS), fix SLOB lockdep: annotate reclaim context (__GFP_NOFS), fix lockdep: build fix for !PROVE_LOCKING lockstat: warn about disabled lock debugging lockdep: use stringify.h lockdep: simplify check_prev_add_irq() lockdep: get_user_chars() redo lockdep: simplify get_user_chars() lockdep: add comments to mark_lock_irq() lockdep: remove macro usage from mark_held_locks() lockdep: fully reduce mark_lock_irq() lockdep: merge the !_READ mark_lock_irq() helpers lockdep: merge the _READ mark_lock_irq() helpers lockdep: simplify mark_lock_irq() helpers #3 lockdep: further simplify mark_lock_irq() helpers lockdep: simplify the mark_lock_irq() helpers lockdep: split up mark_lock_irq() lockdep: generate usage strings lockdep: generate the state bit definitions ...

Linus Torvalds committed 17 years ago

Commit c4e1aa62 parents cf2f7d7 2f8501821 files · +730 −379Browse files

Showing the changes to kernel/timer.c (1 of 21 files). Show all

Unified · Split

kernel/timer.c+57−11
@@ -491,14 +491,18 @@ static inline void debug_timer_free(struct timer_list *timer) · 490 unmodified lines
491 debug_object_free(timer, &timer_debug_descr);491 debug_object_free(timer, &timer_debug_descr);
492}492}
493 493
494static void __init_timer(struct timer_list *timer);494static void __init_timer(struct timer_list *timer,
495 const char *name,
496 struct lock_class_key *key);
495 497
496void init_timer_on_stack(struct timer_list *timer)498void init_timer_on_stack_key(struct timer_list *timer,
499 const char *name,
500 struct lock_class_key *key)
497{501{
498 debug_object_init_on_stack(timer, &timer_debug_descr);502 debug_object_init_on_stack(timer, &timer_debug_descr);
499 __init_timer(timer);503 __init_timer(timer, name, key);
500}504}
501EXPORT_SYMBOL_GPL(init_timer_on_stack);505EXPORT_SYMBOL_GPL(init_timer_on_stack_key);
502 506
503void destroy_timer_on_stack(struct timer_list *timer)507void destroy_timer_on_stack(struct timer_list *timer)
504{508{
@@ -512,7 +516,9 @@ static inline void debug_timer_activate(struct timer_list *timer) { } · 7 unmodified lines
512static inline void debug_timer_deactivate(struct timer_list *timer) { }516static inline void debug_timer_deactivate(struct timer_list *timer) { }
513#endif517#endif
514 518
515static void __init_timer(struct timer_list *timer)519static void __init_timer(struct timer_list *timer,
520 const char *name,
521 struct lock_class_key *key)
516{522{
517 timer->entry.next = NULL;523 timer->entry.next = NULL;
518 timer->base = __raw_get_cpu_var(tvec_bases);524 timer->base = __raw_get_cpu_var(tvec_bases);
@@ -521,6 +527,7 @@ static void __init_timer(struct timer_list *timer) · 2 unmodified lines
521 timer->start_pid = -1;527 timer->start_pid = -1;
522 memset(timer->start_comm, 0, TASK_COMM_LEN);528 memset(timer->start_comm, 0, TASK_COMM_LEN);
523#endif529#endif
530 lockdep_init_map(&timer->lockdep_map, name, key, 0);
524}531}
525 532
526/**533/**
@@ -530,19 +537,23 @@ static void __init_timer(struct timer_list *timer) · 3 unmodified lines
530 * init_timer() must be done to a timer prior calling *any* of the537 * init_timer() must be done to a timer prior calling *any* of the
531 * other timer functions.538 * other timer functions.
532 */539 */
533void init_timer(struct timer_list *timer)540void init_timer_key(struct timer_list *timer,
541 const char *name,
542 struct lock_class_key *key)
534{543{
535 debug_timer_init(timer);544 debug_timer_init(timer);
536 __init_timer(timer);545 __init_timer(timer, name, key);
537}546}
538EXPORT_SYMBOL(init_timer);547EXPORT_SYMBOL(init_timer_key);
539 548
540void init_timer_deferrable(struct timer_list *timer)549void init_timer_deferrable_key(struct timer_list *timer,
550 const char *name,
551 struct lock_class_key *key)
541{552{
542 init_timer(timer);553 init_timer_key(timer, name, key);
543 timer_set_deferrable(timer);554 timer_set_deferrable(timer);
544}555}
545EXPORT_SYMBOL(init_timer_deferrable);556EXPORT_SYMBOL(init_timer_deferrable_key);
546 557
547static inline void detach_timer(struct timer_list *timer,558static inline void detach_timer(struct timer_list *timer,
548 int clear_pending)559 int clear_pending)
@@ -826,6 +837,15 @@ EXPORT_SYMBOL(try_to_del_timer_sync); · 277 unmodified lines
826 */837 */
827int del_timer_sync(struct timer_list *timer)838int del_timer_sync(struct timer_list *timer)
828{839{
840#ifdef CONFIG_LOCKDEP
841 unsigned long flags;
842
843 local_irq_save(flags);
844 lock_map_acquire(&timer->lockdep_map);
845 lock_map_release(&timer->lockdep_map);
846 local_irq_restore(flags);
847#endif
848
829 for (;;) {849 for (;;) {
830 int ret = try_to_del_timer_sync(timer);850 int ret = try_to_del_timer_sync(timer);
831 if (ret >= 0)851 if (ret >= 0)
@@ -897,10 +917,36 @@ static inline void __run_timers(struct tvec_base *base) · 65 unmodified lines
897 917
898 set_running_timer(base, timer);918 set_running_timer(base, timer);
899 detach_timer(timer, 1);919 detach_timer(timer, 1);
920
900 spin_unlock_irq(&base->lock);921 spin_unlock_irq(&base->lock);
901 {922 {
902 int preempt_count = preempt_count();923 int preempt_count = preempt_count();
924
925#ifdef CONFIG_LOCKDEP
926 /*
927 * It is permissible to free the timer from
928 * inside the function that is called from
929 * it, this we need to take into account for
930 * lockdep too. To avoid bogus "held lock
931 * freed" warnings as well as problems when
932 * looking into timer->lockdep_map, make a
933 * copy and use that here.
934 */
935 struct lockdep_map lockdep_map =
936 timer->lockdep_map;
937#endif
938 /*
939 * Couple the lock chain with the lock chain at
940 * del_timer_sync() by acquiring the lock_map
941 * around the fn() call here and in
942 * del_timer_sync().
943 */
944 lock_map_acquire(&lockdep_map);
945
903 fn(data);946 fn(data);
947
948 lock_map_release(&lockdep_map);
949
904 if (preempt_count != preempt_count()) {950 if (preempt_count != preempt_count()) {
905 printk(KERN_ERR "huh, entered %p "951 printk(KERN_ERR "huh, entered %p "
906 "with preempt_count %08x, exited"952 "with preempt_count %08x, exited"