From: Ravikiran G Thirumalai <kiran@in.ibm.com>
To: Andrew Morton <akpm@zip.com.au>
Cc: linux-kernel@vger.kernel.org,
lse <lse-tech@lists.sourceforge.net>,
riel@conectiva.com.br, Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [RFC] Scalable statistics counters using kmalloc_percpu
Date: Mon, 29 Jul 2002 16:27:30 +0530 [thread overview]
Message-ID: <20020729162730.A2393@in.ibm.com> (raw)
In-Reply-To: <3D41990A.EDC1A530@zip.com.au>; from akpm@zip.com.au on Fri, Jul 26, 2002 at 11:46:34AM -0700
On Fri, Jul 26, 2002 at 11:46:34AM -0700, Andrew Morton wrote:
> Ravikiran G Thirumalai wrote:
> >
> > Here is a Scalable statistics counter implementation which works on top
> > of the kmalloc_percpu dynamic allocator published by Dipankar.
> > This patch is against 2.5.27.
> >
> > ...
> > +static inline int __statctr_init(statctr_t *stctr)
> > +{
> > + stctr->ctr = kmalloc_percpu(sizeof(*(stctr->ctr)), GFP_ATOMIC);
> > + if(!stctr->ctr)
> > + return -1;
> > + return 0;
> > +}
>
> Minor nit: please force the caller to pass in the gfp_flags when
> designing an API like this. The fact that you were forced to use
> GFP_ATOMIC here shows why...
Yep, I'll do that with the next release.
<snip>
> General comment: we need to clean up the kernel_stat stuff. We
> cannot just make it per-cpu because it is 32k in size already. I
> would suggest that we should break out the disk accounting and
> make the rest of kernel_stat per CPU.
>
> That would be a great application of your interface, and a good
> way to get your interface merged ;) Is that something which you
> have time to do?
Sure,... anything to get these interfaces merged :)
Are you looking at something on the lines as the diff below?
What about /proc/stat ? Is it a good idea to have separate /proc files
for disk stats and cpu usage stats? (It'll be good for statctrs that way,
applications monitoring disk_stats only don't cause statctr_reads on
cpu_usage stats then)
--- linux-2.5.29/include/linux/kernel_stat.h Sat Jul 27 08:28:36 2002
+++ statctr-2.5.29/include/linux/kernel_stat.h Mon Jul 29 14:21:18 2002
@@ -15,10 +15,13 @@
#define DK_MAX_MAJOR 16
#define DK_MAX_DISK 16
-struct kernel_stat {
- unsigned int per_cpu_user[NR_CPUS],
- per_cpu_nice[NR_CPUS],
- per_cpu_system[NR_CPUS];
+struct cpu_usage_stat {
+ statctr_t cpu_user;
+ statctr_t cpu_nice;
+ statctr_t cpu_system;
+};
+
+struct disk_stat {
unsigned int dk_drive[DK_MAX_MAJOR][DK_MAX_DISK];
unsigned int dk_drive_rio[DK_MAX_MAJOR][DK_MAX_DISK];
unsigned int dk_drive_wio[DK_MAX_MAJOR][DK_MAX_DISK];
@@ -26,13 +29,18 @@
unsigned int dk_drive_wblk[DK_MAX_MAJOR][DK_MAX_DISK];
unsigned int pgpgin, pgpgout;
unsigned int pswpin, pswpout;
- unsigned int pgalloc, pgfree;
- unsigned int pgactivate, pgdeactivate;
- unsigned int pgfault, pgmajfault;
- unsigned int pgscan, pgsteal;
- unsigned int pageoutrun, allocstall;
+ unsigned int pgalloc, pgfree;
+ unsigned int pgactivate, pgdeactivate;
+ unsigned int pgfault, pgmajfault;
+ unsigned int pgscan, pgsteal;
+ unsigned int pageoutrun, allocstall;
+};
+
+struct kernel_stat {
+ struct cpu_usage_stat cpu_stat;
+ struct disk_stat disk_stat;
#if !defined(CONFIG_ARCH_S390)
- unsigned int irqs[NR_CPUS][NR_IRQS];
+ statctr_t irqs[NR_IRQS];
#endif
};
@@ -44,8 +52,8 @@
* Maybe we need to smp-ify kernel_stat some day. It would be nice to do
* that without having to modify all the code that increments the stats.
*/
-#define KERNEL_STAT_INC(x) kstat.x++
-#define KERNEL_STAT_ADD(x, y) kstat.x += y
+#define DISK_STAT_INC(x) kstat.disk_stat.x++
+#define DISK_STAT_ADD(x, y) kstat.disk_sat.x += y
#if !defined(CONFIG_ARCH_S390)
/*
@@ -53,12 +61,7 @@
*/
static inline int kstat_irqs (int irq)
{
- int i, sum=0;
-
- for (i = 0 ; i < NR_CPUS ; i++)
- sum += kstat.irqs[i][irq];
-
- return sum;
+ return statctr_read(&kstat.irqs[irq]);
}
#endif
next prev parent reply other threads:[~2002-07-29 10:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-26 15:10 [RFC] Scalable statistics counters using kmalloc_percpu Ravikiran G Thirumalai
2002-07-26 15:27 ` Rik van Riel
2002-07-26 15:54 ` [Lse-tech] " Dipankar Sarma
2002-07-29 14:18 ` Ravikiran G Thirumalai
2002-07-26 18:46 ` Andrew Morton
2002-07-26 19:46 ` William Lee Irwin III
2002-07-26 19:50 ` Robert Love
2002-07-26 19:53 ` William Lee Irwin III
2002-07-26 20:15 ` [Lse-tech] " William Lee Irwin III
2002-07-26 20:22 ` Robert Love
2002-07-27 12:00 ` Zwane Mwaikambo
2002-07-27 12:21 ` Zwane Mwaikambo
2002-07-28 21:33 ` Martin J. Bligh
2002-07-29 10:31 ` Zwane Mwaikambo
2002-07-29 14:54 ` Martin J. Bligh
2002-07-27 1:56 ` Rusty Russell
2002-07-27 4:45 ` Andrew Morton
2002-07-27 4:59 ` Rusty Russell
2002-07-27 6:16 ` Andrew Morton
2002-07-29 10:57 ` Ravikiran G Thirumalai [this message]
2002-07-29 18:23 ` Andrew Morton
2002-07-29 18:50 ` [Lse-tech] " Dipankar Sarma
2002-07-30 11:25 ` Ravikiran G Thirumalai
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=20020729162730.A2393@in.ibm.com \
--to=kiran@in.ibm.com \
--cc=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
--cc=riel@conectiva.com.br \
--cc=rusty@rustcorp.com.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.