Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3 0/2] rxe should use same buffer size for SGE's and inline data
@ 2020-01-14  0:41 rao Shoaib
  2020-01-14  0:41 ` [PATCH v3 1/2] Introduce maximum WQE size to check limits rao Shoaib
  2020-01-14  0:41 ` [PATCH v3 2/2] SGE buffer and max_inline data must have same size rao Shoaib
  0 siblings, 2 replies; 7+ messages in thread
From: rao Shoaib @ 2020-01-14  0:41 UTC (permalink / raw)
  To: linux-rdma
  Cc: jgg, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel,
	Rao Shoaib

From: Rao Shoaib <rao.shoaib@oracle.com>

I have incorportaed suggestions from Jason. There are two patches.
Patch #1 introduces max WQE size as suggested by Jason
Patch #2 allocates resources requested and makes sure that the buffer size
         is same for SG entries and inline data, maximum of the two values
	 requested is used.

Rao Shoaib (2):
  Introduce maximum WQE size to check limits
  SGE buffer and max_inline data must have same size

 drivers/infiniband/sw/rxe/rxe_param.h |  7 ++++++-
 drivers/infiniband/sw/rxe/rxe_qp.c    | 23 +++++++++++------------
 2 files changed, 17 insertions(+), 13 deletions(-)

-- 
1.8.3.1


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

* [PATCH v3 1/2] Introduce maximum WQE size to check limits
  2020-01-14  0:41 [PATCH v3 0/2] rxe should use same buffer size for SGE's and inline data rao Shoaib
@ 2020-01-14  0:41 ` rao Shoaib
  2020-01-14  0:41 ` [PATCH v3 2/2] SGE buffer and max_inline data must have same size rao Shoaib
  1 sibling, 0 replies; 7+ messages in thread
From: rao Shoaib @ 2020-01-14  0:41 UTC (permalink / raw)
  To: linux-rdma
  Cc: jgg, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel,
	Rao Shoaib

From: Rao Shoaib <rao.shoaib@oracle.com>

Introduce maximum WQE size to impose limits on max SGE's and inline data

Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_param.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h
index 1b596fb..a0e4075 100644
--- a/drivers/infiniband/sw/rxe/rxe_param.h
+++ b/drivers/infiniband/sw/rxe/rxe_param.h
@@ -34,6 +34,8 @@
 #ifndef RXE_PARAM_H
 #define RXE_PARAM_H
 
+#include <uapi/rdma/rdma_user_rxe.h>
+
 static inline enum ib_mtu rxe_mtu_int_to_enum(int mtu)
 {
 	if (mtu < 256)
@@ -68,7 +70,6 @@ enum rxe_device_param {
 	RXE_HW_VER			= 0,
 	RXE_MAX_QP			= 0x10000,
 	RXE_MAX_QP_WR			= 0x4000,
-	RXE_MAX_INLINE_DATA		= 400,
 	RXE_DEVICE_CAP_FLAGS		= IB_DEVICE_BAD_PKEY_CNTR
 					| IB_DEVICE_BAD_QKEY_CNTR
 					| IB_DEVICE_AUTO_PATH_MIG
@@ -80,6 +81,10 @@ enum rxe_device_param {
 					| IB_DEVICE_SRQ_RESIZE
 					| IB_DEVICE_MEM_MGT_EXTENSIONS,
 	RXE_MAX_SGE			= 32,
+	RXE_MAX_WQE_SIZE		= sizeof(struct rxe_send_wqe) +
+					  sizeof(struct ib_sge) * RXE_MAX_SGE,
+	RXE_MAX_INLINE_DATA		= RXE_MAX_WQE_SIZE -
+					  sizeof(struct rxe_send_wqe),
 	RXE_MAX_SGE_RD			= 32,
 	RXE_MAX_CQ			= 16384,
 	RXE_MAX_LOG_CQE			= 15,
-- 
1.8.3.1


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

* [PATCH v3 2/2] SGE buffer and max_inline data must have same size
  2020-01-14  0:41 [PATCH v3 0/2] rxe should use same buffer size for SGE's and inline data rao Shoaib
  2020-01-14  0:41 ` [PATCH v3 1/2] Introduce maximum WQE size to check limits rao Shoaib
@ 2020-01-14  0:41 ` rao Shoaib
  2020-01-15 18:27   ` Jason Gunthorpe
  1 sibling, 1 reply; 7+ messages in thread
From: rao Shoaib @ 2020-01-14  0:41 UTC (permalink / raw)
  To: linux-rdma
  Cc: jgg, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel,
	Rao Shoaib

From: Rao Shoaib <rao.shoaib@oracle.com>

SGE buffer size and max_inline data should be same. Maximum of the
two values requested is used.

Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_qp.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
index aeea994..41c669c 100644
--- a/drivers/infiniband/sw/rxe/rxe_qp.c
+++ b/drivers/infiniband/sw/rxe/rxe_qp.c
@@ -235,18 +235,17 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
 		return err;
 	qp->sk->sk->sk_user_data = qp;
 
-	qp->sq.max_wr		= init->cap.max_send_wr;
-	qp->sq.max_sge		= init->cap.max_send_sge;
-	qp->sq.max_inline	= init->cap.max_inline_data;
-
-	wqe_size = max_t(int, sizeof(struct rxe_send_wqe) +
-			 qp->sq.max_sge * sizeof(struct ib_sge),
-			 sizeof(struct rxe_send_wqe) +
-			 qp->sq.max_inline);
-
-	qp->sq.queue = rxe_queue_init(rxe,
-				      &qp->sq.max_wr,
-				      wqe_size);
+	wqe_size = max_t(int, init->cap.max_send_sge * sizeof(struct ib_sge),
+			 init->cap.max_inline_data);
+	qp->sq.max_sge = wqe_size/sizeof(struct ib_sge);
+	qp->sq.max_inline = wqe_size;
+
+	wqe_size += sizeof(struct rxe_send_wqe);
+
+	qp->sq.max_wr = init->cap.max_send_wr;
+
+	qp->sq.queue = rxe_queue_init(rxe, &qp->sq.max_wr, wqe_size);
+
 	if (!qp->sq.queue)
 		return -ENOMEM;
 
-- 
1.8.3.1


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

* Re: [PATCH v3 2/2] SGE buffer and max_inline data must have same size
  2020-01-14  0:41 ` [PATCH v3 2/2] SGE buffer and max_inline data must have same size rao Shoaib
@ 2020-01-15 18:27   ` Jason Gunthorpe
  2020-01-15 19:57     ` Rao Shoaib
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2020-01-15 18:27 UTC (permalink / raw)
  To: rao Shoaib
  Cc: linux-rdma, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel

On Mon, Jan 13, 2020 at 04:41:20PM -0800, rao Shoaib wrote:
> From: Rao Shoaib <rao.shoaib@oracle.com>
> 
> SGE buffer size and max_inline data should be same. Maximum of the
> two values requested is used.
> 
> Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
>  drivers/infiniband/sw/rxe/rxe_qp.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
> index aeea994..41c669c 100644
> +++ b/drivers/infiniband/sw/rxe/rxe_qp.c
> @@ -235,18 +235,17 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
>  		return err;
>  	qp->sk->sk->sk_user_data = qp;
>  
> -	qp->sq.max_wr		= init->cap.max_send_wr;
> -	qp->sq.max_sge		= init->cap.max_send_sge;
> -	qp->sq.max_inline	= init->cap.max_inline_data;
> -
> -	wqe_size = max_t(int, sizeof(struct rxe_send_wqe) +
> -			 qp->sq.max_sge * sizeof(struct ib_sge),
> -			 sizeof(struct rxe_send_wqe) +
> -			 qp->sq.max_inline);
> -
> -	qp->sq.queue = rxe_queue_init(rxe,
> -				      &qp->sq.max_wr,
> -				      wqe_size);
> +	wqe_size = max_t(int, init->cap.max_send_sge * sizeof(struct ib_sge),
> +			 init->cap.max_inline_data);
> +	qp->sq.max_sge = wqe_size/sizeof(struct ib_sge);
> +	qp->sq.max_inline = wqe_size;
> +
> +	wqe_size += sizeof(struct rxe_send_wqe);

Where does this limit the user's request to RXE_MAX_WQE_SIZE ?

I seem to recall the if the requested max can't be satisified then
that is an EINVAL?

And the init->cap should be updated with the actual allocation.

So more like:

        if (init->cap.max_send_sge > RXE_MAX_SGE ||
           init->cap.max_inline_data > RXE_MAX_INLINE)
            return -EINVAL;

	wqe_size = max_t(int, init->cap.max_sge * sizeof(struct ib_sge),
			 init->cap.max_inline_data)
                   sizeof(struct rxe_send_wqe);
	qp->sq.max_sge = init->cap.max_send_sge = wqe_size/sizeof(struct ib_sge);
	qp->sq.max_inline = init->cap.max_inline_data = wqe_size;
	wqe_size += sizeof(struct rxe_send_wqe);

Jason

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

* Re: [PATCH v3 2/2] SGE buffer and max_inline data must have same size
  2020-01-15 18:27   ` Jason Gunthorpe
@ 2020-01-15 19:57     ` Rao Shoaib
  2020-01-15 20:05       ` Rao Shoaib
  2020-01-15 20:36       ` Jason Gunthorpe
  0 siblings, 2 replies; 7+ messages in thread
From: Rao Shoaib @ 2020-01-15 19:57 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: linux-rdma, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel


On 1/15/20 10:27 AM, Jason Gunthorpe wrote:
> On Mon, Jan 13, 2020 at 04:41:20PM -0800, rao Shoaib wrote:
>> From: Rao Shoaib <rao.shoaib@oracle.com>
>>
>> SGE buffer size and max_inline data should be same. Maximum of the
>> two values requested is used.
>>
>> Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
>>   drivers/infiniband/sw/rxe/rxe_qp.c | 23 +++++++++++------------
>>   1 file changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
>> index aeea994..41c669c 100644
>> +++ b/drivers/infiniband/sw/rxe/rxe_qp.c
>> @@ -235,18 +235,17 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
>>   		return err;
>>   	qp->sk->sk->sk_user_data = qp;
>>   
>> -	qp->sq.max_wr		= init->cap.max_send_wr;
>> -	qp->sq.max_sge		= init->cap.max_send_sge;
>> -	qp->sq.max_inline	= init->cap.max_inline_data;
>> -
>> -	wqe_size = max_t(int, sizeof(struct rxe_send_wqe) +
>> -			 qp->sq.max_sge * sizeof(struct ib_sge),
>> -			 sizeof(struct rxe_send_wqe) +
>> -			 qp->sq.max_inline);
>> -
>> -	qp->sq.queue = rxe_queue_init(rxe,
>> -				      &qp->sq.max_wr,
>> -				      wqe_size);
>> +	wqe_size = max_t(int, init->cap.max_send_sge * sizeof(struct ib_sge),
>> +			 init->cap.max_inline_data);
>> +	qp->sq.max_sge = wqe_size/sizeof(struct ib_sge);
>> +	qp->sq.max_inline = wqe_size;
>> +
>> +	wqe_size += sizeof(struct rxe_send_wqe);
> Where does this limit the user's request to RXE_MAX_WQE_SIZE ?

My understanding is that the user request can only specify sge's and/or 
inline data. The check for those is made in rxe_qp_chk_cap. Since max 
sge's and max inline data are constrained by RXE_MAX_WQE_SIZE the limit 
is enforced.

>
> I seem to recall the if the requested max can't be satisified then
> that is an EINVAL?
>
> And the init->cap should be updated with the actual allocation.

Since the user request for both (sge's and inline data) has been 
satisfied I decided not to update the values in case the return values 
are being checked. If you prefer that I update the values I can do that.

Shoaib

>
> So more like:
>
>          if (init->cap.max_send_sge > RXE_MAX_SGE ||
>             init->cap.max_inline_data > RXE_MAX_INLINE)
>              return -EINVAL;
>
> 	wqe_size = max_t(int, init->cap.max_sge * sizeof(struct ib_sge),
> 			 init->cap.max_inline_data)
>                     sizeof(struct rxe_send_wqe);
> 	qp->sq.max_sge = init->cap.max_send_sge = wqe_size/sizeof(struct ib_sge);
> 	qp->sq.max_inline = init->cap.max_inline_data = wqe_size;
> 	wqe_size += sizeof(struct rxe_send_wqe);
>
> Jason

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

* Re: [PATCH v3 2/2] SGE buffer and max_inline data must have same size
  2020-01-15 19:57     ` Rao Shoaib
@ 2020-01-15 20:05       ` Rao Shoaib
  2020-01-15 20:36       ` Jason Gunthorpe
  1 sibling, 0 replies; 7+ messages in thread
From: Rao Shoaib @ 2020-01-15 20:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: linux-rdma, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel


On 1/15/20 11:57 AM, Rao Shoaib wrote:
>
>> I seem to recall the if the requested max can't be satisified then
>> that is an EINVAL?
>>
>> And the init->cap should be updated with the actual allocation.
>
> Since the user request for both (sge's and inline data) has been 
> satisfied I decided not to update the values in case the return values 
> are being checked. If you prefer that I update the values I can do that.
>
> Shoaib
>
In my original v1 patch I did update init->cap, I must have overlooked 
it. I will resubmit the patch with that change once I hear back from you 
about the enforcement.

Shoaib


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

* Re: [PATCH v3 2/2] SGE buffer and max_inline data must have same size
  2020-01-15 19:57     ` Rao Shoaib
  2020-01-15 20:05       ` Rao Shoaib
@ 2020-01-15 20:36       ` Jason Gunthorpe
  1 sibling, 0 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2020-01-15 20:36 UTC (permalink / raw)
  To: Rao Shoaib
  Cc: linux-rdma, monis, dledford, sean.hefty, hal.rosenstock, linux-kernel

On Wed, Jan 15, 2020 at 11:57:08AM -0800, Rao Shoaib wrote:
> 
> On 1/15/20 10:27 AM, Jason Gunthorpe wrote:
> > On Mon, Jan 13, 2020 at 04:41:20PM -0800, rao Shoaib wrote:
> > > From: Rao Shoaib <rao.shoaib@oracle.com>
> > > 
> > > SGE buffer size and max_inline data should be same. Maximum of the
> > > two values requested is used.
> > > 
> > > Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
> > >   drivers/infiniband/sw/rxe/rxe_qp.c | 23 +++++++++++------------
> > >   1 file changed, 11 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
> > > index aeea994..41c669c 100644
> > > +++ b/drivers/infiniband/sw/rxe/rxe_qp.c
> > > @@ -235,18 +235,17 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
> > >   		return err;
> > >   	qp->sk->sk->sk_user_data = qp;
> > > -	qp->sq.max_wr		= init->cap.max_send_wr;
> > > -	qp->sq.max_sge		= init->cap.max_send_sge;
> > > -	qp->sq.max_inline	= init->cap.max_inline_data;
> > > -
> > > -	wqe_size = max_t(int, sizeof(struct rxe_send_wqe) +
> > > -			 qp->sq.max_sge * sizeof(struct ib_sge),
> > > -			 sizeof(struct rxe_send_wqe) +
> > > -			 qp->sq.max_inline);
> > > -
> > > -	qp->sq.queue = rxe_queue_init(rxe,
> > > -				      &qp->sq.max_wr,
> > > -				      wqe_size);
> > > +	wqe_size = max_t(int, init->cap.max_send_sge * sizeof(struct ib_sge),
> > > +			 init->cap.max_inline_data);
> > > +	qp->sq.max_sge = wqe_size/sizeof(struct ib_sge);
> > > +	qp->sq.max_inline = wqe_size;
> > > +
> > > +	wqe_size += sizeof(struct rxe_send_wqe);
> > Where does this limit the user's request to RXE_MAX_WQE_SIZE ?
> 
> My understanding is that the user request can only specify sge's and/or
> inline data. The check for those is made in rxe_qp_chk_cap. Since max sge's
> and max inline data are constrained by RXE_MAX_WQE_SIZE the limit is
> enforced.

Okay, that is fine, it is a bit obtuse because of how distant
rxe_qp_chk_cap() is from this function, lets just add a comment

> > I seem to recall the if the requested max can't be satisified then
> > that is an EINVAL?
> > 
> > And the init->cap should be updated with the actual allocation.
> 
> Since the user request for both (sge's and inline data) has been satisfied I
> decided not to update the values in case the return values are being
> checked. If you prefer that I update the values I can do that.

If the sizes are increased then the driver is supposed to return the
actual maximums.

It is easy, I will fix it.

Also, your patches don't apply cleanly. You need to send patches
against the rdma for-next tree

And subjects should start with some 'RDMA/rxe: ' tag

I fixed it all and applied to for-next

Thanks,
Jason

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14  0:41 [PATCH v3 0/2] rxe should use same buffer size for SGE's and inline data rao Shoaib
2020-01-14  0:41 ` [PATCH v3 1/2] Introduce maximum WQE size to check limits rao Shoaib
2020-01-14  0:41 ` [PATCH v3 2/2] SGE buffer and max_inline data must have same size rao Shoaib
2020-01-15 18:27   ` Jason Gunthorpe
2020-01-15 19:57     ` Rao Shoaib
2020-01-15 20:05       ` Rao Shoaib
2020-01-15 20:36       ` Jason Gunthorpe

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
	public-inbox-index linux-rdma

Example config snippet for mirrors

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