Whamcloud - gitweb
a8c1796e5f75ec91b07a6bcff5e2ae01a33eac27
[fs/lustre-release.git] / lustre / kernel_patches / patches / revert-fix-lockup-in-run_timers-large-jiffies-delta.patch
1 --- linux-3.10.0-1160.11.1.el7.x86_64/kernel/timer.c    2020-11-30 12:40:05.000000000 -0500
2 +++ linux-3.10.0-1160.6.1.el7.x86_64/kernel/timer.c     2020-10-21 13:17:08.000000000 -0400
3 @@ -1213,95 +1213,6 @@
4         }
5  }
6  
7 -/*
8 - * Total number of list_head entries in tv1-tv5 of struct tvec_base.
9 - */
10 -#define TVEC_LEN       ((offsetofend(struct tvec_base, tv5) -  \
11 -                         offsetof(struct tvec_base, tv1)) /    \
12 -                         sizeof(struct list_head))
13 -
14 -/**
15 - * requeue_timers - requeue all the timers in the timer wheel
16 - * @base: the timer vector to be processed.
17 - *
18 - * When a cpu is idle for a long period of time, it is possible that
19 - * timer_jiffies can significantly lag behind jiffies making the iterative
20 - * jiffies check in __run_timers() takes a long time to complete causing
21 - * soft or hard system lockup.
22 - *
23 - * This function remedies this situation by requeuing all the timers in
24 - * the cascading timer wheel and adjusting timer_jiffies to the min() of
25 - * current jiffies and the expiry times of all active timers. The expiry
26 - * times of expired deferrable timers will be set to the new timer_jiffies.
27 - */
28 -static noinline void requeue_timers(struct tvec_base *base)
29 -{
30 -       struct timer_list *timer, *tmp;
31 -       struct list_head list, head, *vecs;
32 -       unsigned long min_jiffies = jiffies;
33 -       unsigned long nactive = base->active_timers;
34 -       unsigned long nall = base->all_timers;
35 -       int i;
36 -
37 -       lockdep_assert_held(&base->lock);
38 -       INIT_LIST_HEAD(&head);
39 -
40 -       /*
41 -        * tv1-tv5 are processed together as a single array of list_head's.
42 -        */
43 -       vecs = (struct list_head *)&base->tv1;
44 -       for (i = 0; i < TVEC_LEN; i++, vecs++) {
45 -               if (list_empty(vecs))
46 -                       continue;
47 -
48 -               list_replace_init(vecs, &list);
49 -
50 -               /*
51 -                * Check all the timers in list and move them over to head.
52 -                */
53 -               list_for_each_entry_safe(timer, tmp, &list, entry) {
54 -                       base->all_timers--;
55 -                       if (!tbase_get_deferrable(timer->base)) {
56 -                               base->active_timers--;
57 -                               if (time_before(timer->expires, min_jiffies))
58 -                                       min_jiffies = timer->expires;
59 -                       }
60 -                       list_add_tail(&timer->entry, &head);
61 -               }
62 -               if (!base->all_timers)
63 -                       break;
64 -       }
65 -       WARN_ON_ONCE(base->all_timers || base->active_timers);
66 -
67 -       /*
68 -        * Restore all_timers and active_timers.
69 -        * Requeue timers back into timer wheel with timer_jiffies
70 -        * set to min_jiffies.
71 -        */
72 -       base->all_timers = nall;
73 -       base->active_timers = nactive;
74 -       base->timer_jiffies = min_jiffies;
75 -
76 -       list_for_each_entry_safe(timer, tmp, &head, entry) {
77 -               unsigned long old_expires;
78 -               bool restore = false;
79 -
80 -               /*
81 -                * For expiry time that is < min_jiffies (deferrable ones),
82 -                * temporarily change it to min_jiffies, insert the timer
83 -                * without accounting and restore the expiry time.
84 -                */
85 -               if (time_before(timer->expires, min_jiffies)) {
86 -                       old_expires = timer->expires;
87 -                       timer->expires = min_jiffies;
88 -                       restore = true;
89 -               }
90 -               __internal_add_timer(base, timer);
91 -               if (restore)
92 -                       timer->expires = old_expires;
93 -       }
94 -}
95 -
96  #define INDEX(N) ((base->timer_jiffies >> (TVR_BITS + (N) * TVN_BITS)) & TVN_MASK)
97  
98  /**
99 @@ -1317,13 +1228,6 @@
100  
101         spin_lock_irq(&base->lock);
102  
103 -       /*
104 -        * Requeue the timers if jiffies - timer_jiffies >= 2*TVEC_LEN.
105 -        */
106 -       if (base->all_timers &&
107 -           time_after_eq(jiffies, base->timer_jiffies + 2 * TVEC_LEN))
108 -               requeue_timers(base);
109 -
110         while (time_after_eq(jiffies, base->timer_jiffies)) {
111                 struct list_head work_list;
112                 struct list_head *head = &work_list;