[lustre-devel] [PATCH 4/7] lustre: give different tcd_lock types different classes.

NeilBrown neilb at suse.com
Sun Jul 29 20:49:32 PDT 2018


There are three different trace contexts:
 process, softirq, irq.
Each has its own lock (tcd_lock) which is locked
as appropriate for that context.
lockdep currently doesn't see that they are different
and so deduces that the different uses might lead to
deadlocks.
So use separate calls to spin_lock_init() so that they
each get a separate lock class, and lockdep sees no
problem.

Signed-off-by: NeilBrown <neilb at suse.com>
---
 drivers/staging/lustre/lnet/libcfs/tracefile.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index d4c80cf254e4..40048165fc16 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -1285,7 +1285,23 @@ int cfs_tracefile_init(int max_pages)
 	cfs_tcd_for_each(tcd, i, j) {
 		int factor = pages_factor[i];
 
-		spin_lock_init(&tcd->tcd_lock);
+		/* Note that we have three separate calls so
+		 * they the locks get three separate classes
+		 * and lockdep never thinks they are related.
+		 * As they are used in different interrupt
+		 * contexts, lockdep think the usage would conflict.
+		 */
+		switch(i) {
+		case CFS_TCD_TYPE_PROC:
+			spin_lock_init(&tcd->tcd_lock);
+			break;
+		case CFS_TCD_TYPE_SOFTIRQ:
+			spin_lock_init(&tcd->tcd_lock);
+			break;
+		case CFS_TCD_TYPE_IRQ:
+			spin_lock_init(&tcd->tcd_lock);
+			break;
+		}
 		tcd->tcd_pages_factor = factor;
 		tcd->tcd_type = i;
 		tcd->tcd_cpu = j;




More information about the lustre-devel mailing list