• Nikolay Borisov's avatar
    ipc/sem.c: add cond_resched in exit_sme · 2a1613a5
    Nikolay Borisov authored
    In CONFIG_PREEMPT=n kernel a softlockup was observed while the for loop in
    exit_sem.  Apparently it's possible for the loop to take quite a long time
    and it doesn't have a scheduling point in it.  Since the codes is
    executing under an rcu read section this may also cause rcu stalls, which
    in turn block synchronize_rcu operations, which more or less de-stabilises
    the whole system.
    
    Fix this by introducing a cond_resched() at the beginning of the loop.
    
    So this patch fixes the following:
    
      NMI watchdog: BUG: soft lockup - CPU#10 stuck for 23s! [httpd:18119]
      CPU: 10 PID: 18119 Comm: httpd Tainted: G           O    4.4.20-clouder2 #6
      Hardware name: Supermicro X10DRi/X10DRi, BIOS 1.1 04/14/2015
      task: ffff88348d695280 ti: ffff881c95550000 task.ti: ffff881c95550000
      RIP: 0010:[<ffffffff81614bc7>]  [<ffffffff81614bc7>] _raw_spin_lock+0x17/0x30
      RSP: 0018:ffff881c95553e40  EFLAGS: 00000246
      RAX: 0000000000000000 RBX: ffff883161b1eea8 RCX: 000000000000000d
      RDX: 00...
    2a1613a5
sem.c 56.3 KB