public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround
@ 2025-09-22 10:49 Ricardo B. Marlière via ltp
  2025-09-22 10:49 ` [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion Ricardo B. Marlière via ltp
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ricardo B. Marlière via ltp @ 2025-09-22 10:49 UTC (permalink / raw)
  To: Linux Test Project; +Cc: Ricardo B. Marlière


---
Changes in v2:
- Split into two patches (Cyril)
- Correct wording (Cyril)
- Link to v1: https://lore.kernel.org/all/20250520-fixes-pthread_rwlock_rdlock-v1-1-402ee45114cc@suse.com

Signed-off-by: Ricardo B. Marlière <rbm@suse.com>

---
Ricardo B. Marlière (2):
      open_posix: pthread_rwlock_rdlock: Update second assertion
      open_posix: pthread_rwlock_rdlock: Add GLIBC workaround

 .../interfaces/pthread_rwlock_rdlock/2-1.c          | 21 ++++++++++++++-------
 .../interfaces/pthread_rwlock_rdlock/2-2.c          | 21 ++++++++++++++-------
 .../interfaces/pthread_rwlock_rdlock/2-3.c          | 13 +++++++------
 .../interfaces/pthread_rwlock_rdlock/assertions.xml | 15 ++++++++-------
 4 files changed, 43 insertions(+), 27 deletions(-)
---
base-commit: ba605cc9557ec86200f47efe36680a1da8cd7757
change-id: 20250922-fixes-pthread_rwlock_rdlock-ac6371da80b4

Best regards,
-- 
Ricardo B. Marlière <rbm@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion
  2025-09-22 10:49 [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround Ricardo B. Marlière via ltp
@ 2025-09-22 10:49 ` Ricardo B. Marlière via ltp
  2025-09-22 10:49 ` [LTP] [PATCH v2 2/2] open_posix: pthread_rwlock_rdlock: Add GLIBC workaround Ricardo B. Marlière via ltp
  2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
  2 siblings, 0 replies; 6+ messages in thread
From: Ricardo B. Marlière via ltp @ 2025-09-22 10:49 UTC (permalink / raw)
  To: Linux Test Project; +Cc: Ricardo B. Marlière

From: Ricardo B. Marlière <rbm@suse.com>

Link: https://austingroupbugs.net/view.php?id=1111
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
 .../conformance/interfaces/pthread_rwlock_rdlock/2-1.c    | 13 +++++++------
 .../conformance/interfaces/pthread_rwlock_rdlock/2-2.c    | 13 +++++++------
 .../conformance/interfaces/pthread_rwlock_rdlock/2-3.c    | 13 +++++++------
 .../interfaces/pthread_rwlock_rdlock/assertions.xml       | 15 ++++++++-------
 4 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
index 288eb3e3566abf26100f999d02081b5ef02a6694..fa57e64985ef46da143d3f323bb3c727eeb3db66 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
@@ -6,12 +6,13 @@
 
  * Test that pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
  *
- * 	If the Thread Execution Scheduling option is supported,
- *	and the threads involved in the lock are executing with the
- *	scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- *	acquire the lock if a writer holds the lock or if writers of
- *	higher or equal priority are blocked on the lock;
- *	otherwise, the calling thread shall acquire the lock.
+ *	If the Thread Execution Scheduling option is supported,
+ *	and the threads that hold or are blocked on the lock are
+ *	executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ *	the calling thread shall not acquire the lock if a writer
+ *	holds the lock or if the calling thread does not already hold
+ *	a read lock and writers of higher or equal priority are blocked
+ *	on the lock; otherwise, the calling thread shall acquire the lock.
  *
  * In this case, we test "higher priority writer block"
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
index 3593e4c7966bef183bc5979e296beff512196d47..f6ffddfbe417a7affdf1114b9cc2e97bc09f8fac 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
@@ -6,12 +6,13 @@
 
  * Test that pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
  *
- * 	If the Thread Execution Scheduling option is supported,
- *	and the threads involved in the lock are executing with the
- *	scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- *	acquire the lock if a writer holds the lock or if writers of
- *	higher or equal priority are blocked on the lock;
- *	otherwise, the calling thread shall acquire the lock.
+ *	If the Thread Execution Scheduling option is supported,
+ *	and the threads that hold or are blocked on the lock are
+ *	executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ *	the calling thread shall not acquire the lock if a writer
+ *	holds the lock or if the calling thread does not already hold
+ *	a read lock and writers of higher or equal priority are blocked
+ *	on the lock; otherwise, the calling thread shall acquire the lock.
  *
  * In this case, we test "equal priority writer block"
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c
index 40170dbb2d025ffda3693644c7d9aa4246f16bcf..aa1511bae3703efc92bc8569d7f4dc81f6219aa3 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c
@@ -6,12 +6,13 @@
 
  * Test that pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
  *
- * 	If the Thread Execution Scheduling option is supported,
- *	and the threads involved in the lock are executing with the
- *	scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- *	acquire the lock if a writer holds the lock or if writers of
- *	higher or equal priority are blocked on the lock;
- *	otherwise, the calling thread shall acquire the lock.
+ *	If the Thread Execution Scheduling option is supported,
+ *	and the threads that hold or are blocked on the lock are
+ *	executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ *	the calling thread shall not acquire the lock if a writer
+ *	holds the lock or if the calling thread does not already hold
+ *	a read lock and writers of higher or equal priority are blocked
+ *	on the lock; otherwise, the calling thread shall acquire the lock.
  *
  * In this case, reader has higher priority than the writer
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml
index 07263b3dedde488196037e7140fcaa367cc49f5c..deb318cb786a5299c20b846eabfbad1111cb24ed 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml
@@ -6,13 +6,14 @@
 	no writers blocked on the lock.
   </assertion>
 
-  <assertion id="2" tag="ref:XSH6:34768:34771">
- 	If the Thread Execution Scheduling option is supported,
-	and the threads involved in the lock are executing with the
-	scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
-	acquire the lock if a writer holds the lock or if writers of
-	higher or equal priority are blocked on the lock;
-	otherwise, the calling thread shall acquire the lock.
+  <assertion id="2" tag="ref:XSH8:{System Interfaces:pthread_rwlock_rdlock:DESCRIPTION}">
+	If the Thread Execution Scheduling option is supported,
+	and the threads that hold or are blocked on the lock are
+	executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+	the calling thread shall not acquire the lock if a writer
+	holds the lock or if the calling thread does not already hold
+	a read lock and writers of higher or equal priority are blocked
+	on the lock; otherwise, the calling thread shall acquire the lock.
   </assertion>
 
   <assertion id="3" tag="ref:XSH6:34772:34775">

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH v2 2/2] open_posix: pthread_rwlock_rdlock: Add GLIBC workaround
  2025-09-22 10:49 [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround Ricardo B. Marlière via ltp
  2025-09-22 10:49 ` [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion Ricardo B. Marlière via ltp
@ 2025-09-22 10:49 ` Ricardo B. Marlière via ltp
  2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
  2 siblings, 0 replies; 6+ messages in thread
From: Ricardo B. Marlière via ltp @ 2025-09-22 10:49 UTC (permalink / raw)
  To: Linux Test Project; +Cc: Ricardo B. Marlière

From: Ricardo B. Marlière <rbm@suse.com>

GNU/Linux does not support the POSIX standard with regards to the second
assertion of this test. Work around it by making use of the non-portable
flag PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=13701
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
 .../conformance/interfaces/pthread_rwlock_rdlock/2-1.c            | 8 +++++++-
 .../conformance/interfaces/pthread_rwlock_rdlock/2-2.c            | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
index fa57e64985ef46da143d3f323bb3c727eeb3db66..3b27a0bbbbdfaadf37fa94e129a937cdd9e986db 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
@@ -144,13 +144,19 @@ int main(void)
 	int cnt = 0;
 	pthread_t rd_thread, wr_thread;
 	int priority;
+	pthread_rwlockattr_t attr;
+
+	pthread_rwlockattr_init(&attr);
+#ifdef __GNUC__
+	pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+#endif
 
 	/* main thread needs to have the highest priority */
 	priority = sched_get_priority_min(TRD_POLICY) + 2;
 	set_priority(pthread_self(), TRD_POLICY, priority);
 	printf("main: has priority: %d\n", priority);
 
-	if (pthread_rwlock_init(&rwlock, NULL) != 0) {
+	if (pthread_rwlock_init(&rwlock, &attr) != 0) {
 		printf("main: Error at pthread_rwlock_init()\n");
 		return PTS_UNRESOLVED;
 	}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
index f6ffddfbe417a7affdf1114b9cc2e97bc09f8fac..4799b1e885caab509fd31173c34ae89beace68e6 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
@@ -144,12 +144,18 @@ int main(void)
 	int cnt = 0;
 	pthread_t rd_thread, wr_thread;
 	int priority;
+	pthread_rwlockattr_t attr;
+
+	pthread_rwlockattr_init(&attr);
+#ifdef __GNUC__
+	pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+#endif
 
 	/* main thread needs to have the highest priority */
 	priority = sched_get_priority_min(TRD_POLICY) + 2;
 	set_priority(pthread_self(), TRD_POLICY, priority);
 
-	if (pthread_rwlock_init(&rwlock, NULL) != 0) {
+	if (pthread_rwlock_init(&rwlock, &attr) != 0) {
 		printf("main: Error at pthread_rwlock_init()\n");
 		return PTS_UNRESOLVED;
 	}

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround
  2025-09-22 10:49 [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround Ricardo B. Marlière via ltp
  2025-09-22 10:49 ` [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion Ricardo B. Marlière via ltp
  2025-09-22 10:49 ` [LTP] [PATCH v2 2/2] open_posix: pthread_rwlock_rdlock: Add GLIBC workaround Ricardo B. Marlière via ltp
@ 2025-09-22 14:15 ` Cyril Hrubis
  2025-09-22 15:12   ` Ricardo B. Marlière via ltp
  2025-09-26 14:48   ` Cyril Hrubis
  2 siblings, 2 replies; 6+ messages in thread
From: Cyril Hrubis @ 2025-09-22 14:15 UTC (permalink / raw)
  To: Ricardo B. Marlière; +Cc: Linux Test Project

Hi!
This version looks good:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround
  2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
@ 2025-09-22 15:12   ` Ricardo B. Marlière via ltp
  2025-09-26 14:48   ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Ricardo B. Marlière via ltp @ 2025-09-22 15:12 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Linux Test Project

On Mon Sep 22, 2025 at 11:15 AM -03, Cyril Hrubis wrote:
> Hi!
> This version looks good:
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Nice, thanks for the review and help!
-	RBM


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround
  2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
  2025-09-22 15:12   ` Ricardo B. Marlière via ltp
@ 2025-09-26 14:48   ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2025-09-26 14:48 UTC (permalink / raw)
  To: Ricardo B. Marlière; +Cc: Linux Test Project

Hi!
> This version looks good:
> 
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Both patches pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2025-09-26 14:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 10:49 [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround Ricardo B. Marlière via ltp
2025-09-22 10:49 ` [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion Ricardo B. Marlière via ltp
2025-09-22 10:49 ` [LTP] [PATCH v2 2/2] open_posix: pthread_rwlock_rdlock: Add GLIBC workaround Ricardo B. Marlière via ltp
2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
2025-09-22 15:12   ` Ricardo B. Marlière via ltp
2025-09-26 14:48   ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox