Skip to contentSkip to conversation

xfs: Remove unused trace events

PATCH Superseded Steven Rostedt 4 participants 28 messages Jun 12, 2025 – Jul 23, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover xfs: Remove unused trace events

Trace events take up to 5K in memory for text and meta data. I have code that will trigger a warning when it detects unused tracepoints. The XFS file system contains many events that are not called. Most of them used to be called but due to code refactoring the calls were removed but the trace events stayed behind.

Some events were added but never used. If they were recent, I just reported them, but if they were older, this series simply removes them.

One is called only when CONFIG_COMPACT is defined, so an #ifdef was placed around it.

A couple are only called in #if 0 code (left as a reminder to fix it), so those events are wrapped by a #if 0 as well (with a comment).

Finally, one event is supposed to be a trace event class, but was created with the TRACE_EVENT() macro and not the DECLARE_EVENT_CLASS() macro. This works because a TRACE_EVENT() is simply a DECLARE_EVENT_CLASS() and DEFINE_EVENT() where the class and event have the same name. But as this was a mistake, the event created should not exist.

Each patch is a stand alone patch. If you ack them, I can take them in my tree, or if you want, you can take them. I may be adding the warning code to linux-next near the end of the cycle, so it would be good to have this cleaned up before hand. As this is removing dead code, it may be even OK to send them to Linus as a fix.

Steven Rostedt (14):
xfs: tracing; Remove unused event xfs_reflink_cow_found
xfs: Remove unused trace event xfs_attr_remove_iter_return
xfs: Remove unused event xlog_iclog_want_sync
xfs: Remove unused event xfs_ioctl_clone
xfs: Remove unused xfs_reflink_compare_extents events
xfs: Remove unused trace event xfs_attr_rmtval_set
xfs: ifdef out unused xfs_attr events
xfs: Remove unused event xfs_attr_node_removename
xfs: Remove unused event xfs_alloc_near_error
xfs: Remove unused event xfs_alloc_near_nominleft
xfs: Remove unused event xfs_pagecache_inval
xfs: Remove usused xfs_end_io_direct events
xfs: Only create event xfs_file_compat_ioctl when CONFIG_COMPAT is configure
xfs: Change xfs_xattr_class from a TRACE_EVENT() to DECLARE_EVENT_CLASS()

----

 fs/xfs/scrub/trace.h |  2 +-
 fs/xfs/xfs_trace.h   | 72 ++++++----------------------------------------------
 2 files changed, 9 insertions(+), 65 deletions(-)
author maintainer
#1 lore raw

PATCH 1/14 xfs: tracing; Remove unused event xfs_reflink_cow_found

From: Steven Rostedt <[email protected]>

Each trace event can take up to around 5K of text and meta data regardless if they are used or not. With the restructuring of the XFS COW handling, the tracepoint trace_xfs_reflink_cow_found() was removed but the trace event was still being created. Remove the creation of that trace event.

Fixes db46e604adf8 ("xfs: merge COW handling into xfs_file_iomap_begin_delay")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index 01d284a1c759..ae0ed0dd0a01 100644
@@ -4242,7 +4242,6 @@ DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
 
 /* copy on write */
 DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_around_shared);
-DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
 DEFINE_INODE_IREC_EVENT(xfs_reflink_convert_cow);
 
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

Re: [PATCH 01/14] xfs: tracing; Remove unused event xfs_reflink_cow_found

Quoted 18 lines · On Thu, 12 Jun 2025 17:24:06 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt <[email protected]>

Each trace event can take up to around 5K of text and meta data regardless if they are used or not. With the restructuring of the XFS COW handling, the tracepoint trace_xfs_reflink_cow_found() was removed but the trace event was still being created. Remove the creation of that trace event.

Fixes db46e604adf8 ("xfs: merge COW handling into xfs_file_iomap_begin_delay")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -0
index 01d284a1c759..ae0ed0dd0a01 100644

fs/xfs/xfs_trace.h DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error); · line 4247

Quoted 7 lines
fs/xfs/xfs_trace.h +0 -1
@@ -4242,7 +4242,6 @@ DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
 
 /* copy on write */
 DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_around_shared);
-DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
 DEFINE_INODE_IREC_EVENT(xfs_reflink_convert_cow);
 

Hmm, it looks like this one is still used. I'll drop this patch.

-- Steve

#3 lore raw

Re: [PATCH 01/14] xfs: tracing; Remove unused event xfs_reflink_cow_found

In reply to Steven Rostedt
kernel test robot noticed the following build errors:

Hi Steven,

kernel test robot noticed the following build errors:

