[patch 13/41] cpu alloc: NFS statistics

From: Christoph Lameter
Date: Fri May 30 2008 - 00:15:52 EST


Convert NFS statistics to cpu alloc.

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>
---
fs/nfs/iostat.h | 27 +++++++++++----------------
fs/nfs/super.c | 2 +-
2 files changed, 12 insertions(+), 17 deletions(-)

Index: linux-2.6/fs/nfs/iostat.h
===================================================================
--- linux-2.6.orig/fs/nfs/iostat.h 2008-05-26 09:35:31.077736336 -0700
+++ linux-2.6/fs/nfs/iostat.h 2008-05-26 10:01:26.178776581 -0700
@@ -119,13 +119,7 @@ struct nfs_iostats {

static inline void nfs_inc_server_stats(struct nfs_server *server, enum nfs_stat_eventcounters stat)
{
- struct nfs_iostats *iostats;
- int cpu;
-
- cpu = get_cpu();
- iostats = per_cpu_ptr(server->io_stats, cpu);
- iostats->events[stat] ++;
- put_cpu_no_resched();
+ _CPU_INC(server->io_stats->events[stat]);
}

static inline void nfs_inc_stats(struct inode *inode, enum nfs_stat_eventcounters stat)
@@ -135,13 +129,14 @@ static inline void nfs_inc_stats(struct

static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat_bytecounters stat, unsigned long addend)
{
- struct nfs_iostats *iostats;
- int cpu;
-
- cpu = get_cpu();
- iostats = per_cpu_ptr(server->io_stats, cpu);
- iostats->bytes[stat] += addend;
- put_cpu_no_resched();
+#ifdef CONFIG_64BIT
+ _CPU_ADD(server->io_stats->bytes[stat], addend);
+#else
+ /* 32bit cannot perform atomic 64 bit inc sodisable preemption */
+ preempt_disable();
+ THIS_CPU(server->io_stats)->bytes[stat] += addend;
+ preempt_enable_no_resched();
+#endif
}

static inline void nfs_add_stats(struct inode *inode, enum nfs_stat_bytecounters stat, unsigned long addend)
@@ -151,13 +146,13 @@ static inline void nfs_add_stats(struct

static inline struct nfs_iostats *nfs_alloc_iostats(void)
{
- return alloc_percpu(struct nfs_iostats);
+ return CPU_ALLOC(struct nfs_iostats, GFP_KERNEL | __GFP_ZERO);
}

static inline void nfs_free_iostats(struct nfs_iostats *stats)
{
if (stats != NULL)
- free_percpu(stats);
+ CPU_FREE(stats);
}

#endif
Index: linux-2.6/fs/nfs/super.c
===================================================================
--- linux-2.6.orig/fs/nfs/super.c 2008-05-26 09:35:31.097738734 -0700
+++ linux-2.6/fs/nfs/super.c 2008-05-26 09:36:15.900248119 -0700
@@ -620,7 +620,7 @@ static int nfs_show_stats(struct seq_fil
struct nfs_iostats *stats;

preempt_disable();
- stats = per_cpu_ptr(nfss->io_stats, cpu);
+ stats = CPU_PTR(nfss->io_stats, cpu);

for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
totals.events[i] += stats->events[i];

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/