Bug #262

Threadding issue

Added by elekktretterr about 8 years ago. Updated about 8 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html

Can someone please fix it? Its really bugging me, and Im not the only
one to have that issue. Some people say growisofs does the same.

Thank you,

Petr

History

#1 Updated by qhwt+dfly about 8 years ago

On Thu, Jul 27, 2006 at 02:42:29PM +1000, Petr Janda wrote:
> http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html
>
> Can someone please fix it? Its really bugging me, and Im not the only
> one to have that issue. Some people say growisofs does the same.

IIUC, libc_r's thread scheduler may call sys_set_tls_area() at most twice
per call, so if the application tries to switch between threads very
frequently, it can call sys_set_tls_area() very often. There are many
places in libc_r's code where the thread scheduler is called, but the
easiest way to make it happen is calling sched_yield().
For example, src/engine.c in gxine has the following code:

static gboolean js_queue_cb (GtkWidget *widget, GdkEventClient *event,
gpointer data)
{
exec_t *js;
while ((js = g_async_queue_try_pop (js_queue)))
{
/* spin; play_exec gets this & the GDK lock in reverse order */
while (pthread_mutex_trylock (&widgets_update_lock))
sched_yield ();
pthread_mutex_unlock (&widgets_update_lock); /* JS 'play()' needs it */
engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
free (js->cmd);
free (js->src);
free (js);
}
return TRUE;
}

I wonder what happens if you use libthread_xu instead of libc_r
(not sure if it's easy to replace the use of pthead library).

#2 Updated by elekktretterr about 8 years ago

1) I can bzip the whole ktrace dump and put it on my webserver, will
that help you?
2) How do i switch to libthread_xu?

Petr

YONETANI Tomokazu wrote:
> On Thu, Jul 27, 2006 at 02:42:29PM +1000, Petr Janda wrote:
>
>> http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html
>>
>> Can someone please fix it? Its really bugging me, and Im not the only
>> one to have that issue. Some people say growisofs does the same.
>>
>
> IIUC, libc_r's thread scheduler may call sys_set_tls_area() at most twice
> per call, so if the application tries to switch between threads very
> frequently, it can call sys_set_tls_area() very often. There are many
> places in libc_r's code where the thread scheduler is called, but the
> easiest way to make it happen is calling sched_yield().
> For example, src/engine.c in gxine has the following code:
>
> static gboolean js_queue_cb (GtkWidget *widget, GdkEventClient *event,
> gpointer data)
> {
> exec_t *js;
> while ((js = g_async_queue_try_pop (js_queue)))
> {
> /* spin; play_exec gets this & the GDK lock in reverse order */
> while (pthread_mutex_trylock (&widgets_update_lock))
> sched_yield ();
> pthread_mutex_unlock (&widgets_update_lock); /* JS 'play()' needs it */
> engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
> free (js->cmd);
> free (js->src);
> free (js);
> }
> return TRUE;
> }
>
> I wonder what happens if you use libthread_xu instead of libc_r
> (not sure if it's easy to replace the use of pthead library).
>
>
>

#3 Updated by joerg about 8 years ago

On Thu, Jul 27, 2006 at 08:52:25PM +0900, YONETANI Tomokazu wrote:
> static gboolean js_queue_cb (GtkWidget *widget, GdkEventClient *event,
> gpointer data)
> {
> exec_t *js;
> while ((js = g_async_queue_try_pop (js_queue)))
> {
> /* spin; play_exec gets this & the GDK lock in reverse order */
> while (pthread_mutex_trylock (&widgets_update_lock))
> sched_yield ();
> pthread_mutex_unlock (&widgets_update_lock); /* JS 'play()' needs it */
> engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
> free (js->cmd);
> free (js->src);
> free (js);
> }
> return TRUE;
> }

ARGH! IDIOTS! Ok, thanks Yonetani, I'll take care of this instance.

Joerg

#4 Updated by joerg about 8 years ago

On Thu, Jul 27, 2006 at 10:05:53PM +1000, Petr Janda wrote:
> 1) I can bzip the whole ktrace dump and put it on my webserver, will
> that help you?
> 2) How do i switch to libthread_xu?

I'll look at fixing this, now that I got a hint on what is going wrong,
fixing it is easy. growisofs will be a bit more work, since it has to be
done carefully.

Joerg

