From 2cfb4743cd9b3fedd794a1e2efe62081bfdbf47b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 19 Dec 2020 12:32:34 +0100 Subject: [PATCH] 4.9-stable patches added patches: mac80211-mesh-fix-mesh_pathtbl_init-error-path.patch net-bridge-vlan-fix-error-return-code-in-__vlan_add.patch net-mlx4_en-avoid-scheduling-restart-task-if-it-is-already-running.patch net-stmmac-delete-the-eee_ctrl_timer-after-napi-disabled.patch net-stmmac-dwmac-meson8b-fix-mask-definition-of-the-m250_sel-mux.patch tcp-fix-cwnd-limited-bug-for-tso-deferral-where-we-send-nothing.patch --- ...esh-fix-mesh_pathtbl_init-error-path.patch | 91 +++++++++++++ ...-fix-error-return-code-in-__vlan_add.patch | 37 ++++++ ...estart-task-if-it-is-already-running.patch | 124 ++++++++++++++++++ ...e-eee_ctrl_timer-after-napi-disabled.patch | 62 +++++++++ ...-mask-definition-of-the-m250_sel-mux.patch | 50 +++++++ queue-4.9/series | 6 + ...r-tso-deferral-where-we-send-nothing.patch | 86 ++++++++++++ 7 files changed, 456 insertions(+) create mode 100644 queue-4.9/mac80211-mesh-fix-mesh_pathtbl_init-error-path.patch create mode 100644 queue-4.9/net-bridge-vlan-fix-error-return-code-in-__vlan_add.patch create mode 100644 queue-4.9/net-mlx4_en-avoid-scheduling-restart-task-if-it-is-already-running.patch create mode 100644 queue-4.9/net-stmmac-delete-the-eee_ctrl_timer-after-napi-disabled.patch create mode 100644 queue-4.9/net-stmmac-dwmac-meson8b-fix-mask-definition-of-the-m250_sel-mux.patch create mode 100644 queue-4.9/tcp-fix-cwnd-limited-bug-for-tso-deferral-where-we-send-nothing.patch diff --git a/queue-4.9/mac80211-mesh-fix-mesh_pathtbl_init-error-path.patch b/queue-4.9/mac80211-mesh-fix-mesh_pathtbl_init-error-path.patch new file mode 100644 index 00000000000..b815f4c8a0f --- /dev/null +++ b/queue-4.9/mac80211-mesh-fix-mesh_pathtbl_init-error-path.patch @@ -0,0 +1,91 @@ +From foo@baz Sat Dec 19 12:08:30 PM CET 2020 +From: Eric Dumazet +Date: Fri, 4 Dec 2020 08:24:28 -0800 +Subject: mac80211: mesh: fix mesh_pathtbl_init() error path + +From: Eric Dumazet + +[ Upstream commit 905b2032fa424f253d9126271439cc1db2b01130 ] + +If tbl_mpp can not be allocated, we call mesh_table_free(tbl_path) +while tbl_path rhashtable has not yet been initialized, which causes +panics. + +Simply factorize the rhashtable_init() call into mesh_table_alloc() + +WARNING: CPU: 1 PID: 8474 at kernel/workqueue.c:3040 __flush_work kernel/workqueue.c:3040 [inline] +WARNING: CPU: 1 PID: 8474 at kernel/workqueue.c:3040 __cancel_work_timer+0x514/0x540 kernel/workqueue.c:3136 +Modules linked in: +CPU: 1 PID: 8474 Comm: syz-executor663 Not tainted 5.10.0-rc6-syzkaller #0 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 +RIP: 0010:__flush_work kernel/workqueue.c:3040 [inline] +RIP: 0010:__cancel_work_timer+0x514/0x540 kernel/workqueue.c:3136 +Code: 5d c3 e8 bf ae 29 00 0f 0b e9 f0 fd ff ff e8 b3 ae 29 00 0f 0b 43 80 3c 3e 00 0f 85 31 ff ff ff e9 34 ff ff ff e8 9c ae 29 00 <0f> 0b e9 dc fe ff ff 89 e9 80 e1 07 80 c1 03 38 c1 0f 8c 7d fd ff +RSP: 0018:ffffc9000165f5a0 EFLAGS: 00010293 +RAX: ffffffff814b7064 RBX: 0000000000000001 RCX: ffff888021c80000 +RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 +RBP: ffff888024039ca0 R08: dffffc0000000000 R09: fffffbfff1dd3e64 +R10: fffffbfff1dd3e64 R11: 0000000000000000 R12: 1ffff920002cbebd +R13: ffff888024039c88 R14: 1ffff11004807391 R15: dffffc0000000000 +FS: 0000000001347880(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 0000000020000140 CR3: 000000002cc0a000 CR4: 00000000001506e0 +DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 +DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 +Call Trace: + rhashtable_free_and_destroy+0x25/0x9c0 lib/rhashtable.c:1137 + mesh_table_free net/mac80211/mesh_pathtbl.c:69 [inline] + mesh_pathtbl_init+0x287/0x2e0 net/mac80211/mesh_pathtbl.c:785 + ieee80211_mesh_init_sdata+0x2ee/0x530 net/mac80211/mesh.c:1591 + ieee80211_setup_sdata+0x733/0xc40 net/mac80211/iface.c:1569 + ieee80211_if_add+0xd5c/0x1cd0 net/mac80211/iface.c:1987 + ieee80211_add_iface+0x59/0x130 net/mac80211/cfg.c:125 + rdev_add_virtual_intf net/wireless/rdev-ops.h:45 [inline] + nl80211_new_interface+0x563/0xb40 net/wireless/nl80211.c:3855 + genl_family_rcv_msg_doit net/netlink/genetlink.c:739 [inline] + genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] + genl_rcv_msg+0xe4e/0x1280 net/netlink/genetlink.c:800 + netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2494 + genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 + netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline] + netlink_unicast+0x780/0x930 net/netlink/af_netlink.c:1330 + netlink_sendmsg+0x9a8/0xd40 net/netlink/af_netlink.c:1919 + sock_sendmsg_nosec net/socket.c:651 [inline] + sock_sendmsg net/socket.c:671 [inline] + ____sys_sendmsg+0x519/0x800 net/socket.c:2353 + ___sys_sendmsg net/socket.c:2407 [inline] + __sys_sendmsg+0x2b1/0x360 net/socket.c:2440 + do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 + entry_SYSCALL_64_after_hwframe+0x44/0xa9 + +Fixes: 60854fd94573 ("mac80211: mesh: convert path table to rhashtable") +Signed-off-by: Eric Dumazet +Reported-by: syzbot +Reviewed-by: Johannes Berg +Link: https://lore.kernel.org/r/20201204162428.2583119-1-eric.dumazet@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/mac80211/mesh_pathtbl.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/net/mac80211/mesh_pathtbl.c ++++ b/net/mac80211/mesh_pathtbl.c +@@ -61,6 +61,7 @@ static struct mesh_table *mesh_table_all + INIT_HLIST_HEAD(&newtbl->known_gates); + atomic_set(&newtbl->entries, 0); + spin_lock_init(&newtbl->gates_lock); ++ rhashtable_init(&newtbl->rhead, &mesh_rht_params); + + return newtbl; + } +@@ -849,9 +850,6 @@ int mesh_pathtbl_init(struct ieee80211_s + goto free_path; + } + +- rhashtable_init(&tbl_path->rhead, &mesh_rht_params); +- rhashtable_init(&tbl_mpp->rhead, &mesh_rht_params); +- + sdata->u.mesh.mesh_paths = tbl_path; + sdata->u.mesh.mpp_paths = tbl_mpp; + diff --git a/queue-4.9/net-bridge-vlan-fix-error-return-code-in-__vlan_add.patch b/queue-4.9/net-bridge-vlan-fix-error-return-code-in-__vlan_add.patch new file mode 100644 index 00000000000..9685dcaa880 --- /dev/null +++ b/queue-4.9/net-bridge-vlan-fix-error-return-code-in-__vlan_add.patch @@ -0,0 +1,37 @@ +From foo@baz Sat Dec 19 12:04:16 PM CET 2020 +From: Zhang Changzhong +Date: Fri, 4 Dec 2020 16:48:56 +0800 +Subject: net: bridge: vlan: fix error return code in __vlan_add() + +From: Zhang Changzhong + +[ Upstream commit ee4f52a8de2c6f78b01f10b4c330867d88c1653a ] + +Fix to return a negative error code from the error handling +case instead of 0, as done elsewhere in this function. + +Fixes: f8ed289fab84 ("bridge: vlan: use br_vlan_(get|put)_master to deal with refcounts") +Reported-by: Hulk Robot +Signed-off-by: Zhang Changzhong +Acked-by: Nikolay Aleksandrov +Link: https://lore.kernel.org/r/1607071737-33875-1-git-send-email-zhangchangzhong@huawei.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/bridge/br_vlan.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/net/bridge/br_vlan.c ++++ b/net/bridge/br_vlan.c +@@ -238,8 +238,10 @@ static int __vlan_add(struct net_bridge_ + } + + masterv = br_vlan_get_master(br, v->vid); +- if (!masterv) ++ if (!masterv) { ++ err = -ENOMEM; + goto out_filt; ++ } + v->brvlan = masterv; + v->stats = masterv->stats; + } diff --git a/queue-4.9/net-mlx4_en-avoid-scheduling-restart-task-if-it-is-already-running.patch b/queue-4.9/net-mlx4_en-avoid-scheduling-restart-task-if-it-is-already-running.patch new file mode 100644 index 00000000000..64351ed4d24 --- /dev/null +++ b/queue-4.9/net-mlx4_en-avoid-scheduling-restart-task-if-it-is-already-running.patch @@ -0,0 +1,124 @@ +From foo@baz Sat Dec 19 12:14:44 PM CET 2020 +From: Moshe Shemesh +Date: Wed, 9 Dec 2020 15:03:38 +0200 +Subject: net/mlx4_en: Avoid scheduling restart task if it is already running + +From: Moshe Shemesh + +[ Upstream commit fed91613c9dd455dd154b22fa8e11b8526466082 ] + +Add restarting state flag to avoid scheduling another restart task while +such task is already running. Change task name from watchdog_task to +restart_task to better fit the task role. + +Fixes: 1e338db56e5a ("mlx4_en: Fix a race at restart task") +Signed-off-by: Moshe Shemesh +Signed-off-by: Tariq Toukan +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 20 +++++++++++++------- + drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 7 ++++++- + 2 files changed, 19 insertions(+), 8 deletions(-) + +--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c ++++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +@@ -1311,8 +1311,10 @@ static void mlx4_en_tx_timeout(struct ne + } + + priv->port_stats.tx_timeout++; +- en_dbg(DRV, priv, "Scheduling watchdog\n"); +- queue_work(mdev->workqueue, &priv->watchdog_task); ++ if (!test_and_set_bit(MLX4_EN_STATE_FLAG_RESTARTING, &priv->state)) { ++ en_dbg(DRV, priv, "Scheduling port restart\n"); ++ queue_work(mdev->workqueue, &priv->restart_task); ++ } + } + + +@@ -1746,6 +1748,7 @@ int mlx4_en_start_port(struct net_device + local_bh_enable(); + } + ++ clear_bit(MLX4_EN_STATE_FLAG_RESTARTING, &priv->state); + netif_tx_start_all_queues(dev); + netif_device_attach(dev); + +@@ -1900,7 +1903,7 @@ void mlx4_en_stop_port(struct net_device + static void mlx4_en_restart(struct work_struct *work) + { + struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, +- watchdog_task); ++ restart_task); + struct mlx4_en_dev *mdev = priv->mdev; + struct net_device *dev = priv->dev; + +@@ -2220,7 +2223,7 @@ static int mlx4_en_change_mtu(struct net + if (netif_running(dev)) { + mutex_lock(&mdev->state_lock); + if (!mdev->device_up) { +- /* NIC is probably restarting - let watchdog task reset ++ /* NIC is probably restarting - let restart task reset + * the port */ + en_dbg(DRV, priv, "Change MTU called with card down!?\n"); + } else { +@@ -2229,7 +2232,9 @@ static int mlx4_en_change_mtu(struct net + if (err) { + en_err(priv, "Failed restarting port:%d\n", + priv->port); +- queue_work(mdev->workqueue, &priv->watchdog_task); ++ if (!test_and_set_bit(MLX4_EN_STATE_FLAG_RESTARTING, ++ &priv->state)) ++ queue_work(mdev->workqueue, &priv->restart_task); + } + } + mutex_unlock(&mdev->state_lock); +@@ -2701,7 +2706,8 @@ static int mlx4_xdp_set(struct net_devic + if (err) { + en_err(priv, "Failed starting port %d for XDP change\n", + priv->port); +- queue_work(mdev->workqueue, &priv->watchdog_task); ++ if (!test_and_set_bit(MLX4_EN_STATE_FLAG_RESTARTING, &priv->state)) ++ queue_work(mdev->workqueue, &priv->restart_task); + } + } + +@@ -3080,7 +3086,7 @@ int mlx4_en_init_netdev(struct mlx4_en_d + priv->counter_index = MLX4_SINK_COUNTER_INDEX(mdev->dev); + spin_lock_init(&priv->stats_lock); + INIT_WORK(&priv->rx_mode_task, mlx4_en_do_set_rx_mode); +- INIT_WORK(&priv->watchdog_task, mlx4_en_restart); ++ INIT_WORK(&priv->restart_task, mlx4_en_restart); + INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate); + INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats); + INIT_DELAYED_WORK(&priv->service_task, mlx4_en_service_task); +--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h ++++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +@@ -522,6 +522,10 @@ struct mlx4_en_stats_bitmap { + struct mutex mutex; /* for mutual access to stats bitmap */ + }; + ++enum { ++ MLX4_EN_STATE_FLAG_RESTARTING, ++}; ++ + struct mlx4_en_priv { + struct mlx4_en_dev *mdev; + struct mlx4_en_port_profile *prof; +@@ -586,7 +590,7 @@ struct mlx4_en_priv { + struct mlx4_en_cq *rx_cq[MAX_RX_RINGS]; + struct mlx4_qp drop_qp; + struct work_struct rx_mode_task; +- struct work_struct watchdog_task; ++ struct work_struct restart_task; + struct work_struct linkstate_task; + struct delayed_work stats_task; + struct delayed_work service_task; +@@ -632,6 +636,7 @@ struct mlx4_en_priv { + u32 pflags; + u8 rss_key[MLX4_EN_RSS_KEY_SIZE]; + u8 rss_hash_fn; ++ unsigned long state; + }; + + enum mlx4_en_wol { diff --git a/queue-4.9/net-stmmac-delete-the-eee_ctrl_timer-after-napi-disabled.patch b/queue-4.9/net-stmmac-delete-the-eee_ctrl_timer-after-napi-disabled.patch new file mode 100644 index 00000000000..8d84ab5f287 --- /dev/null +++ b/queue-4.9/net-stmmac-delete-the-eee_ctrl_timer-after-napi-disabled.patch @@ -0,0 +1,62 @@ +From foo@baz Sat Dec 19 11:44:48 AM CET 2020 +From: Fugang Duan +Date: Mon, 7 Dec 2020 18:51:40 +0800 +Subject: net: stmmac: delete the eee_ctrl_timer after napi disabled + +From: Fugang Duan + +[ Upstream commit 5f58591323bf3f342920179f24515935c4b5fd60 ] + +There have chance to re-enable the eee_ctrl_timer and fire the timer +in napi callback after delete the timer in .stmmac_release(), which +introduces to access eee registers in the timer function after clocks +are disabled then causes system hang. Found this issue when do +suspend/resume and reboot stress test. + +It is safe to delete the timer after napi disabled and disable lpi mode. + +Fixes: d765955d2ae0b ("stmmac: add the Energy Efficient Ethernet support") +Signed-off-by: Fugang Duan +Signed-off-by: Joakim Zhang +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +@@ -1901,9 +1901,6 @@ static int stmmac_release(struct net_dev + { + struct stmmac_priv *priv = netdev_priv(dev); + +- if (priv->eee_enabled) +- del_timer_sync(&priv->eee_ctrl_timer); +- + /* Stop and disconnect the PHY */ + if (priv->phydev) { + phy_stop(priv->phydev); +@@ -1924,6 +1921,11 @@ static int stmmac_release(struct net_dev + if (priv->lpi_irq > 0) + free_irq(priv->lpi_irq, dev); + ++ if (priv->eee_enabled) { ++ priv->tx_path_in_lpi_mode = false; ++ del_timer_sync(&priv->eee_ctrl_timer); ++ } ++ + /* Stop TX/RX DMA and clear the descriptors */ + priv->hw->dma->stop_tx(priv->ioaddr); + priv->hw->dma->stop_rx(priv->ioaddr); +@@ -3503,6 +3505,11 @@ int stmmac_suspend(struct device *dev) + + napi_disable(&priv->napi); + ++ if (priv->eee_enabled) { ++ priv->tx_path_in_lpi_mode = false; ++ del_timer_sync(&priv->eee_ctrl_timer); ++ } ++ + /* Stop TX/RX DMA */ + priv->hw->dma->stop_tx(priv->ioaddr); + priv->hw->dma->stop_rx(priv->ioaddr); diff --git a/queue-4.9/net-stmmac-dwmac-meson8b-fix-mask-definition-of-the-m250_sel-mux.patch b/queue-4.9/net-stmmac-dwmac-meson8b-fix-mask-definition-of-the-m250_sel-mux.patch new file mode 100644 index 00000000000..d7406fc800d --- /dev/null +++ b/queue-4.9/net-stmmac-dwmac-meson8b-fix-mask-definition-of-the-m250_sel-mux.patch @@ -0,0 +1,50 @@ +From foo@baz Sat Dec 19 12:08:30 PM CET 2020 +From: Martin Blumenstingl +Date: Sat, 5 Dec 2020 22:32:07 +0100 +Subject: net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux + +From: Martin Blumenstingl + +[ Upstream commit 82ca4c922b8992013a238d65cf4e60cc33e12f36 ] + +The m250_sel mux clock uses bit 4 in the PRG_ETH0 register. Fix this by +shifting the PRG_ETH0_CLK_M250_SEL_MASK accordingly as the "mask" in +struct clk_mux expects the mask relative to the "shift" field in the +same struct. + +While here, get rid of the PRG_ETH0_CLK_M250_SEL_SHIFT macro and use +__ffs() to determine it from the existing PRG_ETH0_CLK_M250_SEL_MASK +macro. + +Fixes: 566e8251625304 ("net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC") +Signed-off-by: Martin Blumenstingl +Reviewed-by: Jerome Brunet +Link: https://lore.kernel.org/r/20201205213207.519341-1-martin.blumenstingl@googlemail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +@@ -30,7 +30,6 @@ + #define PRG_ETH0_RGMII_MODE BIT(0) + + /* mux to choose between fclk_div2 (bit unset) and mpll2 (bit set) */ +-#define PRG_ETH0_CLK_M250_SEL_SHIFT 4 + #define PRG_ETH0_CLK_M250_SEL_MASK GENMASK(4, 4) + + #define PRG_ETH0_TXDLY_SHIFT 5 +@@ -123,8 +122,9 @@ static int meson8b_init_clk(struct meson + init.num_parents = MUX_CLK_NUM_PARENTS; + + dwmac->m250_mux.reg = dwmac->regs + PRG_ETH0; +- dwmac->m250_mux.shift = PRG_ETH0_CLK_M250_SEL_SHIFT; +- dwmac->m250_mux.mask = PRG_ETH0_CLK_M250_SEL_MASK; ++ dwmac->m250_mux.shift = __ffs(PRG_ETH0_CLK_M250_SEL_MASK); ++ dwmac->m250_mux.mask = PRG_ETH0_CLK_M250_SEL_MASK >> ++ dwmac->m250_mux.shift; + dwmac->m250_mux.flags = 0; + dwmac->m250_mux.table = NULL; + dwmac->m250_mux.hw.init = &init; diff --git a/queue-4.9/series b/queue-4.9/series index ca7aadab58e..f0542e11005 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -9,3 +9,9 @@ input-i8042-add-acer-laptops-to-the-i8042-reset-list.patch pinctrl-amd-remove-debounce-filter-setting-in-irq-type-setting.patch scsi-be2iscsi-revert-fix-a-theoretical-leak-in-beiscsi_create_eqs.patch spi-prevent-adding-devices-below-an-unregistering-controller.patch +net-mlx4_en-avoid-scheduling-restart-task-if-it-is-already-running.patch +tcp-fix-cwnd-limited-bug-for-tso-deferral-where-we-send-nothing.patch +net-stmmac-delete-the-eee_ctrl_timer-after-napi-disabled.patch +net-stmmac-dwmac-meson8b-fix-mask-definition-of-the-m250_sel-mux.patch +net-bridge-vlan-fix-error-return-code-in-__vlan_add.patch +mac80211-mesh-fix-mesh_pathtbl_init-error-path.patch diff --git a/queue-4.9/tcp-fix-cwnd-limited-bug-for-tso-deferral-where-we-send-nothing.patch b/queue-4.9/tcp-fix-cwnd-limited-bug-for-tso-deferral-where-we-send-nothing.patch new file mode 100644 index 00000000000..a2c3ab70b6e --- /dev/null +++ b/queue-4.9/tcp-fix-cwnd-limited-bug-for-tso-deferral-where-we-send-nothing.patch @@ -0,0 +1,86 @@ +From foo@baz Sat Dec 19 12:14:44 PM CET 2020 +From: Neal Cardwell +Date: Tue, 8 Dec 2020 22:57:59 -0500 +Subject: tcp: fix cwnd-limited bug for TSO deferral where we send nothing + +From: Neal Cardwell + +[ Upstream commit 299bcb55ecd1412f6df606e9dc0912d55610029e ] + +When cwnd is not a multiple of the TSO skb size of N*MSS, we can get +into persistent scenarios where we have the following sequence: + +(1) ACK for full-sized skb of N*MSS arrives + -> tcp_write_xmit() transmit full-sized skb with N*MSS + -> move pacing release time forward + -> exit tcp_write_xmit() because pacing time is in the future + +(2) TSQ callback or TCP internal pacing timer fires + -> try to transmit next skb, but TSO deferral finds remainder of + available cwnd is not big enough to trigger an immediate send + now, so we defer sending until the next ACK. + +(3) repeat... + +So we can get into a case where we never mark ourselves as +cwnd-limited for many seconds at a time, even with +bulk/infinite-backlog senders, because: + +o In case (1) above, every time in tcp_write_xmit() we have enough +cwnd to send a full-sized skb, we are not fully using the cwnd +(because cwnd is not a multiple of the TSO skb size). So every time we +send data, we are not cwnd limited, and so in the cwnd-limited +tracking code in tcp_cwnd_validate() we mark ourselves as not +cwnd-limited. + +o In case (2) above, every time in tcp_write_xmit() that we try to +transmit the "remainder" of the cwnd but defer, we set the local +variable is_cwnd_limited to true, but we do not send any packets, so +sent_pkts is zero, so we don't call the cwnd-limited logic to update +tp->is_cwnd_limited. + +Fixes: ca8a22634381 ("tcp: make cwnd-limited checks measurement-based, and gentler") +Reported-by: Ingemar Johansson +Signed-off-by: Neal Cardwell +Signed-off-by: Yuchung Cheng +Acked-by: Soheil Hassas Yeganeh +Signed-off-by: Eric Dumazet +Link: https://lore.kernel.org/r/20201209035759.1225145-1-ncardwell.kernel@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/ipv4/tcp_output.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/net/ipv4/tcp_output.c ++++ b/net/ipv4/tcp_output.c +@@ -1532,7 +1532,8 @@ static void tcp_cwnd_validate(struct soc + * window, and remember whether we were cwnd-limited then. + */ + if (!before(tp->snd_una, tp->max_packets_seq) || +- tp->packets_out > tp->max_packets_out) { ++ tp->packets_out > tp->max_packets_out || ++ is_cwnd_limited) { + tp->max_packets_out = tp->packets_out; + tp->max_packets_seq = tp->snd_nxt; + tp->is_cwnd_limited = is_cwnd_limited; +@@ -2259,6 +2260,10 @@ repair: + break; + } + ++ is_cwnd_limited |= (tcp_packets_in_flight(tp) >= tp->snd_cwnd); ++ if (likely(sent_pkts || is_cwnd_limited)) ++ tcp_cwnd_validate(sk, is_cwnd_limited); ++ + if (likely(sent_pkts)) { + if (tcp_in_cwnd_reduction(sk)) + tp->prr_out += sent_pkts; +@@ -2266,8 +2271,6 @@ repair: + /* Send one loss probe per tail loss episode. */ + if (push_one != 2) + tcp_schedule_loss_probe(sk); +- is_cwnd_limited |= (tcp_packets_in_flight(tp) >= tp->snd_cwnd); +- tcp_cwnd_validate(sk, is_cwnd_limited); + return false; + } + return !tp->packets_out && tcp_send_head(sk); -- 2.47.3