From: Mr NeilBrown Date: Fri, 20 Nov 2020 02:19:49 +0000 (+1100) Subject: LU-16807 libcfs: give the tcd_lock types different classes. X-Git-Tag: 2.15.56~23 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F50992%2F3;p=fs%2Flustre-release.git LU-16807 libcfs: give the tcd_lock types different classes. 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. Test-Parameters: trivial testlist=sanity-lnet Signed-off-by: Mr NeilBrown Change-Id: Icca7706d8e0d8ae8add4c540d2da090b53d7e65c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50992 Tested-by: Maloo Tested-by: jenkins Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index d79ec06..e45cf82 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -1140,7 +1140,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 spin_lock_init() + * calls so that the locks get three separate classes + * and lockdep never thinks they are related. As they + * are used in different interrupt contexts, lockdep + * would otherwise think that 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;