public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ima: use of radix tree cache indexing == massive waste of memory?
@ 2010-10-16  6:52 Dave Chinner
  2010-10-16 19:20 ` Christoph Hellwig
  0 siblings, 1 reply; 52+ messages in thread
From: Dave Chinner @ 2010-10-16  6:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mimi Zohar

Folks,

I was doing a quick check of kernel.org memory usage and behaviour
after the recent outage that occurred. I just noticed that slabtop
was reportingi an awfully high usage of radix tree nodes:

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                   
4200331 2778082  66%    0.55K 144839       29   2317424K radix_tree_node
2321500 2060290  88%    1.00K  72581       32   2322592K xfs_inode
2235648 2069791  92%    0.12K  69864       32    279456K iint_cache

That is, 2.7M radix tree nodes are allocated, and the cache itself
is consuming 2.3GB of RAM. I know that the XFS inodei caches are
indexed by radix tree node, but for 2 million cached inodes that
would mean a density of 1 inode per radix tree node, which for a
system with 16M inodes in the filsystems is an impossibly low
density. The worst I've seen in a production system like kernel.org
is about 20-25% density, which would mean about 150−200k radix tree
nodes for that many inodes. So it's not the inode cache.

There's about 5GB of cached pages, so there's a few hundred thousand
nodes there, but even considering that there's still roughly 2
million nodes unaccounted for.

So I looked up what the iint_cache was. It appears to used for storing
per-inode IMA information, and uses a radix tree for indexing.
It uses the *address* of the struct inode as the indexing key. That
means the key space is extremely sparse - for XFS the struct inode
addresses are approximately 1000 bytes apart, which means the
closest the radix tree index keys get is ~1000. Which means
that there is a single entry per radix tree leaf node, so the radix
tree is using roughly 550 bytes for every 120byte structure being
cached. For the above example, it's probably wasting close to 1GB of
RAM....

IOWs, it looks to me like the choice a a radix tree for indexing the
IMA structures is probably the worst choice that could be made from
a memory usage point of view. Is there any specific reason this
cache uses radix trees, or can it be converted to use btrees or
rbtrees to stop it wasting so much memory?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: ima: use of radix tree cache indexing == massive waste of memory?
@ 2010-10-18 15:09 Christoph Hellwig
  0 siblings, 0 replies; 52+ messages in thread
From: Christoph Hellwig @ 2010-10-18 15:09 UTC (permalink / raw)
  To: Eric Paris
  Cc: Ted Ts'o, Peter Zijlstra, Eric Paris, Mimi Zohar,
	Christoph Hellwig, Dave Chinner, linux-kernel, Mimi Zohar,
	warthog9, hpa

> It can be turned on any time inside the initrd without loss of integrity
> assuming the kernel and initrd were both measured and stored in a TPM
> PCR.  I'm willing to agree that the usefulness might be limited, but it
> isn't non-existant.  I'm going to make a note to look at other ways to
> cut down the memory usage.

It's not just memory overhead - it also adds another global reasource
and global lock for every inode allocation/freeing.  That's okay if
people actually want to use IMA - but if you do it everywhere it's
a real PITA.

If there's seriously no way to fix it up to not cause harm by default
just extending the inode is the much better way to go.  But given
that it's already in distros with a kABI I suspect some people will
be interested in fixing it for people instead of forcing this overhead
on their customers for years.  We might want to just piggyback on that.

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2010-10-27  6:31 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-16  6:52 ima: use of radix tree cache indexing == massive waste of memory? Dave Chinner
2010-10-16 19:20 ` Christoph Hellwig
2010-10-16 21:10   ` H. Peter Anvin
2010-10-17  0:35     ` Dave Chinner
2010-10-17  0:54       ` J.H.
2010-10-17  2:11         ` Dave Chinner
2010-10-18 18:12           ` J.H.
2010-10-17  0:49     ` Christoph Hellwig
2010-10-17  1:09       ` Kyle McMartin
2010-10-17  1:13         ` Christoph Hellwig
2010-10-17  5:49           ` Ingo Molnar
2010-10-17  5:40       ` Ingo Molnar
2010-10-17 18:46         ` Christoph Hellwig
2010-10-18  0:49           ` James Morris
2010-10-18  6:25             ` Kyle McMartin
2010-10-18  6:36               ` Andrew Morton
2010-10-18  9:29                 ` Dave Chinner
2010-10-18 13:31                   ` Mimi Zohar
2010-10-18 20:50                     ` Ware, Ryan R
2010-10-26  7:31                       ` Pavel Machek
2010-10-18 16:03               ` Mimi Zohar
2010-10-18 19:24                 ` John Stoffel
2010-10-18 16:46               ` Ryan Ware
2010-10-18 16:48               ` Eric Paris
2010-10-18 17:10                 ` Kyle McMartin
2010-10-18 17:34                 ` Kyle McMartin
2010-10-18 17:56                 ` Linus Torvalds
2010-10-18 18:13                   ` Eric Paris
2010-10-18 18:19                     ` Ingo Molnar
2010-10-18 18:43                       ` Eric Paris
2010-10-19  0:58                       ` Eric Paris
2010-10-18 18:06                 ` H. Peter Anvin
2010-10-18 18:11                   ` Ingo Molnar
2010-10-18 18:13                     ` H. Peter Anvin
2010-10-25 13:18             ` Pavel Machek
2010-10-17  5:57   ` Mimi Zohar
2010-10-17 11:02     ` Peter Zijlstra
2010-10-17 13:12       ` Eric Paris
2010-10-17 13:59         ` Peter Zijlstra
2010-10-17 14:04           ` Peter Zijlstra
2010-10-17 14:16           ` Eric Paris
2010-10-18 11:57             ` Peter Zijlstra
2010-10-18 14:59               ` Ted Ts'o
2010-10-18 15:02                 ` Peter Zijlstra
2010-10-18 15:02                 ` Eric Paris
2010-10-17 18:52           ` Christoph Hellwig
2010-10-18 16:44             ` Ryan Ware
2010-10-18  0:07         ` Dave Chinner
2010-10-17 14:09       ` Mimi Zohar
2010-10-17 18:49     ` Christoph Hellwig
2010-10-17 19:39     ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2010-10-18 15:09 Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox