All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed
@ 2013-06-12  6:15 Jan Kiszka
  2013-06-12 11:06 ` Gilles Chanteperdrix
  2013-07-26 17:54 ` Jan Kiszka
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Kiszka @ 2013-06-12  6:15 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai

While the user can also avoid double shadowing by providing the
XENO_NOSHADOW environment variable, there is still no reason to attempt
auto-shadowing in their absence if the current thread is already a
Xenomai thread. This helps, e.g., in complex dlopen scenarios where
the POSIX lib is pulled in belatedly, potentially after some other lib
already shadowed the dlopen caller.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 src/skins/posix/init.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c
index 80725c5..ca1d9e1 100644
--- a/src/skins/posix/init.c
+++ b/src/skins/posix/init.c
@@ -31,6 +31,7 @@
 #include <rtdk.h>
 
 #include <asm-generic/xenomai/bind.h>
+#include <asm-generic/xenomai/current.h>
 
 int __pse51_muxid = -1;
 int __pse51_rtdm_muxid = -1;
@@ -67,7 +68,7 @@ static __constructor__ void __init_posix_interface(void)
 	}
 
 	noshadow = getenv("XENO_NOSHADOW");
-	if (!noshadow || !*noshadow) {
+	if ((!noshadow || !*noshadow) && xeno_get_current() == XN_NO_HANDLE) {
 		err = __real_pthread_getschedparam(pthread_self(), &policy,
 						   &parm);
 		if (err) {
-- 
1.7.3.4


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

* Re: [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed
  2013-06-12  6:15 [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed Jan Kiszka
@ 2013-06-12 11:06 ` Gilles Chanteperdrix
  2013-06-13  4:21   ` Jan Kiszka
  2013-07-26 17:54 ` Jan Kiszka
  1 sibling, 1 reply; 6+ messages in thread
From: Gilles Chanteperdrix @ 2013-06-12 11:06 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai

On 06/12/2013 08:15 AM, Jan Kiszka wrote:

> While the user can also avoid double shadowing by providing the
> XENO_NOSHADOW environment variable, there is still no reason to attempt
> auto-shadowing in their absence if the current thread is already a
> Xenomai thread. This helps, e.g., in complex dlopen scenarios where
> the POSIX lib is pulled in belatedly, potentially after some other lib
> already shadowed the dlopen caller.


Well, last time I checked, calling __wrap_pthread_setschedparam for an
already shadowed threads was a nop. It usefaults the thread stack
though, maybe we can move the faulting of the tread stack to the
"promoted" case.


-- 
                                                                Gilles.


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

* Re: [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed
  2013-06-12 11:06 ` Gilles Chanteperdrix
@ 2013-06-13  4:21   ` Jan Kiszka
  2013-06-13  4:23     ` Jan Kiszka
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2013-06-13  4:21 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai

On 2013-06-12 13:06, Gilles Chanteperdrix wrote:
> On 06/12/2013 08:15 AM, Jan Kiszka wrote:
> 
>> While the user can also avoid double shadowing by providing the
>> XENO_NOSHADOW environment variable, there is still no reason to attempt
>> auto-shadowing in their absence if the current thread is already a
>> Xenomai thread. This helps, e.g., in complex dlopen scenarios where
>> the POSIX lib is pulled in belatedly, potentially after some other lib
>> already shadowed the dlopen caller.
> 
> 
> Well, last time I checked, calling __wrap_pthread_setschedparam for an
> already shadowed threads was a nop.

I'm getting an EBUSY from xnshadow_map as called by __pthread_shadow.
And that, of course, lets the lib init code bail out.

> It usefaults the thread stack
> though, maybe we can move the faulting of the tread stack to the
> "promoted" case.

Isn't it reasonable to assume that an existing Xenomai thread also
properly went through stack faulting?

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux


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

* Re: [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed
  2013-06-13  4:21   ` Jan Kiszka
@ 2013-06-13  4:23     ` Jan Kiszka
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2013-06-13  4:23 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai

On 2013-06-13 06:21, Jan Kiszka wrote:
> On 2013-06-12 13:06, Gilles Chanteperdrix wrote:
>> On 06/12/2013 08:15 AM, Jan Kiszka wrote:
>>
>>> While the user can also avoid double shadowing by providing the
>>> XENO_NOSHADOW environment variable, there is still no reason to attempt
>>> auto-shadowing in their absence if the current thread is already a
>>> Xenomai thread. This helps, e.g., in complex dlopen scenarios where
>>> the POSIX lib is pulled in belatedly, potentially after some other lib
>>> already shadowed the dlopen caller.
>>
>>
>> Well, last time I checked, calling __wrap_pthread_setschedparam for an
>> already shadowed threads was a nop.
> 
> I'm getting an EBUSY from xnshadow_map as called by __pthread_shadow.
> And that, of course, lets the lib init code bail out.

BTW, the test pattern is pretty simple:

main()
{
	...
	rt_task_shadow(&task, "test", 0, 0);
	handle = dlopen("libpthread_rt.so", RTLD_LAZY);
	...
}

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux


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

* Re: [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed
  2013-06-12  6:15 [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed Jan Kiszka
  2013-06-12 11:06 ` Gilles Chanteperdrix
@ 2013-07-26 17:54 ` Jan Kiszka
  2013-07-26 19:12   ` Gilles Chanteperdrix
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2013-07-26 17:54 UTC (permalink / raw)
  Cc: Xenomai

On 2013-06-12 08:15, Jan Kiszka wrote:
> While the user can also avoid double shadowing by providing the
> XENO_NOSHADOW environment variable, there is still no reason to attempt
> auto-shadowing in their absence if the current thread is already a
> Xenomai thread. This helps, e.g., in complex dlopen scenarios where
> the POSIX lib is pulled in belatedly, potentially after some other lib
> already shadowed the dlopen caller.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  src/skins/posix/init.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c
> index 80725c5..ca1d9e1 100644
> --- a/src/skins/posix/init.c
> +++ b/src/skins/posix/init.c
> @@ -31,6 +31,7 @@
>  #include <rtdk.h>
>  
>  #include <asm-generic/xenomai/bind.h>
> +#include <asm-generic/xenomai/current.h>
>  
>  int __pse51_muxid = -1;
>  int __pse51_rtdm_muxid = -1;
> @@ -67,7 +68,7 @@ static __constructor__ void __init_posix_interface(void)
>  	}
>  
>  	noshadow = getenv("XENO_NOSHADOW");
> -	if (!noshadow || !*noshadow) {
> +	if ((!noshadow || !*noshadow) && xeno_get_current() == XN_NO_HANDLE) {
>  		err = __real_pthread_getschedparam(pthread_self(), &policy,
>  						   &parm);
>  		if (err) {
> 

Ping for this patch. Any concerns remaining?

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux


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

* Re: [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed
  2013-07-26 17:54 ` Jan Kiszka
@ 2013-07-26 19:12   ` Gilles Chanteperdrix
  0 siblings, 0 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2013-07-26 19:12 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai

On 07/26/2013 07:54 PM, Jan Kiszka wrote:

> On 2013-06-12 08:15, Jan Kiszka wrote:
>> While the user can also avoid double shadowing by providing the
>> XENO_NOSHADOW environment variable, there is still no reason to attempt
>> auto-shadowing in their absence if the current thread is already a
>> Xenomai thread. This helps, e.g., in complex dlopen scenarios where
>> the POSIX lib is pulled in belatedly, potentially after some other lib
>> already shadowed the dlopen caller.
>>
>> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
>> ---
>>   src/skins/posix/init.c |    3 ++-
>>   1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c
>> index 80725c5..ca1d9e1 100644
>> --- a/src/skins/posix/init.c
>> +++ b/src/skins/posix/init.c
>> @@ -31,6 +31,7 @@
>>   #include<rtdk.h>
>>
>>   #include<asm-generic/xenomai/bind.h>
>> +#include<asm-generic/xenomai/current.h>
>>
>>   int __pse51_muxid = -1;
>>   int __pse51_rtdm_muxid = -1;
>> @@ -67,7 +68,7 @@ static __constructor__ void __init_posix_interface(void)
>>   	}
>>
>>   	noshadow = getenv("XENO_NOSHADOW");
>> -	if (!noshadow || !*noshadow) {
>> +	if ((!noshadow || !*noshadow)&&  xeno_get_current() == XN_NO_HANDLE) {
>>   		err = __real_pthread_getschedparam(pthread_self(),&policy,
>>   						&parm);
>>   		if (err) {
>>
>
> Ping for this patch. Any concerns remaining?


Will merge, thanks for the reminder.

-- 
                                                                 Gilles.


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

end of thread, other threads:[~2013-07-26 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-12  6:15 [Xenomai] [PATCH] posix: Skip auto-shadowing if current thread is already shadowed Jan Kiszka
2013-06-12 11:06 ` Gilles Chanteperdrix
2013-06-13  4:21   ` Jan Kiszka
2013-06-13  4:23     ` Jan Kiszka
2013-07-26 17:54 ` Jan Kiszka
2013-07-26 19:12   ` Gilles Chanteperdrix

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.