Arvind M | 8e87d85 | 2018-01-29 00:04:29 -0800 | [diff] [blame] | 1 | From 3d5be1891644e6f254e2ff1022428d60d075165a Mon Sep 17 00:00:00 2001 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 2 | From: Marc Kleine-Budde <mkl@pengutronix.de> |
| 3 | Date: Wed, 5 Mar 2014 00:49:47 +0100 |
Arvind M | 10268e7 | 2017-12-04 22:18:06 -0800 | [diff] [blame] | 4 | Subject: [PATCH 020/366] net: sched: Use msleep() instead of yield() |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 5 | |
| 6 | On PREEMPT_RT enabled systems the interrupt handler run as threads at prio 50 |
| 7 | (by default). If a high priority userspace process tries to shut down a busy |
| 8 | network interface it might spin in a yield loop waiting for the device to |
| 9 | become idle. With the interrupt thread having a lower priority than the |
| 10 | looping process it might never be scheduled and so result in a deadlock on UP |
| 11 | systems. |
| 12 | |
| 13 | With Magic SysRq the following backtrace can be produced: |
| 14 | |
| 15 | > test_app R running 0 174 168 0x00000000 |
| 16 | > [<c02c7070>] (__schedule+0x220/0x3fc) from [<c02c7870>] (preempt_schedule_irq+0x48/0x80) |
| 17 | > [<c02c7870>] (preempt_schedule_irq+0x48/0x80) from [<c0008fa8>] (svc_preempt+0x8/0x20) |
| 18 | > [<c0008fa8>] (svc_preempt+0x8/0x20) from [<c001a984>] (local_bh_enable+0x18/0x88) |
| 19 | > [<c001a984>] (local_bh_enable+0x18/0x88) from [<c025316c>] (dev_deactivate_many+0x220/0x264) |
| 20 | > [<c025316c>] (dev_deactivate_many+0x220/0x264) from [<c023be04>] (__dev_close_many+0x64/0xd4) |
| 21 | > [<c023be04>] (__dev_close_many+0x64/0xd4) from [<c023be9c>] (__dev_close+0x28/0x3c) |
| 22 | > [<c023be9c>] (__dev_close+0x28/0x3c) from [<c023f7f0>] (__dev_change_flags+0x88/0x130) |
| 23 | > [<c023f7f0>] (__dev_change_flags+0x88/0x130) from [<c023f904>] (dev_change_flags+0x10/0x48) |
| 24 | > [<c023f904>] (dev_change_flags+0x10/0x48) from [<c024c140>] (do_setlink+0x370/0x7ec) |
| 25 | > [<c024c140>] (do_setlink+0x370/0x7ec) from [<c024d2f0>] (rtnl_newlink+0x2b4/0x450) |
| 26 | > [<c024d2f0>] (rtnl_newlink+0x2b4/0x450) from [<c024cfa0>] (rtnetlink_rcv_msg+0x158/0x1f4) |
| 27 | > [<c024cfa0>] (rtnetlink_rcv_msg+0x158/0x1f4) from [<c0256740>] (netlink_rcv_skb+0xac/0xc0) |
| 28 | > [<c0256740>] (netlink_rcv_skb+0xac/0xc0) from [<c024bbd8>] (rtnetlink_rcv+0x18/0x24) |
| 29 | > [<c024bbd8>] (rtnetlink_rcv+0x18/0x24) from [<c02561b8>] (netlink_unicast+0x13c/0x198) |
| 30 | > [<c02561b8>] (netlink_unicast+0x13c/0x198) from [<c025651c>] (netlink_sendmsg+0x264/0x2e0) |
| 31 | > [<c025651c>] (netlink_sendmsg+0x264/0x2e0) from [<c022af98>] (sock_sendmsg+0x78/0x98) |
| 32 | > [<c022af98>] (sock_sendmsg+0x78/0x98) from [<c022bb50>] (___sys_sendmsg.part.25+0x268/0x278) |
| 33 | > [<c022bb50>] (___sys_sendmsg.part.25+0x268/0x278) from [<c022cf08>] (__sys_sendmsg+0x48/0x78) |
| 34 | > [<c022cf08>] (__sys_sendmsg+0x48/0x78) from [<c0009320>] (ret_fast_syscall+0x0/0x2c) |
| 35 | |
| 36 | This patch works around the problem by replacing yield() by msleep(1), giving |
| 37 | the interrupt thread time to finish, similar to other changes contained in the |
| 38 | rt patch set. Using wait_for_completion() instead would probably be a better |
| 39 | solution. |
| 40 | |
| 41 | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> |
| 42 | Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 43 | --- |
| 44 | net/sched/sch_generic.c | 2 +- |
| 45 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 46 | |
| 47 | diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c |
Ishan Mittal | b799826 | 2017-01-17 16:11:50 +0530 | [diff] [blame] | 48 | index 2704a13..3f02edc 100644 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 49 | --- a/net/sched/sch_generic.c |
| 50 | +++ b/net/sched/sch_generic.c |
Allen Martin | fc468d8 | 2016-11-15 17:57:52 -0800 | [diff] [blame] | 51 | @@ -900,7 +900,7 @@ void dev_deactivate_many(struct list_head *head) |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 52 | /* Wait for outstanding qdisc_run calls. */ |
| 53 | list_for_each_entry(dev, head, close_list) |
| 54 | while (some_qdisc_is_busy(dev)) |
| 55 | - yield(); |
| 56 | + msleep(1); |
| 57 | } |
| 58 | |
| 59 | void dev_deactivate(struct net_device *dev) |
| 60 | -- |
Arvind M | 10268e7 | 2017-12-04 22:18:06 -0800 | [diff] [blame] | 61 | 1.9.1 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 62 | |