From: Paul Moore <paul.moore@hp.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Stephen Smalley <sds@tycho.nsa.gov>,
James Carter <jwcart2@tycho.nsa.gov>,
James Morris <jmorris@namei.org>
Subject: Re: [bug] very high non-preempt latency in context_struct_compute_av()
Date: Mon, 4 Jun 2007 17:11:42 -0400 [thread overview]
Message-ID: <200706041711.42755.paul.moore@hp.com> (raw)
In-Reply-To: <20070604112745.GA26350@elte.hu>
On Monday, June 4 2007 7:27:45 am Ingo Molnar wrote:
> a simple ssh login triggers a ~130 msecs non-preemptible latency even
> with CONFIG_PREEMPT enabled, on a fast Core2Duo CPU (!).
>
> the latency is caused by a _very_ long loop in the SELinux code:
>
> sshd-4828 0.N.. 465894us : avtab_search_node
> (context_struct_compute_av) sshd-4828 0.N.. 465895us : cond_compute_av
> (context_struct_compute_av) sshd-4828 0.N.. 465895us : avtab_search_node
> (cond_compute_av) sshd-4828 0.N.. 465895us : avtab_search_node
> (context_struct_compute_av) sshd-4828 0.N.. 465896us : cond_compute_av
> (context_struct_compute_av) sshd-4828 0.N.. 465896us : avtab_search_node
> (cond_compute_av) sshd-4828 0.N.. 465896us : avtab_search_node
> (context_struct_compute_av) sshd-4828 0.N.. 465896us : cond_compute_av
> (context_struct_compute_av) sshd-4828 0.N.. 465896us : avtab_search_node
> (cond_compute_av)
>
> it is triggered like this:
>
> sshd-4828 0..s. 462986us : tasklet_action (__do_softirq)
> sshd-4828 0..s. 462986us : rcu_process_callbacks (tasklet_action)
> sshd-4828 0..s. 462986us : __rcu_process_callbacks
> (rcu_process_callbacks) sshd-4828 0..s. 462987us : __rcu_process_callbacks
> (rcu_process_callbacks) sshd-4828 0D.s. 462987us : _local_bh_enable
> (__do_softirq)
> sshd-4828 0DN.. 462987us : idle_cpu (irq_exit)
> sshd-4828 0.N.. 462988us : avtab_search_node
> (context_struct_compute_av) sshd-4828 0.N.. 462989us : cond_compute_av
> (context_struct_compute_av)
>
> {snip}
>
> The distribution is Fedora 7, v2.6.21 (but also happens in recent -git)
> and a simple 'ssh localhost' login is enough to trigger this. It
> triggers every time and this is causing audio skipping in certain apps.
> It is even visible in glxgears smoothness: a small 'bump' is visible in
> the otherwise smooth rotation of glxgears. Enabling CONFIG_PREEMPT does
> not fix this issue as the function runs under spinlocks. (enabling
> CONFIG_PREEMPT_RT in -rt fixes the issue - but that still leaves us with
> the huge 130 msecs cost of that function.)
I'm not an expert on the SELinux security server guts like the other people on
the To/CC line of this thread, but here are my two cents on the issue above.
>From what I can tell the nasty loop that is taking so long is the actual
access vector lookup which determines if the subject has access to the object
(i.e. can user/application X access resource Y on the system). While it may
be possible to optimize this code I wonder if a quicker/easier solution would
be to refactor the lock. At present SELinux uses a read/write spinlock to
protect the policy stored in the kernel with macros to take and release the
lock, POLICY_{RD,WR}LOCK and POLICY_{RD,WR}UNLOCK. From personal
observations as well as a quick check of the code, it appears that most of
the time we only want to read lock the policy and not write lock the policy -
a spinlock, even a read/write spinlock, seems a bit expensive here.
If we were to convert from a read/write spinlock to a RCU locking mechanism
would this solve the preemption problem (I'm not a lock expert either)? If
so, can anyone think of any reasons why converting the policy lock to RCU is
a bad idea (James, Stephen, the other James)?
--
paul moore
linux security @ hp
next prev parent reply other threads:[~2007-06-04 21:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-04 11:27 [bug] very high non-preempt latency in context_struct_compute_av() Ingo Molnar
2007-06-04 13:25 ` James Morris
2007-06-04 14:17 ` Ingo Molnar
2007-06-04 21:11 ` Paul Moore [this message]
2007-06-04 21:39 ` Stephen Smalley
2007-06-04 22:48 ` Paul Moore
2007-06-04 22:54 ` James Morris
2007-06-07 19:34 ` Stephen Smalley
2007-06-07 19:51 ` Ingo Molnar
2007-06-07 20:11 ` James Morris
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=200706041711.42755.paul.moore@hp.com \
--to=paul.moore@hp.com \
--cc=akpm@linux-foundation.org \
--cc=jmorris@namei.org \
--cc=jwcart2@tycho.nsa.gov \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sds@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.