Re: [Fwd: Re: [patch] Real-Time Preemption, -RT-2.6.9-mm1-V0.4]

Ingo Molnar
2004-10-29T21:32:15Z

* Florian Schmidt <mista.tapas@gmx.net> wrote:

> > do you compile jackd from sources? If yes then could you try the patch
> > below? With this added, the kernel will produce a stackdump whenever
> > jackd does an 'illegal' sleep.
> >
> > Also, could you do a small modification to kernel/sched.c and remove
> > this line:
> >
> > send_sig(SIGUSR1, current, 1);
> >
> > just to make it easier to get Jack up and running. (by default an
> > atomicity violation triggers a signal to make it easier to debug it in
> > userspace, but i suspect there will be alot of such violations so jackd
> > would stop all the time.)
>
> [snip]
>
> will do so. btw: i think i'm a bit confused right now. What debugging
> features should i have enabled for this test?

this particular one (atomicity-checking) is always-enabled if you have
the -RT patch applied (it's a really cheap check).

for the 'application-triggered tracing' facility we talked about earlier
is only active if LATENCY_TRACING is enabled. In that case to turn the
tracer on, call:

gettimeofday(0,1);

and to turn the tracer off and save the current trace into
/proc/latency_trace, call:

gettimeofday(0,0);

or apply the patch below - i've added the tracer bits too. I've added a
simple limit: all delays above 2 msec will be saved - you might want to
do a maximum search there or something. And dont forget to:

echo 2 > /proc/sys/kernel/trace_enabled

to activate the jackd-triggered kernel tracer.

Ingo

--- jack-audio-connection-kit-0.99.0/drivers/alsa/alsa_driver.c.orig
+++ jack-audio-connection-kit-0.99.0/drivers/alsa/alsa_driver.c
@@ -1161,6 +1161,7 @@ alsa_driver_wait (alsa_driver_t *driver,
unsigned int p_timed_out, c_timed_out;
unsigned int ci = 0;
unsigned int nfds;
+ int ret;

nfds = 0;

@@ -1194,7 +1195,20 @@ alsa_driver_wait (alsa_driver_t *driver,

poll_enter = jack_get_microseconds ();

- if (poll (driver->pfd, nfds, driver->poll_timeout) < 0) {
+ gettimeofday((void *)1,(void *)0); // atomic off
+
+ gettimeofday((void *)0,(void *)1); // start tracing
+
+ ret = poll (driver->pfd, nfds, driver->poll_timeout);
+
+ poll_ret = jack_get_microseconds ();
+
+ if (poll_ret - poll_enter > 2000)
+ gettimeofday((void *)0,(void *)0); // save trace
+
+ gettimeofday((void *)1,(void *)1); // atomic on
+
+ if (ret < 0) {

if (errno == EINTR) {
printf ("poll interrupt\n");
@@ -1214,8 +1228,6 @@ alsa_driver_wait (alsa_driver_t *driver,

}

- poll_ret = jack_get_microseconds ();
-
if (extra_fd < 0) {
if (driver->poll_next && poll_ret > driver->poll_next) {
*delayed_usecs = poll_ret - driver->poll_next;