[lkml]   [2009]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subjectutime/stime decreasing on thread exit
    I am seeing a problem with utime/stime decreasing on thread exit in a
    multi-threaded process. I have been able to track this regression down
    to the "process wide cpu clocks/timers" changes introduces in
    2.6.29-rc5, specifically when I revert the following commits I know
    longer see decreasing utime/stime values:


    I poked around a little, but I am afraid I have to admit that I am not
    familiar enough with how this works to resolve this or suggest a fix.

    I have verified this in happening in kernels 2.6.29-rc5 - 2.6.32-rc6, I
    have been testing this on x86 vanilla kernels, but have also verified it
    on several x86 2.6.29+ distro kernels (fedora and ubuntu).

    I first noticed this on a production environment running Apache with the
    worker MPM, however while tracking this down I put together a simple
    program that has been reliable in showing me utime decreasing, hopefully
    it will be helpful in demonstrating the issue:

    #include <stdio.h>
    #include <pthread.h>
    #include <sys/times.h>

    #define NUM_THREADS 500

    struct tms start;
    int oldutime;

    void *pound (void *threadid)
    struct tms end;
    int utime;
    int c;
    for (c = 0; c < 10000000; c++);
    utime = ((int)end.tms_utime - (int)start.tms_utime);
    if (oldutime > utime) {
    printf("utime decreased, was %d, now %d!\n", oldutime, utime);
    oldutime = utime;

    int main()
    pthread_t th[NUM_THREADS];
    long i;
    for (i = 0; i < NUM_THREADS; i++) {
    pthread_create (&th[i], NULL, pound, (void *)i);
    return 0;


    # ./decrease_utime
    utime decreased, was 1288, now 1287!
    utime decreased, was 1294, now 1293!
    utime decreased, was 1296, now 1295!
    utime decreased, was 1297, now 1296!
    utime decreased, was 1298, now 1297!
    utime decreased, was 1299, now 1298!

    Please let me know if you need any additional information.

    Thank you,
    Spencer Candland

     \ /
      Last update: 2009-11-04 01:33    [W:0.021 / U:4.660 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site