public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH 5/5] Dump the inode structure (for debugging purposes only)
Date: Thu, 21 May 2009 16:01:03 -0400	[thread overview]
Message-ID: <1242936063-31689-6-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1242936063-31689-5-git-send-email-tytso@mit.edu>

This is not intended for merging; but it's useful for determining how
much varous fields in the struct inode space, and whether there is any
padding leading to waste, especially on a 64-bit platforms.

For example:

Begin dump of struct inode (size 1144)
i_hash    : 0 16 0
i_list    : 16 16 0
i_sb_list : 32 16 0
i_dentry  : 48 16 0
i_ino     : 64 8 0
i_count   : 72 4 0
i_nlink   : 76 4 0
i_uid     : 80 4 0
i_gid     : 84 4 0
i_rdev    : 88 4 0
i_version : 96 8 4
i_size    : 104 8 0
i_atime   : 112 16 0
i_mtime   : 128 16 0
i_ctime   : 144 16 0
i_blocks  : 160 8 0
i_blkbits : 168 4 0
i_bytes   : 172 2 0
i_mode    : 174 2 0
i_lock    : 176 64 0
i_mutex   : 240 152 0
i_alloc_sem: 392 128 0
i_op      : 520 8 0
i_fop     : 528 8 0
i_sb      : 536 8 0
i_flock   : 544 8 0
i_mapping : 552 8 0
i_data    : 560 328 0
i_dquot   : 888 16 0
i_devices : 904 16 0
i_pipe    : 920 8 0
i_bdev    : 920 8 -8
i_cdev    : 920 8 -8
i_generation: 928 4 0
i_dnotify_mask: 932 4 0
i_dnotify : 936 8 0
inotify_watches: 944 16 0
inotify_mutex: 960 152 0
dirtied_when: 1112 8 0
i_state   : 1120 2 0
i_flags   : 1122 2 0
i_writecount: 1124 4 0
i_security: 1128 8 0
i_private : 1136 8 0

This shows us that i_data, an struct address_space data structure,
takes 328 bytes; i_mutex takes 152 bytes, the i_alloc_sem rw_semaphore
takes 128 bytes, and the i_lock spinlock takes 64 bytes.  A lot of
this space is due to varous LOCKDEP and spinlock debugging options.

(With all debugging turned off, the inode structure shrinks from 1144
bytes to 560 bytes, with i_data being 144 bytes, i_mutex being 32
bytes, i_alloc_sem being 24 bytes, and i_lock taking 4 bytes.)
---
 fs/Makefile              |    1 +
 fs/inode-struct-dumper.c |   87 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
 create mode 100644 fs/inode-struct-dumper.c

diff --git a/fs/Makefile b/fs/Makefile
index af6d047..196f3f5 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_AIO)               += aio.o
 obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
+obj-y				+= inode-struct-dumper.o	
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o
 obj-y				+= $(nfsd-y) $(nfsd-m)
diff --git a/fs/inode-struct-dumper.c b/fs/inode-struct-dumper.c
new file mode 100644
index 0000000..c85d792
--- /dev/null
+++ b/fs/inode-struct-dumper.c
@@ -0,0 +1,87 @@
+/*
+ * inode struct dumper --- dump out the inode structure
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/stddef.h>
+
+#define ELEMENT(xx) { \
+	offset=offsetof(struct inode, xx);		 \
+	size=sizeof(p->xx);					\
+	printk(KERN_NOTICE "%-10s: %d %d %d\n", #xx,		 \
+	       offset, size, offset-(last_offset+last_size));	\
+	last_offset=offset;					\
+	last_size = size;					\
+	}
+
+static int __init dumper_init(void)
+{
+	struct inode *p;
+	int offset, size, last_offset=0, last_size=0;
+
+	printk(KERN_NOTICE "Begin dump of struct inode (size %lu)\n",
+	       sizeof(struct inode));
+	ELEMENT(i_hash);
+	ELEMENT(i_list);
+	ELEMENT(i_sb_list);
+	ELEMENT(i_dentry);
+	ELEMENT(i_ino);
+	ELEMENT(i_count);
+	ELEMENT(i_nlink);
+	ELEMENT(i_uid);
+	ELEMENT(i_gid);
+	ELEMENT(i_rdev);
+	ELEMENT(i_version);
+	ELEMENT(i_size);
+#ifdef __NEED_I_SIZE_ORDERED
+	ELEMENT(i_size_seqcount);
+#endif
+	ELEMENT(i_atime);
+	ELEMENT(i_mtime);
+	ELEMENT(i_ctime);
+	ELEMENT(i_blocks);
+	ELEMENT(i_blkbits);
+	ELEMENT(i_bytes);
+	ELEMENT(i_mode);
+	ELEMENT(i_lock);
+	ELEMENT(i_mutex);
+	ELEMENT(i_alloc_sem);
+	ELEMENT(i_op);
+	ELEMENT(i_fop);
+	ELEMENT(i_sb);
+	ELEMENT(i_flock);
+	ELEMENT(i_mapping);
+	ELEMENT(i_data);
+#ifdef CONFIG_QUOTA
+	ELEMENT(i_dquot);
+#endif
+	ELEMENT(i_devices);
+	ELEMENT(i_pipe);
+	ELEMENT(i_bdev);
+	ELEMENT(i_cdev);
+	ELEMENT(i_generation);
+#ifdef CONFIG_DNOTIFY
+	ELEMENT(i_dnotify_mask);
+	ELEMENT(i_dnotify);
+#endif
+#ifdef CONFIG_INOTIFY
+	ELEMENT(inotify_watches);
+	ELEMENT(inotify_mutex);
+#endif
+	ELEMENT(dirtied_when);
+	ELEMENT(i_state);
+	ELEMENT(i_flags);
+	ELEMENT(i_writecount);
+#ifdef CONFIG_SECURITY
+	ELEMENT(i_security);
+#endif
+	ELEMENT(i_private);
+	return 0;
+}
+
+module_init(dumper_init);
+
-- 
1.6.3.1.1.g75fc.dirty


  reply	other threads:[~2009-05-21 20:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-21 20:00 [RFC PATCH 0/5] Put struct inode on a diet Theodore Ts'o
2009-05-21 20:00 ` [PATCH 1/5] fs: i_flags and i_state in struct inode only need to be unsigned short Theodore Ts'o
2009-05-21 20:01   ` [PATCH 2/5] fs: Remove i_cindex from struct inode Theodore Ts'o
2009-05-21 20:01     ` [PATCH 3/5] fs: Slim down inode by only using an unsigned int for i_dnotify_mask Theodore Ts'o
2009-05-21 20:01       ` [PATCH 4/5] fs: Rearrange inode structure elements to avoid waste due to padding Theodore Ts'o
2009-05-21 20:01         ` Theodore Ts'o [this message]
2009-05-21 20:09           ` [PATCH 5/5] Dump the inode structure (for debugging purposes only) Matthew Wilcox
2009-05-21 20:28             ` Theodore Tso
2009-05-21 20:30     ` [PATCH 2/5] fs: Remove i_cindex from struct inode Stefan Richter

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=1242936063-31689-6-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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