2006-08-15 19:06:49

by Andreas Mohr

[permalink] [raw]
Subject: [PATCH -mm] fs/inode.c tweaks

Only touch inode's i_mtime and i_ctime to make them equal to "now"
in case they aren't yet (don't just update timestamp unconditionally).
Uninline the hash function to save 259 Bytes.

This tiny inode change which may improve cache behaviour
also shaves off 8 Bytes from file_update_time() on i386.


Please complain loudly if you think that hash() really should remain
inlined (but note that it has 7 callsites in this file and a function size
of 42 Bytes on i386!).


0000004d <hash>:
4d: 0f af c2 imul %edx,%eax
50: 81 ea ff ff c8 61 sub $0x61c8ffff,%edx
56: 8b 0d 04 00 00 00 mov 0x4,%ecx
58: R_386_32 .data.read_mostly
5c: 55 push %ebp
5d: c1 ea 07 shr $0x7,%edx
60: 89 e5 mov %esp,%ebp
62: 31 d0 xor %edx,%eax
64: 89 c2 mov %eax,%edx
66: 81 f2 01 00 37 9e xor $0x9e370001,%edx
6c: d3 ea shr %cl,%edx
6e: 31 d0 xor %edx,%eax
70: 23 05 00 00 00 00 and 0x0,%eax
72: R_386_32 .data.read_mostly
76: c9 leave
77: c3 ret


Included a tiny codestyle cleanup, too.

Compile-tested and run-tested on 2.6.18-rc4-mm1.


Signed-off-by: Andreas Mohr <[email protected]>


--- linux-2.6.18-rc4-mm1.orig/fs/inode.c 2006-08-22 21:13:22.000000000 +0200
+++ linux-2.6.18-rc4-mm1/fs/inode.c 2006-08-23 20:34:20.000000000 +0200
@@ -678,7 +678,7 @@
return inode;
}

-static inline unsigned long hash(struct super_block *sb, unsigned long hashval)
+static unsigned long hash(struct super_block *sb, unsigned long hashval)
{
unsigned long tmp;

@@ -1024,7 +1024,7 @@

list_del_init(&inode->i_list);
list_del_init(&inode->i_sb_list);
- inode->i_state|=I_FREEING;
+ inode->i_state |= I_FREEING;
inodes_stat.nr_inodes--;
spin_unlock(&inode_lock);

@@ -1231,13 +1231,15 @@
return;

now = current_fs_time(inode->i_sb);
- if (!timespec_equal(&inode->i_mtime, &now))
+ if (!timespec_equal(&inode->i_mtime, &now)) {
+ inode->i_mtime = now;
sync_it = 1;
- inode->i_mtime = now;
+ }

- if (!timespec_equal(&inode->i_ctime, &now))
+ if (!timespec_equal(&inode->i_ctime, &now)) {
+ inode->i_ctime = now;
sync_it = 1;
- inode->i_ctime = now;
+ }

if (sync_it)
mark_inode_dirty_sync(inode);