From: Andrew Morton <akpm@osdl.org>
To: Kingsley Cheung <kingsley@aurema.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] For preventing kstat overflow
Date: Mon, 8 Mar 2004 18:53:54 -0800 [thread overview]
Message-ID: <20040308185354.70040c8b.akpm@osdl.org> (raw)
In-Reply-To: <20040309132338.A30341@aurema.com>
Kingsley Cheung <kingsley@aurema.com> wrote:
>
> Hi All,
>
> What do people think of a patch to change the fields in cpu_usage_stat
> from unsigned ints to unsigned long longs? And the same change for
> nr_switches in the runqueue structure too?
Sounds unavoidable.
> Its actually worse for context
> switches on a busy system, for we've been seeing an average of ten
> switches a tick for some of the statistics we have.
Sounds broken. What CPU scheduler are you using?
> for_each_online_cpu(i) {
> - seq_printf(p, "cpu%d %u %u %u %u %u %u %u\n",
> + seq_printf(p, "cpu%d %llu %llu %llu %llu %llu %llu %llu\n",
> i,
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.user),
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.nice),
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.system),
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.idle),
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.iowait),
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.irq),
> - jiffies_to_clock_t(kstat_cpu(i).cpustat.softirq));
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.user),
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.nice),
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.system),
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.idle),
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.iowait),
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.irq),
> + jiffies_64_to_clock_t(kstat_cpu(i).cpustat.softirq));
jiffies_64_to_clock_t() takes and returns a u64, not an unsigned long long.
> }
> - seq_printf(p, "intr %u", sum);
> + seq_printf(p, "intr %llu", sum);
It would be best to convert everything to u64, not to unsigned long long.
But cast them to unsigned long long for printk.
It's a bit ugly, but at least it pins everything down to know types and
sizes on all architectures.
> struct cpu_usage_stat {
> - unsigned int user;
> - unsigned int nice;
> - unsigned int system;
> - unsigned int softirq;
> - unsigned int irq;
> - unsigned int idle;
> - unsigned int iowait;
> + unsigned long long user;
> + unsigned long long nice;
> + unsigned long long system;
> + unsigned long long softirq;
> + unsigned long long irq;
> + unsigned long long idle;
> + unsigned long long iowait;
Do these have appropriate locking or are we just accepting the occasional
glitch?
next prev parent reply other threads:[~2004-03-09 2:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-09 2:23 Kingsley Cheung
2004-03-09 2:53 ` Andrew Morton [this message]
2004-03-09 5:57 ` Kingsley Cheung
2004-03-09 23:13 ` Kingsley Cheung
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=20040308185354.70040c8b.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=kingsley@aurema.com \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®