All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net/smc: show unique rsn code for exceeded max dmb count
@ 2020-07-26 18:34 Karsten Graul
  2020-07-26 18:34 ` [PATCH net-next 1/2] s390/ism: indicate correct error reason in ism_alloc_dmb() Karsten Graul
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karsten Graul @ 2020-07-26 18:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

Resolve some confusion at the user side when the reason code shows
out-of-memory but actually there is enough memory left.

Karsten Graul (2):
  s390/ism: indicate correct error reason in ism_alloc_dmb()
  net/smc: unique reason code for exceeded max dmb count

 drivers/s390/net/ism_drv.c |  2 +-
 net/smc/af_smc.c           | 13 +++++++++----
 net/smc/smc_clc.h          |  1 +
 net/smc/smc_core.c         |  4 ++--
 4 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.17.1


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

* [PATCH net-next 1/2] s390/ism: indicate correct error reason in ism_alloc_dmb()
  2020-07-26 18:34 [PATCH net-next 0/2] net/smc: show unique rsn code for exceeded max dmb count Karsten Graul
@ 2020-07-26 18:34 ` Karsten Graul
  2020-07-26 18:34 ` [PATCH net-next 2/2] net/smc: unique reason code for exceeded max dmb count Karsten Graul
  2020-07-27 17:30 ` [PATCH net-next 0/2] net/smc: show unique rsn " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2020-07-26 18:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

When the ism driver allocates a new dmb in ism_alloc_dmb() it must
first check for and reserve a slot in the sba bitmap. When
find_next_zero_bit() finds no free slot then the return code is -ENOMEM.
This code conflicts with the error when the alloc() fails later in the
code. As a result of that the caller can not differentiate
between out-of-memory conditions and sba-bitmap-full conditions.
Fix that by using the return code -ENOSPC when the sba slot
reservation failed.

Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 drivers/s390/net/ism_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c
index c7fade836d83..5fbe9eae84d1 100644
--- a/drivers/s390/net/ism_drv.c
+++ b/drivers/s390/net/ism_drv.c
@@ -231,7 +231,7 @@ static int ism_alloc_dmb(struct ism_dev *ism, struct smcd_dmb *dmb)
 		bit = find_next_zero_bit(ism->sba_bitmap, ISM_NR_DMBS,
 					 ISM_DMB_BIT_OFFSET);
 		if (bit == ISM_NR_DMBS)
-			return -ENOMEM;
+			return -ENOSPC;
 
 		dmb->sba_idx = bit;
 	}
-- 
2.17.1


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

