All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frank Mayer" <mayerf@tresys.com>
To: "'Karl MacMillan'" <kmacmillan@tresys.com>,
	"'Stephen Smalley'" <sds@tycho.nsa.gov>, <ivg2@cornell.edu>
Cc: "'James Morris'" <jmorris@redhat.com>, <selinux@tycho.nsa.gov>,
	"'Daniel J Walsh'" <dwalsh@redhat.com>
Subject: RE: file contexts and modularity
Date: Fri, 24 Jun 2005 14:05:41 -0400	[thread overview]
Message-ID: <200506241805.j5OI5fqc018169@gotham.columbia.tresys.com> (raw)
In-Reply-To: <200506241605.j5OG5tqc016540@gotham.columbia.tresys.com>

Karl MacMillan wrote:
> One more idea - remove the multiple data fields in avtab_datum and
> have multiple entries for each key representing different rule types.
> If a small enough percentage of keys have only 1 type of rule
> (probably allow) then this should be a win. Haven't done the analysis
> of a real policy yet to know if this is a win, but seems like it
> would be (and anecdotal evidence from libapol suggests that it will
> be - this is similar to how the libapol av hash works).      

Just to expand on this, we have contemplated making this change in the past.
Here's a quick analysis: An avtab_datum_t is 4 x 32 bit words = 16 bytes .
An avtab node has a 3 x 32 bit (12 bytes) key, an avtab_datum (16 bytes) and
a next pointer (4 bytes) for 32 bytes total. 32 bytes times 100,000s rules
== mucho memory.

Taking am arbitrary sample policy and looking at the stats with apol, I have
298,894 allow rules, 2,076 type_trans rules, 25 type_change rules, 3
auditallow rules, and 53,719 dontaudit rules. Assume that all the
type_change rules share a common key with one of the type_trans rules, and
that all the audit rules share a common key with allow rules (a generally
safe assumption IMHO), we should have 300,970 avtab entries of which only
53,744 use more than one datum. 

So if we eliminated the 3 datum fields and just have one, and use the rule
type already encoded in the specified flag as part of the key (and we
partially do this now anyway), we would add 53,744 avtab entries but reduce
the size of each entry by 8 bytes for a (32-8 = 24) 24 byte avtab node size.


So the avtab that we have now would be 300,970 x 32 bytes = ~9.6MB versus
the alternative avtab of 354,714 * 24 = ~8.5MB or about a ~1.1MB savings
(about 10%) with very little code change and essentially zero performance
impact. If the audit-to-allow rule ration stays 1-10, then this change makes
sense.

I suspect we can look around and find other examples where small or no
performance tradeoffs can made for large size savings. For example if we
make the specified flag 16 bit instead of 32 (we're using less then 16 now),
we could save another ~.7MB of memory, or a total of ~1.8MB or about 19%.
Coupled with smaller policies in the future, we should be able to make
significant progress with less pain than a complete restructure of the
policydb.

If we go ahead and keep attributes around (as we have in the loadable module
work), then the savings can be much greater, but we'd have to study the
performance impacts better. The implementation changes would also be more
radical. For example the same sample policy above that had ~300K allow rules
in the binary policy had only ~27K allow rules in the source policy before
expansion. Some rules will expand anyway because of multiple classes, but I
believe most expansion is due to attribute expansion.

Frank



--
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.

  reply	other threads:[~2005-06-24 18:05 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-23  3:00 file contexts and modularity Ivan Gyurdiev
2005-06-23 17:37 ` Karl MacMillan
2005-06-23 18:05   ` Ivan Gyurdiev
2005-06-23 18:21     ` Karl MacMillan
2005-06-23 18:25       ` Ivan Gyurdiev
2005-06-23 18:40         ` Karl MacMillan
2005-06-23 19:00           ` Ivan Gyurdiev
2005-06-23 19:39             ` Karl MacMillan
2005-06-23 20:28               ` Ivan Gyurdiev
2005-06-23 20:36                 ` Ivan Gyurdiev
2005-06-24 12:08                 ` Stephen Smalley
2005-06-24 15:43                   ` Ivan Gyurdiev
2005-06-24 18:32                     ` Stephen Smalley
2005-06-24 18:37                       ` Ivan Gyurdiev
2005-06-24 12:21                 ` Stephen Smalley
2005-06-24 14:30                   ` Karl MacMillan
2005-06-24 16:05                     ` Karl MacMillan
2005-06-24 18:05                       ` Frank Mayer [this message]
2005-06-24 18:40                         ` Stephen Smalley
2005-06-28 15:41                           ` Karl MacMillan
2005-06-28 16:21                             ` Stephen Smalley
2005-06-24 15:51                   ` Casey Schaufler
2005-06-24 16:36                     ` Karl MacMillan
2005-06-24 16:47                       ` Casey Schaufler
2005-06-24 16:56                         ` Karl MacMillan
2005-06-24 17:10                           ` Casey Schaufler
2005-06-24 15:39                 ` Karl MacMillan
2005-06-24 16:03                   ` Ivan Gyurdiev
2005-06-24 16:28                     ` Karl MacMillan
2005-06-24 17:56                       ` Ivan Gyurdiev
2005-06-27 15:07                         ` Karl MacMillan
2005-06-27 15:36                           ` Ivan Gyurdiev
2005-06-27 17:25                             ` Karl MacMillan
2005-06-27 17:56                               ` Ivan Gyurdiev
2005-06-28 13:47                                 ` Karl MacMillan
2005-06-28 19:31                                   ` Ivan Gyurdiev
2005-06-29 17:28                                     ` Ivan Gyurdiev
2005-06-29 18:17                                       ` Karl MacMillan
2005-06-29 18:46                                         ` Ivan Gyurdiev
2005-06-29 18:53                                           ` Stephen Smalley
2005-06-29 19:04                                             ` Karl MacMillan
2005-06-29 19:24                                               ` Ivan Gyurdiev
2005-06-29 19:50                                                 ` Stephen Smalley
2005-06-29 20:03                                                   ` Ivan Gyurdiev
2005-06-29 20:09                                                     ` Stephen Smalley
2005-06-29 20:22                                                       ` Ivan Gyurdiev
2005-06-30 13:54                                                         ` Stephen Smalley
2005-06-29 20:22                                                     ` Janak Desai
2005-06-29 20:43                                                       ` Ivan Gyurdiev
2005-06-30 13:53                                                         ` Ivan Gyurdiev
2005-06-30 13:58                                                           ` Stephen Smalley
2005-06-30 14:48                                                             ` Karl MacMillan
2005-06-30 14:52                                                               ` Stephen Smalley
2005-06-30 13:56                                                         ` Stephen Smalley
2005-06-29 20:13                                                   ` Janak Desai
2005-06-30  0:40                                                   ` Luke Kenneth Casson Leighton
2005-06-29 19:04                                           ` Karl MacMillan
2005-06-29 19:20                                             ` Ivan Gyurdiev
2005-06-24  5:03           ` Ivan Gyurdiev

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=200506241805.j5OI5fqc018169@gotham.columbia.tresys.com \
    --to=mayerf@tresys.com \
    --cc=dwalsh@redhat.com \
    --cc=ivg2@cornell.edu \
    --cc=jmorris@redhat.com \
    --cc=kmacmillan@tresys.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.