* [Xenomai-core] Unwanted mode switch.
@ 2007-01-11 15:24 Gilles Chanteperdrix
2007-01-11 15:33 ` Jan Kiszka
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2007-01-11 15:24 UTC (permalink / raw)
To: xenomai-core
[-- Attachment #1: Type: text/plain, Size: 362 bytes --]
Hi,
in order to test the nocow patch, I wrote the attached test. Despite the
fact that there is no longer any page fault (I have nucleus debugging
on, so I would get a message if there was a fault), there is still an
unwanted mode switch at step 5. Any idea what could be the cause ?
--
Gilles Chanteperdrix
[-- Attachment #2: test_fork.c --]
[-- Type: text/x-csrc, Size: 2663 bytes --]
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <signal.h>
#include <string.h>
#include <sys/mman.h>
#include <execinfo.h>
#include <native/timer.h>
#include <native/task.h>
unsigned step;
void do_backtrace(void)
{
static void *buffer[200];
int levels = backtrace(buffer, sizeof(buffer)/sizeof(void *));
backtrace_symbols_fd(buffer, levels, STDOUT_FILENO);
}
void mode_switch(int sig)
{
printf("mode switch at step %d, test failed!\n", step);
do_backtrace();
exit(EXIT_FAILURE);
}
int main(void)
{
RT_TASK task;
RTIME time;
pid_t pid;
int rc;
if ((SIG_ERR == signal(SIGXCPU, &mode_switch))) {
perror("signal");
exit(EXIT_FAILURE);
}
pid = fork();
if (pid < 0) {
perror("fork");
exit(EXIT_FAILURE);
}
if (pid > 0) {
int status;
if (waitpid(pid, &status, 0) == -1) {
perror("waitpid");
exit(EXIT_FAILURE);
}
status = WEXITSTATUS(status);
if (status == EXIT_SUCCESS)
fprintf(stderr, "Test passed\n");
_exit(status);
}
if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
perror("mlockall");
exit(EXIT_FAILURE);
}
step = 1;
if ((rc = rt_task_shadow(&task, "test_vm1", 1, 0))) {
fprintf(stderr,
"rt_task_shadow: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
step = 2;
if ((rc = rt_task_set_mode(0, T_WARNSW, NULL))) {
fprintf(stderr,
"rt_task_set_mode_np: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
step = 3;
time = rt_timer_read();
step = 4;
if ((rc = rt_task_set_mode(T_PRIMARY, 0, NULL))) {
fprintf(stderr,
"rt_task_set_mode_np: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
pid = fork();
if (pid < 0) {
perror("fork");
exit(EXIT_FAILURE);
}
if (pid > 0) {
int status;
step = 5;
time = rt_timer_read();
if ((rc = rt_task_set_mode(T_PRIMARY, 0, NULL))) {
fprintf(stderr,
"rt_task_set_mode_np: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
if (waitpid(pid, &status, 0) == -1) {
perror("waitpid");
exit(EXIT_FAILURE);
}
_exit(WEXITSTATUS(status));
}
if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
perror("mlockall");
exit(EXIT_FAILURE);
}
step = 6;
if ((rc = rt_task_shadow(&task, "test_vm2", 1, 0))) {
fprintf(stderr,
"rt_task_shadow: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
step = 7;
if ((rc = rt_task_set_mode(0, T_WARNSW, NULL))) {
fprintf(stderr,
"rt_task_set_mode_np: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
step = 8;
time = rt_timer_read();
if ((rc = rt_task_set_mode(T_PRIMARY, 0, NULL))) {
fprintf(stderr,
"rt_task_set_mode_np: %s\n", strerror(-rc));
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Xenomai-core] Unwanted mode switch.
2007-01-11 15:24 [Xenomai-core] Unwanted mode switch Gilles Chanteperdrix
@ 2007-01-11 15:33 ` Jan Kiszka
2007-01-11 15:36 ` Gilles Chanteperdrix
2007-01-15 21:47 ` Philippe Gerum
2 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2007-01-11 15:33 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai-core
[-- Attachment #1: Type: text/plain, Size: 702 bytes --]
Gilles Chanteperdrix wrote:
> Hi,
>
> in order to test the nocow patch, I wrote the attached test. Despite the
> fact that there is no longer any page fault (I have nucleus debugging
> on, so I would get a message if there was a fault), there is still an
> unwanted mode switch at step 5. Any idea what could be the cause ?
>
Put in some xntrace_user_freeze(0) before or after the point-of-interest
in the program, switch on the tracer, and check ipipe/trace/frozen (with
appropriate back_trace_points or post_trace_points) what is going on.
Once you know the particular code path, instrumenting it can also be
done this way: xntrace_special(some_id, some_value_of_interest).
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-core] Unwanted mode switch.
2007-01-11 15:24 [Xenomai-core] Unwanted mode switch Gilles Chanteperdrix
2007-01-11 15:33 ` Jan Kiszka
@ 2007-01-11 15:36 ` Gilles Chanteperdrix
2007-01-11 20:57 ` Philippe Gerum
2007-01-15 21:47 ` Philippe Gerum
2 siblings, 1 reply; 5+ messages in thread
From: Gilles Chanteperdrix @ 2007-01-11 15:36 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai-core
Gilles Chanteperdrix wrote:
> Hi,
>
> in order to test the nocow patch, I wrote the attached test. Despite the
> fact that there is no longer any page fault (I have nucleus debugging
> on, so I would get a message if there was a fault), there is still an
> unwanted mode switch at step 5. Any idea what could be the cause ?
I added a show_stack(NULL, NULL) in xnshadow_relax, and I get the
following stack trace:
xnshadow_relax
hisyscall_event
xnshadow_sys_migrate
losyscall_event
--
Gilles Chanteperdrix
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Xenomai-core] Unwanted mode switch.
2007-01-11 15:36 ` Gilles Chanteperdrix
@ 2007-01-11 20:57 ` Philippe Gerum
0 siblings, 0 replies; 5+ messages in thread
From: Philippe Gerum @ 2007-01-11 20:57 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai-core
On Thu, 2007-01-11 at 16:36 +0100, Gilles Chanteperdrix wrote:
> Gilles Chanteperdrix wrote:
> > Hi,
> >
> > in order to test the nocow patch, I wrote the attached test. Despite the
> > fact that there is no longer any page fault (I have nucleus debugging
> > on, so I would get a message if there was a fault), there is still an
> > unwanted mode switch at step 5. Any idea what could be the cause ?
>
> I added a show_stack(NULL, NULL) in xnshadow_relax, and I get the
> following stack trace:
> xnshadow_relax
> hisyscall_event
^^^ Eeek... Which would mean that we would somehow be running the
hi-stage handler for a task on behalf of, say, xnshadow_harden()? Could
you confirm the backtrace? Any chance the frame unwinding went south
here?
Dumping the muxid/muxop pair for the hisyscall_event call which attempts
to relax the underlying task might be interesting.
> xnshadow_sys_migrate
> losyscall_event
>
--
Philippe.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-core] Unwanted mode switch.
2007-01-11 15:24 [Xenomai-core] Unwanted mode switch Gilles Chanteperdrix
2007-01-11 15:33 ` Jan Kiszka
2007-01-11 15:36 ` Gilles Chanteperdrix
@ 2007-01-15 21:47 ` Philippe Gerum
2 siblings, 0 replies; 5+ messages in thread
From: Philippe Gerum @ 2007-01-15 21:47 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai-core
On Thu, 2007-01-11 at 16:24 +0100, Gilles Chanteperdrix wrote:
> Hi,
>
> in order to test the nocow patch, I wrote the attached test. Despite the
> fact that there is no longer any page fault (I have nucleus debugging
> on, so I would get a message if there was a fault), there is still an
> unwanted mode switch at step 5. Any idea what could be the cause ?
>
I'll have a look asap.
>
> _______________________________________________
> Xenomai-core mailing list
> Xenomai-core@domain.hid
> https://mail.gna.org/listinfo/xenomai-core
--
Philippe.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-01-15 21:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-11 15:24 [Xenomai-core] Unwanted mode switch Gilles Chanteperdrix
2007-01-11 15:33 ` Jan Kiszka
2007-01-11 15:36 ` Gilles Chanteperdrix
2007-01-11 20:57 ` Philippe Gerum
2007-01-15 21:47 ` Philippe Gerum
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.