Smack: Create smack_rule cache to optimize memory usage
authorCasey Schaufler <cschaufler@localhost.localdomain>
Tue, 2 Apr 2019 18:37:12 +0000 (11:37 -0700)
committerCasey Schaufler <cschaufler@localhost.localdomain>
Tue, 2 Apr 2019 18:45:41 +0000 (11:45 -0700)
commit4e328b08882a68649df2c2b76fd208b0d0b85503
tree1d11925b2e79b19646ff675a0d02bae725f4b21e
parent460d95a1d69d5c0352379a3651c9cb6ec09e4ddb
Smack: Create smack_rule cache to optimize memory usage

This patch allows for small memory optimization by creating the
kmem cache for "struct smack_rule" instead of using kzalloc.
For adding new smack rule, kzalloc is used to allocate the memory
for "struct smack_rule". kzalloc will always allocate 32 or 64 bytes
for 1 structure depending upon the kzalloc cache sizes available in
system. Although the size of structure is 20 bytes only, resulting
in memory wastage per object in the default pool.

For e.g., if there are 20000 rules, then it will save 240KB(20000*12)
which is crucial for small memory targets.

Signed-off-by: Vishal Goel <vishal.goel@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smack.h
security/smack/smack_lsm.c
security/smack/smackfs.c