From af1eacfca23ba264c394753ef32cfb65fd052722 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Thu, 12 Mar 2009 15:05:31 +0000 Subject: [PATCH] Branch b1_8 b=18033 i=adilger, johann Audit code for CONFIG_PREEMPT interaction. --- lustre/include/linux/lustre_compat25.h | 10 ---------- lustre/include/lprocfs_status.h | 12 +++++++++--- lustre/llite/llite_internal.h | 8 ++++---- lustre/llite/lproc_llite.c | 4 ++-- lustre/llite/rw.c | 4 ++-- lustre/obdclass/class_obd.c | 2 +- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 7f25733..10a2fe3 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -456,16 +456,6 @@ int ll_unregister_blkdev(unsigned int dev, const char *name) vfs_rename(old,old_dir,new,new_dir) #endif -#ifndef get_cpu -#ifdef CONFIG_PREEMPT -#define get_cpu() ({ preempt_disable(); smp_processor_id(); }) -#define put_cpu() preempt_enable() -#else -#define get_cpu() smp_processor_id() -#define put_cpu() -#endif -#endif /* get_cpu & put_cpu */ - #ifndef for_each_possible_cpu #define for_each_possible_cpu(i) for_each_cpu(i) #endif diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index d24e9dc..3dd0b01 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -165,9 +165,11 @@ struct lprocfs_percpu { #define LPROCFS_GET_SMP_ID 0x0002 enum lprocfs_stats_flags { - LPROCFS_STATS_FLAG_PERCPU = 0x0000, /* per cpu counter */ + LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */ LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu * area and need locking */ + LPROCFS_STATS_GET_SMP_ID = 0x0002, /* just record locking with + * LPROCFS_GET_SMP_ID flag */ }; enum lprocfs_fields_flags { @@ -327,8 +329,10 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int type) } else { if (type & LPROCFS_GET_NUM_CPU) rc = num_possible_cpus(); - if (type & LPROCFS_GET_SMP_ID) - rc = smp_processor_id(); + if (type & LPROCFS_GET_SMP_ID) { + stats->ls_flags &= LPROCFS_STATS_GET_SMP_ID; + rc = cfs_get_cpu(); + } } return rc; } @@ -337,6 +341,8 @@ static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats) { if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) spin_unlock(&stats->ls_lock); + else if (stats->ls_flags & LPROCFS_STATS_GET_SMP_ID) + cfs_put_cpu(); } /* Two optimized LPROCFS counter increment functions are provided: diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 4e8748e..9c4f990 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -421,7 +421,7 @@ static inline struct ll_pglist_data *ll_pglist_double_lock( struct ll_sb_info *sbi, int cpu, struct ll_pglist_data **pd_cpu) { - int current_cpu = get_cpu(); + int current_cpu = cfs_get_cpu(); if (cpu == current_cpu) { ll_pglist_cpu_lock(sbi, cpu); @@ -448,19 +448,19 @@ static inline void ll_pglist_double_unlock(struct ll_sb_info *sbi, int cpu) ll_pglist_cpu_unlock(sbi, cpu); ll_pglist_cpu_unlock(sbi, current_cpu); } - put_cpu(); + cfs_put_cpu(); } static inline struct ll_pglist_data *ll_pglist_lock(struct ll_sb_info *sbi) { - ll_pglist_cpu_lock(sbi, get_cpu()); + ll_pglist_cpu_lock(sbi, cfs_get_cpu()); return LL_PGLIST_DATA(sbi); } static inline void ll_pglist_unlock(struct ll_sb_info *sbi) { ll_pglist_cpu_unlock(sbi, smp_processor_id()); - put_cpu(); + cfs_put_cpu(); } struct ll_ra_read { diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 6d3bb3d..4c17455 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -735,7 +735,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, entry->data = sbi; sbi->ll_ra_stats = lprocfs_alloc_stats(LL_RA_STAT, - LPROCFS_STATS_FLAG_PERCPU); + LPROCFS_STATS_FLAG_NONE); for (id = 0; id < LL_RA_STAT; id++) lprocfs_counter_init(sbi->ll_ra_stats, id, 0, ra_stats_string[id], "pages"); @@ -763,7 +763,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, /* File operations stats */ sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES, - LPROCFS_STATS_FLAG_PERCPU); + LPROCFS_STATS_FLAG_NONE); if (sbi->ll_stats == NULL) GOTO(out, err = -ENOMEM); /* do counter init */ diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 87fecc5..5a9c582 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -824,7 +824,7 @@ static struct ll_async_page *llap_from_page_with_lockh(struct page *page, RETURN(ERR_PTR(-EINVAL)); /* limit the number of lustre-cached pages */ - cpu = get_cpu(); + cpu = cfs_get_cpu(); pd = LL_PGLIST_DATA(sbi); target = pd->llpd_count - pd->llpd_budget; if (target > 0) { @@ -845,7 +845,7 @@ static struct ll_async_page *llap_from_page_with_lockh(struct page *page, if ((rc == 0) && target > 0) llap_shrink_cache_internal(sbi, cpu, target + 32); } - put_cpu(); + cfs_put_cpu(); OBD_SLAB_ALLOC(llap, ll_async_page_slab, CFS_ALLOC_STD, ll_async_page_slab_size); diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 9a12337..0eb7ea2 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -545,7 +545,7 @@ int init_obdclass(void) obd_zombie_impexp_init(); #ifdef LPROCFS obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, - LPROCFS_STATS_FLAG_PERCPU); + LPROCFS_STATS_FLAG_NONE); if (obd_memory == NULL) { CERROR("kmalloc of 'obd_memory' failed\n"); RETURN(-ENOMEM); -- 1.8.3.1