Re: [GIT PULL] cputime patch for 2.6.30-rc6

From: Martin Schwidefsky
Date: Mon May 25 2009 - 06:50:59 EST

On Tue, 19 May 2009 11:00:35 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> So, I'm really not objecting too much to the patch at hand, but I'd love
> to find a solution to this problem.

It is not hard so solve the problem for /proc/uptime, e.g. like this:

static u64 uptime_jiffies = INITIAL_JIFFIES;
static struct timespec ts_uptime;
static struct timespec ts_idle;

static int uptime_proc_show(struct seq_file *m, void *v)
cputime_t idletime;
u64 now;
int i;

now = get_jiffies_64();
if (uptime_jiffies != now) {
uptime_jiffies = now;
idletime = cputime_zero;
idletime = cputime64_add(idletime,
cputime_to_timespec(idletime, &ts_idle);

seq_printf(m, "%lu.%02lu %lu.%02lu\n",
(unsigned long) ts_uptime.tv_sec,
(ts_uptime.tv_nsec / (NSEC_PER_SEC / 100)),
(unsigned long) ts_idle.tv_sec,
(ts_idle.tv_nsec / (NSEC_PER_SEC / 100)));
return 0;

For /proc/stat it is less clear. Just storing the values in static
variables is not such a good idea as there are lots of values.
10*NR_CPUS + NR_IRQS values to be exact. With NR_CPUS in the thousands
this will waste quite a bit of memory.

I fixed another problem with Michael original patch and added the new
one to reduce the frequency of accesses to kstat_cpu for /proc/uptime.
You'll find both at:

git:// cputime

blue skies,

"Reality continues to ruin my life." - Calvin.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at