From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 1/5] xfs: track deferred ops statistics
Date: Sun, 31 Dec 2023 14:00:59 -0800 [thread overview]
Message-ID: <170404854737.1769671.8541528862677264303.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <170404854709.1769671.12231107418026207335.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Track some basic statistics on how hard we're pushing the defer ops.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_defer.c | 14 ++++++++++++++
fs/xfs/xfs_trace.h | 19 +++++++++++++++++++
fs/xfs/xfs_trans.c | 3 +++
fs/xfs/xfs_trans.h | 7 +++++++
4 files changed, 43 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index cd28b96b49ea9..bf83508edf822 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -617,6 +617,8 @@ xfs_defer_finish_one(
/* Done with the dfp, free it. */
list_del(&dfp->dfp_list);
kmem_cache_free(xfs_defer_pending_cache, dfp);
+ tp->t_dfops_nr--;
+ tp->t_dfops_finished++;
out:
if (ops->finish_cleanup)
ops->finish_cleanup(tp, state, error);
@@ -679,6 +681,9 @@ xfs_defer_finish_noroll(
list_splice_init(&(*tp)->t_dfops, &dop_pending);
+ (*tp)->t_dfops_nr_max = max((*tp)->t_dfops_nr,
+ (*tp)->t_dfops_nr_max);
+
if (has_intents < 0) {
error = has_intents;
goto out_shutdown;
@@ -720,6 +725,7 @@ xfs_defer_finish_noroll(
xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE);
trace_xfs_defer_finish_error(*tp, error);
xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending);
+ (*tp)->t_dfops_nr = 0;
xfs_defer_cancel(*tp);
return error;
}
@@ -767,6 +773,7 @@ xfs_defer_cancel(
trace_xfs_defer_cancel(tp, _RET_IP_);
xfs_defer_trans_abort(tp, &tp->t_dfops);
xfs_defer_cancel_list(mp, &tp->t_dfops);
+ tp->t_dfops_nr = 0;
}
/*
@@ -830,6 +837,7 @@ xfs_defer_alloc(
dfp->dfp_ops = ops;
INIT_LIST_HEAD(&dfp->dfp_work);
list_add_tail(&dfp->dfp_list, &tp->t_dfops);
+ tp->t_dfops_nr++;
return dfp;
}
@@ -942,6 +950,12 @@ xfs_defer_move(
struct xfs_trans *stp)
{
list_splice_init(&stp->t_dfops, &dtp->t_dfops);
+ dtp->t_dfops_nr += stp->t_dfops_nr;
+ dtp->t_dfops_nr_max = stp->t_dfops_nr_max;
+ dtp->t_dfops_finished = stp->t_dfops_finished;
+ stp->t_dfops_nr = 0;
+ stp->t_dfops_nr_max = 0;
+ stp->t_dfops_finished = 0;
/*
* Low free space mode was historically controlled by a dfops field.
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 906e35eef223d..6c99bf56184b0 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -2711,6 +2711,25 @@ TRACE_EVENT(xfs_btree_free_block,
/* deferred ops */
struct xfs_defer_pending;
+TRACE_EVENT(xfs_defer_stats,
+ TP_PROTO(struct xfs_trans *tp),
+ TP_ARGS(tp),
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(unsigned int, max)
+ __field(unsigned int, finished)
+ ),
+ TP_fast_assign(
+ __entry->dev = tp->t_mountp->m_super->s_dev;
+ __entry->max = tp->t_dfops_nr_max;
+ __entry->finished = tp->t_dfops_finished;
+ ),
+ TP_printk("dev %d:%d max %u finished %u",
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+ __entry->max,
+ __entry->finished)
+)
+
DECLARE_EVENT_CLASS(xfs_defer_class,
TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
TP_ARGS(tp, caller_ip),
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 008380482777b..eb7d4272aef28 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -70,6 +70,9 @@ xfs_trans_free(
xfs_extent_busy_sort(&tp->t_busy);
xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false);
+ if (tp->t_dfops_finished > 0)
+ trace_xfs_defer_stats(tp);
+
trace_xfs_trans_free(tp, _RET_IP_);
xfs_trans_clear_context(tp);
if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT))
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 2046ee06fe88f..6017efe354adc 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -151,6 +151,13 @@ typedef struct xfs_trans {
struct list_head t_busy; /* list of busy extents */
struct list_head t_dfops; /* deferred operations */
unsigned long t_pflags; /* saved process flags state */
+
+ /* Count of deferred ops attached to transaction. */
+ unsigned int t_dfops_nr;
+ /* Maximum t_dfops_nr seen in a loop. */
+ unsigned int t_dfops_nr_max;
+ /* Number of dfops finished. */
+ unsigned int t_dfops_finished;
} xfs_trans_t;
/*
next prev parent reply other threads:[~2023-12-31 22:01 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-31 18:25 [NYE PATCHRIVER 4/4] xfs: freespace defrag for online shrink Darrick J. Wong
2023-12-31 19:38 ` [PATCHSET 1/5] xfs: improve post-close eofblocks gc behavior Darrick J. Wong
2023-12-31 22:00 ` [PATCH 1/3] xfs: only free posteof blocks on first close Darrick J. Wong
2023-12-31 22:00 ` [PATCH 2/3] xfs: don't free EOF blocks on read close Darrick J. Wong
2023-12-31 22:00 ` [PATCH 3/3] xfs: Don't free EOF blocks on close when extent size hints are set Darrick J. Wong
2023-12-31 19:38 ` [PATCHSET RFC 2/5] xfs: noalloc allocation groups Darrick J. Wong
2023-12-31 22:00 ` Darrick J. Wong [this message]
2023-12-31 22:01 ` [PATCH 2/5] xfs: whine to dmesg when we encounter errors Darrick J. Wong
2023-12-31 22:01 ` [PATCH 3/5] xfs: create a noalloc mode for allocation groups Darrick J. Wong
2023-12-31 22:01 ` [PATCH 4/5] xfs: enable userspace to hide an AG from allocation Darrick J. Wong
2023-12-31 22:02 ` [PATCH 5/5] xfs: apply noalloc mode to inode allocations too Darrick J. Wong
2023-12-31 19:39 ` [PATCHSET 3/5] xfs: report refcount information to userspace Darrick J. Wong
2023-12-31 22:02 ` [PATCH 1/1] xfs: export reference count " Darrick J. Wong
2023-12-31 19:39 ` [PATCHSET 4/5] xfs: defragment free space Darrick J. Wong
2023-12-31 22:02 ` [PATCH 1/2] xfs: capture the offset and length in fallocate tracepoints Darrick J. Wong
2023-12-31 22:02 ` [PATCH 2/2] xfs: add an ioctl to map free space into a file Darrick J. Wong
2023-12-31 19:39 ` [PATCHSET v2 5/5] xfs: aligned file data extent mappings Darrick J. Wong
2023-12-31 22:03 ` [PATCH 1/4] xfs: create a new inode flag to require extsize alignment of file data space Darrick J. Wong
2023-12-31 22:03 ` [PATCH 2/4] xfs: make file data allocations observe the 'forcealign' flag Darrick J. Wong
2024-01-16 9:26 ` John Garry
2023-12-31 22:03 ` [PATCH 3/4] xfs: support reflink with force align enabled Darrick J. Wong
2023-12-31 22:03 ` [PATCH 4/4] xfs: enable file data force-align feature Darrick J. Wong
2023-12-31 19:56 ` [PATCHSET RFC 1/3] xfsprogs: noalloc allocation groups Darrick J. Wong
2023-12-27 13:38 ` [PATCH 1/5] xfs: track deferred ops statistics Darrick J. Wong
2023-12-27 13:38 ` [PATCH 2/5] xfs: create a noalloc mode for allocation groups Darrick J. Wong
2023-12-27 13:38 ` [PATCH 3/5] xfs: enable userspace to hide an AG from allocation Darrick J. Wong
2023-12-27 13:39 ` [PATCH 4/5] xfs: apply noalloc mode to inode allocations too Darrick J. Wong
2023-12-27 13:39 ` [PATCH 5/5] xfs_io: enhance the aginfo command to control the noalloc flag Darrick J. Wong
2023-12-31 19:56 ` [PATCHSET 2/3] xfsprogs: report refcount information to userspace Darrick J. Wong
2023-12-27 13:39 ` [PATCH 1/2] xfs: export reference count " Darrick J. Wong
2023-12-27 13:39 ` [PATCH 2/2] xfs_io: dump reference count information Darrick J. Wong
2023-12-31 19:56 ` [PATCHSET 3/3] xfsprogs: defragment free space Darrick J. Wong
2023-12-27 13:40 ` [PATCH 01/10] xfs: add an ioctl to map free space into a file Darrick J. Wong
2023-12-27 13:40 ` [PATCH 02/10] xfs_io: support using XFS_IOC_MAP_FREESP to map free space Darrick J. Wong
2023-12-27 13:40 ` [PATCH 03/10] xfs_db: get and put blocks on the AGFL Darrick J. Wong
2023-12-27 13:41 ` [PATCH 04/10] xfs_spaceman: implement clearing free space Darrick J. Wong
2023-12-27 13:41 ` [PATCH 05/10] spaceman: physically move a regular inode Darrick J. Wong
2023-12-27 13:41 ` [PATCH 06/10] spaceman: find owners of space in an AG Darrick J. Wong
2023-12-27 13:41 ` [PATCH 07/10] xfs_spaceman: wrap radix tree accesses in find_owner.c Darrick J. Wong
2023-12-27 13:42 ` [PATCH 08/10] xfs_spaceman: port relocation structure to 32-bit systems Darrick J. Wong
2023-12-27 13:42 ` [PATCH 09/10] spaceman: relocate the contents of an AG Darrick J. Wong
2023-12-27 13:42 ` [PATCH 10/10] spaceman: move inodes with hardlinks Darrick J. Wong
2023-12-31 20:02 ` [PATCHSET 1/2] fstests: functional test for refcount reporting Darrick J. Wong
2023-12-27 14:06 ` [PATCH 1/2] xfs/122: update for the getfsrefs ioctl Darrick J. Wong
2023-12-27 14:06 ` [PATCH 2/2] xfs: test output of new FSREFCOUNTS ioctl Darrick J. Wong
2023-12-31 20:02 ` [PATCHSET 2/2] fstests: defragment free space Darrick J. Wong
2023-12-27 14:06 ` [PATCH 1/2] xfs/122: update for XFS_IOC_MAP_FREESP Darrick J. Wong
2023-12-27 14:07 ` [PATCH 2/2] xfs: test clearing of free space Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2024-12-31 23:32 [PATCHSET RFC 2/5] xfs: noalloc allocation groups Darrick J. Wong
2024-12-31 23:36 ` [PATCH 1/5] xfs: track deferred ops statistics Darrick J. Wong
2024-12-31 23:33 [PATCHSET RFC 1/5] xfsprogs: noalloc allocation groups Darrick J. Wong
2024-12-31 23:43 ` [PATCH 1/5] xfs: track deferred ops statistics Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170404854737.1769671.8541528862677264303.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox