LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: malc <av1474@comtv.ru>
To: Con Kolivas <kernel@kolivas.org>
Cc: Ingo Molnar <mingo@elte.hu>,
linux list <linux-kernel@vger.kernel.org>,
zwane@infradead.org, ck list <ck@vds.kolivas.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [patch] sched: accurate user accounting
Date: Mon, 26 Mar 2007 14:49:33 +0400 (MSD) [thread overview]
Message-ID: <Pine.LNX.4.64.0703261439270.2621@linmac.oyster.ru> (raw)
In-Reply-To: <200703260957.34798.kernel@kolivas.org>
On Mon, 26 Mar 2007, Con Kolivas wrote:
> On Monday 26 March 2007 09:01, Con Kolivas wrote:
>> On Monday 26 March 2007 03:14, malc wrote:
>>> On Mon, 26 Mar 2007, Con Kolivas wrote:
>>>> On Monday 26 March 2007 01:19, malc wrote:
>>> Erm... i just looked at the code and suddenly it stopped making any sense
>>> at all:
>>>
>>> p->last_ran = rq->most_recent_timestamp = now;
>>> /* Sanity check. It should never go backwards or ruin accounting
>>> */ if (unlikely(now < p->last_ran))
>>> return;
>>> time_diff = now - p->last_ran;
>>>
>>> First `now' is assigned to `p->last_ran' and the very next line
>>> compares those two values, and then the difference is taken.. I quite
>>> frankly am either very tired or fail to see the point.. time_diff is
>>> either always zero or there's always a race here.
>>
>> Bah major thinko error on my part! That will teach me to post patches
>> untested at 1:30 am. I'll try again shortly sorry.
>
> Ok this one is heavily tested. Please try it when you find the time.
[..snip..]
Done, works. However there's a problem with accuracy comming from a
different angle.
I have this USB video grabber and also quite efficient way of putting
the pixels to the screen. Video is grabbed using isochronous
transfers, i.e. lots of small(on the order of 1K) chunks of data are
being transferred continously instead of one big burst unlike in, for
instance, PCI setup. With your accounting change idle from
`/proc/stat' is accurate but unfortunatelly top(1)/icewm's monitor/etc
apparently use user+sys+nice+intr+softirq+iowait to show the system
load, so system tools claim that the load is 10-12% while in reality
it is ~3%.
This situation is harder to write a hog-like testcase for. Anyhow it
seems the difference in percentage stems from the `intr' field of
`/proc/stat', which fits. And following patch (which should be applied
on top of yours) seems to help. I wouldn't really know what to do with
softirq and the rest of counts touched by this function, so i left them
alone.
Comments?
diff -ru linux-2.6.21-rc4/include/linux/kernel_stat.h linux-2.6.21-rc4-load/include/linux/kernel_stat.h
--- linux-2.6.21-rc4/include/linux/kernel_stat.h 2007-03-26 14:33:19.000000000 +0400
+++ linux-2.6.21-rc4-load/include/linux/kernel_stat.h 2007-03-26 14:06:21.000000000 +0400
@@ -22,6 +22,7 @@
cputime64_t system;
cputime64_t softirq;
cputime64_t irq;
+ cputime64_t irq_ns;
cputime64_t idle;
cputime64_t idle_ns;
cputime64_t iowait;
diff -ru linux-2.6.21-rc4/kernel/sched.c linux-2.6.21-rc4-load/kernel/sched.c
--- linux-2.6.21-rc4/kernel/sched.c 2007-03-26 14:33:19.000000000 +0400
+++ linux-2.6.21-rc4-load/kernel/sched.c 2007-03-26 14:11:36.000000000 +0400
@@ -3148,9 +3148,14 @@
/* Add system time to cpustat. */
tmp = cputime_to_cputime64(cputime);
- if (hardirq_count() - hardirq_offset)
- cpustat->irq = cputime64_add(cpustat->irq, tmp);
- else if (softirq_count())
+ if (hardirq_count() - hardirq_offset) {
+ cpustat->irq_ns = cputime64_add(cpustat->irq_ns, tmp);
+ if (cpustat->irq_ns > JIFFY_NS) {
+ cpustat->irq_ns = cputime64_sub(cpustat->irq_ns,
+ JIFFY_NS);
+ cpustat->irq = cputime64_add(cpustat->irq, 1);
+ }
+ } else if (softirq_count())
cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
else if (p != rq->idle)
cpustat->system = cputime64_add(cpustat->system, tmp);
--
vale
next prev parent reply other threads:[~2007-03-26 10:49 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-25 1:59 [PATCH] [RFC] " Con Kolivas
2007-03-25 2:14 ` Con Kolivas
2007-03-25 7:51 ` [patch] " Ingo Molnar
2007-03-25 8:39 ` Con Kolivas
2007-03-25 9:04 ` Ingo Molnar
2007-03-25 11:34 ` malc
2007-03-25 11:46 ` Con Kolivas
2007-03-25 12:02 ` Con Kolivas
2007-03-25 12:32 ` Gene Heskett
2007-03-25 12:41 ` Con Kolivas
2007-03-25 13:33 ` Gene Heskett
2007-03-25 13:05 ` malc
2007-03-25 13:06 ` malc
2007-03-25 14:15 ` Con Kolivas
2007-03-25 14:57 ` malc
2007-03-25 15:08 ` Con Kolivas
2007-03-25 15:19 ` malc
2007-03-25 15:28 ` Con Kolivas
2007-03-25 17:14 ` malc
2007-03-25 23:01 ` Con Kolivas
2007-03-25 23:57 ` Con Kolivas
2007-03-26 10:49 ` malc [this message]
2007-03-28 11:37 ` Ingo Molnar
2007-06-14 17:56 ` Vassili Karpov
2007-06-14 20:42 ` Ingo Molnar
2007-06-14 20:56 ` malc
2007-06-14 21:18 ` Ingo Molnar
2007-06-14 21:37 ` malc
2007-06-15 3:44 ` Balbir Singh
2007-06-15 6:07 ` malc
2007-06-16 13:21 ` Balbir Singh
2007-06-16 14:07 ` malc
2007-06-16 18:40 ` Ingo Molnar
2007-06-16 20:31 ` malc
2007-03-26 5:11 Al Boldi
2007-03-26 5:27 ` Mike Galbraith
2007-03-26 8:45 ` Con Kolivas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0703261439270.2621@linmac.oyster.ru \
--to=av1474@comtv.ru \
--cc=akpm@linux-foundation.org \
--cc=ck@vds.kolivas.org \
--cc=kernel@kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=zwane@infradead.org \
--subject='Re: [patch] sched: accurate user accounting' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).