All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH perftest] Avoid configuring the MRs with 1's
@ 2017-02-26 12:21 Ram Amrani
       [not found] ` <1488111691-23620-1-git-send-email-Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
       [not found] ` <HE1PR05MB11618D7789611C3526FBB791B5540@HE1PR05MB1161.eurprd05.prod.outlook.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Ram Amrani @ 2017-02-26 12:21 UTC (permalink / raw)
  To: gilr-VPRAkNaXOzVWk0Htik3J/w
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA, Ram Amrani

Avoid setting the value '1' in the MR. If this happens in a write latency
test then the server will send two consecutive packets, regardless of the
client's state. This can cause the application to hang - If the client
reaches the busy-wait loop after the second write then it'll keep waiting
for the value of the first write forever.

Signed-off-by: Ram Amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
---
 src/perftest_resources.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/perftest_resources.c b/src/perftest_resources.c
index afae5f2..dc768c4 100755
--- a/src/perftest_resources.c
+++ b/src/perftest_resources.c
@@ -1252,7 +1252,11 @@ int create_single_mr(struct pingpong_context *ctx, struct perftest_parameters *u
 	/* Initialize buffer with random numbers */
 	srand(time(NULL));
 	for (i = 0; i < ctx->buff_size; i++) {
-		((char*)ctx->buf[qp_index])[i] = (char)rand();
+		/* prevent the value 1 from being written into the buffer so in,
+		 * e.g., write latency test, the server won't send two packets
+		 * consecutively without receiving a packet from the client first.
+		 */ 
+		((char*)ctx->buf[qp_index])[i] = 2 + ((char)rand() % 255);
 	}
 
 	return 0;
-- 
1.8.3.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] 5+ messages in thread

* Re: [PATCH perftest] Avoid configuring the MRs with 1's
       [not found] ` <1488111691-23620-1-git-send-email-Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
@ 2017-02-28 20:00   ` Leon Romanovsky
       [not found]     ` <20170228200040.GD2754-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2017-02-28 20:00 UTC (permalink / raw)
  To: zoharb-VPRAkNaXOzVWk0Htik3J/w, Ram Amrani
  Cc: gilr-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]

On Sun, Feb 26, 2017 at 02:21:31PM +0200, Ram Amrani wrote:
> Avoid setting the value '1' in the MR. If this happens in a write latency
> test then the server will send two consecutive packets, regardless of the
> client's state. This can cause the application to hang - If the client
> reaches the busy-wait loop after the second write then it'll keep waiting
> for the value of the first write forever.
>
> Signed-off-by: Ram Amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
> ---
>  src/perftest_resources.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/perftest_resources.c b/src/perftest_resources.c
> index afae5f2..dc768c4 100755
> --- a/src/perftest_resources.c
> +++ b/src/perftest_resources.c
> @@ -1252,7 +1252,11 @@ int create_single_mr(struct pingpong_context *ctx, struct perftest_parameters *u
>  	/* Initialize buffer with random numbers */
>  	srand(time(NULL));
>  	for (i = 0; i < ctx->buff_size; i++) {
> -		((char*)ctx->buf[qp_index])[i] = (char)rand();
> +		/* prevent the value 1 from being written into the buffer so in,
> +		 * e.g., write latency test, the server won't send two packets
> +		 * consecutively without receiving a packet from the client first.
> +		 */
> +		((char*)ctx->buf[qp_index])[i] = 2 + ((char)rand() % 255);
>  	}
>
>  	return 0;

Zohar?

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* RE: [PATCH perftest] Avoid configuring the MRs with 1's
       [not found]     ` <20170228200040.GD2754-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
