Skip to contentSkip to conversation

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

PATCH Superseded Brian Foster 2 participants 4 messages Jun 7, 2017 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix spurious spin_is_locked() assert failures on non-smp kernels

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.

---

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(-)
fs/xfs/xfs_buf.c +1 -1
index 07b77b7..d60f917 100644
@@ -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;
fs/xfs/xfs_icache.c +3 -3
index f61c84f8..5cecb36 100644
@@ -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;
 
Signature · 1 line
2.7.5
#1 lore raw
Quoted 11 lines · Brian Foster

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.

Just switch to lockdep_assert_held instead of this mess..

#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster

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.

Quoted 7 lines
Quoted 5 lines

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.

Just switch to lockdep_assert_held instead of this mess..

Seems reasonable, I wasn't aware of that. What about the !spin_is_locked() case? Do you want to drop it?

Brian

Quoted 4 lines

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

#3 lore raw
Quoted 4 lines · Brian Foster
Quoted 1 line

Just switch to lockdep_assert_held instead of this mess..

Seems reasonable, I wasn't aware of that. What about the !spin_is_locked() case? Do you want to drop it?

Yes, I would just drop it.