mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: Matt Mackall <mpm@selenic.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Hugh Dickins <hugh@veritas.com>, Andi Kleen <andi@firstfloor.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] procfs: provide slub's /proc/slabinfo
Date: Thu, 3 Jan 2008 18:21:43 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0801031808470.7244@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <1199378818.8274.25.camel@cinder.waste.org>

On Thu, 3 Jan 2008, Matt Mackall wrote:

> There are three downsides with the slab-like approach: internal
> fragmentation, under-utilized slabs, and pinning.
> 
> The first is the situation where we ask for a kmalloc of 33 bytes and
> get 64. I think the average kmalloc wastes about 30% trying to fit into
> power-of-two buckets. We can tune our buckets a bit, but I think in
> general trying to back kmalloc with slabs is problematic. SLOB has a
> 2-byte granularity up to the point where it just hands things off to the
> page allocator.

The 2 byte overhead of SLOB becomes a liability when it comes to correctly 
aligning power of two sized object. SLOB has to add two bytes and then 
align the combined object (argh!). SLUB can align these without a 2 byte 
overhead. In some configurations this results in SLUB using even less 
memory than SLOB. See f.e. Pekka's test at 
http://marc.info/?l=linux-kernel&m=118405559214029&w=2

> If we tried to add more slabs to fill the gaps, we'd exacerbate the
> second problem: because only one type of object can go on a slab, a lot
> of slabs are half-full. SLUB's automerging of slabs helps some here, but
> is still restricted to objects of the same size.

The advantage of SLOB is to be able to put objects of multiple sizes into 
the same slab page. That advantage goes away once we have more than a few 
objects per slab because SLUB can store object in a denser way than SLOB.
 
> And finally, there's the whole pinning problem: we can have a cache like
> the dcache grow very large and then contract, but still have most of its
> slabs used by pinned dentries. Christoph has some rather hairy patches
> to address this, but SLOB doesn't have much of a problem here - those
> pages are still available to allocate other objects on.

Well if you just have a few dentries then they are likely all pinned. A 
large number of dentries will typically result in reclaimable slabs.
The slab defrag patchset not only deals with the dcache issue but provides 
similar solutions for inode and buffer_heads. Support for other slabs that
defragment can be added by providing two hooks per slab.

 > By comparison, SLOB's big downsides are that it's not O(1) and it has a
> single lock. But it's currently fast enough to keep up with SLUB on
> kernel compiles on my 2G box and Nick had an allocator benchmark where
> scalability didn't fall off until beyond 4 CPUs.

Both SLOB and SLAB suffer from the single lock problem. SLOB does it for 
every item allocated. SLAB does it for every nth item allocated. Given 
a fast allocation from multiple processors both will generate a bouncing 
cacheline. SLUB can take pages from the page allocator pools and allocate 
all objects from it without taking a lock.

> > right now we are far away from it - SLUB has an order of magnitude 
> > larger .o than SLOB, even on UP. I'm wondering why that is so - SLUB's 
> > data structures _are_ quite compact and could in theory be used in a 
> > SLOB-alike way. Perhaps one problem is that much of SLUB's debugging 
> > code is always built in?
> 
> I think we should probably just accept that it makes sense to have more
> than one allocator. A 64MB single CPU machine is very, very different
> than a 64TB 4096-CPU machine. On one of those, it probably makes some
> sense to burn some memory for maximum scalability.

