On Fri, Aug 26, 2011 at 7:00 AM, Kamal Dasu <[email protected]> wrote: > Using uClibc 09.30.1 I hit a problem when running timers with SIGEV_THREAD > option on a MIPS system with PAGE_SIZE>=16K. > In uClibc pthread library PTHREAD_STACK_MIN is defined at 16K. This is used > when creating a thread to set the default pthread_attr stack size. However > implementations could have page_size >= 16K in which case the check for the > minimum stack size in _pthread_create() will fail. The only fix seems to be > increasing the value to 2* PAGE_SIZE. However a cleaner way to fix this > would be increasing the PTHREAD_STACK_MIN based on the page size to make > optimal use of resources. The patch below shows the only feasible way I > could find to do this. > > > Adjust stack size for PAGE_SIZE >= 16K. Needed to make timer uses > SIGEV_THREAD attribute.
solution seems ok. > > --- > .../uClibc/libpthread/nptl/pthread_attr_setstack.c | 2 +- > .../libpthread/nptl/pthread_attr_setstacksize.c | 2 +- > > .../libpthread/nptl/sysdeps/pthread/pthread.h | 1 + > .../nptl/sysdeps/unix/sysv/linux/bits/local_lim.h | 3 ++- > 4 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstack.c > b/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstack.c > > index d400f3d..7327e7d 100644 > --- a/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstack.c > +++ b/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstack.c > @@ -49,7 +49,7 @@ __pthread_attr_setstack ( > > return 0; > } > > -#if PTHREAD_STACK_MIN == 16384 > +#if PTHREAD_STACK_MIN >= 16384 why is this needed > strong_alias(__pthread_attr_setstack, pthread_attr_setstack) > #else > weak_alias(__pthread_attr_setstack, pthread_attr_setstack) > > diff --git > a/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstacksize.c > b/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstacksize.c > index 24e5b0a..d2ae5fe 100644 > --- a/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstacksize.c > > +++ b/uclinux-rootfs/lib/uClibc/libpthread/nptl/pthread_attr_setstacksize.c > @@ -42,7 +42,7 @@ __pthread_attr_setstacksize ( > return 0; > } > > -#if PTHREAD_STACK_MIN == 16384 > +#if PTHREAD_STACK_MIN >= 16384 > same here > strong_alias(__pthread_attr_setstacksize, pthread_attr_setstacksize) > #else > weak_alias(__pthread_attr_setstacksize, pthread_attr_setstacksize) > diff --git > a/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/pthread/pthread.h > b/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/pthread/pthread.h > > index deb7430..eeeefb7 100644 > --- a/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/pthread/pthread.h > +++ b/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/pthread/pthread.h > @@ -32,6 +32,7 @@ > #include <bits/wordsize.h> > > #if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc ) > #include <bits/uClibc_pthread.h> > +#include <bits/uClibc_page.h> > #endif > > > diff --git > a/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h > b/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h > > index 8f0df4f..07cd5bd 100644 > --- > a/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h > +++ > b/uclinux-rootfs/lib/uClibc/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h > @@ -37,6 +37,7 @@ > > > /* The kernel sources contain a file with all the needed information. */ > #include <linux/limits.h> > +#include <pthread.h> > > /* Have to remove NR_OPEN? */ > #ifdef __undef_NR_OPEN > @@ -79,7 +80,7 @@ > > #define AIO_PRIO_DELTA_MAX 20 > > /* Minimum size for a thread. We are free to choose a reasonable value. */ > -#define PTHREAD_STACK_MIN 16384 > +#define PTHREAD_STACK_MIN ( (PAGE_SIZE == 4096) ? 16384 : PAGE_SIZE << 1 ) > > > /* Maximum number of timer expiration overruns. */ > #define DELAYTIMER_MAX 2147483647 > -- > > > Kamal > _______________________________________________ > uClibc mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/uclibc > _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
