From: Yuichi Nakamura <ynakam@hitachisoft.jp>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: ynakam@hitachisoft.jp, selinux@tycho.nsa.gov,
busybox@kaigai.gr.jp, James Morris <jmorris@namei.org>,
Eric Paris <eparis@parisplace.org>,
kaigai@ak.jp.nec.com, method@manicmethod.com
Subject: Appropriate number of hash slots for te_avtab(Was:Re: [RFC] Dynamically deciding number of hash slots for avtab
Date: Tue, 07 Aug 2007 18:05:27 +0900 [thread overview]
Message-ID: <20070807175824.4CBF.YNAKAM@hitachisoft.jp> (raw)
In-Reply-To: <1185368380.2900.40.camel@moss-spartans.epoch.ncsc.mil>
Hi.
In previous discussion,
I posted patch to reduce memory usage of te_avtab,
and it could save up to 300k memory.
I had to determin two things about te_avtab hash table.
1) Determin appropriate max number of hash slots.
It is 32768(MAX_AVTAB_HASH_SIZE) in previous patch.
If it can be smaller, kmalloc can be used instead of zmalloc.
2) Determin number of hash slots from number of rules.
In previous patch, number of allocated hash slots is the same as number of rules.
To determin 1),
We have to see hash stats when big policy is loaded.
I loaded full-size refpolicy(It is strict policy), and looked at hash stats.
# I defined DEBUG_HASHES to see hash stats.
And varied max number of hash slots.
* Version of refpolicy: selinux-policy-strict-2.4.6-80.fc6
* Num of uncond rules: 166741.
To determin 2),
We have to see hash stats when small policy is loaded.
I loaded small size refpolicy, and looked at hash stats.
Varied number of hash slots.
* Version of refpoilcy: serefpolicy-2.4.6
* Num of uncond rules: 8188
# Removed unneeded sources, and made it smaller.
Below is a result of measurement of hash stats.
Please give me advice about appropriate number of hash slots.
1. Result for 1)
* max table size = 32768
SELinux:32768 avtab hash slots allocated. Num of rules:166741
rules: 166741 entries and 30128/32768 buckets used, longest chain length 34
-> chain length = 34
* 16384
SELinux:16384 avtab hash slots allocated. Num of rules:166741
rules: 166741 entries and 16221/16384 buckets used, longest chain length 59
* 8192
SELinux:8192 avtab hash slots allocated. Num of rules:166741
rules: 166741 entries and 8190/8192 buckets used, longest chain length 97
* 4096
SELinux:4096 avtab hash slots allocated. Num of rules:166741enfs_contexts
rules: 166741 entries and 4096/4096 buckets used, longest chain length 182
It seems that 4096, 8192 is small, because chain length is 182, 97.
It might be better not to alter max table size, but I am not sure..
2. Result for 2)
* Number of slot = num of rules
SELinux:8192 avtab hash slots allocated. Num of rules:8188
rules: 8188 entries and 3925/8192 buckets used, longest chain length 13
-> chain length = 13
* Number of slot = num of rules/2
SELinux:4096 avtab hash slots allocated. Num of rules:8188
rules: 8188 entries and 2809/4096 buckets used, longest chain length 21
* Number of slot = num of rules/4
SELinux:2048 avtab hash slots allocated. Num of rules:8188
rules: 8188 entries and 1742/2048 buckets used, longest chain length 35
* Number of slot = num of rules/8
SELinux:1024 avtab hash slots allocated. Num of rules:8188
rules: 8188 entries and 978/1024 buckets used, longest chain length 64
"Number of slot = num of rules/8" may be too small.
/4 or /2 is good?
Regards,
--
Yuichi Nakamura
Hitachi Software Engineering Co., Ltd.
Japan SELinux Users Group(JSELUG): http://www.selinux.gr.jp/
SELinux Policy Editor: http://seedit.sourceforge.net/
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2007-08-07 9:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 7:03 [patch] customizable AVTAB_HASH_BITS for embedded devices Yuichi Nakamura
2007-07-23 19:58 ` Stephen Smalley
2007-07-23 20:00 ` Stephen Smalley
2007-07-24 3:06 ` KaiGai Kohei
2007-07-24 3:31 ` Joshua Brindle
2007-07-24 8:05 ` Yuichi Nakamura
2007-07-24 12:14 ` Stephen Smalley
2007-07-24 12:12 ` Stephen Smalley
2007-07-24 13:10 ` James Morris
2007-07-24 9:32 ` [RFC] Dynamically deciding number of hash slots for avtab (Was:Re: " Yuichi Nakamura
2007-07-24 12:52 ` Stephen Smalley
2007-07-25 3:01 ` Yuichi Nakamura
2007-07-25 12:59 ` Stephen Smalley
2007-07-25 14:07 ` Yuichi Nakamura
2007-08-07 9:05 ` Yuichi Nakamura [this message]
2007-08-07 12:33 ` Appropriate number of hash slots for te_avtab(Was:Re: [RFC] Dynamically deciding number of hash slots for avtab Stephen Smalley
2007-08-08 6:00 ` Yuichi Nakamura
2007-08-08 14:43 ` James Morris
2007-08-08 14:58 ` Yuichi Nakamura
2007-08-08 15:01 ` Stephen Smalley
2007-08-08 14:45 ` Stephen Smalley
2007-08-08 15:02 ` Yuichi Nakamura
2007-08-08 15:35 ` James Morris
2007-08-10 7:25 ` Yuichi Nakamura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070807175824.4CBF.YNAKAM@hitachisoft.jp \
--to=ynakam@hitachisoft.jp \
--cc=busybox@kaigai.gr.jp \
--cc=eparis@parisplace.org \
--cc=jmorris@namei.org \
--cc=kaigai@ak.jp.nec.com \
--cc=method@manicmethod.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.