[auto build test ERROR on xfs-linux/for-next]
[also build test ERROR on linus/master v6.16-rc1 next-20250613] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Steven-Rostedt/xfs-tracing-Remove-unused-event-xfs_reflink_cow_found/20250613-052758
base:   https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
patch link:    https://lore.kernel.org/r/20250612212634.746367055%40goodmis.org
patch subject: [PATCH 01/14] xfs: tracing; Remove unused event xfs_reflink_cow_found
config: s390-randconfig-r073-20250614 (https://download.01.org/0day-ci/archive/20250614/[email protected]/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250614/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> fs/xfs/xfs_iomap.c:1614:3: error: call to undeclared function 'trace_xfs_reflink_cow_found'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1614 |                 trace_xfs_reflink_cow_found(ip, &got);
         |                 ^
   fs/xfs/xfs_iomap.c:1614:3: note: did you mean 'trace_xfs_reflink_cow_enospc'?
   fs/xfs/xfs_trace.h:4245:1: note: 'trace_xfs_reflink_cow_enospc' declared here
    4245 | DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
         | ^
   fs/xfs/xfs_trace.h:4073:39: note: expanded from macro 'DEFINE_INODE_IREC_EVENT'
    4073 | #define DEFINE_INODE_IREC_EVENT(name) \
         |                                       ^
   include/linux/tracepoint.h:594:2: note: expanded from macro '\
   DEFINE_EVENT'
     594 |         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
         |         ^
   include/linux/tracepoint.h:467:2: note: expanded from macro 'DECLARE_TRACE'
     467 |         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
         |         ^
   include/linux/tracepoint.h:409:2: note: expanded from macro '__DECLARE_TRACE'
     409 |         __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto))
         |         ^
   include/linux/tracepoint.h:385:21: note: expanded from macro '__DECLARE_TRACE_COMMON'
     385 |         static inline void trace_##name(proto)                          \
         |                            ^
   <scratch space>:36:1: note: expanded from here
      36 | trace_xfs_reflink_cow_enospc
         | ^
   fs/xfs/xfs_iomap.c:1792:4: error: call to undeclared function 'trace_xfs_reflink_cow_found'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1792 |                         trace_xfs_reflink_cow_found(ip, &cmap);
         |                         ^

2 errors generated.

vim +/trace_xfs_reflink_cow_found +1614 fs/xfs/xfs_iomap.c

