From: Dave Chinner Date: Tue, 9 May 2023 09:29:42 +0000 (+0200) Subject: xfs: rework the perag trace points to be perag centric X-Git-Tag: v6.3.0~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35398d0d644ffb50f3146564e62f8c23ad2bcb6b;p=thirdparty%2Fxfsprogs-dev.git xfs: rework the perag trace points to be perag centric Source kernel commit: 368e2d09b41caa5b44a61bb518c362f46d6d615c So that they all output the same information in the traces to make debugging refcount issues easier. This means that all the lookup/drop functions no longer need to use the full memory barrier atomic operations (atomic*_return()) so will have less overhead when tracing is off. The set/clear tag tracepoints no longer abuse the reference count to pass the tag - the tag being cleared is obvious from the _RET_IP_ that is recorded in the trace point. Signed-off-by: Dave Chinner Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- diff --git a/include/xfs_trace.h b/include/xfs_trace.h index 65c2a225e..c9398c4d8 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -181,11 +181,11 @@ /* set c = c to avoid unused var warnings */ #define trace_xfs_write_extent(a,b,c,d) ((c) = (c)) -#define trace_xfs_perag_get(a,b,c,d) ((c) = (c)) -#define trace_xfs_perag_get_tag(a,b,c,d) ((c) = (c)) +#define trace_xfs_perag_get(c,d) ((c) = (c)) +#define trace_xfs_perag_get_tag(c,d) ((c) = (c)) #define trace_xfs_perag_grab(...) ((void) 0) #define trace_xfs_perag_grab_tag(...) ((void) 0) -#define trace_xfs_perag_put(a,b,c,d) ((c) = (c)) +#define trace_xfs_perag_put(c,d) ((c) = (c)) #define trace_xfs_perag_rele(...) ((void) 0) #define trace_xfs_trans_alloc(a,b) ((void) 0) @@ -326,9 +326,4 @@ #define trace_xfs_fs_mark_healthy(a,b) ((void) 0) -/* set c = c to avoid unused var warnings */ -#define trace_xfs_perag_get(a,b,c,d) ((c) = (c)) -#define trace_xfs_perag_get_tag(a,b,c,d) ((c) = (c)) -#define trace_xfs_perag_put(a,b,c,d) ((c) = (c)) - #endif /* __TRACE_H__ */ diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 19a5e5dc8..1b0e03502 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -42,16 +42,15 @@ xfs_perag_get( xfs_agnumber_t agno) { struct xfs_perag *pag; - int ref = 0; rcu_read_lock(); pag = radix_tree_lookup(&mp->m_perag_tree, agno); if (pag) { + trace_xfs_perag_get(pag, _RET_IP_); ASSERT(atomic_read(&pag->pag_ref) >= 0); - ref = atomic_inc_return(&pag->pag_ref); + atomic_inc(&pag->pag_ref); } rcu_read_unlock(); - trace_xfs_perag_get(mp, agno, ref, _RET_IP_); return pag; } @@ -66,7 +65,6 @@ xfs_perag_get_tag( { struct xfs_perag *pag; int found; - int ref; rcu_read_lock(); found = radix_tree_gang_lookup_tag(&mp->m_perag_tree, @@ -75,9 +73,9 @@ xfs_perag_get_tag( rcu_read_unlock(); return NULL; } - ref = atomic_inc_return(&pag->pag_ref); + trace_xfs_perag_get_tag(pag, _RET_IP_); + atomic_inc(&pag->pag_ref); rcu_read_unlock(); - trace_xfs_perag_get_tag(mp, pag->pag_agno, ref, _RET_IP_); return pag; } @@ -85,11 +83,9 @@ void xfs_perag_put( struct xfs_perag *pag) { - int ref; - + trace_xfs_perag_put(pag, _RET_IP_); ASSERT(atomic_read(&pag->pag_ref) > 0); - ref = atomic_dec_return(&pag->pag_ref); - trace_xfs_perag_put(pag->pag_mount, pag->pag_agno, ref, _RET_IP_); + atomic_dec(&pag->pag_ref); } /* @@ -108,8 +104,7 @@ xfs_perag_grab( rcu_read_lock(); pag = radix_tree_lookup(&mp->m_perag_tree, agno); if (pag) { - trace_xfs_perag_grab(mp, pag->pag_agno, - atomic_read(&pag->pag_active_ref), _RET_IP_); + trace_xfs_perag_grab(pag, _RET_IP_); if (!atomic_inc_not_zero(&pag->pag_active_ref)) pag = NULL; } @@ -136,8 +131,7 @@ xfs_perag_grab_tag( rcu_read_unlock(); return NULL; } - trace_xfs_perag_grab_tag(mp, pag->pag_agno, - atomic_read(&pag->pag_active_ref), _RET_IP_); + trace_xfs_perag_grab_tag(pag, _RET_IP_); if (!atomic_inc_not_zero(&pag->pag_active_ref)) pag = NULL; rcu_read_unlock(); @@ -148,8 +142,7 @@ void xfs_perag_rele( struct xfs_perag *pag) { - trace_xfs_perag_rele(pag->pag_mount, pag->pag_agno, - atomic_read(&pag->pag_active_ref), _RET_IP_); + trace_xfs_perag_rele(pag, _RET_IP_); if (atomic_dec_and_test(&pag->pag_active_ref)) wake_up(&pag->pag_active_wq); }