#5 Updated by justin about 8 years ago

On Thu, July 27, 2006 12:42 am, Petr Janda wrote:
> http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html
>
> Can someone please fix it? Its really bugging me, and Im not the only
> one to have that issue. Some people say growisofs does the same.

If I'm recalling it correctly, this was solved with growisofs with this
patch:

http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/pkgsrc/sysutils/dvd+rw-tools/patches/patch-ad.diff?r1=1.2;r2=1.3;f=h

This may apply to xine too.

#6 Updated by steve about 8 years ago

On Thu, 27 Jul 2006 10:46:38 -0400 (EDT)
"Justin C. Sherrill" <> wrote:

> On Thu, July 27, 2006 12:42 am, Petr Janda wrote:
> > http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html
> >
> > Can someone please fix it? Its really bugging me, and Im not the only
> > one to have that issue. Some people say growisofs does the same.
>
> If I'm recalling it correctly, this was solved with growisofs with this
> patch:
>
> http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/pkgsrc/sysutils/dvd+rw-tools/patches/patch-ad.diff?r1=1.2;r2=1.3;f=h

No. That patch is necessary for growisofs to work at all on
DragonFly. I have had that patch since some time before it went into the
pkgsrc repository. The high CPU usage and slow burning is new.

#7 Updated by corecode about 8 years ago

YONETANI Tomokazu wrote:
> exec_t *js;
> while ((js = g_async_queue_try_pop (js_queue)))
> {
> /* spin; play_exec gets this & the GDK lock in reverse order */
> while (pthread_mutex_trylock (&widgets_update_lock))
> sched_yield ();
> pthread_mutex_unlock (&widgets_update_lock); /* JS 'play()' needs it */

ehm? are they using the event of unlocking a mutex as some kind of signaling? and why wouldn't they just use get the lock?

> engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
> free (js->cmd);
> free (js->src);
> free (js);
> }
> return TRUE;
> }

> I wonder what happens if you use libthread_xu instead of libc_r
> (not sure if it's easy to replace the use of pthead library).

I'm not sure how much works with libthread_xu. We're at least missing signaling bits in the kernel.

cheers
simon

#8 Updated by elekktretterr about 8 years ago

This is what beep-media-player does upon I try to exit it. The GUI part
disappears, but according to 'top' it stays in the process list, and has
nearly 100% CPU usage and generates thousands of these errors untill i
kill -9 it. This is the extract of ktrace:

1343 beep-media-playe CALL poll(0x28a44e40,0x1,0)
1343 beep-media-playe RET poll 0
1343 beep-media-playe CALL poll(0x28a16000,0x1,0)
1343 beep-media-playe RET poll 0
1343 beep-media-playe CALL sys_set_tls_area(0,0x28a09f98,0x8)
1343 beep-media-playe RET sys_set_tls_area 123/0x7b
1343 beep-media-playe CALL poll(0x28a16000,0x2,0x2563)
1343 beep-media-playe RET poll 1
1343 beep-media-playe CALL gettimeofday(0x2890c378,0)
1343 beep-media-playe RET gettimeofday 0
1343 beep-media-playe CALL sys_set_tls_area(0,0x28a09f98,0x8)
1343 beep-media-playe RET sys_set_tls_area 123/0x7b
1343 beep-media-playe CALL
__pread(0x6,0xbfbff8a0,0x20,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET __pread 32/0x20
1343 beep-media-playe CALL
__pread(0x6,0xbfbff898,0x8,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET __pread 8
1343 beep-media-playe CALL
__pwrite(0x6,0x28a49000,0xc,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET __pwrite 12/0xc
1343 beep-media-playe CALL
__pread(0x6,0xbfbff8a0,0x20,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET __pread -1 errno 35 Resource temporarily
unavailable

It seems to be the same problem as with growisofs, gmplayer, xine,
gxine. It seems unlikely that all of these programs would share the same
bug.

Any further feedback would be nice..

Petr
>
>

#9 Updated by elekktretterr about 8 years ago

Share the same bug as in, the bug is in the actual programs and not in
DragonFly. This list probably doesn't end yet, its only these i know
about. Im running HEAD about 1-2 weeks old at around the time of the 1.6
release.

>
>

#10 Updated by corecode about 8 years ago

not our bug, fixed in pkgsrc

Also available in: Atom PDF