mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: "Olivér Pintér" <oliver.pntr@gmail.com>
Cc: Christoph Lameter <clameter@sgi.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Willy Tarreau <w@1wt.eu>,
	linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH 1/2] slub: fix leakage
Date: Sat, 3 Nov 2007 18:52:10 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0711031847450.13845@blonde.wat.veritas.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0711031741160.10953@blonde.wat.veritas.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2876 bytes --]

On Sat, 3 Nov 2007, Hugh Dickins wrote:
> On Sat, 3 Nov 2007, Olivér Pintér wrote:
> > Q: It's needed auch to 2.6.22-stable?
> 
> I guess so: though SLUB wasn't on by default in 2.6.22; and it being
> only a slow leak rather than a corruption, I was less inclined to
> agitate about it for releases further back.
> 
> But your question makes me realize I never even looked at 2.6.23 or
> 2.6.22 hereabouts, just assumed they were the same; let alone patch
> or build or test them.  The patches reject as such because quite a
> lot has changed around (there was no struct kmem_cache_cpu in either).
> 
> A hurried look suggests that the leakage problem was there in both,
> but let's wait to hear Christoph's expert opinion.

Okay, here's a version for 2.6.23 and 2.6.22...
Christoph, you've now Acked the 2.6.24 one, thanks:
do you agree this patch below should go to -stable?


Slub has been quite leaky under load.  Taking mm_struct as an example, in
a loop of swapping kernel builds, after the first iteration slabinfo shows:
Name        Objects Objsize    Space Slabs/Part/Cpu  O/S O %Fr %Ef Flg
mm_struct        55     840    73.7K         18/7/4    4 0  38  62 A
but Objects and Partials steadily creep up - after the 340th iteration:
mm_struct       110     840   188.4K        46/36/4    4 0  78  49 A
(example taken from 2.6.24-rc1: YMMV).

The culprit turns out to be __slab_alloc(), where it copes with the race
that another task has assigned the cpu slab while we were allocating one.
Don't rush off to load_freelist there: that assumes page->lockless_freelist
is empty, and will lose all its free slots when page->freelist is not empty.
Instead just do a local allocation from lockless_freelist when it has one.

Which fixes the leakage: Objects and Partials then remain stable.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
Version of patch suitable and recommended for both 2.6.23-stable and
2.6.22-stable.  I've not run tests on either to observe the mounting
leakage; but a version of the patch below with a printk announcing
when non-empty freelist would overwrite non-empty lockless_freelist
does indeed show up in both (though notably less frequently than in
2.6.24-rc1 - something else seems to be making it more likely now).
But please wait for Christoph's Ack before committing to -stable.

 mm/slub.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- 2.6.23/mm/slub.c	2007-10-09 21:31:38.000000000 +0100
+++ linux/mm/slub.c	2007-11-03 18:23:07.000000000 +0000
@@ -1517,6 +1517,12 @@ new_slab:
 				 */
 				discard_slab(s, page);
 				page = s->cpu_slab[cpu];
+				if (page->lockless_freelist) {
+					object = page->lockless_freelist;
+					page->lockless_freelist =
+							object[page->offset];
+					return object;
+				}
 				slab_lock(page);
 				goto load_freelist;
 			}

  reply	other threads:[~2007-11-03 18:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-03 17:10 Hugh Dickins
2007-11-03 17:11 ` [PATCH 2/2] slub: fix Objects count Hugh Dickins
2007-11-03 18:26   ` Christoph Lameter
2007-11-03 19:09     ` Hugh Dickins
2007-11-03 19:33       ` Christoph Lameter
2007-11-03 20:03         ` Hugh Dickins
2007-11-03 17:27 ` [PATCH 1/2] slub: fix leakage Olivér Pintér
2007-11-03 17:50   ` Hugh Dickins
2007-11-03 18:52     ` Hugh Dickins [this message]
2007-11-03 19:39       ` Hugh Dickins
2007-11-03 19:47         ` Christoph Lameter
2007-11-03 19:52           ` Hugh Dickins
2007-11-03 19:54             ` Christoph Lameter
2007-11-03 20:10               ` Hugh Dickins
2007-11-03 20:26                 ` Christoph Lameter
2007-11-04 11:18                   ` Hugh Dickins
2007-11-05 18:45                     ` Christoph Lameter
2007-11-05 19:09                       ` Hugh Dickins
2007-11-05 19:15                         ` Christoph Lameter
2007-11-05 19:23                           ` Christoph Lameter
2007-11-05 19:26                           ` Linus Torvalds
2007-11-05 19:31                             ` Christoph Lameter
2007-11-05 19:36                               ` Linus Torvalds
2007-11-06  6:15                       ` Jeff Chua
2007-11-06  7:58                         ` Hugh Dickins
2007-11-03 17:38 ` Willy Tarreau
2007-11-03 17:55   ` Hugh Dickins
2007-11-03 17:59     ` Willy Tarreau
2007-11-03 18:31 ` Christoph Lameter
2007-11-03 18:48 ` Christoph Lameter
2007-11-03 18:51   ` Christoph Lameter
2007-11-03 19:04   ` Hugh Dickins
2007-11-03 19:26     ` Christoph Lameter
2007-11-03 19:35       ` Hugh Dickins

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.0711031847450.13845@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver.pntr@gmail.com \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=w@1wt.eu \
    /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®