bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

phtreads program causes massive ctx switches in 2.4, not in 2.2


From: David Mansfield
Subject: phtreads program causes massive ctx switches in 2.4, not in 2.2
Date: Mon, 18 Dec 2000 16:20:55 -0500

Problem summary:  use of localtime_r glibc function causes massive
context switching on kernel 2.4, but not on 2.2, leading to ctx switch
rates of >50000/sec (!) on my Athlon 700 mhz.  In 2.2 ctx switch rates
are < 1000.  (according to vmstat).

I don't know if this is a kernel bug, or a glibc bug, so I'm submitting
it to both places.  It's a stupid program, granted, because it's
computing invalid (stupid) data. But the problem it exhibits is real
(scenario extracted from actual application).  As the subject indicates,
this only occurs in 2.4 kernels.

My system:
Kernel is 2.4.0-test13-pre3 or 2.2.18.  Glibc is glibc-2.1.3-15 (RedHat
RPM).
Uniprocessor Athlon 700mhz.

Also tested on:
glibc-2.1.2-11 (RedHat RPM) with kernel 2.2.15 and it doesn't have the
problem, consistent with kernel 2.4 being the culprit.

Here's the program:

---------- cut --------------
#define _REENTRANT
#include <pthread.h>
#include <time.h>
#include <stdio.h>

int foo = 0;

void * func(void * arg)
{
    while(1) {
        struct tm tm;
        localtime_r((time_t*)&foo, &tm);
        foo += tm.tm_sec;
    }
}

main()
{
    pthread_t t;
    pthread_create(&t, NULL, func, NULL);
    func(NULL);
}
------- cut ------------

Strace only shows a bunch of rt_sigsuspend, kill, sigreturn that I can't
really decipher (then again, I'm skeptical that strace and pthreads work
together):

<... rt_sigsuspend resumed> )           = -1 EINTR (Interrupted system
call)
sigreturn()                             = ? (mask now [])
kill(2030, SIGRT_0)                     = 0
rt_sigprocmask(SIG_SETMASK, NULL, [RT_0], 8) = 0
rt_sigsuspend([] <unfinished ...>
--- SIGRT_0 (Real-time signal 0) ---


Any ideas?

David Mansfield
Ultramaster Group, LLC.
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]