Skip to contentSkip to conversation

fcntl36: make sure write threads complete at least 1 loop

PATCH New Jan Stancek 2 participants 3 messages Feb 22, 2019 – Feb 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fcntl36: make sure write threads complete at least 1 loop

A failure has been reported while this test ran on a 1 CPU KVM guest with 4.20 kernel:
...
fcntl36.c:303: INFO: OFD r/w lock vs POSIX read lock fcntl36.c:360: FAIL: Unexpected data offset 3072 value 1

I wasn't able to reproduce it, to test the theory that one of write threads was given time on CPU only after loop_flag changed. Which means it wasn't able to complete a single iteration.

This patch makes sure that write threads make at least one iteration.

---
 testcases/kernel/syscalls/fcntl/fcntl36.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl36.c +4 -4
index 2942e4e6adc2..58a37e7bc562 100644
@@ -95,7 +95,7 @@ static void *fn_ofd_w(void *arg)
 		.l_pid    = 0,
 	};
 
-	while (loop_flag) {
+	do {
 
 		memset(buf, wt, pa->length);
 
@@ -113,7 +113,7 @@ static void *fn_ofd_w(void *arg)
 			wt = pa->cnt;
 
 		sched_yield();
-	}
+	} while (loop_flag);
 
 	pthread_barrier_wait(&barrier);
 	SAFE_CLOSE(fd);
@@ -134,7 +134,7 @@ static void *fn_posix_w(void *arg)
 		.l_len    = pa->length,
 	};
 
-	while (loop_flag) {
+	do {
 
 		memset(buf, wt, pa->length);
 
@@ -152,7 +152,7 @@ static void *fn_posix_w(void *arg)
 			wt = pa->cnt;
 
 		sched_yield();
-	}
+	} while (loop_flag);
 
 	pthread_barrier_wait(&barrier);
 	SAFE_CLOSE(fd);
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 fcntl36: make sure write threads complete at least 1 loop

Quoted 10 lines · Jan Stancek

A failure has been reported while this test ran on a 1 CPU KVM guest with 4.20 kernel:
...
fcntl36.c:303: INFO: OFD r/w lock vs POSIX read lock fcntl36.c:360: FAIL: Unexpected data offset 3072 value 1

I wasn't able to reproduce it, to test the theory that one of write threads was given time on CPU only after loop_flag changed. Which means it wasn't able to complete a single iteration.

Ack. Thanks!

Quoted 52 lines

This patch makes sure that write threads make at least one iteration.

---
 testcases/kernel/syscalls/fcntl/fcntl36.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl36.c +4 -4
index 2942e4e6adc2..58a37e7bc562 100644
@@ -95,7 +95,7 @@ static void *fn_ofd_w(void *arg)
 		.l_pid    = 0,
 	};
 
-	while (loop_flag) {
+	do {
 
 		memset(buf, wt, pa->length);
 
@@ -113,7 +113,7 @@ static void *fn_ofd_w(void *arg)
 			wt = pa->cnt;
 
 		sched_yield();
-	}
+	} while (loop_flag);
 
 	pthread_barrier_wait(&barrier);
 	SAFE_CLOSE(fd);
@@ -134,7 +134,7 @@ static void *fn_posix_w(void *arg)
 		.l_len    = pa->length,
 	};
 
-	while (loop_flag) {
+	do {
 
 		memset(buf, wt, pa->length);
 
@@ -152,7 +152,7 @@ static void *fn_posix_w(void *arg)
 			wt = pa->cnt;
 
 		sched_yield();
-	}
+	} while (loop_flag);
 
 	pthread_barrier_wait(&barrier);
 	SAFE_CLOSE(fd);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 1/1 fcntl36: make sure write threads complete at least 1 loop

----- Original Message -----

Quoted 7 lines · Jan Stancek
Quoted 6 lines

A failure has been reported while this test ran on a 1 CPU KVM guest with 4.20 kernel:
...
fcntl36.c:303: INFO: OFD r/w lock vs POSIX read lock fcntl36.c:360: FAIL: Unexpected data offset 3072 value 1

Quoted 7 lines
Quoted 4 lines

I wasn't able to reproduce it, to test the theory that one of write threads was given time on CPU only after loop_flag changed. Which means it wasn't able to complete a single iteration.

Ack. Thanks!

Pushed.

Regards,
Jan