alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: peter.enderborg@sony.com, Paul Moore <paul@paul-moore.com>,
	Eric Paris <eparis@parisplace.org>,
	James Morris <james.l.morris@oracle.com>,
	Daniel Jurgens <danielj@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	alsa-devel@alsa-project.org,
	"Serge E . Hallyn" <serge@hallyn.com>
Subject: Re: [PATCH v2 0/5] selinux:Significant reduce of preempt_disable holds
Date: Tue, 30 Jan 2018 08:37:38 -0500	[thread overview]
Message-ID: <1517319458.14420.1.camel@tycho.nsa.gov> (raw)
In-Reply-To: <20180126143241.23108-1-peter.enderborg@sony.com>

On Fri, 2018-01-26 at 15:32 +0100, peter.enderborg@sony.com wrote:
> Holding the preempt_disable is very bad for low latency tasks
> as audio and therefore we need to break out the rule-set dependent
> part from this disable. By using a RCU instead of rwlock we
> have an efficient locking and less preemption interference.

NB: rcu_read_lock() may disable preemption as well if
CONFIG_PREEMPT_COUNT=y.  I assume you aren't concerned with that
configuration?

> 
> Selinux uses a lot of read_locks. This patch replaces the rwlock
> with RCY that does not hold preempt_disable.
> 
> Intel Xeon W3520 2.67 Ghz running FC27 with 4.15.0-rc9git
> (+measurement)
> I get preempt_disable in worst case for 1.2ms in
> security_compute_av().
> With the patch I get 960us as the longest security_compute_av()
> without preempt disabeld. It very much noise in the measurement
> but it is not likely a degrade.
> 
> And the preempt_disable times is also very dependent on the selinux
> rule-set.
> 
> In security_get_user_sids() we have two nested for-loops and the
> inner part calls sittab_context_to_sid() that calls
> sidtab_search_context() that has a for loop() over a while() where
> the loops is dependent on the rules.
> 
> On the test system the average lookup time is 60us and does
> not change with the RCU usage.
> 
> To use RCU the structure of policydb has to be accesses through a
> pointer.
> We need 4 patches to get there.
> 
>   [PATCH v2 1/5] selinux:Remove direct references to policydb.
>   We remove direct references and pass it through function arguments.
> 
>   [PATCH v2 2/5] selinux: Move policydb to pointer structure
>   Move the policydb to dynamic allocated structure.
> 
>   [PATCH v2 3/5] selinux: Move sidtab to pointer structure
>   Same as for policydb but for sidtab. They are closly related
>   and should be switched at the same time.
>   
>   [PATCH v2 4/5] selinux: Use pointer to switch policydb and sidtab
>   Now we can switch rules by switching pointers.
> 
>   [PATCH v2 5/5] selinux: Switch locking to RCU.
>   We are now ready to use RCU.
>   
> History: V1 rwsem
> 

      parent reply	other threads:[~2018-01-30 13:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 14:32 [PATCH v2 0/5] selinux:Significant reduce of preempt_disable holds peter.enderborg
2018-01-26 14:32 ` [PATCH v2 1/5] selinux:Remove direct references to policydb peter.enderborg
2018-01-30 13:46   ` Stephen Smalley
2018-01-26 14:32 ` [PATCH v2 2/5] selinux: Move policydb to pointer structure peter.enderborg
2018-01-26 14:32 ` [PATCH v2 3/5] selinux: Move sidtab " peter.enderborg
2018-01-26 14:32 ` [PATCH v2 4/5] selinux: Use pointer to switch policydb and sidtab peter.enderborg
2018-01-30 14:37   ` Stephen Smalley
2018-01-26 14:32 ` [PATCH v2 5/5] selinux: Switch locking to RCU peter.enderborg
2018-01-30 13:37 ` Stephen Smalley [this message]

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=1517319458.14420.1.camel@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=alsa-devel@alsa-project.org \
    --cc=danielj@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=eparis@parisplace.org \
    --cc=james.l.morris@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=peter.enderborg@sony.com \
    --cc=selinux@tycho.nsa.gov \
    --cc=serge@hallyn.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).