Skip to contentSkip to conversation

Xenomai 3: kill() to non-Xenomai PIDs

Xenomai Jan Kiszka 3 participants 12 messages Oct 16, 2015

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
author
#1 lore raw
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

Signature · 1 line
Philippe.
author
#3 lore raw
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
#4 lore raw
Quoted 38 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

Quoted 4 lines

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Probably, yes.

Signature · 1 line
Philippe.
author
#5 lore raw
Quoted 39 lines · Philippe Gerum
Quoted 38 lines · Jan Kiszka
Quoted 36 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

Quoted 7 lines
Quoted 4 lines

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Probably, yes.

Looking at cluster_probe, I wonder if there is actually a problem. Doesn't that code also run over mercury? Then kill(pid, 0) also targets the whole system, not just a set of Xenomai applications. Or do we need to ensure that the caller is not migrated to Linux needlessly under cobalt? IOW: can that probing happen under RT constraints?

The same applies for me to the other users of the kill-based probing pattern (copperplate/heapobj-pshared.c and copperplate/regd/fs-common.c).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
#6 lore raw
Quoted 45 lines · Jan Kiszka
Quoted 44 lines · Philippe Gerum
Quoted 42 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Quoted 6 lines
Quoted 2 lines

Probably, yes.

Looking at cluster_probe, I wonder if there is actually a problem. Doesn't that code also run over mercury? Then kill(pid, 0) also targets the whole system, not just a set of Xenomai applications.

Over mercury, the whole system is the rt domain.

Or do we need

Quoted 3 lines

to ensure that the caller is not migrated to Linux needlessly under cobalt? IOW: can that probing happen under RT constraints?

It does with clusters. In general, no restriction on the calling domain should exist for this low level interface.

Quoted 5 lines

The same applies for me to the other users of the kill-based probing pattern (copperplate/heapobj-pshared.c and copperplate/regd/fs-common.c).

Jan

Signature · 1 line
Philippe.
author
#7 lore raw
Quoted 55 lines · Philippe Gerum
Quoted 45 lines · Jan Kiszka
Quoted 44 lines · Philippe Gerum
Quoted 42 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Quoted 6 lines
Quoted 2 lines

Probably, yes.

Looking at cluster_probe, I wonder if there is actually a problem. Doesn't that code also run over mercury? Then kill(pid, 0) also targets the whole system, not just a set of Xenomai applications.

Over mercury, the whole system is the rt domain.

Quoted 7 lines

Or do we need

Quoted 3 lines

to ensure that the caller is not migrated to Linux needlessly under cobalt? IOW: can that probing happen under RT constraints?

It does with clusters. In general, no restriction on the calling domain should exist for this low level interface.

Ok, will handle that path cobalt-specific then.

Quoted 3 lines
Quoted 3 lines

The same applies for me to the other users of the kill-based probing pattern (copperplate/heapobj-pshared.c and copperplate/regd/fs-common.c).

But these are fine, no?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
#8 lore raw
Quoted 64 lines · Jan Kiszka
Quoted 55 lines · Philippe Gerum
Quoted 45 lines · Jan Kiszka
Quoted 44 lines · Philippe Gerum
Quoted 42 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Quoted 6 lines
Quoted 2 lines

Probably, yes.

Looking at cluster_probe, I wonder if there is actually a problem. Doesn't that code also run over mercury? Then kill(pid, 0) also targets the whole system, not just a set of Xenomai applications.

Over mercury, the whole system is the rt domain.

Quoted 7 lines

Or do we need

Quoted 3 lines

to ensure that the caller is not migrated to Linux needlessly under cobalt? IOW: can that probing happen under RT constraints?

It does with clusters. In general, no restriction on the calling domain should exist for this low level interface.

Quoted 8 lines

Ok, will handle that path cobalt-specific then.

Quoted 3 lines
Quoted 3 lines

The same applies for me to the other users of the kill-based probing pattern (copperplate/heapobj-pshared.c and copperplate/regd/fs-common.c).

But these are fine, no?

Yes, don't care for mode switches there.

Signature · 1 line
Philippe.
#9 lore raw
Quoted 68 lines · Philippe Gerum
Quoted 67 lines · Jan Kiszka
Quoted 55 lines · Philippe Gerum
Quoted 45 lines · Jan Kiszka
Quoted 44 lines · Philippe Gerum
Quoted 42 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

Quoted 6 lines
Quoted 2 lines

Probably, yes.

Looking at cluster_probe, I wonder if there is actually a problem. Doesn't that code also run over mercury? Then kill(pid, 0) also targets the whole system, not just a set of Xenomai applications.

Over mercury, the whole system is the rt domain.

Quoted 7 lines

Or do we need

Quoted 3 lines

to ensure that the caller is not migrated to Linux needlessly under cobalt? IOW: can that probing happen under RT constraints?

It does with clusters. In general, no restriction on the calling domain should exist for this low level interface.

Ok, will handle that path cobalt-specific then.

Quoted 1 line
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

The same applies for me to the other users of the kill-based probing pattern (copperplate/heapobj-pshared.c and copperplate/regd/fs-common.c).

But these are fine, no?

Yes, don't care for mode switches there.

In fact, those will never target a non-Xenomai thread over cobalt.

Signature · 1 line
Philippe.
#10 lore raw
In reply to Jan Kiszka
Quoted 38 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 7 lines
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

Quoted 3 lines

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

If I have understood the "xenomai 3" philosophy, is not an application which wants to use the standard call supposed to use the __STD prefix, or not use the wrapping at all ?

Signature · 2 lines
					    Gilles.
https://click-hack.org
author
#11 lore raw
Quoted 39 lines · Gilles Chanteperdrix
Quoted 38 lines · Jan Kiszka
Quoted 36 lines · Philippe Gerum
Quoted 28 lines · Jan Kiszka
Quoted 8 lines · Jan Kiszka

Hi,

kill() is currently handled by libcobalt such that PIDs <= 0 are forwarded to Linux and PIDs > 0 are considered to target only Xenomai threads. But what if the user wants to address a regular Linux task from within a Xenomai application? Shouldn't we retry kill via the Linux path if Xenomai's syscall reports ESRCH?

IOW:

lib/cobalt/signal.c +4 -0
index aac4059..7e03301 100644
@@ -99,6 +99,10 @@ COBALT_IMPL(int, kill, (pid_t pid, int sig))
 
 	ret = XENOMAI_SYSCALL2(sc_cobalt_kill, pid, sig);
 	if (ret) {
+		/* Retry with regular kill is no RT target was found. */
+		if (ret == -ESRCH)
+			return __STD(kill(pid, sig));
+
 		errno = -ret;
 		return -1;
 	}
Quoted 2 lines

Jan

This may break code that sends signal 0 to detect whether a rt thread exists (like copperplate does), which is the reason for the lack of forwarding IIRC. (ret == -ESRCH && sig) would be required to forward without breaking such assumption.

Quoted 7 lines
Quoted 3 lines

That still breaks POSIX (what if the user wants to test for a non-rt thread, like this is possible under regular Linux?). Can't copperplate be changed to bypass the wrapper?

If I have understood the "xenomai 3" philosophy, is not an application which wants to use the standard call supposed to use the __STD prefix, or not use the wrapping at all ?

That's also a theoretical option, but should only be used if we can't fix the limitation otherwise. The more exceptions we define, the less portable we become for POSIX/Linux applications.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux