Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] RDMA/siw: Relax from kmap_atomic() use in TX path
@ 2019-09-06 11:18 Bernard Metzler
  2019-09-06 22:31 ` Steve Wise
  2019-09-09 12:25 ` Bernard Metzler
  0 siblings, 2 replies; 3+ messages in thread
From: Bernard Metzler @ 2019-09-06 11:18 UTC (permalink / raw)
  To: linux-rdma; +Cc: dledford, 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().

Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
---
 drivers/infiniband/sw/siw/siw_qp_tx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c
index 8e72f955921d..5d97bba0ce6d 100644
--- a/drivers/infiniband/sw/siw/siw_qp_tx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_tx.c
@@ -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;
-- 
2.17.2


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

* Re: [PATCH] RDMA/siw: Relax from kmap_atomic() use in TX path
  2019-09-06 11:18 [PATCH] RDMA/siw: Relax from kmap_atomic() use in TX path Bernard Metzler
@ 2019-09-06 22:31 ` Steve Wise
  2019-09-09 12:25 ` Bernard Metzler
  1 sibling, 0 replies; 3+ messages in thread
From: Steve Wise @ 2019-09-06 22:31 UTC (permalink / raw)
  To: Bernard Metzler; +Cc: linux-rdma, dledford

Hey Bernard,  is the code below called directly from the driver’s post_send function?  If so it must use atomic...I think.

Stevo

> On Sep 6, 2019, at 6:18 AM, Bernard Metzler <bmt@zurich.ibm.com> wrote:
> 
> Since the transmit path is never executed in an atomic
> context, we do not need kmap_atomic() and can always
> use less demanding kmap().
> 
> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
> ---
> drivers/infiniband/sw/siw/siw_qp_tx.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c
> index 8e72f955921d..5d97bba0ce6d 100644
> --- a/drivers/infiniband/sw/siw/siw_qp_tx.c
> +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c
> @@ -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;
> -- 
> 2.17.2
> 

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

* Re: Re: [PATCH] RDMA/siw: Relax from kmap_atomic() use in TX path
  2019-09-06 11:18 [PATCH] RDMA/siw: Relax from kmap_atomic() use in TX path Bernard Metzler
  2019-09-06 22:31 ` Steve Wise
@ 2019-09-09 12:25 ` Bernard Metzler
  1 sibling, 0 replies; 3+ messages in thread
From: Bernard Metzler @ 2019-09-09 12:25 UTC (permalink / raw)
  To: Steve Wise; +Cc: linux-rdma, dledford

-----"Steve Wise" <larrystevenwise@gmail.com> wrote: -----

>To: "Bernard Metzler" <bmt@zurich.ibm.com>
>From: "Steve Wise" <larrystevenwise@gmail.com>
>Date: 09/07/2019 12:31AM
>Cc: linux-rdma@vger.kernel.org, dledford@redhat.com
>Subject: [EXTERNAL] Re: [PATCH] RDMA/siw: Relax from kmap_atomic()
>use in TX path
>
>Hey Bernard,  is the code below called directly from the driver’s
>post_send function?  If so it must use atomic...I think.
>

Hey Steve,

Only a kernel TX thread executes the TX path. It is not
executed directly from the drivers post_send() method,
which only queues work for TX processing and wakes up
the TX thread if it currently does not run.
The single exception is TX processing
out of a user space application context, if no TX
thread is currently running, but only for a small
burst. In any case, all TX processing is done out of
a non-atomic context.

Best,
Bernard.

>Stevo
>
>> On Sep 6, 2019, at 6:18 AM, Bernard Metzler <bmt@zurich.ibm.com>
>wrote:
>> 
>> Since the transmit path is never executed in an atomic
>> context, we do not need kmap_atomic() and can always
>> use less demanding kmap().
>> 
>> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
>> ---
>> drivers/infiniband/sw/siw/siw_qp_tx.c | 12 +++++-------
>> 1 file changed, 5 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c
>b/drivers/infiniband/sw/siw/siw_qp_tx.c
>> index 8e72f955921d..5d97bba0ce6d 100644
>> --- a/drivers/infiniband/sw/siw/siw_qp_tx.c
>> +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c
>> @@ -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;
>> -- 
>> 2.17.2
>> 
>
>


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 11:18 [PATCH] RDMA/siw: Relax from kmap_atomic() use in TX path Bernard Metzler
2019-09-06 22:31 ` Steve Wise
2019-09-09 12:25 ` Bernard Metzler

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org linux-rdma@archiver.kernel.org
	public-inbox-index linux-rdma


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/ public-inbox