Whamcloud - gitweb
LU-9859 libcfs: move tcd locking across to tracefile.c 01/38601/4
authorMr NeilBrown <neilb@suse.de>
Thu, 14 May 2020 16:23:01 +0000 (12:23 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 08:25:54 +0000 (08:25 +0000)
No need to have this in linux-tracefile.c

Test-Parameters: trivial
Change-Id: I3fdc70ad5f32ea7ff78c778565f01eaaa78f1e94
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/38601
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/linux-tracefile.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h

index 5e6b18b..937fe65 100644 (file)
@@ -117,41 +117,6 @@ enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)
        return CFS_TCD_TYPE_PROC;
 }
 
-/*
- * The walking argument indicates the locking comes from all tcd types
- * iterator and we must lock it and dissable local irqs to avoid deadlocks
- * with other interrupt locks that might be happening. See LU-1311
- * for details.
- */
-int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking)
-       __acquires(&tcd->tcd_lock)
-{
-       __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_MAX);
-       if (tcd->tcd_type == CFS_TCD_TYPE_IRQ)
-               spin_lock_irqsave(&tcd->tcd_lock, tcd->tcd_lock_flags);
-       else if (tcd->tcd_type == CFS_TCD_TYPE_SOFTIRQ)
-               spin_lock_bh(&tcd->tcd_lock);
-       else if (unlikely(walking))
-               spin_lock_irq(&tcd->tcd_lock);
-       else
-               spin_lock(&tcd->tcd_lock);
-       return 1;
-}
-
-void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking)
-       __releases(&tcd->tcd_lock)
-{
-       __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_MAX);
-       if (tcd->tcd_type == CFS_TCD_TYPE_IRQ)
-               spin_unlock_irqrestore(&tcd->tcd_lock, tcd->tcd_lock_flags);
-       else if (tcd->tcd_type == CFS_TCD_TYPE_SOFTIRQ)
-               spin_unlock_bh(&tcd->tcd_lock);
-       else if (unlikely(walking))
-               spin_unlock_irq(&tcd->tcd_lock);
-       else
-               spin_unlock(&tcd->tcd_lock);
-}
-
 int cfs_tcd_owns_tage(struct cfs_trace_cpu_data *tcd,
                      struct cfs_trace_page *tage)
 {
index 7ab2371..ac126e8 100644 (file)
@@ -63,6 +63,64 @@ static DECLARE_RWSEM(cfs_tracefile_sem);
 static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
                                        struct cfs_trace_cpu_data *tcd);
 
+/* trace file lock routines */
+/* The walking argument indicates the locking comes from all tcd types
+ * iterator and we must lock it and dissable local irqs to avoid deadlocks
+ * with other interrupt locks that might be happening. See LU-1311
+ * for details.
+ */
+int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking)
+       __acquires(&tcd->tcd_lock)
+{
+       __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_MAX);
+       if (tcd->tcd_type == CFS_TCD_TYPE_IRQ)
+               spin_lock_irqsave(&tcd->tcd_lock, tcd->tcd_lock_flags);
+       else if (tcd->tcd_type == CFS_TCD_TYPE_SOFTIRQ)
+               spin_lock_bh(&tcd->tcd_lock);
+       else if (unlikely(walking))
+               spin_lock_irq(&tcd->tcd_lock);
+       else
+               spin_lock(&tcd->tcd_lock);
+       return 1;
+}
+
+void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking)
+       __releases(&tcd->tcd_lock)
+{
+       __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_MAX);
+       if (tcd->tcd_type == CFS_TCD_TYPE_IRQ)
+               spin_unlock_irqrestore(&tcd->tcd_lock, tcd->tcd_lock_flags);
+       else if (tcd->tcd_type == CFS_TCD_TYPE_SOFTIRQ)
+               spin_unlock_bh(&tcd->tcd_lock);
+       else if (unlikely(walking))
+               spin_unlock_irq(&tcd->tcd_lock);
+       else
+               spin_unlock(&tcd->tcd_lock);
+}
+
+#define cfs_tcd_for_each_type_lock(tcd, i, cpu)                                \
+       for (i = 0; cfs_trace_data[i] &&                                \
+            (tcd = &(*cfs_trace_data[i])[cpu].tcd) &&                  \
+            cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++)
+
+static inline struct cfs_trace_cpu_data *
+cfs_trace_get_tcd(void)
+{
+       struct cfs_trace_cpu_data *tcd =
+               &(*cfs_trace_data[cfs_trace_buf_idx_get()])[get_cpu()].tcd;
+
+       cfs_trace_lock_tcd(tcd, 0);
+
+       return tcd;
+}
+
+static inline void cfs_trace_put_tcd(struct cfs_trace_cpu_data *tcd)
+{
+       cfs_trace_unlock_tcd(tcd, 0);
+
+       put_cpu();
+}
+
 static inline struct cfs_trace_page *
 cfs_tage_from_list(struct list_head *list)
 {
index 30c5ae2..51b0cb4 100644 (file)
@@ -42,8 +42,6 @@ enum cfs_trace_buf_type {
        CFS_TCD_TYPE_MAX
 };
 
-/* trace file lock routines */
-
 #define TRACEFILE_NAME_SIZE 1024
 extern char      cfs_tracefile[TRACEFILE_NAME_SIZE];
 extern long long cfs_tracefile_size;
@@ -187,11 +185,6 @@ extern union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS];
             j < num_possible_cpus();                                     \
             j++, (tcd) = &(*cfs_trace_data[i])[j].tcd)
 
-#define cfs_tcd_for_each_type_lock(tcd, i, cpu)                           \
-    for (i = 0; cfs_trace_data[i] &&                                      \
-         (tcd = &(*cfs_trace_data[i])[cpu].tcd) &&                        \
-         cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++)
-
 /* XXX nikita: this declaration is internal to tracefile.c and should probably
  * be moved there */
 struct page_collection {
@@ -250,9 +243,6 @@ extern void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
                                  const char *buf, int len, const char *file,
                                  const char *fn);
 
-extern int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
-extern void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
-
 extern char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
 extern enum cfs_trace_buf_type cfs_trace_buf_idx_get(void);
 
@@ -264,22 +254,6 @@ static inline char *cfs_trace_get_console_buffer(void)
        return cfs_trace_console_buffers[i][j];
 }
 
-static inline struct cfs_trace_cpu_data *cfs_trace_get_tcd(void)
-{
-       struct cfs_trace_cpu_data *tcd =
-               &(*cfs_trace_data[cfs_trace_buf_idx_get()])[get_cpu()].tcd;
-
-       cfs_trace_lock_tcd(tcd, 0);
-
-       return tcd;
-}
-
-static inline void cfs_trace_put_tcd(struct cfs_trace_cpu_data *tcd)
-{
-       cfs_trace_unlock_tcd(tcd, 0);
-       put_cpu();
-}
-
 int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp,
                                struct list_head *stock);