WSL2-Linux-Kernel/drivers/oprofile
Nick Piggin c2452f3278 shrink struct dentry
struct dentry is one of the most critical structures in the kernel. So it's
sad to see it going neglected.

With CONFIG_PROFILING turned on (which is probably the common case at least
for distros and kernel developers), sizeof(struct dcache) == 208 here
(64-bit). This gives 19 objects per slab.

I packed d_mounted into a hole, and took another 4 bytes off the inline
name length to take the padding out from the end of the structure. This
shinks it to 200 bytes. I could have gone the other way and increased the
length to 40, but I'm aiming for a magic number, read on...

I then got rid of the d_cookie pointer. This shrinks it to 192 bytes. Rant:
why was this ever a good idea? The cookie system should increase its hash
size or use a tree or something if lookups are a problem. Also the "fast
dcookie lookups" in oprofile should be moved into the dcookie code -- how
can oprofile possibly care about the dcookie_mutex? It gets dropped after
get_dcookie() returns so it can't be providing any sort of protection.

At 192 bytes, 21 objects fit into a 4K page, saving about 3MB on my system
with ~140 000 entries allocated. 192 is also a multiple of 64, so we get
nice cacheline alignment on 64 and 32 byte line systems -- any given dentry
will now require 3 cachelines to touch all fields wheras previously it
would require 4.

I know the inline name size was chosen quite carefully, however with the
reduction in cacheline footprint, it should actually be just about as fast
to do a name lookup for a 36 character name as it was before the patch (and
faster for other sizes). The memory footprint savings for names which are
<= 32 or > 36 bytes long should more than make up for the memory cost for
33-36 byte names.

Performance is a feature...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2008-12-31 18:07:38 -05:00
..
buffer_sync.c shrink struct dentry 2008-12-31 18:07:38 -05:00
buffer_sync.h oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00
cpu_buffer.c oprofile: fix lost sample counter 2008-12-10 20:25:15 +01:00
cpu_buffer.h oprofile: port to the new ring_buffer 2008-12-10 14:20:18 +01:00
event_buffer.c oprofile: fix memory ordering 2008-10-27 19:15:41 +01:00
event_buffer.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile 2008-10-23 10:05:40 -07:00
oprof.c oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00
oprof.h oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00
oprofile_files.c oprofile: set values to default when creating oprofilefs 2008-12-10 14:20:10 +01:00
oprofile_stats.c oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00
oprofile_stats.h oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00
oprofilefs.c oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00
timer_int.c oprofile: fixing whitespaces in drivers/oprofile/* 2008-10-16 15:01:40 +02:00