7c879c8275c0505 Christoph Hellwig 2024-11-17  1514  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1515  static int
058dd70c65ab736 Christoph Hellwig 2025-02-13  1516  xfs_zoned_buffered_write_iomap_begin(
058dd70c65ab736 Christoph Hellwig 2025-02-13  1517  	struct inode		*inode,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1518  	loff_t			offset,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1519  	loff_t			count,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1520  	unsigned		flags,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1521  	struct iomap		*iomap,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1522  	struct iomap		*srcmap)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1523  {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1524  	struct iomap_iter	*iter =
058dd70c65ab736 Christoph Hellwig 2025-02-13  1525  		container_of(iomap, struct iomap_iter, iomap);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1526  	struct xfs_zone_alloc_ctx *ac = iter->private;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1527  	struct xfs_inode	*ip = XFS_I(inode);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1528  	struct xfs_mount	*mp = ip->i_mount;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1529  	xfs_fileoff_t		offset_fsb = XFS_B_TO_FSBT(mp, offset);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1530  	xfs_fileoff_t		end_fsb = xfs_iomap_end_fsb(mp, offset, count);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1531  	u16			iomap_flags = IOMAP_F_SHARED;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1532  	unsigned int		lockmode = XFS_ILOCK_EXCL;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1533  	xfs_filblks_t		count_fsb;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1534  	xfs_extlen_t		indlen;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1535  	struct xfs_bmbt_irec	got;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1536  	struct xfs_iext_cursor	icur;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1537  	int			error = 0;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1538  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1539  	ASSERT(!xfs_get_extsz_hint(ip));
058dd70c65ab736 Christoph Hellwig 2025-02-13  1540  	ASSERT(!(flags & IOMAP_UNSHARE));
058dd70c65ab736 Christoph Hellwig 2025-02-13  1541  	ASSERT(ac);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1542  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1543  	if (xfs_is_shutdown(mp))
058dd70c65ab736 Christoph Hellwig 2025-02-13  1544  		return -EIO;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1545  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1546  	error = xfs_qm_dqattach(ip);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1547  	if (error)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1548  		return error;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1549  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1550  	error = xfs_ilock_for_iomap(ip, flags, &lockmode);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1551  	if (error)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1552  		return error;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1553  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1554  	if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
058dd70c65ab736 Christoph Hellwig 2025-02-13  1555  	    XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1556  		xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1557  		error = -EFSCORRUPTED;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1558  		goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1559  	}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1560  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1561  	XFS_STATS_INC(mp, xs_blk_mapw);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1562  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1563  	error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1564  	if (error)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1565  		goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1566  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1567  	/*
058dd70c65ab736 Christoph Hellwig 2025-02-13  1568  	 * For zeroing operations check if there is any data to zero first.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1569  	 *
058dd70c65ab736 Christoph Hellwig 2025-02-13  1570  	 * For regular writes we always need to allocate new blocks, but need to
058dd70c65ab736 Christoph Hellwig 2025-02-13  1571  	 * provide the source mapping when the range is unaligned to support
058dd70c65ab736 Christoph Hellwig 2025-02-13  1572  	 * read-modify-write of the whole block in the page cache.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1573  	 *
058dd70c65ab736 Christoph Hellwig 2025-02-13  1574  	 * In either case we need to limit the reported range to the boundaries
058dd70c65ab736 Christoph Hellwig 2025-02-13  1575  	 * of the source map in the data fork.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1576  	 */
058dd70c65ab736 Christoph Hellwig 2025-02-13  1577  	if (!IS_ALIGNED(offset, mp->m_sb.sb_blocksize) ||
058dd70c65ab736 Christoph Hellwig 2025-02-13  1578  	    !IS_ALIGNED(offset + count, mp->m_sb.sb_blocksize) ||
058dd70c65ab736 Christoph Hellwig 2025-02-13  1579  	    (flags & IOMAP_ZERO)) {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1580  		struct xfs_bmbt_irec	smap;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1581  		struct xfs_iext_cursor	scur;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1582  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1583  		if (!xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &scur,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1584  				&smap))
058dd70c65ab736 Christoph Hellwig 2025-02-13  1585  			smap.br_startoff = end_fsb; /* fake hole until EOF */
058dd70c65ab736 Christoph Hellwig 2025-02-13  1586  		if (smap.br_startoff > offset_fsb) {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1587  			/*
058dd70c65ab736 Christoph Hellwig 2025-02-13  1588  			 * We never need to allocate blocks for zeroing a hole.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1589  			 */
058dd70c65ab736 Christoph Hellwig 2025-02-13  1590  			if (flags & IOMAP_ZERO) {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1591  				xfs_hole_to_iomap(ip, iomap, offset_fsb,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1592  						smap.br_startoff);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1593  				goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1594  			}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1595  			end_fsb = min(end_fsb, smap.br_startoff);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1596  		} else {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1597  			end_fsb = min(end_fsb,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1598  				smap.br_startoff + smap.br_blockcount);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1599  			xfs_trim_extent(&smap, offset_fsb,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1600  					end_fsb - offset_fsb);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1601  			error = xfs_bmbt_to_iomap(ip, srcmap, &smap, flags, 0,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1602  					xfs_iomap_inode_sequence(ip, 0));
058dd70c65ab736 Christoph Hellwig 2025-02-13  1603  			if (error)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1604  				goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1605  		}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1606  	}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1607  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1608  	if (!ip->i_cowfp)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1609  		xfs_ifork_init_cow(ip);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1610  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1611  	if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got))
058dd70c65ab736 Christoph Hellwig 2025-02-13  1612  		got.br_startoff = end_fsb;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1613  	if (got.br_startoff <= offset_fsb) {
058dd70c65ab736 Christoph Hellwig 2025-02-13 @1614  		trace_xfs_reflink_cow_found(ip, &got);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1615  		goto done;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1616  	}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1617  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1618  	/*
058dd70c65ab736 Christoph Hellwig 2025-02-13  1619  	 * Cap the maximum length to keep the chunks of work done here somewhat
058dd70c65ab736 Christoph Hellwig 2025-02-13  1620  	 * symmetric with the work writeback does.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1621  	 */
058dd70c65ab736 Christoph Hellwig 2025-02-13  1622  	end_fsb = min(end_fsb, got.br_startoff);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1623  	count_fsb = min3(end_fsb - offset_fsb, XFS_MAX_BMBT_EXTLEN,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1624  			 XFS_B_TO_FSB(mp, 1024 * PAGE_SIZE));
058dd70c65ab736 Christoph Hellwig 2025-02-13  1625  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1626  	/*
058dd70c65ab736 Christoph Hellwig 2025-02-13  1627  	 * The block reservation is supposed to cover all blocks that the
058dd70c65ab736 Christoph Hellwig 2025-02-13  1628  	 * operation could possible write, but there is a nasty corner case
058dd70c65ab736 Christoph Hellwig 2025-02-13  1629  	 * where blocks could be stolen from underneath us:
058dd70c65ab736 Christoph Hellwig 2025-02-13  1630  	 *
058dd70c65ab736 Christoph Hellwig 2025-02-13  1631  	 *  1) while this thread iterates over a larger buffered write,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1632  	 *  2) another thread is causing a write fault that calls into
058dd70c65ab736 Christoph Hellwig 2025-02-13  1633  	 *     ->page_mkwrite in range this thread writes to, using up the
058dd70c65ab736 Christoph Hellwig 2025-02-13  1634  	 *     delalloc reservation created by a previous call to this function.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1635  	 *  3) another thread does direct I/O on the range that the write fault
058dd70c65ab736 Christoph Hellwig 2025-02-13  1636  	 *     happened on, which causes writeback of the dirty data.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1637  	 *  4) this then set the stale flag, which cuts the current iomap
058dd70c65ab736 Christoph Hellwig 2025-02-13  1638  	 *     iteration short, causing the new call to ->iomap_begin that gets
058dd70c65ab736 Christoph Hellwig 2025-02-13  1639  	 *     us here again, but now without a sufficient reservation.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1640  	 *
058dd70c65ab736 Christoph Hellwig 2025-02-13  1641  	 * This is a very unusual I/O pattern, and nothing but generic/095 is
058dd70c65ab736 Christoph Hellwig 2025-02-13  1642  	 * known to hit it. There's not really much we can do here, so turn this
058dd70c65ab736 Christoph Hellwig 2025-02-13  1643  	 * into a short write.
058dd70c65ab736 Christoph Hellwig 2025-02-13  1644  	 */
058dd70c65ab736 Christoph Hellwig 2025-02-13  1645  	if (count_fsb > ac->reserved_blocks) {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1646  		xfs_warn_ratelimited(mp,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1647  "Short write on ino 0x%llx comm %.20s due to three-way race with write fault and direct I/O",
058dd70c65ab736 Christoph Hellwig 2025-02-13  1648  			ip->i_ino, current->comm);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1649  		count_fsb = ac->reserved_blocks;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1650  		if (!count_fsb) {
058dd70c65ab736 Christoph Hellwig 2025-02-13  1651  			error = -EIO;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1652  			goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1653  		}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1654  	}
058dd70c65ab736 Christoph Hellwig 2025-02-13  1655  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1656  	error = xfs_quota_reserve_blkres(ip, count_fsb);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1657  	if (error)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1658  		goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1659  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1660  	indlen = xfs_bmap_worst_indlen(ip, count_fsb);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1661  	error = xfs_dec_fdblocks(mp, indlen, false);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1662  	if (error)
058dd70c65ab736 Christoph Hellwig 2025-02-13  1663  		goto out_unlock;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1664  	ip->i_delayed_blks += count_fsb;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1665  	xfs_mod_delalloc(ip, count_fsb, indlen);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1666  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1667  	got.br_startoff = offset_fsb;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1668  	got.br_startblock = nullstartblock(indlen);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1669  	got.br_blockcount = count_fsb;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1670  	got.br_state = XFS_EXT_NORM;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1671  	xfs_bmap_add_extent_hole_delay(ip, XFS_COW_FORK, &icur, &got);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1672  	ac->reserved_blocks -= count_fsb;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1673  	iomap_flags |= IOMAP_F_NEW;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1674  
058dd70c65ab736 Christoph Hellwig 2025-02-13  1675  	trace_xfs_iomap_alloc(ip, offset, XFS_FSB_TO_B(mp, count_fsb),
058dd70c65ab736 Christoph Hellwig 2025-02-13  1676  			XFS_COW_FORK, &got);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1677  done:
058dd70c65ab736 Christoph Hellwig 2025-02-13  1678  	error = xfs_bmbt_to_iomap(ip, iomap, &got, flags, iomap_flags,
058dd70c65ab736 Christoph Hellwig 2025-02-13  1679  			xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED));
058dd70c65ab736 Christoph Hellwig 2025-02-13  1680  out_unlock:
058dd70c65ab736 Christoph Hellwig 2025-02-13  1681  	xfs_iunlock(ip, lockmode);
058dd70c65ab736 Christoph Hellwig 2025-02-13  1682  	return error;
058dd70c65ab736 Christoph Hellwig 2025-02-13  1683  }
058dd70c65ab736 Christoph Hellwig 2025-02-13  1684  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#4 lore raw

