[PATCH] xfs: fix spurious spin_is_locked() assert failures on non-smp kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The 0-day kernel test robot reports assertion failures on
!CONFIG_SMP kernels due to failed spin_is_locked() checks. As it
turns out, spin_is_locked() is hardcoded to return zero on
!CONFIG_SMP kernels and so this function cannot be relied on to
verify spinlock state in this configuration.

To avoid this problem, update the associated asserts to fail only
when CONFIG_SMP is enabled in the kernel. Note that this is not
necessary for one assert that expects a zero return from
spin_is_locked(). Update this assert anyways for consistency and
future proofing.

Reported-by: kbuild test robot <fengguang.wu@xxxxxxxxx>
Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---

Darrick,

FYI, this one applies on top of Linus' latest 4.12.0-rc4 tree as that is where
the particular assert that the 0-day test tripped over is. Otherwise this
suppresses these assert failures on some quick !SMP tests and survives some
overnight sanity testing on my normal (SMP) test box. Thanks!

Brian

 fs/xfs/xfs_buf.c    | 2 +-
 fs/xfs/xfs_icache.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 07b77b7..d60f917 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -117,7 +117,7 @@ static inline void
 __xfs_buf_ioacct_dec(
 	struct xfs_buf	*bp)
 {
-	ASSERT(spin_is_locked(&bp->b_lock));
+	ASSERT(spin_is_locked(&bp->b_lock) || !IS_ENABLED(CONFIG_SMP));
 
 	if (bp->b_state & XFS_BSTATE_IN_FLIGHT) {
 		bp->b_state &= ~XFS_BSTATE_IN_FLIGHT;
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index f61c84f8..5cecb36 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -66,7 +66,7 @@ xfs_inode_alloc(
 
 	XFS_STATS_INC(mp, vn_active);
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
-	ASSERT(!spin_is_locked(&ip->i_flags_lock));
+	ASSERT(!spin_is_locked(&ip->i_flags_lock) || !IS_ENABLED(CONFIG_SMP));
 	ASSERT(!xfs_isiflocked(ip));
 	ASSERT(ip->i_ino == 0);
 
@@ -190,7 +190,7 @@ xfs_perag_set_reclaim_tag(
 {
 	struct xfs_mount	*mp = pag->pag_mount;
 
-	ASSERT(spin_is_locked(&pag->pag_ici_lock));
+	ASSERT(spin_is_locked(&pag->pag_ici_lock) || !IS_ENABLED(CONFIG_SMP));
 	if (pag->pag_ici_reclaimable++)
 		return;
 
@@ -212,7 +212,7 @@ xfs_perag_clear_reclaim_tag(
 {
 	struct xfs_mount	*mp = pag->pag_mount;
 
-	ASSERT(spin_is_locked(&pag->pag_ici_lock));
+	ASSERT(spin_is_locked(&pag->pag_ici_lock) || !IS_ENABLED(CONFIG_SMP));
 	if (--pag->pag_ici_reclaimable)
 		return;
 
-- 
2.7.5

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux