From: Wenlin Kang <[email protected]>

With RT, if a high priority task that runs d_alloc_parallel() preempts a
low priority task that runs __d_add(), it can make d_alloc_parallel() go
into an infinite retry.

low priority task:                  high priority task:
__lookup_slow()
d_add()
    __d_add
        start_dir_add(dir)          __lookup_slow()
                                        d_alloc_parallel()

When the low priority task finished start_dir_add(), i_dir_seq has been
incremented to an odd value. Since __d_add() uses spin_lock(), migration
is disabled, so if the low priority task is preempted during start_dir_add()
/end_dir_add(), then high priority task can go into an infinite waiting for
i_dir_seq.

This patch avoid the issue by enable preempt_disable() during start_dir_add()
/end_dir_add().


Steps to reproduce:
$ taskset -c 1 chrt -f 70 ./test1.sh &
$ taskset -c 1 chrt -f 80 ./test2.sh &

After about 30 minutes, check whether serial console responds.
The problem happens with specific script combinations(test1.sh and test2.sh)

This problem was reproduced on v4.12 with preempt-rt, but I think it should be
exist on v5.2/standard/preempt-rt

P.S.
$ cat test1.sh 
#!/bin/bash

while true; do
        usleep 1
done

$ cat test2.sh
#!/bin/bash

while true; do
        cat /proc/stat > /dev/null
        usleep 100
done


Wenlin Kang (1):
  fs: dcache: avoid livelocks on d_alloc_parallel

 fs/dcache.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
1.9.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9848): 
https://lists.yoctoproject.org/g/linux-yocto/message/9848
Mute This Topic: https://lists.yoctoproject.org/mt/82675356/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to