Skip to contentSkip to conversation

selftests/bpf: adding delay in socketmap_listen to reduce flakyness

PATCH Applied Yucong Sun 4 participants 5 messages Aug 19, 2021

Subsystems (3)
lore
Share & tools
lore

Yucong Sun

author
#0 lore raw

PATCH 1/1 selftests/bpf: adding delay in socketmap_listen to reduce flakyness

This patch adds a 1ms delay to reduce flakyness of the test.

---
 .../selftests/bpf/prog_tests/sockmap_listen.c        | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +9 -3
index afa14fb66f08..6a5df28f9a3d 100644
@@ -1603,8 +1603,10 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
 again:
 	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
 	if (n < 0) {
-		if (errno == EAGAIN && retries--)
+		if (errno == EAGAIN && retries--) {
+			usleep(1000);
 			goto again;
+		}
 		FAIL_ERRNO("%s: read", log_prefix);
 	}
 	if (n == 0)
@@ -1776,8 +1778,10 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
 again:
 	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
 	if (n < 0) {
-		if (errno == EAGAIN && retries--)
+		if (errno == EAGAIN && retries--) {
+			usleep(1000);
 			goto again;
+		}
 		FAIL_ERRNO("%s: read", log_prefix);
 	}
 	if (n == 0)
@@ -1869,8 +1873,10 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
 again:
 	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
 	if (n < 0) {
-		if (errno == EAGAIN && retries--)
+		if (errno == EAGAIN && retries--) {
+			usleep(1000);
 			goto again;
+		}
 		FAIL_ERRNO("%s: read", log_prefix);
 	}
 	if (n == 0)
Signature · 1 line
2.30.2
#1 lore raw
Quoted 5 lines · Yucong Sun

This patch adds a 1ms delay to reduce flakyness of the test.

---

Any reasons to not implement exponential back-off, like we did for test_maps?

Quoted 46 lines
 .../selftests/bpf/prog_tests/sockmap_listen.c        | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +9 -4
index afa14fb66f08..6a5df28f9a3d 100644
@@ -1603,8 +1603,10 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
@@ -1776,8 +1778,10 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
@@ -1869,8 +1873,10 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
--

2.30.2

#2 lore raw
Quoted 9 lines · Andrii Nakryiko
Quoted 5 lines · Yucong Sun

This patch adds a 1ms delay to reduce flakyness of the test.

---

Any reasons to not implement exponential back-off, like we did for test_maps?

for simplicity, since there are no contention involved here I figured we don’t need random delay and back-offs.

(sorry for resending, I was fooled by the mobile gmail client that it doesn't do plain text).

Quoted 47 lines
Quoted 47 lines
 .../selftests/bpf/prog_tests/sockmap_listen.c        | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +9 -4
index afa14fb66f08..6a5df28f9a3d 100644
@@ -1603,8 +1603,10 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
@@ -1776,8 +1778,10 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
@@ -1869,8 +1873,10 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
--

2.30.2

#3 lore raw
Quoted 8 lines · On Thu, Aug 19, 2021 at 12:16 PM [email protected] <[email protected]>…
Quoted 5 lines · Andrii Nakryiko
Quoted 3 lines · Yucong Sun

This patch adds a 1ms delay to reduce flakyness of the test.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

---

Any reasons to not implement exponential back-off, like we did for test_maps?

for simplicity, since there are no contention involved here I figured we don’t need random delay and back-offs.

Alright, it's an improvement anyways. Let's see if it still causes problem. Applied to bpf-next, thanks!

Quoted 4 lines

(sorry for resending, I was fooled by the mobile gmail client that it doesn't do plain text).

AFAIK, mobile client doesn't support plain text

Quoted 48 lines
Quoted 48 lines
Quoted 48 lines

 .../selftests/bpf/prog_tests/sockmap_listen.c        | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +9 -4
index afa14fb66f08..6a5df28f9a3d 100644
@@ -1603,8 +1603,10 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
@@ -1776,8 +1778,10 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
@@ -1869,8 +1873,10 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
 again:
        n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
        if (n < 0) {
-               if (errno == EAGAIN && retries--)
+               if (errno == EAGAIN && retries--) {
+                       usleep(1000);
                        goto again;
+               }
                FAIL_ERRNO("%s: read", log_prefix);
        }
        if (n == 0)
--

2.30.2

#4 lore raw
In reply to Yucong Sun
This patch was applied to bpf/bpf-next.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

Quoted 6 lines · On Thu, 19 Aug 2021 09:36:09 -0700 you wrote:

This patch adds a 1ms delay to reduce flakyness of the test.

---
 .../selftests/bpf/prog_tests/sockmap_listen.c        | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Here is the summary with links:
- [bpf-next] selftests/bpf: adding delay in socketmap_listen to reduce flakyness

    https://git.kernel.org/bpf/bpf-next/c/3666b167ea68

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html