[rfc 15/45] cpu alloc: genhd statistics conversion

clameter
2007-11-20T01:18:35Z

[-- Attachment #1: 0023-cpu-alloc-genhd-statistics-conversion.patch --]
[-- Type: text/plain, Size: 2228 bytes --]

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
include/linux/genhd.h | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

Index: linux-2.6/include/linux/genhd.h
===================================================================
--- linux-2.6.orig/include/linux/genhd.h 2007-11-18 14:38:24.285456612 -0800
+++ linux-2.6/include/linux/genhd.h 2007-11-18 22:04:47.428523761 -0800
@@ -158,21 +158,21 @@ struct disk_attribute {
*/
#ifdef CONFIG_SMP
#define __disk_stat_add(gendiskp, field, addnd) \
- (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd)
+ __CPU_ADD(gendiskp->dkstats->field, addnd)

#define disk_stat_read(gendiskp, field) \
({ \
typeof(gendiskp->dkstats->field) res = 0; \
int i; \
for_each_possible_cpu(i) \
- res += per_cpu_ptr(gendiskp->dkstats, i)->field; \
+ res += CPU_PTR(gendiskp->dkstats, i)->field; \
res; \
})

static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
int i;
for_each_possible_cpu(i)
- memset(per_cpu_ptr(gendiskp->dkstats, i), value,
+ memset(CPU_PTR(gendiskp->dkstats, i), value,
sizeof (struct disk_stats));
}

@@ -187,11 +187,7 @@ static inline void disk_stat_set_all(str
#endif

#define disk_stat_add(gendiskp, field, addnd) \
- do { \
- preempt_disable(); \
- __disk_stat_add(gendiskp, field, addnd); \
- preempt_enable(); \
- } while (0)
+ _CPU_ADD(gendiskp->dkstats->field, addnd);

#define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1)
#define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1)
@@ -209,7 +205,7 @@ static inline void disk_stat_set_all(str
#ifdef CONFIG_SMP
static inline int init_disk_stats(struct gendisk *disk)
{
- disk->dkstats = alloc_percpu(struct disk_stats);
+ disk->dkstats = CPU_ALLOC(struct disk_stats, GFP_KERNEL | __GFP_ZERO);
if (!disk->dkstats)
return 0;
return 1;
@@ -217,7 +213,7 @@ static inline int init_disk_stats(struct

static inline void free_disk_stats(struct gendisk *disk)
{
- free_percpu(disk->dkstats);
+ CPU_FREE(disk->dkstats);
}
#else /* CONFIG_SMP */
static inline int init_disk_stats(struct gendisk *disk)

--