All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust
@ 2022-11-18 15:42 Florian Bezdeka
  2022-11-21  9:16 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Bezdeka @ 2022-11-18 15:42 UTC (permalink / raw)
  To: xenomai; +Cc: jan.kiszka, Florian Bezdeka

With recent glibc (at least 2.34), autoconf fails to detect
pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So
switch to pthread_mutexattr_setrobust and only fall back to _np when
needed.

This is a backport of the following commits from stable 3.2:

746cbeb6ccc0 ("lib: Switch to pthread_mutexattr_setrobust")
3f85c174e297 ("lib: Fix fallback signature of pthread_mutexattr_setrobust")
2d947e6fe3f8 ("lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub")

Backporting allows the stable 3.0 branch to be build with the latest
Debian toolchain, so we don't need a special CI setup for the 3.0
branch.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---

Hi all,

would it be acceptable to apply this patch to the 3.0.x stable branch? 
It would allow us to build this branch with the same infrastructure once 
we like to update to the next Debian version (12).

Especially the y2038 tests require a recent glibc version the next 
Debian stable release (bookworm, Debian 12) will ship such a version.

One alternative would be to use different build environments for
different Xenomai stable branches. I fear that's hard to maintain -
especially the CI configuration will likely explode.

WDYT?

This patch has been tested with both build environments, so Debian 11
(as is now) and the upcoming Debian 12.

Best regards,
Florian

 configure.ac               |  1 +
 include/boilerplate/libc.h | 14 +++++++++++---
 lib/alchemy/mutex.c        |  4 ++--
 lib/vxworks/semLib.c       |  4 ++--
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index f31365c7a..0ad866ddd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -489,6 +489,7 @@ save_LIBS="$LIBS"
 LIBS="$LIBS -lrt -lpthread"
 AC_CHECK_FUNCS([pthread_mutexattr_setprotocol	\
 		pthread_mutexattr_getprotocol	\
+		pthread_mutexattr_setrobust	\
 		pthread_mutexattr_setrobust_np	\
 		pthread_condattr_getclock	\
 		pthread_condattr_setclock	\
diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index 134176e54..e7d33101f 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -186,10 +186,18 @@ __weak int shm_unlink(const char *name)
 }
 #endif	/* !HAVE_SHM_UNLINK */
 
-#ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
-#define pthread_mutexattr_setrobust_np(__attr, __robust)	\
-	({ ENOSYS; })
+#ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST
+#ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
+#define pthread_mutexattr_setrobust	pthread_mutexattr_setrobust_np
+#else
+static inline
+int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr,
+				int *robustness)
+{
+	return ENOSYS;
+}
 #endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP */
+#endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST */
 
 #if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY)
 static inline
diff --git a/lib/alchemy/mutex.c b/lib/alchemy/mutex.c
index 09eb1364e..f89338586 100644
--- a/lib/alchemy/mutex.c
+++ b/lib/alchemy/mutex.c
@@ -131,8 +131,8 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
 	pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
-	/* pthread_mutexattr_setrobust_np() might not be implemented. */
-	pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP);
+	/* pthread_mutexattr_setrobust() might not be implemented. */
+	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
 	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
diff --git a/lib/vxworks/semLib.c b/lib/vxworks/semLib.c
index acce160ee..180ed2000 100644
--- a/lib/vxworks/semLib.c
+++ b/lib/vxworks/semLib.c
@@ -411,8 +411,8 @@ SEM_ID semMCreate(int options)
 	 */
 	pthread_mutexattr_init(&mattr);
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
-	/* pthread_mutexattr_setrobust_np() might not be implemented. */
-	pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP);
+	/* pthread_mutexattr_setrobust() might not be implemented. */
+	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
 	if (options & SEM_INVERSION_SAFE)
 		pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
 	pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);
-- 
2.35.1


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

* Re: [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust
  2022-11-18 15:42 [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust Florian Bezdeka
@ 2022-11-21  9:16 ` Jan Kiszka
  2022-11-21  9:51   ` Bezdeka, Florian
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2022-11-21  9:16 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 18.11.22 16:42, Florian Bezdeka wrote:
> With recent glibc (at least 2.34), autoconf fails to detect
> pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So
> switch to pthread_mutexattr_setrobust and only fall back to _np when
> needed.
> 
> This is a backport of the following commits from stable 3.2:
> 
> 746cbeb6ccc0 ("lib: Switch to pthread_mutexattr_setrobust")
> 3f85c174e297 ("lib: Fix fallback signature of pthread_mutexattr_setrobust")
> 2d947e6fe3f8 ("lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub")
> 
> Backporting allows the stable 3.0 branch to be build with the latest
> Debian toolchain, so we don't need a special CI setup for the 3.0
> branch.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
> 
> Hi all,
> 
> would it be acceptable to apply this patch to the 3.0.x stable branch? 
> It would allow us to build this branch with the same infrastructure once 
> we like to update to the next Debian version (12).
> 
> Especially the y2038 tests require a recent glibc version the next 
> Debian stable release (bookworm, Debian 12) will ship such a version.
> 
> One alternative would be to use different build environments for
> different Xenomai stable branches. I fear that's hard to maintain -
> especially the CI configuration will likely explode.
> 
> WDYT?
> 
> This patch has been tested with both build environments, so Debian 11
> (as is now) and the upcoming Debian 12.
> 

I don't mind backporting with this use case in mind, but why can't we
cherry-pick and possibly massage the original commits?

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

* Re: [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust
  2022-11-21  9:16 ` Jan Kiszka
@ 2022-11-21  9:51   ` Bezdeka, Florian
  2022-11-21 17:49     ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Bezdeka, Florian @ 2022-11-21  9:51 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai

On Mon, 2022-11-21 at 10:16 +0100, Jan Kiszka wrote:
> On 18.11.22 16:42, Florian Bezdeka wrote:
> > With recent glibc (at least 2.34), autoconf fails to detect
> > pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So
> > switch to pthread_mutexattr_setrobust and only fall back to _np when
> > needed.
> > 
> > This is a backport of the following commits from stable 3.2:
> > 
> > 746cbeb6ccc0 ("lib: Switch to pthread_mutexattr_setrobust")
> > 3f85c174e297 ("lib: Fix fallback signature of pthread_mutexattr_setrobust")
> > 2d947e6fe3f8 ("lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub")
> > 
> > Backporting allows the stable 3.0 branch to be build with the latest
> > Debian toolchain, so we don't need a special CI setup for the 3.0
> > branch.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> > 
> > Hi all,
> > 
> > would it be acceptable to apply this patch to the 3.0.x stable branch? 
> > It would allow us to build this branch with the same infrastructure once 
> > we like to update to the next Debian version (12).
> > 
> > Especially the y2038 tests require a recent glibc version the next 
> > Debian stable release (bookworm, Debian 12) will ship such a version.
> > 
> > One alternative would be to use different build environments for
> > different Xenomai stable branches. I fear that's hard to maintain -
> > especially the CI configuration will likely explode.
> > 
> > WDYT?
> > 
> > This patch has been tested with both build environments, so Debian 11
> > (as is now) and the upcoming Debian 12.
> > 
> 
> I don't mind backporting with this use case in mind, but why can't we
> cherry-pick and possibly massage the original commits?

Hi Jan,

I tried but the first one requires merging / does not apply directly to
the 3.0.x stable branch.

How to proceed? Should I resend without RFC tag?

Florian

> 
> Jan
> 


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

* Re: [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust
  2022-11-21  9:51   ` Bezdeka, Florian
@ 2022-11-21 17:49     ` Jan Kiszka
  2022-11-22 10:20       ` Florian Bezdeka
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2022-11-21 17:49 UTC (permalink / raw)
  To: Bezdeka, Florian (T CED SES-DE), xenomai

On 21.11.22 10:51, Bezdeka, Florian (T CED SES-DE) wrote:
> On Mon, 2022-11-21 at 10:16 +0100, Jan Kiszka wrote:
>> On 18.11.22 16:42, Florian Bezdeka wrote:
>>> With recent glibc (at least 2.34), autoconf fails to detect
>>> pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So
>>> switch to pthread_mutexattr_setrobust and only fall back to _np when
>>> needed.
>>>
>>> This is a backport of the following commits from stable 3.2:
>>>
>>> 746cbeb6ccc0 ("lib: Switch to pthread_mutexattr_setrobust")
>>> 3f85c174e297 ("lib: Fix fallback signature of pthread_mutexattr_setrobust")
>>> 2d947e6fe3f8 ("lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub")
>>>
>>> Backporting allows the stable 3.0 branch to be build with the latest
>>> Debian toolchain, so we don't need a special CI setup for the 3.0
>>> branch.
>>>
>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>> ---
>>>
>>> Hi all,
>>>
>>> would it be acceptable to apply this patch to the 3.0.x stable branch? 
>>> It would allow us to build this branch with the same infrastructure once 
>>> we like to update to the next Debian version (12).
>>>
>>> Especially the y2038 tests require a recent glibc version the next 
>>> Debian stable release (bookworm, Debian 12) will ship such a version.
>>>
>>> One alternative would be to use different build environments for
>>> different Xenomai stable branches. I fear that's hard to maintain -
>>> especially the CI configuration will likely explode.
>>>
>>> WDYT?
>>>
>>> This patch has been tested with both build environments, so Debian 11
>>> (as is now) and the upcoming Debian 12.
>>>
>>
>> I don't mind backporting with this use case in mind, but why can't we
>> cherry-pick and possibly massage the original commits?
> 
> Hi Jan,
> 
> I tried but the first one requires merging / does not apply directly to
> the 3.0.x stable branch.
> 
> How to proceed? Should I resend without RFC tag?
> 

I've merged these four into stable/3.0.x here:

fed3436a19 lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub
e4111b3c17 lib: Fix fallback signature of pthread_mutexattr_setrobust
87c719d48a lib: Switch to pthread_mutexattr_setrobust
cafb1e21ef lib/boilerplate: Convert pthread_mutexattr_setrobust_np stub into inline function

Only the second one (from the bottom) required a simple conflict 
resolution.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

* Re: [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust
  2022-11-21 17:49     ` Jan Kiszka
@ 2022-11-22 10:20       ` Florian Bezdeka
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Bezdeka @ 2022-11-22 10:20 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

On Mon, 2022-11-21 at 18:49 +0100, Jan Kiszka wrote:
> On 21.11.22 10:51, Bezdeka, Florian (T CED SES-DE) wrote:
> > On Mon, 2022-11-21 at 10:16 +0100, Jan Kiszka wrote:
> > > On 18.11.22 16:42, Florian Bezdeka wrote:
> > > > With recent glibc (at least 2.34), autoconf fails to detect
> > > > pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So
> > > > switch to pthread_mutexattr_setrobust and only fall back to _np when
> > > > needed.
> > > > 
> > > > This is a backport of the following commits from stable 3.2:
> > > > 
> > > > 746cbeb6ccc0 ("lib: Switch to pthread_mutexattr_setrobust")
> > > > 3f85c174e297 ("lib: Fix fallback signature of pthread_mutexattr_setrobust")
> > > > 2d947e6fe3f8 ("lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub")
> > > > 
> > > > Backporting allows the stable 3.0 branch to be build with the latest
> > > > Debian toolchain, so we don't need a special CI setup for the 3.0
> > > > branch.
> > > > 
> > > > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > > > ---
> > > > 
> > > > Hi all,
> > > > 
> > > > would it be acceptable to apply this patch to the 3.0.x stable branch? 
> > > > It would allow us to build this branch with the same infrastructure once 
> > > > we like to update to the next Debian version (12).
> > > > 
> > > > Especially the y2038 tests require a recent glibc version the next 
> > > > Debian stable release (bookworm, Debian 12) will ship such a version.
> > > > 
> > > > One alternative would be to use different build environments for
> > > > different Xenomai stable branches. I fear that's hard to maintain -
> > > > especially the CI configuration will likely explode.
> > > > 
> > > > WDYT?
> > > > 
> > > > This patch has been tested with both build environments, so Debian 11
> > > > (as is now) and the upcoming Debian 12.
> > > > 
> > > 
> > > I don't mind backporting with this use case in mind, but why can't we
> > > cherry-pick and possibly massage the original commits?
> > 
> > Hi Jan,
> > 
> > I tried but the first one requires merging / does not apply directly to
> > the 3.0.x stable branch.
> > 
> > How to proceed? Should I resend without RFC tag?
> > 
> 
> I've merged these four into stable/3.0.x here:
> 
> fed3436a19 lib: Re-add "static" to pthread_mutexattr_setrobust fallback stub
> e4111b3c17 lib: Fix fallback signature of pthread_mutexattr_setrobust
> 87c719d48a lib: Switch to pthread_mutexattr_setrobust
> cafb1e21ef lib/boilerplate: Convert pthread_mutexattr_setrobust_np stub into inline function
> 
> Only the second one (from the bottom) required a simple conflict 
> resolution.

Works! Thanks a lot.

> 
> Jan
> 


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

end of thread, other threads:[~2022-11-22 10:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 15:42 [RFC][stable 3.0.x] lib: Switch to pthread_mutexattr_setrobust Florian Bezdeka
2022-11-21  9:16 ` Jan Kiszka
2022-11-21  9:51   ` Bezdeka, Florian
2022-11-21 17:49     ` Jan Kiszka
2022-11-22 10:20       ` Florian Bezdeka

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.