Skip to contentSkip to conversation

RDMA/siw: Relax from kmap_atomic() use in TX path

PATCH In review Bernard Metzler 2 participants 3 messages Sep 9, 2019 – Sep 10, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/siw: Relax from kmap_atomic() use in TX path

Since the transmit path is never executed in an atomic context, we do not need kmap_atomic() and can always use less demanding kmap().

---
 drivers/infiniband/sw/siw/siw_qp_tx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +5 -7
index 8e72f955921d..5d97bba0ce6d 100644
@@ -76,16 +76,15 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)
 			if (unlikely(!p))
 				return -EFAULT;
 
-			buffer = kmap_atomic(p);
+			buffer = kmap(p);
 
 			if (likely(PAGE_SIZE - off >= bytes)) {
 				memcpy(paddr, buffer + off, bytes);
-				kunmap_atomic(buffer);
 			} else {
 				unsigned long part = bytes - (PAGE_SIZE - off);
 
 				memcpy(paddr, buffer + off, part);
-				kunmap_atomic(buffer);
+				kunmap(p);
 
 				if (!mem->is_pbl)
 					p = siw_get_upage(mem->umem,
@@ -97,11 +96,10 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)
 				if (unlikely(!p))
 					return -EFAULT;
 
-				buffer = kmap_atomic(p);
-				memcpy(paddr + part, buffer,
-				       bytes - part);
-				kunmap_atomic(buffer);
+				buffer = kmap(p);
+				memcpy(paddr + part, buffer, bytes - part);
 			}
+			kunmap(p);
 		}
 	}
 	return (int)bytes;
Signature · 1 line
2.17.2
#1 lore raw
Quoted 14 lines · Bernard Metzler

Since the transmit path is never executed in an atomic context, we do not need kmap_atomic() and can always use less demanding kmap().

---
 drivers/infiniband/sw/siw/siw_qp_tx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
index 8e72f955921d..5d97bba0ce6d 100644

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 83

Quoted 9 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -2
@@ -76,16 +76,15 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)
 			if (unlikely(!p))
 				return -EFAULT;
 
-			buffer = kmap_atomic(p);
+			buffer = kmap(p);
 
 			if (likely(PAGE_SIZE - off >= bytes)) {
 				memcpy(paddr, buffer + off, bytes);
-				kunmap_atomic(buffer);

missing kunmap()

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 87

Quoted 6 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
 			} else {
 				unsigned long part = bytes - (PAGE_SIZE - off);
 
 				memcpy(paddr, buffer + off, part);
-				kunmap_atomic(buffer);
+				kunmap(p);

kunmap(buffer)

Quoted 5 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
 				if (!mem->is_pbl)
 					p = siw_get_upage(mem->umem,
@@ -97,11 +96,10 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)
 				if (unlikely(!p))

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 102

Quoted 10 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +3 -4
 					return -EFAULT;
 
-				buffer = kmap_atomic(p);
-				memcpy(paddr + part, buffer,
-				       bytes - part);
-				kunmap_atomic(buffer);
+				buffer = kmap(p);
+				memcpy(paddr + part, buffer, bytes - part);
 			}
+			kunmap(p);

Can this be out of if()? the buffers seem to be different.

Quoted 6 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
 		}
 	}
 	return (int)bytes;
Signature · 1 line
2.17.2
#2 lore raw

-----"Potnuri Bharat Teja" <[email protected]> wrote: -----

Quoted 29 lines

To: "Bernard Metzler" <[email protected]>
From: "Potnuri Bharat Teja" <[email protected]>
Date: 09/09/2019 04:54PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH v1 rdma-next] RDMA/siw: Relax from kmap_atomic() use in TX path

Review

Quoted 10 lines · Bernard Metzler

Since the transmit path is never executed in an atomic context, we do not need kmap_atomic() and can always use less demanding kmap().

---
 drivers/infiniband/sw/siw/siw_qp_tx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/infiniband/sw/siw/siw_qp_tx.c

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx

Quoted 4 lines

index 8e72f955921d..5d97bba0ce6d 100644

drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
@@ -76,16 +76,15 @@ static int siw_try_1seg(struct siw_iwarp_tx

*c_tx, void *paddr)

Quoted 3 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
 			if (unlikely(!p))
 				return -EFAULT;
 
Quoted 7 lines

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 83

Quoted 6 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -2
-			buffer = kmap_atomic(p);
+			buffer = kmap(p);
 
 			if (likely(PAGE_SIZE - off >= bytes)) {
 				memcpy(paddr, buffer + off, bytes);
-				kunmap_atomic(buffer);

missing kunmap()

No it's not missing. we are in the if-path, and we unmap 'p' at the next line (skipping the else-path).

Quoted 15 lines

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 87

Quoted 6 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
 			} else {
 				unsigned long part = bytes - (PAGE_SIZE - off);
 
 				memcpy(paddr, buffer + off, part);
-				kunmap_atomic(buffer);
+				kunmap(p);

kunmap(buffer)

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx

Quoted 4 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
 				if (!mem->is_pbl)
 					p = siw_get_upage(mem->umem,
@@ -97,11 +96,10 @@ static int siw_try_1seg(struct siw_iwarp_tx

*c_tx, void *paddr)

Quoted 3 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
 				if (unlikely(!p))
 					return -EFAULT;
 
Quoted 9 lines

drivers/infiniband/sw/siw/siw_qp_tx.c static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr) · line 102

Quoted 8 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +3 -4
-				buffer = kmap_atomic(p);
-				memcpy(paddr + part, buffer,
-				       bytes - part);
-				kunmap_atomic(buffer);
+				buffer = kmap(p);
+				memcpy(paddr + part, buffer, bytes - part);
 			}
+			kunmap(p);

Can this be out of if()? the buffers seem to be different.

the page pointer gets reassigned since the data span two pages. so we unmap the first page after copying out of it what we need, get the second page into 'p', and map it. at the end, the current page p gets unmapped. if we do not have data spanning two pages, we unmap the first page. If we do have, we unmap the second page.

It should be all good.

Thanks & best regards,
Bernard.

Quoted 8 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_qp_tx.c +0 -0
 		}
 	}
 	return (int)bytes;
Signature · 1 line
2.17.2