I still have trouble to see that SLOB still has much to offer. An embedded 
allocator that in many cases has more allocation overhead than the default 
one? Ok you still have advantages if allocations are rounded up to the 
next power of two for a kmalloc and because of the combining of different 
types of allocations in a single slab if there are an overall small number 
of allocations. If one would create a custom slab for the worst problems 
there then this may also go away.

  reply	other threads:[~2008-01-04  2:21 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-02 18:43 Hugh Dickins
2008-01-02 18:53 ` Christoph Lameter
2008-01-02 19:09 ` Pekka Enberg
2008-01-02 19:35   ` Linus Torvalds
2008-01-02 19:45     ` Linus Torvalds
2008-01-02 19:49     ` Pekka Enberg
2008-01-02 22:50     ` Matt Mackall
2008-01-03  8:52       ` Ingo Molnar
2008-01-03 16:46         ` Matt Mackall
2008-01-04  2:21           ` Christoph Lameter [this message]
2008-01-04  2:45             ` Andi Kleen
2008-01-04  4:34               ` Matt Mackall
2008-01-04  9:17               ` Peter Zijlstra
2008-01-04 20:37                 ` Christoph Lameter
2008-01-04  4:11             ` Matt Mackall
2008-01-04 20:34               ` Christoph Lameter
2008-01-04 20:55                 ` Matt Mackall
2008-01-04 21:36                   ` Christoph Lameter
2008-01-04 22:30                     ` Matt Mackall
2008-01-05 20:16                       ` Christoph Lameter
2008-01-05 16:21               ` Pekka J Enberg
2008-01-05 17:14                 ` Andi Kleen
2008-01-05 20:05                 ` Christoph Lameter
2008-01-07 20:12                   ` Pekka J Enberg
2008-01-06 17:51                 ` Matt Mackall
2008-01-07 18:06                   ` Pekka J Enberg
2008-01-07 19:03                     ` Matt Mackall
2008-01-07 19:53                       ` Pekka J Enberg
2008-01-07 20:44                       ` Pekka J Enberg
2008-01-10 10:04                       ` Pekka J Enberg
2008-01-09 19:15                     ` [RFC PATCH] greatly reduce SLOB external fragmentation Matt Mackall
2008-01-09 22:43                       ` Pekka J Enberg
2008-01-09 22:59                         ` Matt Mackall
2008-01-10 10:02                           ` Pekka J Enberg
2008-01-10 10:54                             ` Pekka J Enberg
2008-01-10 15:44                               ` Matt Mackall
2008-01-10 16:13                               ` Linus Torvalds
2008-01-10 17:49                                 ` Matt Mackall
2008-01-10 18:28                                   ` Linus Torvalds
2008-01-10 18:42                                     ` Matt Mackall
2008-01-10 19:24                                       ` Christoph Lameter
2008-01-10 19:44                                         ` Matt Mackall
2008-01-10 19:51                                           ` Christoph Lameter
2008-01-10 19:41                                       ` Linus Torvalds
2008-01-10 19:46                                         ` Christoph Lameter
2008-01-10 19:53                                         ` Andi Kleen
2008-01-10 19:52                                           ` Christoph Lameter
2008-01-10 19:16                                   ` Christoph Lameter
2008-01-10 19:23                                     ` Matt Mackall
2008-01-10 19:31                                       ` Christoph Lameter
2008-01-10 21:25                                   ` Jörn Engel
2008-01-10 18:13                                 ` Andi Kleen
2008-07-30 21:51                                 ` Pekka J Enberg
2008-07-30 22:00                                   ` Linus Torvalds
2008-07-30 22:22                                     ` Pekka Enberg
2008-07-30 22:35                                       ` Linus Torvalds
2008-07-31  0:42                                         ` malc
2008-07-31  1:03                                         ` Matt Mackall
2008-07-31  1:09                                     ` Matt Mackall
2008-07-31 14:11                                       ` Andi Kleen
2008-07-31 15:25                                         ` Christoph Lameter
2008-07-31 16:03                                           ` Andi Kleen
2008-07-31 16:05                                             ` Christoph Lameter
2008-07-31 14:26                                       ` Christoph Lameter
2008-07-31 15:38                                         ` Matt Mackall
2008-07-31 15:42                                           ` Christoph Lameter
2008-01-10  2:46                         ` Matt Mackall
2008-01-10 10:03                       ` Pekka J Enberg
2008-01-03 20:31         ` [PATCH] procfs: provide slub's /proc/slabinfo Christoph Lameter

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=Pine.LNX.4.64.0801031808470.7244@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=andi@firstfloor.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mpm@selenic.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®