This reverts commit d4c22d70d7253dd727c71484c58d504f6c630343. There is no netdev queue left to wake after reverting commit 1d6e569b7d0c ("tun/tap & vhost-net: avoid ptr_ring tail-drop when a qdisc is present").
Unified · Split
| @@ -145,8 +145,6 @@ struct tun_file { · 144 unmodified lines | ||
| 145 | 145 | struct list_head next; |
| 146 | 146 | struct tun_struct *detached; |
| 147 | 147 | struct ptr_ring tx_ring; |
| 148 | − /* Protected by tx_ring.consumer_lock */ | |
| 149 | − int cons_cnt; | |
| 150 | 148 | struct xdp_rxq_info xdp_rxq; |
| 151 | 149 | }; |
| 152 | 150 | |
| @@ -590,13 +588,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean) · 437 unmodified lines | ||
| 590 | 588 | rcu_assign_pointer(tun->tfiles[index], |
| 591 | 589 | tun->tfiles[tun->numqueues - 1]); |
| 592 | 590 | ntfile = rtnl_dereference(tun->tfiles[index]); |
| 593 | − spin_lock(&ntfile->tx_ring.consumer_lock); | |
| 594 | 591 | ntfile->queue_index = index; |
| 595 | 592 | ntfile->xdp_rxq.queue_index = index; |
| 596 | − ntfile->cons_cnt = 0; | |
| 597 | − if (__ptr_ring_empty(&ntfile->tx_ring)) | |
| 598 | − netif_wake_subqueue(tun->dev, index); | |
| 599 | − spin_unlock(&ntfile->tx_ring.consumer_lock); | |
| 600 | 593 | rcu_assign_pointer(tun->tfiles[tun->numqueues - 1], |
| 601 | 594 | NULL); |
| 602 | 595 | |
| @@ -737,9 +730,6 @@ static int tun_attach(struct tun_struct *tun, struct file *file, · 134 unmodified lines | ||
| 737 | 730 | goto out; |
| 738 | 731 | } |
| 739 | 732 | |
| 740 | − spin_lock(&tfile->tx_ring.consumer_lock); | |
| 741 | − tfile->cons_cnt = 0; | |
| 742 | − spin_unlock(&tfile->tx_ring.consumer_lock); | |
| 743 | 733 | tfile->queue_index = tun->numqueues; |
| 744 | 734 | tfile->socket.sk->sk_shutdown &= ~RCV_SHUTDOWN; |
| 745 | 735 | |
| @@ -2126,46 +2116,13 @@ done: · 1380 unmodified lines | ||
| 2126 | 2116 | return total; |
| 2127 | 2117 | } |
| 2128 | 2118 | |
| 2129 | −/* Callers must hold ring.consumer_lock */ | |
| 2130 | −static void __tun_wake_queue(struct tun_struct *tun, | |
| 2131 | − struct tun_file *tfile, int consumed) | |
| 2132 | −{ | |
| 2133 | − struct netdev_queue *txq = netdev_get_tx_queue(tun->dev, | |
| 2134 | − tfile->queue_index); | |
| 2135 | − | |
| 2136 | − /* Paired with smp_mb__after_atomic() in tun_net_xmit() */ | |
| 2137 | − smp_mb(); | |
| 2138 | − if (netif_tx_queue_stopped(txq)) { | |
| 2139 | − tfile->cons_cnt += consumed; | |
| 2140 | − if (tfile->cons_cnt >= tfile->tx_ring.size / 2 || | |
| 2141 | − __ptr_ring_empty(&tfile->tx_ring)) { | |
| 2142 | − netif_tx_wake_queue(txq); | |
| 2143 | − tfile->cons_cnt = 0; | |
| 2144 | − } | |
| 2145 | − } | |
| 2146 | −} | |
| 2147 | − | |
| 2148 | −static void *tun_ring_consume(struct tun_struct *tun, struct tun_file *tfile) | |
| 2149 | −{ | |
| 2150 | − void *ptr; | |
| 2151 | − | |
| 2152 | − spin_lock(&tfile->tx_ring.consumer_lock); | |
| 2153 | − ptr = __ptr_ring_consume(&tfile->tx_ring); | |
| 2154 | − if (ptr) | |
| 2155 | − __tun_wake_queue(tun, tfile, 1); | |
| 2156 | − | |
| 2157 | − spin_unlock(&tfile->tx_ring.consumer_lock); | |
| 2158 | − return ptr; | |
| 2159 | −} | |
| 2160 | − | |
| 2161 | −static void *tun_ring_recv(struct tun_struct *tun, struct tun_file *tfile, | |
| 2162 | − int noblock, int *err) | |
| 2119 | +static void *tun_ring_recv(struct tun_file *tfile, int noblock, int *err) | |
| 2163 | 2120 | { |
| 2164 | 2121 | DECLARE_WAITQUEUE(wait, current); |
| 2165 | 2122 | void *ptr = NULL; |
| 2166 | 2123 | int error = 0; |
| 2167 | 2124 | |
| 2168 | − ptr = tun_ring_consume(tun, tfile); | |
| 2125 | + ptr = ptr_ring_consume(&tfile->tx_ring); | |
| 2169 | 2126 | if (ptr) |
| 2170 | 2127 | goto out; |
| 2171 | 2128 | if (noblock) { |
| @@ -2177,7 +2134,7 @@ static void *tun_ring_recv(struct tun_struct *tun, struct tun_file *tfile, · 5 unmodified lines | ||
| 2177 | 2134 | |
| 2178 | 2135 | while (1) { |
| 2179 | 2136 | set_current_state(TASK_INTERRUPTIBLE); |
| 2180 | − ptr = tun_ring_consume(tun, tfile); | |
| 2137 | + ptr = ptr_ring_consume(&tfile->tx_ring); | |
| 2181 | 2138 | if (ptr) |
| 2182 | 2139 | break; |
| 2183 | 2140 | if (signal_pending(current)) { |
| @@ -2214,7 +2171,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile, · 30 unmodified lines | ||
| 2214 | 2171 | |
| 2215 | 2172 | if (!ptr) { |
| 2216 | 2173 | /* Read frames from ring */ |
| 2217 | − ptr = tun_ring_recv(tun, tfile, noblock, &err); | |
| 2174 | + ptr = tun_ring_recv(tfile, noblock, &err); | |
| 2218 | 2175 | if (!ptr) |
| 2219 | 2176 | return err; |
| 2220 | 2177 | } |
| @@ -3669,16 +3626,6 @@ static int tun_queue_resize(struct tun_struct *tun) · 1448 unmodified lines | ||
| 3669 | 3626 | dev->tx_queue_len, GFP_KERNEL, |
| 3670 | 3627 | tun_ptr_free); |
| 3671 | 3628 | |
| 3672 | − if (!ret) { | |
| 3673 | − for (i = 0; i < tun->numqueues; i++) { | |
| 3674 | − tfile = rtnl_dereference(tun->tfiles[i]); | |
| 3675 | − spin_lock(&tfile->tx_ring.consumer_lock); | |
| 3676 | − netif_wake_subqueue(tun->dev, tfile->queue_index); | |
| 3677 | − tfile->cons_cnt = 0; | |
| 3678 | − spin_unlock(&tfile->tx_ring.consumer_lock); | |
| 3679 | − } | |
| 3680 | − } | |
| 3681 | − | |
| 3682 | 3629 | kfree(rings); |
| 3683 | 3630 | return ret; |
| 3684 | 3631 | } |