PATCH 2/14 xfs: Remove unused trace event xfs_attr_remove_iter_return

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When the function xfs_attri_remove_iter was removed, it did not remove the trace event that it called. As a trace event can take up to 5K of memory for text and meta data regardless of if it is used or not, remove this unused trace event.

Fixes 59782a236b62 ("xfs: remove xfs_attri_remove_iter")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index ae0ed0dd0a01..67bdcab9ff47 100644
@@ -5076,7 +5076,6 @@ DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_leaf_addname_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return);
-DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_alloc);
 DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return);
 DEFINE_DAS_STATE_EVENT(xfs_attr_defer_add);
Signature · 1 line
2.47.2
Reviewed-by on v1 2/14
#5 lore raw

Re: [PATCH 02/14] xfs: Remove unused trace event xfs_attr_remove_iter_return

Please lover case the start of the commit message after the subsystem prefix like other xfs commits. The Subject line / one line summary is not a sentence. Same for all the other pathes.

Otherwise looks good:

author maintainer
#6 lore raw

Re: [PATCH 02/14] xfs: Remove unused trace event xfs_attr_remove_iter_return

Quoted 1 line · On Mon, 16 Jun 2025 07:26:45 +0200 Christoph Hellwig <[email protected]> wrote:

Please lover case the start of the commit message after the subsystem

OK.

Quoted 6 lines

prefix like other xfs commits. The Subject line / one line summary is not a sentence. Same for all the other pathes.

Otherwise looks good:

Thanks,

-- Steve

author maintainer
#7 lore raw

PATCH 3/14 xfs: Remove unused event xlog_iclog_want_sync

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The trace event xlog_iclog_want_sync was added but never used. As trace events can take up around 5K of memory in text and meta data regardless if they are used or not, remove this unused event.

Fixes 956f6daa84bf ("xfs: add iclog state trace events")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index 67bdcab9ff47..049bf9e34063 100644
@@ -5027,7 +5027,6 @@ DEFINE_ICLOG_EVENT(xlog_iclog_switch);
 DEFINE_ICLOG_EVENT(xlog_iclog_sync);
 DEFINE_ICLOG_EVENT(xlog_iclog_syncing);
 DEFINE_ICLOG_EVENT(xlog_iclog_sync_done);
-DEFINE_ICLOG_EVENT(xlog_iclog_want_sync);
 DEFINE_ICLOG_EVENT(xlog_iclog_wait_on);
 DEFINE_ICLOG_EVENT(xlog_iclog_write);
 
Signature · 1 line
2.47.2
author maintainer
#8 lore raw

PATCH 4/14 xfs: Remove unused event xfs_ioctl_clone

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The trace event xfs_ioctl_clone was added but never used. As trace events can take up to 5K of memory in text and meta data regardless if they are used or not, remove the unused trace event.

Fixes 53aa1c34f4eb ("xfs: define tracepoints for reflink activities")
---
 fs/xfs/xfs_trace.h | 26 --------------------------
 1 file changed, 26 deletions(-)
fs/xfs/xfs_trace.h +0 -26
index 049bf9e34063..ad686fe0a577 100644
@@ -4210,32 +4210,6 @@ DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_dest);
 DEFINE_DOUBLE_IO_EVENT(xfs_reflink_compare_extents);
 DEFINE_INODE_ERROR_EVENT(xfs_reflink_compare_extents_error);
 
-/* ioctl tracepoints */
-TRACE_EVENT(xfs_ioctl_clone,
-	TP_PROTO(struct inode *src, struct inode *dest),
-	TP_ARGS(src, dest),
-	TP_STRUCT__entry(
-		__field(dev_t, dev)
-		__field(unsigned long, src_ino)
-		__field(loff_t, src_isize)
-		__field(unsigned long, dest_ino)
-		__field(loff_t, dest_isize)
-	),
-	TP_fast_assign(
-		__entry->dev = src->i_sb->s_dev;
-		__entry->src_ino = src->i_ino;
-		__entry->src_isize = i_size_read(src);
-		__entry->dest_ino = dest->i_ino;
-		__entry->dest_isize = i_size_read(dest);
-	),
-	TP_printk("dev %d:%d ino 0x%lx isize 0x%llx -> ino 0x%lx isize 0x%llx",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->src_ino,
-		  __entry->src_isize,
-		  __entry->dest_ino,
-		  __entry->dest_isize)
-);
-
 /* unshare tracepoints */
 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_unshare);
 DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
Signature · 1 line
2.47.2
author maintainer
#9 lore raw

PATCH 5/14 xfs: Remove unused xfs_reflink_compare_extents events

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When the clone/dedupe_file_rang common functions were refactored, it removed the calls to the xfs_reflink_compare_extents and xfs_reflink_compare_extents_error events. As each event can take up to 5K in memory for text and meta data regardless if they are used or not, they should not be created if they are not used. Remove these unused events.

Fixes 876bec6f9bbf ("vfs: refactor clone/dedupe_file_range common functions")
---
 fs/xfs/xfs_trace.h | 4 ----
 1 file changed, 4 deletions(-)
fs/xfs/xfs_trace.h +0 -4
index ad686fe0a577..fe22f791de6e 100644
@@ -4206,10 +4206,6 @@ DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_extent_error);
 DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_src);
 DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_dest);
 
-/* dedupe tracepoints */
-DEFINE_DOUBLE_IO_EVENT(xfs_reflink_compare_extents);
-DEFINE_INODE_ERROR_EVENT(xfs_reflink_compare_extents_error);
-
 /* unshare tracepoints */
 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_unshare);
 DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
Signature · 1 line
2.47.2
author maintainer
#10 lore raw

PATCH 6/14 xfs: Remove unused trace event xfs_attr_rmtval_set

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When the function xfs_attr_rmtval_set() was removed, the call to the corresponding trace event was also removed but the trace event itself was not. As trace events can take up to 5K of memory in text and meta data regardless if they are used or not they should not be created when not used. Remove the unused trace event.

Fixes 0e6acf29db6f ("xfs: Remove xfs_attr_rmtval_set")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index fe22f791de6e..cdc639198bb9 100644
@@ -2471,7 +2471,6 @@ DEFINE_ATTR_EVENT(xfs_attr_fillstate);
 DEFINE_ATTR_EVENT(xfs_attr_refillstate);
 
 DEFINE_ATTR_EVENT(xfs_attr_rmtval_get);
