[PATCH] Tweak tracing allocation sizes

Lachlan McIlroy
2008-09-02T05:39:44Z

The size of a single ktrace entry is 16 pointers so 128 bytes. For the case
of XFS_RW_KTRACE_SIZE which is 128 entries this equates to 16KB and on a system
with 4KB pages that is under memory pressure this can stall that process for a
significant time while it hunts for 4 free pages. Cutting this value back to
32 means it will only need one page.

Initialize the ktrace system with a zone size of 32 so calls to ktrace_alloc()
that want 32 trace entries (ie 1 page) will go through the ktrace entry zone.
Bump INODE_TRACE_SIZE from 16 to 32 since if we are going to allocate half a
page we might as well give it a full page and have it allocate from the zone
too.

More can be done here but these changes reduce the liklihood of hitting
deadlocks due to memory pressure.

--- a/fs/xfs/linux-2.6/xfs_lrw.h 2008-09-02 15:28:27.000000000 +1000
+++ b/fs/xfs/linux-2.6/xfs_lrw.h 2008-08-22 14:50:55.000000000 +1000
@@ -28,7 +28,7 @@ struct xfs_iomap;
/*
* Defines for the trace mechanisms in xfs_lrw.c.
*/
-#define XFS_RW_KTRACE_SIZE 128
+#define XFS_RW_KTRACE_SIZE 32

#define XFS_READ_ENTER 1
#define XFS_WRITE_ENTER 2

--- a/fs/xfs/linux-2.6/xfs_super.c 2008-09-02 15:28:27.000000000 +1000
+++ b/fs/xfs/linux-2.6/xfs_super.c 2008-08-22 14:52:58.000000000 +1000
@@ -2151,7 +2151,7 @@ init_xfs_fs(void)

printk(message);

- ktrace_init(64);
+ ktrace_init(32);
vn_init();
xfs_dir_startup();

--- a/fs/xfs/linux-2.6/xfs_vnode.h 2008-09-02 15:28:27.000000000 +1000
+++ b/fs/xfs/linux-2.6/xfs_vnode.h 2008-08-22 14:52:14.000000000 +1000
@@ -126,7 +126,7 @@ static inline void vn_atime_to_time_t(st
*/
#if defined(XFS_INODE_TRACE)

-#define INODE_TRACE_SIZE 16 /* number of trace entries */
+#define INODE_TRACE_SIZE 32 /* number of trace entries */
#define INODE_KTRACE_ENTRY 1
#define INODE_KTRACE_EXIT 2
#define INODE_KTRACE_HOLD 3