]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: rework the perag trace points to be perag centric
authorDave Chinner <dchinner@redhat.com>
Tue, 9 May 2023 09:29:42 +0000 (11:29 +0200)
committerCarlos Maiolino <cem@kernel.org>
Wed, 10 May 2023 06:23:34 +0000 (08:23 +0200)
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 <dchinner@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
include/xfs_trace.h
libxfs/xfs_ag.c

index 65c2a225ecceb03cc4a58c706dbe97250a0d374a..c9398c4d8997c3622c69d6c81b67ab9ae0f52958 100644 (file)
 
 /* 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)
 
 #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__ */
index 19a5e5dc84400acecf92b3af4a83e26c17651123..1b0e03502d47b4048fda2488fd19d6f449cbd6ed 100644 (file)
@@ -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);
 }