linux/security/selinux/ss
Eric Paris 76f7ba35d4 SELinux: shrink sizeof av_inhert selinux_class_perm and context
I started playing with pahole today and decided to put it against the
selinux structures.  Found we could save a little bit of space on x86_64
(and no harm on i686) just reorganizing some structs.

Object size changes:
av_inherit: 24 -> 16
selinux_class_perm: 48 -> 40
context: 80 -> 72

Admittedly there aren't many of av_inherit or selinux_class_perm's in
the kernel (33 and 1 respectively) But the change to the size of struct
context reverberate out a bit.  I can get some hard number if they are
needed, but I don't see why they would be.  We do change which cacheline
context->len and context->str would be on, but I don't see that as a
problem since we are clearly going to have to load both if the context
is to be of any value.  I've run with the patch and don't seem to be
having any problems.

An example of what's going on using struct av_inherit would be:

form: to:
struct av_inherit {			struct av_inherit {
	u16 tclass;				const char **common_pts;
	const char **common_pts;		u32 common_base;
	u32 common_base;			u16 tclass;
};

(notice all I did was move u16 tclass to the end of the struct instead
of the beginning)

Memory layout before the change:
struct av_inherit {
	u16 tclass; /* 2 */
	/* 6 bytes hole */
	const char** common_pts; /* 8 */
	u32 common_base; /* 4 */
	/* 4 byes padding */

	/* size: 24, cachelines: 1 */
	/* sum members: 14, holes: 1, sum holes: 6 */
	/* padding: 4 */
};

Memory layout after the change:
struct av_inherit {
	const char ** common_pts; /* 8 */
	u32 common_base; /* 4 */
	u16 tclass; /* 2 */
	/* 2 bytes padding */

	/* size: 16, cachelines: 1 */
	/* sum members: 14, holes: 0, sum holes: 0 */
	/* padding: 2 */
};

Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
2009-01-05 19:19:55 +11:00
..
avtab.c selinux: Unify for- and while-loop style 2008-08-15 08:40:47 +10:00
avtab.h SELinux: add more validity checks on policy load 2007-11-08 08:56:23 +11:00
conditional.c selinux: Unify for- and while-loop style 2008-08-15 08:40:47 +10:00
conditional.h selinux: conditional expression type validation was off-by-one 2008-08-07 08:56:16 +10:00
constraint.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
context.h SELinux: shrink sizeof av_inhert selinux_class_perm and context 2009-01-05 19:19:55 +11:00
ebitmap.c selinux: Unify for- and while-loop style 2008-08-15 08:40:47 +10:00
ebitmap.h SELinux: kills warnings in Improve SELinux performance when AVC misses 2007-10-17 08:59:36 +10:00
hashtab.c selinux: Unify for- and while-loop style 2008-08-15 08:40:47 +10:00
hashtab.h SELinux: hashtab.h whitespace, syntax, and other cleanups 2008-04-28 09:29:04 +10:00
Makefile Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mls_types.h SELinux: mls_types.h whitespace, syntax, and other cleanups 2008-04-28 09:29:06 +10:00
mls.c SELinux: Trivial minor fixes that change C null character style 2008-08-05 10:55:30 +10:00
mls.h selinux: support deferred mapping of contexts 2008-07-14 15:01:34 +10:00
policydb.c SELinux: add boundary support and thread context assignment 2008-08-29 00:33:33 +10:00
policydb.h SELinux: add boundary support and thread context assignment 2008-08-29 00:33:33 +10:00
services.c Merge branch 'master' of git://git.infradead.org/users/pcmoore/lblnet-2.6_next into next 2008-10-11 09:26:14 +11:00
services.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sidtab.c selinux: Unify for- and while-loop style 2008-08-15 08:40:47 +10:00
sidtab.h selinux: support deferred mapping of contexts 2008-07-14 15:01:34 +10:00
symtab.c SELinux: ensure keys constant in hashtab_search 2006-11-28 12:04:37 -05:00
symtab.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00