* [PATCH net-next 2/2] net/smc: unique reason code for exceeded max dmb count
  2020-07-26 18:34 [PATCH net-next 0/2] net/smc: show unique rsn code for exceeded max dmb count Karsten Graul
  2020-07-26 18:34 ` [PATCH net-next 1/2] s390/ism: indicate correct error reason in ism_alloc_dmb() Karsten Graul
@ 2020-07-26 18:34 ` Karsten Graul
  2020-07-27 17:30 ` [PATCH net-next 0/2] net/smc: show unique rsn " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2020-07-26 18:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

When the maximum dmb buffer limit for an ism device is reached no more
dmb buffers can be registered. When this happens the reason code is set
to SMC_CLC_DECL_MEM indicating out-of-memory. This is the same reason
code that is used when no memory could be allocated for the new dmb
buffer.
This is confusing for users when they see this error but there is more
memory available. To solve this set a separate new reason code when the
maximum dmb limit exceeded.

Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
 net/smc/af_smc.c   | 13 +++++++++----
 net/smc/smc_clc.h  |  1 +
 net/smc/smc_core.c |  4 ++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 832e36269b10..e7649bbc2b87 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -719,8 +719,11 @@ static int smc_connect_ism(struct smc_sock *smc,
 	}
 
 	/* Create send and receive buffers */
-	if (smc_buf_create(smc, true))
-		return smc_connect_abort(smc, SMC_CLC_DECL_MEM,
+	rc = smc_buf_create(smc, true);
+	if (rc)
+		return smc_connect_abort(smc, (rc == -ENOSPC) ?
+					      SMC_CLC_DECL_MAX_DMB :
+					      SMC_CLC_DECL_MEM,
 					 ini->cln_first_contact);
 
 	smc_conn_save_peer_info(smc, aclc);
@@ -1200,12 +1203,14 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
 	}
 
 	/* Create send and receive buffers */
-	if (smc_buf_create(new_smc, true)) {
+	rc = smc_buf_create(new_smc, true);
+	if (rc) {
 		if (ini->cln_first_contact == SMC_FIRST_CONTACT)
 			smc_lgr_cleanup_early(&new_smc->conn);
 		else
 			smc_conn_free(&new_smc->conn);
-		return SMC_CLC_DECL_MEM;
+		return (rc == -ENOSPC) ? SMC_CLC_DECL_MAX_DMB :
+					 SMC_CLC_DECL_MEM;
 	}
 
 	return 0;
diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
index 76c2b150d040..cf7b45306f4e 100644
--- a/net/smc/smc_clc.h
+++ b/net/smc/smc_clc.h
@@ -48,6 +48,7 @@
 #define SMC_CLC_DECL_NOACTLINK	0x030a0000  /* no active smc-r link in lgr    */
 #define SMC_CLC_DECL_NOSRVLINK	0x030b0000  /* SMC-R link from srv not found  */
 #define SMC_CLC_DECL_VERSMISMAT	0x030c0000  /* SMC version mismatch	      */
+#define SMC_CLC_DECL_MAX_DMB	0x030d0000  /* SMC-D DMB limit exceeded       */
 #define SMC_CLC_DECL_SYNCERR	0x04000000  /* synchronization error          */
 #define SMC_CLC_DECL_PEERDECL	0x05000000  /* peer declined during handshake */
 #define SMC_CLC_DECL_INTERR	0x09990000  /* internal error		      */
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index f82a2e599917..b42fa3b00d00 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -1614,7 +1614,7 @@ static struct smc_buf_desc *smcd_new_buf_create(struct smc_link_group *lgr,
 		rc = smc_ism_register_dmb(lgr, bufsize, buf_desc);
 		if (rc) {
 			kfree(buf_desc);
-			return ERR_PTR(-EAGAIN);
+			return (rc == -ENOMEM) ? ERR_PTR(-EAGAIN) : ERR_PTR(rc);
 		}
 		buf_desc->pages = virt_to_page(buf_desc->cpu_addr);
 		/* CDC header stored in buf. So, pretend it was smaller */
@@ -1688,7 +1688,7 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_smcd, bool is_rmb)
 	}
 
 	if (IS_ERR(buf_desc))
-		return -ENOMEM;
+		return PTR_ERR(buf_desc);
 
 	if (!is_smcd) {
 		if (smcr_buf_map_usable_links(lgr, buf_desc, is_rmb)) {
-- 
2.17.1


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

* Re: [PATCH net-next 0/2] net/smc: show unique rsn code for exceeded max dmb count
  2020-07-26 18:34 [PATCH net-next 0/2] net/smc: show unique rsn code for exceeded max dmb count Karsten Graul
  2020-07-26 18:34 ` [PATCH net-next 1/2] s390/ism: indicate correct error reason in ism_alloc_dmb() Karsten Graul
  2020-07-26 18:34 ` [PATCH net-next 2/2] net/smc: unique reason code for exceeded max dmb count Karsten Graul
@ 2020-07-27 17:30 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-07-27 17:30 UTC (permalink / raw)
  To: kgraul; +Cc: netdev, linux-s390, heiko.carstens, raspl, ubraun

From: Karsten Graul <kgraul@linux.ibm.com>
Date: Sun, 26 Jul 2020 20:34:26 +0200

> Resolve some confusion at the user side when the reason code shows
> out-of-memory but actually there is enough memory left.

Series applied, thank you.

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

end of thread, other threads:[~2020-07-27 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-26 18:34 [PATCH net-next 0/2] net/smc: show unique rsn code for exceeded max dmb count Karsten Graul
2020-07-26 18:34 ` [PATCH net-next 1/2] s390/ism: indicate correct error reason in ism_alloc_dmb() Karsten Graul
2020-07-26 18:34 ` [PATCH net-next 2/2] net/smc: unique reason code for exceeded max dmb count Karsten Graul
2020-07-27 17:30 ` [PATCH net-next 0/2] net/smc: show unique rsn " David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.