All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 20/24] lustre: move tcd locking across to tracefile.c
Date: Fri, 15 Jun 2018 17:11:30 +1000	[thread overview]
Message-ID: <152904669080.10587.2737350683529078044.stgit@noble> (raw)
In-Reply-To: <152904663333.10587.10934053155404014785.stgit@noble>

No need to have this in linux-tracefile.c

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lnet/libcfs/linux-tracefile.c   |   35 ------------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |   59 ++++++++++++++++++++
 drivers/staging/lustre/lnet/libcfs/tracefile.h     |   28 ---------
 3 files changed, 59 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c b/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
index 64a5bc1e2db8..3af77228cd7a 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
@@ -116,41 +116,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->tc_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);
-}
-
 void
 cfs_set_ptldebug_header(struct ptldebug_header *header,
 			struct libcfs_debug_msg_data *msgdata,
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 72321ce4c394..6d567a9ad8ea 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -109,6 +109,65 @@ struct cfs_trace_page {
 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->tc_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)
 {
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index 9f6b73d3b6fd..f49a9ba00864 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -49,8 +49,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;
@@ -195,11 +193,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++)
-
 void cfs_set_ptldebug_header(struct ptldebug_header *header,
 			     struct libcfs_debug_msg_data *m,
 			     unsigned long stack);
@@ -207,9 +200,6 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
 			  const char *buf, int len, const char *file,
 			  const char *fn);
 
-int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
-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];
 enum cfs_trace_buf_type cfs_trace_buf_idx_get(void);
 
@@ -222,24 +212,6 @@ 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);
 

  parent reply	other threads:[~2018-06-15  7:11 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  7:11 [lustre-devel] [PATCH 00/24] lustre - more cleanups including module reduction NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 18/24] lustre/lnet: move tracefile locking from linux-tracefile.c to tracefile.c NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 17/24] lustre: remove lustre_compat.h NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 21/24] lustre: move remainder of linux-tracefile.c to tracefile.c NeilBrown
2018-06-21  1:37   ` James Simmons
2018-06-22  3:19     ` NeilBrown
2018-06-24 20:29       ` James Simmons
2018-06-24 23:25         ` NeilBrown
2018-06-25 21:52           ` James Simmons
2018-06-15  7:11 ` [lustre-devel] [PATCH 03/24] kbuild: support building of per-directory mod.a NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 16/24] lustre: remove redefinition of module_init() NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 06/24] lustre: build ldlm in the ldlm directory NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 05/24] kbuild: Add documentation for modobj-m NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 11/24] lustre: discard current_n*groups macros NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 04/24] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 24/24] lustre: discard TCD_MAX_TYPES NeilBrown
2018-06-21  1:38   ` James Simmons
2018-06-21  4:28     ` NeilBrown
2018-06-24 20:37       ` James Simmons
2018-06-24 23:26         ` NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 13/24] lustre: discard NO_QUOTA and QUOTA_OK NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 01/24] kbuild: detect directories in components of a module NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 22/24] lustre: fold cfs_tracefile_*_arch into their only callers NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 08/24] lustre: use truncate_inode_page in place of truncate_complete_page NeilBrown
2018-06-16  0:17   ` James Simmons
2018-06-16  0:52     ` NeilBrown
2018-06-16  0:59       ` Oleg Drokin
2018-06-18  2:03         ` NeilBrown
2018-06-25  0:02           ` [lustre-devel] [PATCH 1/3] lustre: use generic_error_remove_page() NeilBrown
2018-06-25  0:02             ` [lustre-devel] [PATCH 2/3] lustre: use delete_from_page_cache() for directory pages NeilBrown
2018-06-25  0:03               ` [lustre-devel] [PATCH 3/3] lustre: discard truncate_complete_page() NeilBrown
2018-06-26  0:19                 ` James Simmons
2018-06-25  0:38               ` [lustre-devel] [PATCH 2/3] lustre: use delete_from_page_cache() for directory pages Oleg Drokin
2018-06-26  0:18               ` James Simmons
2018-06-25  0:38             ` [lustre-devel] [PATCH 1/3] lustre: use generic_error_remove_page() Oleg Drokin
2018-06-25  1:57               ` NeilBrown
2018-06-26  0:26                 ` James Simmons
2018-06-26  0:14             ` James Simmons
2018-06-15  7:11 ` [lustre-devel] [PATCH 15/24] lustre: centralize TIMES_SET_FLAGS NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 07/24] lustre: merge libcfs module into lnet NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 09/24] lustre: don't use spare bits in iattr.ia_valid NeilBrown
2018-06-21  1:35   ` James Simmons
2018-06-21  4:19     ` NeilBrown
2018-06-22  2:23       ` NeilBrown
2018-06-24 20:33         ` James Simmons
2018-06-24 23:50           ` NeilBrown
2018-06-15  7:11 ` NeilBrown [this message]
2018-06-15  7:11 ` [lustre-devel] [PATCH 10/24] lustre: remove lustre_patchless_compat.h NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 19/24] lustre: open code cfs_trace_max_debug_mb() into cfs_trace_set_debug_mb() NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 02/24] kbuild: treat a directory listed in a composite object as foo/mod.a NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 14/24] lustre: discard ext2* bit operations NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 12/24] lustre: discard LTIME_S macro NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 23/24] lustre: renamed CFS_TCD_TYPE_MAX to CFS_TCD_TYPE_CNT NeilBrown
2018-06-21  1:48 ` [lustre-devel] [PATCH 00/24] lustre - more cleanups including module reduction James Simmons
2018-06-21  2:29   ` Patrick Farrell
2018-06-21  2:57     ` James Simmons
2018-06-21  7:22       ` Andreas Dilger
2018-06-21 12:28         ` Patrick Farrell
2018-06-24 20:35           ` James Simmons
2018-06-24 23:40           ` NeilBrown
2018-06-26  1:13             ` James Simmons
2018-06-26 13:51               ` Patrick Farrell
2018-06-27  3:08                 ` NeilBrown
2018-06-27  4:00                   ` Cory Spitz
2018-06-28  1:26                     ` NeilBrown
2018-06-27 11:01                   ` Andreas Dilger
2018-06-27 12:06                     ` Patrick Farrell
2018-06-28  1:59                       ` NeilBrown
2018-06-28  2:35                         ` Patrick Farrell
2018-06-28 23:12                           ` Andreas Dilger
2018-07-05 23:47                             ` James Simmons
2018-07-06  0:01                               ` Doug Oucharek
2018-06-28 15:03                         ` Cory Spitz
2018-06-28 17:03                           ` Doug Oucharek
2018-07-04 17:54                             ` Alexey Lyashkov
2018-06-28  1:39                     ` NeilBrown
2018-06-21  3:00     ` NeilBrown
2018-06-21  3:42       ` Patrick Farrell
2018-06-24 20:39       ` James Simmons
2018-06-21  2:54   ` NeilBrown
2018-06-24 20:46     ` James Simmons
2018-06-24 23:58       ` NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=152904669080.10587.2737350683529078044.stgit@noble \
    --to=neilb@suse.com \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.