Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2009 16:13:13 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Andrew Brampton <brampton+freebsd-hackers@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: pahole - Finding holes in kernel structs
Message-ID:  <20090212141313.GD2723@deviant.kiev.zoral.com.ua>
In-Reply-To: <d41814900902120608i4b54c86fp9f565bbeead5a476@mail.gmail.com>
References:  <d41814900902120608i4b54c86fp9f565bbeead5a476@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--W5WqUoFLvi1M7tJE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Feb 12, 2009 at 02:08:22PM +0000, Andrew Brampton wrote:
> I found this useful tool called pahole[1]. It basically finds holes
> within structs, so for example on my 64bit machine this struct:
>=20
> struct test {
>    int foo;
>    const char *bar;
>    int blah;
> }
>=20
> Would have a hole between foo and bar of 4 bytes because both for and
> bar have been aligned on a 8 byte boundary, and the struct would also
> have 4 bytes of padding on the end. However, if I simply moved blah
> between foo and bar then the struct has shrunk by 8 bytes, which could
> be a good thing. This could also help keep structs within single cache
> lines, and just generally keep memory usage to a minimum when the
> struct is used many times (for example in an array).
>=20
> So I ran the tool pahole over a 7.1 FreeBSD Kernel, and found that
Did you ported it to FreeBSD, or run on the Linux host ?

> many of the struct had holes, and some of which could be rearranged to
> fill the gap. I've made the list available here[2]. So my questions
> are two fold:
>=20
> 1) Is it worth my time trying to rearrange structs? If so do you think
> many of my patches would be accepted?
>=20
> 2) Is there a way to find out the most heavily used structs? There are
> ~3600 structs, and ~2000 holes, it might be a waste of my time fixing
> the structs which are only used once.
>=20
> thanks
> Andrew
>=20
> [1] http://lwn.net/Articles/206805/
> [2] http://bramp.net/projects/kernel.pahole.bz2 (~260kB)
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"

--W5WqUoFLvi1M7tJE
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkmULm0ACgkQC3+MBN1Mb4joYwCfSkvwNVqw3CxhBwtylz2H09AE
u44AnjQ5EJklVTyfp+a6bshkWMsRuD/i
=50k3
-----END PGP SIGNATURE-----

--W5WqUoFLvi1M7tJE--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090212141313.GD2723>