[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4B16262A.3030604@jp.fujitsu.com>
Date: Wed, 02 Dec 2009 17:32:42 +0900
From: Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
To: Stanislaw Gruszka <sgruszka@...hat.com>
CC: Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Spencer Candland <spencer@...ehost.com>,
Américo Wang <xiyou.wangcong@...il.com>,
linux-kernel@...r.kernel.org, Oleg Nesterov <oleg@...hat.com>,
Balbir Singh <balbir@...ibm.com>
Subject: reproducer: invisible utime
This program can reproduce another problem that originally
task_{u,s}time() intended to solve, I think.
Adjustment by task_{u,s}time() was only applied on getrusage()
and /proc/<pid>/stat. So even in .32-rc8, we can reproduce this
problem on sys_times() which has no adjustment.
I confirmed that my patches fix it, by thread_group_times().
Thanks,
H.Seto
===
/*
* Sample program to demonstrate invisible utime
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/times.h>
/* 300 million, arbitrary */
#define LOOP (300 * 1000 * 1000)
unsigned long lpt, l, c;
int do_loop(void)
{
struct tms t1, t2;
clock_t j1, j2;
unsigned long i;
printf("Loop %d times, sleeping %d times every %d.\n", l, l/c, c);
printf(" start ...\n");
j1 = times(&t1);
for (i = 1; i <= l; i++)
if (!(i % c))
usleep(0);
j2 = times(&t2);
printf(" ... done.\n");
/* tms_{u,s}time is clock_t */
printf(" user : %5d ms\n", (t2.tms_utime - t1.tms_utime) * 10);
printf(" system : %5d ms\n", (t2.tms_stime - t1.tms_stime) * 10);
printf(" elapse : %5d ms\n\n", (j2 - j1) * 10);
return (t2.tms_utime - t1.tms_utime) * 10;
}
int main(int argc, char **argv)
{
int u0, u1, u2, u3;
int ticks;
l = argc > 1 ? atoi(argv[1]) : LOOP;
printf("### Prep:\n");
c = l;
ticks = do_loop();
lpt = l / ticks;
printf("loops/tick: %d\n", lpt);
l = lpt * 1000;
printf("change loop to %d to short test.\n\n", l);
printf("### Test:\n");
c = l;
u0 = do_loop();
c = lpt;
u1 = do_loop();
c = lpt / 2;
u2 = do_loop();
c = lpt / 8;
u3 = do_loop();
printf("result: %s\n\n",
(u0 <= u1) && (u1 <= u2) && (u2 <= u3) ? "GOOD" : "BAD");
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists