mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
SELinux: tune avtab to reduce memory usage
This patch reduces memory usage of SELinux by tuning avtab. Number of hash slots in avtab was 32768. Unused slots used memory when number of rules is fewer. This patch decides number of hash slots dynamically based on number of rules. (chain length)^2 is also printed out in avtab_hash_eval to see standard deviation of avtab hash table. Signed-off-by: Yuichi Nakamura<ynakam@hitachisoft.jp> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
821f3eff7c
commit
3232c110b5
4 changed files with 82 additions and 36 deletions
|
@ -456,6 +456,10 @@ int cond_read_list(struct policydb *p, void *fp)
|
|||
|
||||
len = le32_to_cpu(buf[0]);
|
||||
|
||||
rc = avtab_alloc(&(p->te_cond_avtab), p->te_avtab.nel);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
node = kzalloc(sizeof(struct cond_node), GFP_KERNEL);
|
||||
if (!node)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue