Whamcloud - gitweb
Branch HEAD
authoryangsheng <yangsheng>
Thu, 12 Mar 2009 07:10:12 +0000 (07:10 +0000)
committeryangsheng <yangsheng>
Thu, 12 Mar 2009 07:10:12 +0000 (07:10 +0000)
b=18033

i=adilger, johann

Audit code for CONFIG_PREEMPT interaction.

build/autoconf/lustre-build-linux.m4
libcfs/include/libcfs/linux/kp30.h
libcfs/libcfs/linux/linux-tracefile.c
lustre/include/linux/lustre_compat25.h
lustre/include/lprocfs_status.h
lustre/llite/lproc_llite.c
lustre/obdclass/class_obd.c

index 9f474ce..b7d94a4 100644 (file)
@@ -475,10 +475,6 @@ LB_LINUX_CONFIG([MODULES],[],[
 
 LB_LINUX_CONFIG([MODVERSIONS])
 
-LB_LINUX_CONFIG([PREEMPT],[
-       AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
-])
-
 LB_LINUX_CONFIG([KALLSYMS],[],[
 if test "x$ARCH_UM" = "x" ; then
        AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
index 1f0badd..cbea707 100644 (file)
@@ -404,5 +404,17 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
 }
 #endif
 
+#ifndef get_cpu
+# ifdef CONFIG_PREEMPT
+#  define cfs_get_cpu()  ({ preempt_disable(); smp_processor_id(); })
+#  define cfs_put_cpu()  preempt_enable()
+# else
+#  define cfs_get_cpu()  smp_processor_id()
+#  define cfs_put_cpu()
+# endif
+#else
+# define cfs_get_cpu()   get_cpu()
+# define cfs_put_cpu()   put_cpu()
+#endif /* get_cpu & put_cpu */
 
 #endif
index 52986c2..78d0d8a 100644 (file)
 #include <libcfs/libcfs.h>
 #include "tracefile.h"
 
-#ifndef get_cpu
-#define get_cpu() smp_processor_id()
-#define put_cpu() do { } while (0)
-#endif
-
 /* three types of trace_data in linux */
 enum {
        TCD_TYPE_PROC = 0,
@@ -152,7 +147,7 @@ void tracefile_write_unlock()
 char *
 trace_get_console_buffer(void)
 {
-       int  cpu = get_cpu();
+       int  cpu = cfs_get_cpu();
        int  idx;
 
        if (in_irq()) {
@@ -169,7 +164,7 @@ trace_get_console_buffer(void)
 void
 trace_put_console_buffer(char *buffer)
 {
-       put_cpu();
+       cfs_put_cpu();
 }
 
 struct trace_cpu_data *
@@ -178,7 +173,7 @@ trace_get_tcd(void)
        struct trace_cpu_data *tcd;
        int cpu;
 
-       cpu = get_cpu();
+       cpu = cfs_get_cpu();
        if (in_irq())
                tcd = &(*trace_data[TCD_TYPE_IRQ])[cpu].tcd;
        else if (in_softirq())
@@ -196,7 +191,7 @@ trace_put_tcd (struct trace_cpu_data *tcd)
 {
        trace_unlock_tcd(tcd);
 
-       put_cpu();
+       cfs_put_cpu();
 }
 
 int trace_lock_tcd(struct trace_cpu_data *tcd)
index b197133..e06d907 100644 (file)
@@ -620,16 +620,6 @@ static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
                 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
index 3056bd0..e7e3e8b 100644 (file)
@@ -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 {
@@ -354,8 +356,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;
 }
@@ -364,6 +368,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:
index be49e62..cd077aa 100644 (file)
@@ -712,7 +712,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 */
@@ -735,7 +735,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
                 GOTO(out, err);
 
         sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string),
-                                               LPROCFS_STATS_FLAG_PERCPU);
+                                               LPROCFS_STATS_FLAG_NONE);
         if (sbi->ll_ra_stats == NULL)
                 GOTO(out, err = -ENOMEM);
 
index 29ca59b..b1857a8 100644 (file)
@@ -552,7 +552,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);