All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] register_to_trap(): Increase number of iterations from 3 to 5
@ 2017-12-08 17:22 Bart Van Assche
       [not found] ` <20171208172237.312-1-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2017-12-08 17:22 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Bart Van Assche, Hal Rosenstock, Nicolas Morey-Chaisemartin

Master SM changes can take more than three seconds. Hence increase
the time during which to wait for a master SM to appear from 3 to 5
seconds.

Signed-off-by: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
Cc: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Cc: Nicolas Morey-Chaisemartin <NMoreyChaisemartin-l3A5Bk7waGM@public.gmane.org>
---
 srp_daemon/srp_handle_traps.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/srp_daemon/srp_handle_traps.c b/srp_daemon/srp_handle_traps.c
index 6d94634ef6df..dda746a5c69d 100644
--- a/srp_daemon/srp_handle_traps.c
+++ b/srp_daemon/srp_handle_traps.c
@@ -550,8 +550,8 @@ static int register_to_trap(struct sync_resources *sync_res,
 	struct ibv_sge sg;
 	struct ibv_send_wr *_bad_wr = NULL;
 	struct ibv_send_wr **bad_wr = &_bad_wr;
-	int counter = 0;
-	int rc = 0;
+	int counter;
+	int rc;
 	int ret;
 	long long unsigned comp_mask = 0;
 
@@ -609,7 +609,7 @@ static int register_to_trap(struct sync_resources *sync_res,
 	p_sa_mad->comp_mask = htobe64(comp_mask);
 	pr_debug("comp_mask: %llx\n", comp_mask);
 
-	do {
+	for (counter = 5, rc = 0; counter > 0 && rc == 0; counter--) {
 		pthread_mutex_lock(res->mad_buffer_mutex);
 		res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty
 		pthread_mutex_unlock(res->mad_buffer_mutex);
@@ -640,10 +640,9 @@ static int register_to_trap(struct sync_resources *sync_res,
 			}
 			pthread_mutex_unlock(res->mad_buffer_mutex);
 		} while (rc == 2); // while old response.
+	}
 
-	} while (rc == 0 && ++counter < 3);
-
-	if (counter==3) {
+	if (counter == 0) {
 		pr_err("No response to inform info registration\n");
 		return -EAGAIN;
 	}
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] register_to_trap(): Increase number of iterations from 3 to 5
       [not found] ` <20171208172237.312-1-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
@ 2017-12-08 17:38   ` Hal Rosenstock
       [not found]     ` <c92fa8ad-7d15-29fa-4c09-b7593e7160cf-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Hal Rosenstock @ 2017-12-08 17:38 UTC (permalink / raw)
  To: Bart Van Assche, linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Nicolas Morey-Chaisemartin