-DEFINE_ATTR_EVENT(xfs_attr_rmtval_set);
 
 #define DEFINE_DA_EVENT(name) \
 DEFINE_EVENT(xfs_da_class, name, \
Signature · 1 line
2.47.2
author maintainer
#11 lore raw

PATCH 7/14 xfs: ifdef out unused xfs_attr events

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Trace events can take up to 5K in memory for text and meta data per event regardless if they are used or not, so they should not be defined when not used. The events xfs_attr_fillstate and xfs_attr_refillstate are only called in code that is #ifdef out and exists only for future reference.

Ifdef out the events that go with that code and add a comment mentioning the other code.

Fixes 59782a236b622 ("xfs: remove xfs_attri_remove_iter")
---
 fs/xfs/xfs_trace.h | 6 ++++++
 1 file changed, 6 insertions(+)
fs/xfs/xfs_trace.h +6 -0
index cdc639198bb9..bd4e5a727b73 100644
@@ -2467,8 +2467,14 @@ DEFINE_ATTR_EVENT(xfs_attr_node_get);
 DEFINE_ATTR_EVENT(xfs_attr_node_replace);
 DEFINE_ATTR_EVENT(xfs_attr_node_removename);
 
+/*
+ * When the corresponding code in xfs_attr.c is re-enabled
+ * then so can these trace events.
+ */
+#if 0
 DEFINE_ATTR_EVENT(xfs_attr_fillstate);
 DEFINE_ATTR_EVENT(xfs_attr_refillstate);
+#endif
 
 DEFINE_ATTR_EVENT(xfs_attr_rmtval_get);
 
Signature · 1 line
2.47.2
#12 lore raw

Re: [PATCH 07/14] xfs: ifdef out unused xfs_attr events

Quoted 9 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

Trace events can take up to 5K in memory for text and meta data per event regardless if they are used or not, so they should not be defined when not used. The events xfs_attr_fillstate and xfs_attr_refillstate are only called in code that is #ifdef out and exists only for future reference.

Ifdef out the events that go with that code and add a comment mentioning the other code.

Just drop them entirely, which is what the code using them should have done as well. We can always triviall bring back code from git history.

author maintainer
#13 lore raw

Re: [PATCH 07/14] xfs: ifdef out unused xfs_attr events

Quoted 8 lines · On Mon, 16 Jun 2025 07:28:10 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 7 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

Trace events can take up to 5K in memory for text and meta data per event regardless if they are used or not, so they should not be defined when not used. The events xfs_attr_fillstate and xfs_attr_refillstate are only called in code that is #ifdef out and exists only for future reference.

Quoted 6 lines
Quoted 2 lines

Ifdef out the events that go with that code and add a comment mentioning the other code.

Just drop them entirely, which is what the code using them should have done as well. We can always triviall bring back code from git history.

OK. But I'll only send a patch to delete the trace events. I'll let someone else remove the actual code.

-- Steve

#14 lore raw

Re: [PATCH 07/14] xfs: ifdef out unused xfs_attr events

Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Mon, 16 Jun 2025 07:28:10 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 9 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

Trace events can take up to 5K in memory for text and meta data per event regardless if they are used or not, so they should not be defined when not used. The events xfs_attr_fillstate and xfs_attr_refillstate are only called in code that is #ifdef out and exists only for future reference.

Ifdef out the events that go with that code and add a comment mentioning the other code.

Quoted 6 lines
Quoted 3 lines

Just drop them entirely, which is what the code using them should have done as well. We can always triviall bring back code from git history.

OK. But I'll only send a patch to delete the trace events. I'll let someone else remove the actual code.

Yeah, no need for you to fix up the other code.

author maintainer
#15 lore raw

PATCH 8/14 xfs: Remove unused event xfs_attr_node_removename

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When xfs_attri_remove_iter() was removed, so was the call to the trace event xfs_attr_node_removename. As trace events can take up to 5K in memory for text and meta data regardless if they are used or not, they should not be created when unused. Remove the unused event.

Fixes 59782a236b622 ("xfs: remove xfs_attri_remove_iter")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index bd4e5a727b73..3c15282b2a8a 100644
@@ -2465,7 +2465,6 @@ DEFINE_ATTR_EVENT(xfs_attr_leaf_toosmall);
 DEFINE_ATTR_EVENT(xfs_attr_node_addname);
 DEFINE_ATTR_EVENT(xfs_attr_node_get);
 DEFINE_ATTR_EVENT(xfs_attr_node_replace);
-DEFINE_ATTR_EVENT(xfs_attr_node_removename);
 
 /*
  * When the corresponding code in xfs_attr.c is re-enabled
Signature · 1 line
2.47.2
author maintainer
#16 lore raw

PATCH 9/14 xfs: Remove unused event xfs_alloc_near_error

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Trace events take up to 5K of memory in text and meta data regardless if they are used or not. The call to the event xfs_alloc_near_error was removed when the cursor data structure allocation was introduced. Remove it as it is no longer used and is just wasting memory.

Fixes f5e7dbea1e3e ("xfs: introduce allocation cursor data structure")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index 3c15282b2a8a..6ec483341bc4 100644
@@ -2270,7 +2270,6 @@ DEFINE_ALLOC_EVENT(xfs_alloc_cur_right);
 DEFINE_ALLOC_EVENT(xfs_alloc_cur_left);
 DEFINE_ALLOC_EVENT(xfs_alloc_cur_lookup);
 DEFINE_ALLOC_EVENT(xfs_alloc_cur_lookup_done);
-DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
 DEFINE_ALLOC_EVENT(xfs_alloc_near_noentry);
 DEFINE_ALLOC_EVENT(xfs_alloc_near_busy);
 DEFINE_ALLOC_EVENT(xfs_alloc_size_neither);
Signature · 1 line
2.47.2
author maintainer
#17 lore raw

PATCH 10/14 xfs: Remove unused event xfs_alloc_near_nominleft

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When the function xfs_alloc_space_available() was restructured, it removed the only calls to the trace event xfs_alloc_near_nominleft. As trace events take up to 5K of memory for text and meta data for each event, they should not be created when not used. Remove this unused event.

Fixes 54fee133ad59 ("xfs: adjust allocation length in xfs_alloc_space_available")
---
 fs/xfs/xfs_trace.h | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_trace.h +0 -1
index 6ec483341bc4..277402801394 100644
@@ -2263,7 +2263,6 @@ DEFINE_EVENT(xfs_alloc_class, name, \
 DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
 DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
 DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
-DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
 DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
 DEFINE_ALLOC_EVENT(xfs_alloc_cur);
 DEFINE_ALLOC_EVENT(xfs_alloc_cur_right);
Signature · 1 line
2.47.2
author maintainer
#18 lore raw

PATCH 11/14 xfs: Remove unused event xfs_pagecache_inval

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When the function xfs_flushinval_pages() was removed, it removed the only caller to the trace event xfs_pagecache_inval. As trace events can take up to 5K of memory in text and meta data each regardless if they are used or not, they should not be created when unused. Remove the unused event.

Fixes fb59581404ab ("xfs: remove xfs_flushinval_pages")
---
 fs/xfs/xfs_trace.h | 25 -------------------------
 1 file changed, 25 deletions(-)
fs/xfs/xfs_trace.h +0 -25
index 277402801394..ee21ce3651a5 100644
@@ -1893,31 +1893,6 @@ DEFINE_EVENT(xfs_itrunc_class, name, \
 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_start);
 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_end);
 
-TRACE_EVENT(xfs_pagecache_inval,
-	TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
-	TP_ARGS(ip, start, finish),
-	TP_STRUCT__entry(
-		__field(dev_t, dev)
-		__field(xfs_ino_t, ino)
-		__field(xfs_fsize_t, size)
-		__field(xfs_off_t, start)
-		__field(xfs_off_t, finish)
-	),
-	TP_fast_assign(
-		__entry->dev = VFS_I(ip)->i_sb->s_dev;
-		__entry->ino = ip->i_ino;
-		__entry->size = ip->i_disk_size;
-		__entry->start = start;
-		__entry->finish = finish;
-	),
-	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx start 0x%llx finish 0x%llx",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->ino,
-		  __entry->size,
-		  __entry->start,
-		  __entry->finish)
-);
-
 TRACE_EVENT(xfs_bunmap,
 	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t fileoff, xfs_filblks_t len,
 		 int flags, unsigned long caller_ip),
Signature · 1 line
2.47.2
author maintainer
#19 lore raw

PATCH 12/14 xfs: Remove usused xfs_end_io_direct events

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

When the use of iomap_dio_rw was added, the calls to the trace events xfs_end_io_direct_unwritten and xfs_end_io_direct_append were removed but those trace events were not. As trace events can take up to 5K in memory for text and meta data regardless if they are used or not, they should not be created when not used. Remove the unused events.

Fixes acdda3aae146 ("xfs: use iomap_dio_rw")
---
 fs/xfs/xfs_trace.h | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/xfs_trace.h +0 -2
index ee21ce3651a5..83d4ef8386a1 100644
@@ -1859,8 +1859,6 @@ DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert);
 DEFINE_SIMPLE_IO_EVENT(xfs_setfilesize);
 DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof);
 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write);
-DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten);
-DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append);
 DEFINE_SIMPLE_IO_EVENT(xfs_file_splice_read);
 DEFINE_SIMPLE_IO_EVENT(xfs_zoned_map_blocks);
 
Signature · 1 line
2.47.2
author maintainer
#20 lore raw

PATCH 13/14 xfs: Only create event xfs_file_compat_ioctl when CONFIG_COMPAT is configure

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The trace event xfs_file_compat_ioctl is only used when CONFIG_COMPAT is configured in the build. As trace events can take up to 5K in memory for text and meta data regardless if they are used, they should not be created when unused. Add #ifdef CONFIG_COMPAT around the event so that it is only created when that is configured.

Fixes cca28fb83d9e6 ("xfs: split xfs_itrace_entry")
---
 fs/xfs/xfs_trace.h | 2 ++
 1 file changed, 2 insertions(+)
fs/xfs/xfs_trace.h +2 -0
index 83d4ef8386a1..76928583549a 100644
@@ -1083,7 +1083,9 @@ DEFINE_INODE_EVENT(xfs_get_acl);
 #endif
 DEFINE_INODE_EVENT(xfs_vm_bmap);
 DEFINE_INODE_EVENT(xfs_file_ioctl);
+#ifdef CONFIG_COMPAT
 DEFINE_INODE_EVENT(xfs_file_compat_ioctl);
+#endif
 DEFINE_INODE_EVENT(xfs_ioctl_setattr);
 DEFINE_INODE_EVENT(xfs_dir_fsync);
 DEFINE_INODE_EVENT(xfs_file_fsync);
Signature · 1 line
2.47.2
author maintainer
#21 lore raw

PATCH 14/14 xfs: Change xfs_xattr_class from a TRACE_EVENT() to DECLARE_EVENT_CLASS()

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

xfs_xattr_class was accidentally created as a TRACE_EVENT() instead of a class with DECLARE_EVENT_CLASS().

Note, TRACE_EVENT() is just defined as:

 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
	DECLARE_EVENT_CLASS(name,			       \
			     PARAMS(proto),		       \
			     PARAMS(args),		       \
			     PARAMS(tstruct),		       \
			     PARAMS(assign),		       \
			     PARAMS(print));		       \
	DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));

The difference between TRACE_EVENT() and DECLARE_EVENT_CLASS() is that TRACE_EVENT() also creates an event with the class name.

Switch xfs_xattr_class over to being a class and not an event as it is not called directly, and that event with the class name takes up unnecessary memory.

Fixes e47dcf113ae3 ("xfs: repair extended attributes")
---
 fs/xfs/scrub/trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/trace.h +1 -1
index d7c4ced47c15..1e6e9c10cea2 100644
@@ -2996,7 +2996,7 @@ DEFINE_EVENT(xrep_pptr_salvage_class, name, \
 DEFINE_XREP_PPTR_SALVAGE_EVENT(xrep_xattr_salvage_pptr);
 DEFINE_XREP_PPTR_SALVAGE_EVENT(xrep_xattr_insert_pptr);
 
-TRACE_EVENT(xrep_xattr_class,
+DECLARE_EVENT_CLASS(xrep_xattr_class,
 	TP_PROTO(struct xfs_inode *ip, struct xfs_inode *arg_ip),
 	TP_ARGS(ip, arg_ip),
 	TP_STRUCT__entry(
Signature · 1 line
2.47.2
#22 lore raw
In reply to Steven Rostedt
Quoted 2 lines · Steven Rostedt

Trace events take up to 5K in memory for text and meta data. I have code that

Under what circumstances do they eat up that much memory? And is that per-class? Or per-tracepoint?

Quoted 7 lines

will trigger a warning when it detects unused tracepoints. The XFS file system contains many events that are not called. Most of them used to be called but due to code refactoring the calls were removed but the trace events stayed behind.

Some events were added but never used. If they were recent, I just reported them, but if they were older, this series simply removes them.

TBH it'd be really nice if there was /something/ in the build path that would complain about disused tracepoints. I often put in tracepoints while developing a feature, then the code gets massively rewritten during review, and none of us remember to rip out the orphaned traces...

Quoted 12 lines

One is called only when CONFIG_COMPACT is defined, so an #ifdef was placed around it.

A couple are only called in #if 0 code (left as a reminder to fix it), so those events are wrapped by a #if 0 as well (with a comment).

Finally, one event is supposed to be a trace event class, but was created with the TRACE_EVENT() macro and not the DECLARE_EVENT_CLASS() macro. This works because a TRACE_EVENT() is simply a DECLARE_EVENT_CLASS() and DEFINE_EVENT() where the class and event have the same name. But as this was a mistake, the event created should not exist.

Quoted 5 lines

Each patch is a stand alone patch. If you ack them, I can take them in my tree, or if you want, you can take them. I may be adding the warning code to linux-next near the end of the cycle, so it would be good to have this cleaned up before hand. As this is removing dead code, it may be even OK to send them to Linus as a fix.

...oh, you /do/ have a program and it's coming down the pipeline. Excellent <tents fingers>. :)

--D

Quoted 22 lines

Steven Rostedt (14):
xfs: tracing; Remove unused event xfs_reflink_cow_found
xfs: Remove unused trace event xfs_attr_remove_iter_return
xfs: Remove unused event xlog_iclog_want_sync
xfs: Remove unused event xfs_ioctl_clone
xfs: Remove unused xfs_reflink_compare_extents events
xfs: Remove unused trace event xfs_attr_rmtval_set
xfs: ifdef out unused xfs_attr events
xfs: Remove unused event xfs_attr_node_removename
xfs: Remove unused event xfs_alloc_near_error
xfs: Remove unused event xfs_alloc_near_nominleft
xfs: Remove unused event xfs_pagecache_inval
xfs: Remove usused xfs_end_io_direct events
xfs: Only create event xfs_file_compat_ioctl when CONFIG_COMPAT is configure
xfs: Change xfs_xattr_class from a TRACE_EVENT() to DECLARE_EVENT_CLASS()

----

 fs/xfs/scrub/trace.h |  2 +-
 fs/xfs/xfs_trace.h   | 72 ++++++----------------------------------------------
 2 files changed, 9 insertions(+), 65 deletions(-)
author maintainer
#23 lore raw
Quoted 6 lines · On Fri, 13 Jun 2025 08:08:55 -0700 "Darrick J. Wong" <[email protected]> wrote:
Quoted 2 lines · Steven Rostedt

Trace events take up to 5K in memory for text and meta data. I have code that

Under what circumstances do they eat up that much memory? And is that per-class? Or per-tracepoint?

I just did an analysis of this:

https://lore.kernel.org/lkml/[email protected]/T/#md81abade0df19ba9062fd51ced4458161f885ac3

A TRACE_EVENT() is about 5K, and each DEFINE_EVENT() is about 1K.

Quoted 6 lines
Quoted 6 lines

will trigger a warning when it detects unused tracepoints. The XFS file system contains many events that are not called. Most of them used to be called but due to code refactoring the calls were removed but the trace events stayed behind.

Quoted 8 lines
Quoted 2 lines

Some events were added but never used. If they were recent, I just reported them, but if they were older, this series simply removes them.

TBH it'd be really nice if there was /something/ in the build path that would complain about disused tracepoints. I often put in tracepoints while developing a feature, then the code gets massively rewritten during review, and none of us remember to rip out the orphaned traces...

That's exactly what I'm doing. In the thread I did the analysis, it has code that triggers a warning for unused events. I'm currently cleaning them up (and asking others to do it too), so that I can add that code without triggering all the current unused tracepoints.

Feel free to take those patches and it will warn at build time. Note, it currently only works for built in code, so you have to build your module as a built in and not a module.

Quoted 12 lines
Quoted 12 lines

One is called only when CONFIG_COMPACT is defined, so an #ifdef was placed around it.

A couple are only called in #if 0 code (left as a reminder to fix it), so those events are wrapped by a #if 0 as well (with a comment).

Finally, one event is supposed to be a trace event class, but was created with the TRACE_EVENT() macro and not the DECLARE_EVENT_CLASS() macro. This works because a TRACE_EVENT() is simply a DECLARE_EVENT_CLASS() and DEFINE_EVENT() where the class and event have the same name. But as this was a mistake, the event created should not exist.

Quoted 8 lines
Quoted 5 lines

Each patch is a stand alone patch. If you ack them, I can take them in my tree, or if you want, you can take them. I may be adding the warning code to linux-next near the end of the cycle, so it would be good to have this cleaned up before hand. As this is removing dead code, it may be even OK to send them to Linus as a fix.

...oh, you /do/ have a program and it's coming down the pipeline. Excellent <tents fingers>. :)

Ah you did notice ;-)

-- Steve

#24 lore raw
Quoted 7 lines · Steven Rostedt
Quoted 4 lines · On Fri, 13 Jun 2025 08:08:55 -0700 "Darrick J. Wong" <[email protected]> wrote:
Quoted 2 lines · Steven Rostedt

Trace events take up to 5K in memory for text and meta data. I have code that

Quoted 8 lines
Quoted 2 lines

Under what circumstances do they eat up that much memory? And is that per-class? Or per-tracepoint?

I just did an analysis of this:

https://lore.kernel.org/lkml/[email protected]/T/#md81abade0df19ba9062fd51ced4458161f885ac3

A TRACE_EVENT() is about 5K, and each DEFINE_EVENT() is about 1K.

That's really quite expensive. And you only measured the tezt/data/bss overhead and not even the dynamic memory overhead, which is probably a lot more.

author maintainer
#25 lore raw
Quoted 7 lines · On Mon, 16 Jun 2025 07:31:19 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 5 lines

I just did an analysis of this:

https://lore.kernel.org/lkml/[email protected]/T/#md81abade0df19ba9062fd51ced4458161f885ac3

A TRACE_EVENT() is about 5K, and each DEFINE_EVENT() is about 1K.

That's really quite expensive. And you only measured the tezt/data/bss

Yes. This is something I've spent a bit of time over the years trying to address. With moving a bunch of code into trace_event.c with the added expense that trace events do function calls.

It looks like it's still growing as the last time I checked it was just under 5K (something around 4800 bytes) and now it's over 5K, and the tracepoint code grew 4x. I'll start looking into "why" later when I have more time to deal with this. My time budget for removing unused events has pretty much dried up.

Quoted 2 lines

overhead and not even the dynamic memory overhead, which is probably a lot more.

Yes, and this is another area I look to make better. It was the motivation for eventfs which saved over 20 megs of memory by having trace event files dynamically created instead of being permanent.

-- Steve

author maintainer
#26 lore raw
In reply to Darrick J. Wong
Quoted 8 lines · On Fri, 13 Jun 2025 08:08:55 -0700 "Darrick J. Wong" <[email protected]> wrote:
Quoted 5 lines

Each patch is a stand alone patch. If you ack them, I can take them in my tree, or if you want, you can take them. I may be adding the warning code to linux-next near the end of the cycle, so it would be good to have this cleaned up before hand. As this is removing dead code, it may be even OK to send them to Linus as a fix.

...oh, you /do/ have a program and it's coming down the pipeline. Excellent <tents fingers>. :)

Well, Linus didn't like its current implementation, so it may be a release or two or three before that program gets upstream :-/

-- Steve