netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] net/smc: fixes 2020-07-20
@ 2020-07-20 14:24 Karsten Graul
  2020-07-20 14:24 ` [PATCH net 1/2] net/smc: put slot when connection is killed Karsten Graul
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karsten Graul @ 2020-07-20 14:24 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

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(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] net/smc: put slot when connection is killed
  2020-07-20 14:24 [PATCH net 0/2] net/smc: fixes 2020-07-20 Karsten Graul
@ 2020-07-20 14:24 ` Karsten Graul
  2020-07-20 14:24 ` [PATCH net 2/2] net/smc: fix dmb buffer shortage Karsten Graul
  2020-07-21  0:52 ` [PATCH net 0/2] net/smc: fixes 2020-07-20 David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2020-07-20 14:24 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

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.

Fixes: b290098092e4 ("net/smc: cancel send and receive for terminated socket")
Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/smc_cdc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
index a47e8855e045..ce468ff62a19 100644
--- a/net/smc/smc_cdc.c
+++ b/net/smc/smc_cdc.c
@@ -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;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net/smc: fix dmb buffer shortage
  2020-07-20 14:24 [PATCH net 0/2] net/smc: fixes 2020-07-20 Karsten Graul
  2020-07-20 14:24 ` [PATCH net 1/2] net/smc: put slot when connection is killed Karsten Graul
@ 2020-07-20 14:24 ` Karsten Graul
  2020-07-21  0:52 ` [PATCH net 0/2] net/smc: fixes 2020-07-20 David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2020-07-20 14:24 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

There 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.

Fixes: c6ba7c9ba43d ("net/smc: add base infrastructure for SMC-D and ISM")
Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/smc_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index ca3dc6af73af..f82a2e599917 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] net/smc: fixes 2020-07-20
  2020-07-20 14:24 [PATCH net 0/2] net/smc: fixes 2020-07-20 Karsten Graul
  2020-07-20 14:24 ` [PATCH net 1/2] net/smc: put slot when connection is killed Karsten Graul
  2020-07-20 14:24 ` [PATCH net 2/2] net/smc: fix dmb buffer shortage Karsten Graul
@ 2020-07-21  0:52 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-07-21  0:52 UTC (permalink / raw)
  To: kgraul; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

From: Karsten Graul <kgraul@linux.ibm.com>
Date: Mon, 20 Jul 2020 16:24:27 +0200

> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-21  0:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 14:24 [PATCH net 0/2] net/smc: fixes 2020-07-20 Karsten Graul
2020-07-20 14:24 ` [PATCH net 1/2] net/smc: put slot when connection is killed Karsten Graul
2020-07-20 14:24 ` [PATCH net 2/2] net/smc: fix dmb buffer shortage Karsten Graul
2020-07-21  0:52 ` [PATCH net 0/2] net/smc: fixes 2020-07-20 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).