On 12/8/2017 12:22 PM, Bart Van Assche wrote:
> Master SM changes can take more than three seconds. Hence increase
> the time during which to wait for a master SM to appear from 3 to 5
> seconds.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
> Cc: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
> Cc: Nicolas Morey-Chaisemartin <NMoreyChaisemartin-l3A5Bk7waGM@public.gmane.org>
> ---
>  srp_daemon/srp_handle_traps.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/srp_daemon/srp_handle_traps.c b/srp_daemon/srp_handle_traps.c
> index 6d94634ef6df..dda746a5c69d 100644
> --- a/srp_daemon/srp_handle_traps.c
> +++ b/srp_daemon/srp_handle_traps.c
> @@ -550,8 +550,8 @@ static int register_to_trap(struct sync_resources *sync_res,
>  	struct ibv_sge sg;
>  	struct ibv_send_wr *_bad_wr = NULL;
>  	struct ibv_send_wr **bad_wr = &_bad_wr;
> -	int counter = 0;
> -	int rc = 0;
> +	int counter;
> +	int rc;
>  	int ret;
>  	long long unsigned comp_mask = 0;
>  
> @@ -609,7 +609,7 @@ static int register_to_trap(struct sync_resources *sync_res,
>  	p_sa_mad->comp_mask = htobe64(comp_mask);
>  	pr_debug("comp_mask: %llx\n", comp_mask);
>  
> -	do {
> +	for (counter = 5, rc = 0; counter > 0 && rc == 0; counter--) {
>  		pthread_mutex_lock(res->mad_buffer_mutex);
>  		res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty
>  		pthread_mutex_unlock(res->mad_buffer_mutex);
> @@ -640,10 +640,9 @@ static int register_to_trap(struct sync_resources *sync_res,
>  			}
>  			pthread_mutex_unlock(res->mad_buffer_mutex);
>  		} while (rc == 2); // while old response.
> +	}
>  
> -	} while (rc == 0 && ++counter < 3);
> -
> -	if (counter==3) {
> +	if (counter == 0) {
>  		pr_err("No response to inform info registration\n");
>  		return -EAGAIN;
>  	}
> 

Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] register_to_trap(): Increase number of iterations from 3 to 5
       [not found]     ` <c92fa8ad-7d15-29fa-4c09-b7593e7160cf-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2017-12-08 18:17       ` Hal Rosenstock
       [not found]         ` <e06c1dc0-509e-3fc0-4b0d-49d695a1421e-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Hal Rosenstock @ 2017-12-08 18:17 UTC (permalink / raw)
  To: Bart Van Assche, linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Nicolas Morey-Chaisemartin

On 12/8/2017 12:38 PM, Hal Rosenstock wrote:
> On 12/8/2017 12:22 PM, Bart Van Assche wrote:
>> Master SM changes can take more than three seconds. Hence increase
>> the time during which to wait for a master SM to appear from 3 to 5
>> seconds.
>>
>> Signed-off-by: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
>> Cc: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
>> Cc: Nicolas Morey-Chaisemartin <NMoreyChaisemartin-l3A5Bk7waGM@public.gmane.org>
>> ---
>>  srp_daemon/srp_handle_traps.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/srp_daemon/srp_handle_traps.c b/srp_daemon/srp_handle_traps.c
>> index 6d94634ef6df..dda746a5c69d 100644
>> --- a/srp_daemon/srp_handle_traps.c
>> +++ b/srp_daemon/srp_handle_traps.c
>> @@ -550,8 +550,8 @@ static int register_to_trap(struct sync_resources *sync_res,
>>  	struct ibv_sge sg;
>>  	struct ibv_send_wr *_bad_wr = NULL;
>>  	struct ibv_send_wr **bad_wr = &_bad_wr;
>> -	int counter = 0;
>> -	int rc = 0;
>> +	int counter;
>> +	int rc;
>>  	int ret;
>>  	long long unsigned comp_mask = 0;
>>  
>> @@ -609,7 +609,7 @@ static int register_to_trap(struct sync_resources *sync_res,
>>  	p_sa_mad->comp_mask = htobe64(comp_mask);
>>  	pr_debug("comp_mask: %llx\n", comp_mask);
>>  
>> -	do {
>> +	for (counter = 5, rc = 0; counter > 0 && rc == 0; counter--) {
>>  		pthread_mutex_lock(res->mad_buffer_mutex);
>>  		res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty
>>  		pthread_mutex_unlock(res->mad_buffer_mutex);
>> @@ -640,10 +640,9 @@ static int register_to_trap(struct sync_resources *sync_res,
>>  			}
>>  			pthread_mutex_unlock(res->mad_buffer_mutex);
>>  		} while (rc == 2); // while old response.
>> +	}
>>  
>> -	} while (rc == 0 && ++counter < 3);
>> -
>> -	if (counter==3) {
>> +	if (counter == 0) {
>>  		pr_err("No response to inform info registration\n");
>>  		return -EAGAIN;
>>  	} 
>>
> 
> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> 

Given what Nicolas wrote, maybe this should be split into 2 patches with
first being refactoring but not changing counter and leave the counter
increase for Nicolas.

-- Hal
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] register_to_trap(): Increase number of iterations from 3 to 5
       [not found]         ` <e06c1dc0-509e-3fc0-4b0d-49d695a1421e-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2017-12-08 18:35           ` Bart Van Assche
       [not found]             ` <1512758149.26126.3.camel-Sjgp3cTcYWE@public.gmane.org>
  2017-12-11  9:20           ` Nicolas Morey-Chaisemartin
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2017-12-08 18:35 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb
  Cc: NMoreyChaisemartin-l3A5Bk7waGM

On Fri, 2017-12-08 at 13:17 -0500, Hal Rosenstock wrote:
> Given what Nicolas wrote, maybe this should be split into 2 patches with
> first being refactoring but not changing counter and leave the counter
> increase for Nicolas.

Hello Hal,

How about the patch below?

Thanks,

Bart.


[PATCH for rdma-core] register_to_trap(): Specify number of iterations once

Rearrange the loop in register_to_trap() and also the if-statement
after that loop such that the number of iterations only occurs once.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Hal Rosenstock <hal@dev.mellanox.co.il>
Cc: Nicolas Morey-Chaisemartin <NMoreyChaisemartin@suse.de>
---
 srp_daemon/srp_handle_traps.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/srp_daemon/srp_handle_traps.c b/srp_daemon/srp_handle_traps.c
index 6d94634ef6df..6b36b15cc84c 100644
--- a/srp_daemon/srp_handle_traps.c
+++ b/srp_daemon/srp_handle_traps.c
@@ -550,8 +550,8 @@ static int register_to_trap(struct sync_resources *sync_res,
 	struct ibv_sge sg;
 	struct ibv_send_wr *_bad_wr = NULL;
 	struct ibv_send_wr **bad_wr = &_bad_wr;
-	int counter = 0;
-	int rc = 0;
+	int counter;
+	int rc;
 	int ret;
 	long long unsigned comp_mask = 0;
 
@@ -609,7 +609,7 @@ static int register_to_trap(struct sync_resources *sync_res,
 	p_sa_mad->comp_mask = htobe64(comp_mask);
 	pr_debug("comp_mask: %llx\n", comp_mask);
 
-	do {
+	for (counter = 3, rc = 0; counter > 0 && rc == 0; counter--) {
 		pthread_mutex_lock(res->mad_buffer_mutex);
 		res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty
 		pthread_mutex_unlock(res->mad_buffer_mutex);
@@ -640,10 +640,9 @@ static int register_to_trap(struct sync_resources *sync_res,
 			}
 			pthread_mutex_unlock(res->mad_buffer_mutex);
 		} while (rc == 2); // while old response.
+	}
 
-	} while (rc == 0 && ++counter < 3);
-
-	if (counter==3) {
+	if (counter == 0) {
 		pr_err("No response to inform info registration\n");
 		return -EAGAIN;
 	}
-- 
2.15.1

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

* Re: [PATCH] register_to_trap(): Increase number of iterations from 3 to 5
       [not found]             ` <1512758149.26126.3.camel-Sjgp3cTcYWE@public.gmane.org>
@ 2017-12-08 18:59               ` Hal Rosenstock
  0 siblings, 0 replies; 6+ messages in thread
From: Hal Rosenstock @ 2017-12-08 18:59 UTC (permalink / raw)
  To: Bart Van Assche, linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: NMoreyChaisemartin-l3A5Bk7waGM

On 12/8/2017 1:35 PM, Bart Van Assche wrote:
> On Fri, 2017-12-08 at 13:17 -0500, Hal Rosenstock wrote:
>> Given what Nicolas wrote, maybe this should be split into 2 patches with
>> first being refactoring but not changing counter and leave the counter
>> increase for Nicolas.
> 
> Hello Hal,
> 
> How about the patch below?
> 
> Thanks,
> 
> Bart.
> 
> 
> [PATCH for rdma-core] register_to_trap(): Specify number of iterations once
> 
> Rearrange the loop in register_to_trap() and also the if-statement
> after that loop such that the number of iterations only occurs once.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
> Cc: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
> Cc: Nicolas Morey-Chaisemartin <NMoreyChaisemartin-l3A5Bk7waGM@public.gmane.org>
> ---
>  srp_daemon/srp_handle_traps.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/srp_daemon/srp_handle_traps.c b/srp_daemon/srp_handle_traps.c
> index 6d94634ef6df..6b36b15cc84c 100644
> --- a/srp_daemon/srp_handle_traps.c
> +++ b/srp_daemon/srp_handle_traps.c
> @@ -550,8 +550,8 @@ static int register_to_trap(struct sync_resources *sync_res,
>  	struct ibv_sge sg;
>  	struct ibv_send_wr *_bad_wr = NULL;
>  	struct ibv_send_wr **bad_wr = &_bad_wr;
> -	int counter = 0;
> -	int rc = 0;
> +	int counter;
> +	int rc;
>  	int ret;
>  	long long unsigned comp_mask = 0;
>  
> @@ -609,7 +609,7 @@ static int register_to_trap(struct sync_resources *sync_res,
>  	p_sa_mad->comp_mask = htobe64(comp_mask);
>  	pr_debug("comp_mask: %llx\n", comp_mask);
>  
> -	do {
> +	for (counter = 3, rc = 0; counter > 0 && rc == 0; counter--) {
>  		pthread_mutex_lock(res->mad_buffer_mutex);
>  		res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty
>  		pthread_mutex_unlock(res->mad_buffer_mutex);
> @@ -640,10 +640,9 @@ static int register_to_trap(struct sync_resources *sync_res,
>  			}
>  			pthread_mutex_unlock(res->mad_buffer_mutex);
>  		} while (rc == 2); // while old response.
> +	}
>  
> -	} while (rc == 0 && ++counter < 3);
> -
> -	if (counter==3) {
> +	if (counter == 0) {
>  		pr_err("No response to inform info registration\n");
>  		return -EAGAIN;
>  	}
> 

Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] register_to_trap(): Increase number of iterations from 3 to 5
       [not found]         ` <e06c1dc0-509e-3fc0-4b0d-49d695a1421e-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  2017-12-08 18:35           ` Bart Van Assche
@ 2017-12-11  9:20           ` Nicolas Morey-Chaisemartin
  1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Morey-Chaisemartin @ 2017-12-11  9:20 UTC (permalink / raw)
  To: Hal Rosenstock, Bart Van Assche, linux-rdma-u79uwXL29TY76Z2rM5mHXA



Le 08/12/2017 à 19:17, Hal Rosenstock a écrit :
> On 12/8/2017 12:38 PM, Hal Rosenstock wrote:
>> On 12/8/2017 12:22 PM, Bart Van Assche wrote:
>>> Master SM changes can take more than three seconds. Hence increase
>>> the time during which to wait for a master SM to appear from 3 to 5
>>> seconds.
>>>
>>> Signed-off-by: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
>>> Cc: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
>>> Cc: Nicolas Morey-Chaisemartin <NMoreyChaisemartin-l3A5Bk7waGM@public.gmane.org>
>>> ---
>>>  srp_daemon/srp_handle_traps.c | 11 +++++------
>>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/srp_daemon/srp_handle_traps.c b/srp_daemon/srp_handle_traps.c
>>> index 6d94634ef6df..dda746a5c69d 100644
>>> --- a/srp_daemon/srp_handle_traps.c
>>> +++ b/srp_daemon/srp_handle_traps.c
>>> @@ -550,8 +550,8 @@ static int register_to_trap(struct sync_resources *sync_res,
>>>  	struct ibv_sge sg;
>>>  	struct ibv_send_wr *_bad_wr = NULL;
>>>  	struct ibv_send_wr **bad_wr = &_bad_wr;
>>> -	int counter = 0;
>>> -	int rc = 0;
>>> +	int counter;
>>> +	int rc;
>>>  	int ret;
>>>  	long long unsigned comp_mask = 0;
>>>  
>>> @@ -609,7 +609,7 @@ static int register_to_trap(struct sync_resources *sync_res,
>>>  	p_sa_mad->comp_mask = htobe64(comp_mask);
>>>  	pr_debug("comp_mask: %llx\n", comp_mask);
>>>  
>>> -	do {
>>> +	for (counter = 5, rc = 0; counter > 0 && rc == 0; counter--) {
>>>  		pthread_mutex_lock(res->mad_buffer_mutex);
>>>  		res->mad_buffer->mad_hdr.base_version = 0; // flag that the buffer is empty
>>>  		pthread_mutex_unlock(res->mad_buffer_mutex);
>>> @@ -640,10 +640,9 @@ static int register_to_trap(struct sync_resources *sync_res,
>>>  			}
>>>  			pthread_mutex_unlock(res->mad_buffer_mutex);
>>>  		} while (rc == 2); // while old response.
>>> +	}
>>>  
>>> -	} while (rc == 0 && ++counter < 3);
>>> -
>>> -	if (counter==3) {
>>> +	if (counter == 0) {
>>>  		pr_err("No response to inform info registration\n");
>>>  		return -EAGAIN;
>>>  	} 
>>>
>> Reviewed-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>>
> Given what Nicolas wrote, maybe this should be split into 2 patches with
> first being refactoring but not changing counter and leave the counter
> increase for Nicolas.
>
> -- Hal

Yep. I confirm the fix was partly due to the desync between the counter loop and the test for the error message.
Your next patch (cleanup without changing counter to 5) makes sense though.
I'll send an updated fix for my issue as soon as I have one !

Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-12-11  9:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08 17:22 [PATCH] register_to_trap(): Increase number of iterations from 3 to 5 Bart Van Assche
     [not found] ` <20171208172237.312-1-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
2017-12-08 17:38   ` Hal Rosenstock
     [not found]     ` <c92fa8ad-7d15-29fa-4c09-b7593e7160cf-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2017-12-08 18:17       ` Hal Rosenstock
     [not found]         ` <e06c1dc0-509e-3fc0-4b0d-49d695a1421e-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2017-12-08 18:35           ` Bart Van Assche
     [not found]             ` <1512758149.26126.3.camel-Sjgp3cTcYWE@public.gmane.org>
2017-12-08 18:59               ` Hal Rosenstock
2017-12-11  9:20           ` Nicolas Morey-Chaisemartin

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.