Skip to contentSkip to conversation

selinux: reorder inode_security_struct to increase objs/slab on 64bit

PATCH Applied Richard Kennedy 3 participants 5 messages May 18, 2008 – May 20, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: reorder inode_security_struct to increase objs/slab on 64bit

reorder inode_security_struct to remove padding on 64 bit builds

size reduced from 72 to 64 bytes increasing objects per slab to 64.

---
This patch is against 2.6.26-r2 & boots successfully on my AMD64 desktop.

Richard

security/selinux/include/objsec.h +1 -1
index 032c235..5f0be19 100644
@@ -43,8 +43,8 @@ struct inode_security_struct {
 	u32 sid;		/* SID of this object */
 	u16 sclass;		/* security class of this object */
 	unsigned char initialized;	/* initialization flag */
-	struct mutex lock;
 	unsigned char inherit;	/* inherit SID from parent entry */
+	struct mutex lock;
 };
 
 struct file_security_struct {
Applied
#1 lore raw
Quoted 5 lines · Richard Kennedy

reorder inode_security_struct to remove padding on 64 bit builds

size reduced from 72 to 64 bytes increasing objects per slab to 64.

Thanks, applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6.git#for-akpm

(Although I see a reduction from 164 to 160 bytes).

- James

Signature · 2 lines
James Morris
<[email protected]>
#2 lore raw
Quoted 8 lines · James Morris
Quoted 5 lines · Richard Kennedy

reorder inode_security_struct to remove padding on 64 bit builds

size reduced from 72 to 64 bytes increasing objects per slab to 64.

Quoted 7 lines

Thanks, applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6.git#for-akpm

(Although I see a reduction from 164 to 160 bytes).

- James

In that case I think you've got all the lock & mutex debugging turned on :)
CONFIG_DEBUG_MUTEXES & CONFIG_DEBUG_LOCK_ALLOC will add a lot to the mutex directly.

CONFIG_GENERIC_LOCKBREAK, CONFIG_DEBUG_SPINLOCK & CONFIG_DEBUG_LOCK_ALLOC will each grow the spinlock contained in the mutex.

However, I'm seeing all structures packed to size of 8n -- so I'd never get a sizeof 164. Maybe that's just a platform/compiler difference ? I'm running on AMD 64 & gcc 4.1.2

Richard

#3 lore raw
In reply to Richard Kennedy
Quoted 20 lines · Richard Kennedy

reorder inode_security_struct to remove padding on 64 bit builds

size reduced from 72 to 64 bytes increasing objects per slab to 64.

---
This patch is against 2.6.26-r2 & boots successfully on my AMD64 desktop.

Richard

security/selinux/include/objsec.h +0 -0
index 032c235..5f0be19 100644

security/selinux/include/objsec.h struct inode_security_struct { · line 46

Quoted 5 lines
security/selinux/include/objsec.h +0 -1
@@ -43,8 +43,8 @@ struct inode_security_struct {
 	u32 sid;		/* SID of this object */
 	u16 sclass;		/* security class of this object */
 	unsigned char initialized;	/* initialization flag */
-	struct mutex lock;
 	unsigned char inherit;	/* inherit SID from parent entry */

Let's just drop inherit altogether - dead field.

Quoted 5 lines
security/selinux/include/objsec.h +1 -0
+	struct mutex lock;
 };
 
 struct file_security_struct {
Signature · 2 lines
Stephen Smalley
National Security Agency
#4 lore raw
Quoted 7 lines · Stephen Smalley

security/selinux/include/objsec.h struct inode_security_struct { · line 46

Quoted 5 lines
security/selinux/include/objsec.h +0 -1
 	u32 sid;		/* SID of this object */
 	u16 sclass;		/* security class of this object */
 	unsigned char initialized;	/* initialization flag */
-	struct mutex lock;
 	unsigned char inherit;	/* inherit SID from parent entry */

Let's just drop inherit altogether - dead field.

Done in
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6.git#for-akpm

Signature · 1 line
James Morris <[email protected]>