net/smc: fixes 2020-07-20
cover net/smc: fixes 2020-07-20
Please apply the following patch series for smc to netdev's net tree.
Patch 1 fixes a problem with a buffer that is not put back when the connection was killed in the meantime.
Patch 2 fixes a wrong behaviour when the maximum dmb buffer count exceeded.
Thanks,
Karsten
Karsten Graul (2):
net/smc: put slot when connection is killed
net/smc: fix dmb buffer shortage
net/smc/smc_cdc.c | 6 +++++- net/smc/smc_core.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 net/smc: put slot when connection is killed
To get a send slot smc_wr_tx_get_free_slot() is called, which might wait for a free slot. When smc_wr_tx_get_free_slot() returns there is a check if the connection was killed in the meantime. In that case don't only return an error, but also put back the free slot.
--- net/smc/smc_cdc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/smc/smc_cdc.c +5 -1
@@ -66,9 +66,13 @@ int smc_cdc_get_free_slot(struct smc_connection *conn, rc =smc_wr_tx_get_free_slot (link, smc_cdc_tx_handler, wr_buf, wr_rdma_buf, (struct smc_wr_tx_pend_priv **)pend); -if (conn->killed) +if (conn->killed) {/* abnormal termination */ +if (!rc) +smc_wr_tx_put_slot (link, + (struct smc_wr_tx_pend_priv *)pend); rc = -EPIPE ; + }return rc; }
Signature · 1 line
2.17.1
PATCH 2/2 net/smc: fix dmb buffer shortage
In reply to Karsten GraulThere is a current limit of 1920 registered dmb buffers per ISM device for smc-d. One link group can contain 255 connections, each connection is using one dmb buffer. When the connection is closed then the registered buffer is held in a queue and is reused by the next connection. When a link group is 'full' then another link group is created and uses an own buffer pool. The link groups are added to a list using list_add() which puts a new link group to the first position in the list.
In the situation that many connections are opened (>1920) and a few of them stay open while others are closed quickly we end up with at least 8 link groups. For a new connection a matching link group is looked up, iterating over the list of link groups. The trailing 7 link groups all have registered dmb buffers which could be reused, while the first link group has only a few dmb buffers and then hit the 1920 limit. Because the first link group is not full (255 connection limit not reached) it is chosen and finally the connection falls back to TCP because there is no dmb buffer available in this link group. There are multiple ways to fix that: using list_add_tail() allows to scan older link groups first for free buffers which ensures that buffers are reused first. This fixes the problem for smc-r link groups as well. For smc-d there is an even better way to address this problem because smc-d does not have the 255 connections per link group limit. So fix the problem for smc-d by allowing large link groups.
--- net/smc/smc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/smc_core.c +2 -2
@@ -444,7 +444,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini) } smc->conn.lgr = lgr;spin_lock_bh (lgr_lock); -list_add (&lgr->list, lgr_list); +list_add_tail (&lgr->list, lgr_list);spin_unlock_bh (lgr_lock);return 0 ;
@@ -1311,7 +1311,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) smcr_lgr_match(lgr, ini->ib_lcl, role, ini->ib_clcqpn)) && !lgr->sync_err && lgr->vlan_id == ini->vlan_id && - (role ==SMC_CLNT || + (role ==SMC_CLNT || ini->is_smcd || lgr->conns_num < SMC_RMBS_PER_LGR_MAX)) { /* link group found */ ini->cln_first_contact = SMC_REUSE_CONTACT;
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Karsten Graul <[email protected]>
Date: Mon, 20 Jul 2020 16:24:27 +0200
Quoted 6 lines
Please apply the following patch series for smc to netdev's net tree.
Patch 1 fixes a problem with a buffer that is not put back when the connection was killed in the meantime.
Patch 2 fixes a wrong behaviour when the maximum dmb buffer count exceeded.
Series applied, thank you.