@ 2017-03-01  9:03       ` Zohar Ben Aharon
  0 siblings, 0 replies; 5+ messages in thread
From: Zohar Ben Aharon @ 2017-03-01  9:03 UTC (permalink / raw)
  To: Leon Romanovsky, Ram Amrani
  Cc: Gil Rockah, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA

Will push it by the EOW

-----Original Message-----
From: Leon Romanovsky [mailto:leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org] 
Sent: Tuesday, February 28, 2017 10:01 PM
To: Zohar Ben Aharon <zoharb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>; Ram Amrani <Ram.Amrani@cavium.com>
Cc: Gil Rockah <gilr-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>; linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Ariel.Elior@cavium.com
Subject: Re: [PATCH perftest] Avoid configuring the MRs with 1's

On Sun, Feb 26, 2017 at 02:21:31PM +0200, Ram Amrani wrote:
> Avoid setting the value '1' in the MR. If this happens in a write 
> latency test then the server will send two consecutive packets, 
> regardless of the client's state. This can cause the application to 
> hang - If the client reaches the busy-wait loop after the second write 
> then it'll keep waiting for the value of the first write forever.
>
> Signed-off-by: Ram Amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
> ---
>  src/perftest_resources.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/perftest_resources.c b/src/perftest_resources.c index 
> afae5f2..dc768c4 100755
> --- a/src/perftest_resources.c
> +++ b/src/perftest_resources.c
> @@ -1252,7 +1252,11 @@ int create_single_mr(struct pingpong_context *ctx, struct perftest_parameters *u
>  	/* Initialize buffer with random numbers */
>  	srand(time(NULL));
>  	for (i = 0; i < ctx->buff_size; i++) {
> -		((char*)ctx->buf[qp_index])[i] = (char)rand();
> +		/* prevent the value 1 from being written into the buffer so in,
> +		 * e.g., write latency test, the server won't send two packets
> +		 * consecutively without receiving a packet from the client first.
> +		 */
> +		((char*)ctx->buf[qp_index])[i] = 2 + ((char)rand() % 255);
>  	}
>
>  	return 0;

Zohar?

> --
> 1.8.3.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
--
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] 5+ messages in thread

* RE: [PATCH perftest] Avoid configuring the MRs with 1's
       [not found]     ` <AM5PR0501MB2532CD619D600768E58EB1EEA92D0-Z3o2H//EDN6VqDs954T/B8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
@ 2017-03-05 15:14       ` Amrani, Ram
  0 siblings, 0 replies; 5+ messages in thread
From: Amrani, Ram @ 2017-03-05 15:14 UTC (permalink / raw)
  To: Zohar Ben Aharon, Gil Rockah
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Elior, Ariel

>Hi Ram , 
>I applied your patch and  start to review,
>did you aware that :
>
>       ((char*)ctx->buf[qp_index])[i] = 2 + ((char)rand() % 255);
>       
>Will put values from 2-257 ? 
>       
>Thanks,
>
>Zohar Ben Aharon

X % 255 yields a number between 0 and 254.
Adding 2 to that we get a number between 2 and 256.
Since this is a char the actual number stored is in the range 2 and 255 or 0 (for 256).

HOWEVER, there's still a bug in this line.

(char) should be converted to (unsigned char)

Explanation:
Rand returns a number of 0..<some positive value>
That can turn into 0xff when casting to char. This 0xff *remains* 0xff after the modulo because it is a negative number!
And 0xff+2==1 and the bug occurs again.

I should have verified...

Will send you a fix shortly.

Thank,
Ram



--
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] 5+ messages in thread

* RE: [PATCH perftest] Avoid configuring the MRs with 1's
       [not found]   ` <AM5PR0501MB2532CD619D600768E58EB1EEA92D0@AM5PR0501MB2532.eurprd05.prod.outlook.com>
       [not found]     ` <AM5PR0501MB2532CD619D600768E58EB1EEA92D0-Z3o2H//EDN6VqDs954T/B8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
@ 2017-03-05 15:16     ` Amrani, Ram
  1 sibling, 0 replies; 5+ messages in thread
From: Amrani, Ram @ 2017-03-05 15:16 UTC (permalink / raw)
  To: Zohar Ben Aharon, Gil Rockah
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Elior, Ariel

> I should have verified...
> 

BTW, I did verify, just not with 'c' but in another environment that did
not notice this subtlety.

Ram

--
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] 5+ messages in thread

end of thread, other threads:[~2017-03-05 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-26 12:21 [PATCH perftest] Avoid configuring the MRs with 1's Ram Amrani
     [not found] ` <1488111691-23620-1-git-send-email-Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
2017-02-28 20:00   ` Leon Romanovsky
     [not found]     ` <20170228200040.GD2754-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-01  9:03       ` Zohar Ben Aharon
     [not found] ` <HE1PR05MB11618D7789611C3526FBB791B5540@HE1PR05MB1161.eurprd05.prod.outlook.com>
     [not found]   ` <AM5PR0501MB2532CD619D600768E58EB1EEA92D0@AM5PR0501MB2532.eurprd05.prod.outlook.com>
     [not found]     ` <AM5PR0501MB2532CD619D600768E58EB1EEA92D0-Z3o2H//EDN6VqDs954T/B8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-03-05 15:14       ` Amrani, Ram
2017-03-05 15:16     ` Amrani, Ram

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.